Commit 485c7e2a authored by whitlocb's avatar whitlocb
Browse files

Various CQ fixes.



git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@16549 18c085ea-50e0-402c-830e-de6fd14e8384
parent 74e8f6e7
......@@ -38,6 +38,11 @@
#include <SelectionProperties.h>
#include <DataNode.h>
#include <float.h>
const double SelectionProperties::MIN = -FLT_MAX;
const double SelectionProperties::MAX = FLT_MAX;
//
// Enum conversion methods for SelectionProperties::SelectionType
......
Constant: MIN
Declaration: static const double MIN;
Definition: const double SelectionProperties::MIN = -FLT_MAX;
Constant: MAX
Declaration: static const double MAX;
Definition: const double SelectionProperties::MAX = FLT_MAX;
Function: GetOriginatingPlot
Declaration: const std::string &GetOriginatingPlot() const;
Definition:
......@@ -17,3 +25,4 @@ SelectionProperties::SetOriginatingPlot(const std::string &p)
{
SetSource(p);
}
......@@ -84,6 +84,8 @@ public:
UseGlobalZoneIDForID,
UseVariableForID
};
static const double MIN;
static const double MAX;
// These constructors are for objects of this class
SelectionProperties();
......
......@@ -50,21 +50,28 @@
CombineOr
</Field>
<Field name="histogramType" label="Type of histogram being shown" type="enum" subtype="HistogramType">
HistogramTime
</Field>
HistogramTime
</Field>
<Field name="histogramNumBins" label="Number of bins for histogram display" type="int">
10
10
</Field>
<Field name="histogramStartBin" label="Starting bin for histogram selection" type="int">
0
0
</Field>
<Field name="histogramEndBin" label="Ending bin for histogram selection" type="int">
9
9
</Field>
<Field name="histogramVariable" label="Histogram variable" type="string">
</Field>
<Function name="GetOriginatingPlot" user="true" member="true">
</Function>
</Function>
<Function name="SetOriginatingPlot" user="true" member="true">
</Function>
</Function>
<Constant name="MIN" member="true">
</Constant>
<Constant name="MAX" member="true">
</Constant>
<Include file="source" quoted="false">
float.h
</Include>
</Attribute>
......@@ -212,17 +212,11 @@ protected:
for(std::map<std::string,Histogram*>::iterator it = histograms.begin();
it != histograms.end(); ++it)
{
double minmax[2] = {0.,1.};
#if 0
avtExtents *ext = dob->GetInfo().GetAttributes().
GetThisProcsOriginalDataExtents(it->first.c_str());
if(ext != 0)
ext->CopyTo(minmax);
else
#endif
// If we have not created a histogram yet for this variable then do it now.
if(it->second == 0)
{
double minmax[2] = {0.,1.};
// Get the extents
avtDatasetExaminer::GetDataExtents(ds, minmax, it->first.c_str());
debug5 << mName << "Calculated data extents for " << it->first
......@@ -240,9 +234,10 @@ protected:
debug5 << mName << "Calculated histogram for " << it->first << endl;
for(int i = 0; i < 256; ++i)
debug5 << "\thist[" << i << "] = " << hist[i] << endl;
it->second->minimum = minmax[0];
it->second->maximum = minmax[1];
}
it->second->minimum = minmax[0];
it->second->maximum = minmax[1];
}
// Sum the cells and send to all procs.
......@@ -1768,7 +1763,7 @@ CumulativeQueryNamedSelectionExtension::AddFilters(avtDataObject_p dob,
SelectionSummary
CumulativeQueryNamedSelectionExtension::BuildSummary()
{
const char *mName = "CumulativeQueryNamedSelectionExtension::FreeUpResources: ";
const char *mName = "CumulativeQueryNamedSelectionExtension::BuildSummary: ";
// Stash hist's histograms into this class so we can return them from the engine.
SelectionSummary s;
......@@ -1783,7 +1778,6 @@ CumulativeQueryNamedSelectionExtension::BuildSummary()
vs.SetMinimum(h->minimum);
vs.SetMaximum(h->maximum);
vs.SetHistogram(h->frequency);
s.AddVariables(vs);
}
else
......@@ -1798,7 +1792,6 @@ CumulativeQueryNamedSelectionExtension::BuildSummary()
vs.SetMinimum(0.);
vs.SetMaximum(1.);
vs.SetHistogram(frequency);
s.AddVariables(vs);
}
}
......@@ -1807,7 +1800,7 @@ CumulativeQueryNamedSelectionExtension::BuildSummary()
// of time steps that were processed because the time loop filter causes our
// local histogram filter that counts the number of original cells to sum the
// total number of cells for all time steps. This gives us the per time step avg.
debug5 << "CQnamedSelectionExtension: total cells = " << hist->GetTotalCellCount() << endl;
debug5 << mName << "total cells = " << hist->GetTotalCellCount() << endl;
s.SetTotalCellCount((int)hist->GetTotalCellCount());
// Get the histogram computed by the CQ filter.
......
......@@ -3775,6 +3775,9 @@ NetworkManager::Query(const std::vector<int> &ids, QueryAttributes *qa)
// Brad Whitlock, Tue Sep 6 15:56:53 PDT 2011
// Pass a default named selection extension to the NSM.
//
// Brad Whitlock, Thu Oct 27 14:34:45 PDT 2011
// I improved the exception handling.
//
// ****************************************************************************
SelectionSummary
......@@ -3907,6 +3910,9 @@ NetworkManager::CreateNamedSelection(int id, const SelectionProperties &props)
}
CATCH(VisItException)
{
if(f != NULL)
delete f;
RETHROW;
}
ENDTRY
}
......@@ -3921,6 +3927,8 @@ NetworkManager::CreateNamedSelection(int id, const SelectionProperties &props)
{
debug1 << mName << "Could not find a valid data set from which to create"
" a named selection." << endl;
if(f != NULL)
delete f;
EXCEPTION0(NoInputException);
}
......@@ -3937,6 +3945,8 @@ NetworkManager::CreateNamedSelection(int id, const SelectionProperties &props)
debug1 << mName << "The cumulative query is malformed. It must have the same "
"number of elements for each of the variables, mins, maxs lists."
<< endl;
if(f != NULL)
delete f;
EXCEPTION0(ImproperUseException);
}
......@@ -3989,6 +3999,8 @@ NetworkManager::CreateNamedSelection(int id, const SelectionProperties &props)
// Creation: January 30, 2009
//
// Modifications:
// Brad Whitlock, Thu Oct 27 14:23:12 PDT 2011
// Make it not an error when we can't remove a selection that does not exist.
//
// ****************************************************************************
......@@ -3996,7 +4008,7 @@ void
NetworkManager::DeleteNamedSelection(const std::string &selName)
{
avtNamedSelectionManager *nsm = avtNamedSelectionManager::GetInstance();
nsm->DeleteNamedSelection(selName, true);
nsm->DeleteNamedSelection(selName, false);
}
......
......@@ -1059,7 +1059,11 @@ QvisExpressionsWindow::apply()
// Cyrus Harrison, Wed Jun 11 13:49:19 PDT 2008
// Initial Qt4 Port.
//
// Brad Whitlock, Thu Oct 27 14:42:53 PDT 2011
// Make the name active so we can change it.
//
// ****************************************************************************
void
QvisExpressionsWindow::addExpression()
{
......@@ -1090,6 +1094,8 @@ QvisExpressionsWindow::addExpression()
exprListBox->item(i)->setSelected(true);
exprListBox->setCurrentRow(i);
UpdateWindowSingleItem();
nameEdit->setFocus();
nameEdit->selectAll();
break;
}
}
......
......@@ -436,7 +436,9 @@ QvisHistogram::mouseReleaseEvent(QMouseEvent *e)
// Creation: Wed Dec 29 13:57:36 PST 2010
//
// Modifications:
//
// Brad Whitlock, Thu Oct 27 12:23:51 PDT 2011
// Clamp values so we don't get bad pixel values.
//
// ****************************************************************************
int
......@@ -444,9 +446,23 @@ QvisHistogram::value2Pixel(float selectedVal) const
{
float t;
if(totalRangeValid)
{
if(selectedVal < totalRange[0])
selectedVal = totalRange[0];
else if(selectedVal > totalRange[1])
selectedVal = totalRange[1];
t = (selectedVal - totalRange[0]) / (totalRange[1] - totalRange[0]);
}
else
{
if(selectedVal < selectedRange[0])
selectedVal = selectedRange[0];
else if(selectedVal > selectedRange[1])
selectedVal = selectedRange[1];
t = (selectedVal - selectedRange[0]) / (selectedRange[1] - selectedRange[0]);
}
return (contentsRect().width() * t) + contentsRect().x();
}
......@@ -541,14 +557,6 @@ QvisHistogram::setTotalRange(float r0, float r1)
totalRangeValid = true;
totalRange[0] = (r0 < r1) ? r0 : r1;
totalRange[1] = (r0 < r1) ? r1 : r0;
#if 0
// Don't do this
if(selectedRange[0] < totalRange[0])
selectedRange[0] = totalRange[0];
if(selectedRange[1] > totalRange[1])
selectedRange[1] = totalRange[1];
#endif
imageDirty();
update();
......
......@@ -49,6 +49,11 @@
#include <QvisHistogram.h>
#include <float.h>
#define MIN_VALUE -FLT_MAX
#define MAX_VALUE FLT_MAX
#define EPSILON (100 * FLT_MIN)
// ****************************************************************************
// Method: QvisHistogramLimits::QvisHistogramLimits
//
......@@ -169,6 +174,38 @@ QvisHistogramLimits::getTotalRange(bool &valid, float &r0, float &r1) const
histogram->getTotalRange(valid, r0, r1);
}
// ****************************************************************************
// Method: QvisHistogramLimits::GetRangeText
//
// Purpose:
// Get the range text.
//
// Arguments:
//
// Returns:
//
// Note:
//
// Programmer: Brad Whitlock
// Creation: Wed Oct 26 17:08:25 PDT 2011
//
// Modifications:
//
// ****************************************************************************
void
QvisHistogramLimits::GetRangeText(float r0, float r1, QString &r0Text, QString &r1Text) const
{
if(r0 <= (MIN_VALUE + EPSILON))
r0Text = tr("min").toLower();
else
r0Text = QString().setNum(r0);
if(r1 >= (MAX_VALUE - EPSILON))
r1Text = tr("max").toLower();
else
r1Text = QString().setNum(r1);
}
// ****************************************************************************
// Method: QvisHistogramLimits::setTotalRange
//
......@@ -183,14 +220,18 @@ QvisHistogramLimits::getTotalRange(bool &valid, float &r0, float &r1) const
// Creation: Tue Dec 28 16:00:40 PST 2010
//
// Modifications:
//
// Brad Whitlock, Wed Oct 26 16:43:01 PDT 2011
// Handle min and max.
//
// ****************************************************************************
void
QvisHistogramLimits::setTotalRange(float r0, float r1)
{
totalRange[0]->setText(QString().setNum(r0));
totalRange[1]->setText(QString().setNum(r1));
QString r0Text, r1Text;
GetRangeText(r0, r1, r0Text, r1Text);
totalRange[0]->setText(r0Text);
totalRange[1]->setText(r1Text);
histogram->setTotalRange(r0, r1);
}
......@@ -230,12 +271,20 @@ QvisHistogramLimits::invalidateTotalRange()
// Creation: Tue Dec 28 16:00:40 PST 2010
//
// Modifications:
//
// Brad Whitlock, Wed Oct 26 15:31:32 PDT 2011
// Force the min and max to get locked in before we ask for them.
//
// ****************************************************************************
void
QvisHistogramLimits::getSelectedRange(float &r0, float &r1) const
QvisHistogramLimits::getSelectedRange(float &r0, float &r1)
{
// Make sure the values are up to date with the text fields.
blockSignals(true);
minChanged();
maxChanged();
blockSignals(false);
histogram->getSelectedRange(r0, r1);
}
......@@ -253,14 +302,19 @@ QvisHistogramLimits::getSelectedRange(float &r0, float &r1) const
// Creation: Tue Dec 28 16:00:40 PST 2010
//
// Modifications:
//
// Brad Whitlock, Wed Oct 26 16:48:13 PDT 2011
// Handle min/max.
//
// ****************************************************************************
void
QvisHistogramLimits::setSelectedRange(float r0, float r1)
{
selectedRange[0]->setText(QString().setNum(r0));
selectedRange[1]->setText(QString().setNum(r1));
QString r0Text, r1Text;
GetRangeText(r0, r1, r0Text, r1Text);
selectedRange[0]->setText(r0Text);
selectedRange[1]->setText(r1Text);
histogram->setSelectedRange(r0, r1);
}
......@@ -431,7 +485,9 @@ QvisHistogramLimits::mousePressEvent(QMouseEvent *e)
// Creation: Tue Dec 28 16:00:40 PST 2010
//
// Modifications:
//
// Brad Whitlock, Wed Oct 26 16:56:47 PDT 2011
// Use GetRangeText.
//
// ****************************************************************************
void
......@@ -440,8 +496,10 @@ QvisHistogramLimits::updateSelectedText()
float r0, r1;
histogram->getSelectedRange(r0, r1);
selectedRange[0]->setText(QString().setNum(r0));
selectedRange[1]->setText(QString().setNum(r1));
QString r0Text, r1Text;
GetRangeText(r0, r1, r0Text, r1Text);
selectedRange[0]->setText(r0Text);
selectedRange[1]->setText(r1Text);
}
// ****************************************************************************
......@@ -455,7 +513,9 @@ QvisHistogramLimits::updateSelectedText()
// Creation: Tue Dec 28 16:00:40 PST 2010
//
// Modifications:
//
// Brad Whitlock, Wed Oct 26 16:51:29 PDT 2011
// Handle min/max.
//
// ****************************************************************************
void
......@@ -463,7 +523,18 @@ QvisHistogramLimits::minChanged()
{
// Convert the text to a float and store the value into the histogram.
bool okay = false;
float value = selectedRange[0]->text().toFloat(&okay);
QString minText, maxText;
GetRangeText(MIN_VALUE, MAX_VALUE, minText, maxText);
QString txt(selectedRange[0]->text().toLower());
float value;
if(txt == minText)
{
value = MIN_VALUE;
okay = true;
}
else
value = txt.toFloat(&okay);
if(okay)
{
float r0, r1;
......@@ -491,7 +562,9 @@ QvisHistogramLimits::minChanged()
// Creation: Tue Dec 28 16:00:40 PST 2010
//
// Modifications:
//
// Brad Whitlock, Wed Oct 26 16:52:10 PDT 2011
// Handle min/max.
//
// ****************************************************************************
void
......@@ -499,7 +572,18 @@ QvisHistogramLimits::maxChanged()
{
// Convert the text to a float and store the value into the histogram.
bool okay = false;
float value = selectedRange[1]->text().toFloat(&okay);
QString minText, maxText;
GetRangeText(MIN_VALUE, MAX_VALUE, minText, maxText);
QString txt(selectedRange[1]->text().toLower());
float value;
if(txt == maxText)
{
value = MAX_VALUE;
okay = true;
}
else
value = txt.toFloat(&okay);
if(okay)
{
float r0, r1;
......@@ -531,14 +615,18 @@ QvisHistogramLimits::maxChanged()
// Creation: Tue Dec 28 16:00:40 PST 2010
//
// Modifications:
//
// Brad Whitlock, Wed Oct 26 16:52:55 PDT 2011
// Handle min/max.
//
// ****************************************************************************
void
QvisHistogramLimits::rangeChanged(float r0, float r1)
{
selectedRange[0]->setText(QString().setNum(r0));
selectedRange[1]->setText(QString().setNum(r1));
QString r0Text, r1Text;
GetRangeText(r0, r1, r0Text, r1Text);
selectedRange[0]->setText(r0Text);
selectedRange[1]->setText(r1Text);
emit selectedRangeChanged(r0, r1);
emit selectedRangeChanged(getVariable(), r0, r1);
......
......@@ -58,7 +58,9 @@ class QvisHistogram;
// Creation: Tue Dec 28 16:00:40 PST 2010
//
// Modifications:
//
// Brad Whitlock, Thu Oct 27 14:10:23 PDT 2011
// Added GetRangeText.
//
// ****************************************************************************
class GUI_API QvisHistogramLimits : public QGroupBox
......@@ -74,7 +76,7 @@ public:
void setTotalRange(float r0, float r1);
void invalidateTotalRange();
void getSelectedRange(float &r0, float &r1) const;
void getSelectedRange(float &r0, float &r1);
void setSelectedRange(float r0, float r1);
void setVariable(const QString &);
......@@ -91,6 +93,7 @@ signals:
protected:
virtual void paintEvent(QPaintEvent *);
virtual void mousePressEvent(QMouseEvent *);
void GetRangeText(float r0, float r1, QString &r0Text, QString &r1Text) const;
private slots:
void minChanged();
......
......@@ -221,6 +221,14 @@ QvisHostProfileWindow::CreateMachineSettingsGroup()
mLayout->setMargin(5);
mLayout->setSpacing(HOST_PROFILE_SPACING);
hostNickname = new QLineEdit(machineGroup);
connect(hostNickname, SIGNAL(textChanged(const QString &)),
this, SLOT(hostNicknameChanged(const QString &)));
hostNicknameLabel = new QLabel(tr("Host nickname"), machineGroup);
mLayout->addWidget(hostNicknameLabel, mRow, 0);
mLayout->addWidget(hostNickname, mRow, 1);
mRow++;
hostName = new QLineEdit(machineGroup);
connect(hostName, SIGNAL(textChanged(const QString &)),
this, SLOT(hostNameChanged(const QString &)));
......@@ -237,14 +245,6 @@ QvisHostProfileWindow::CreateMachineSettingsGroup()
mLayout->addWidget(hostAliases, mRow, 1);
mRow++;
hostNickname = new QLineEdit(machineGroup);
connect(hostNickname, SIGNAL(textChanged(const QString &)),
this, SLOT(hostNicknameChanged(const QString &)));
hostNicknameLabel = new QLabel(tr("Host nickname"), machineGroup);
mLayout->addWidget(hostNicknameLabel, mRow, 0);
mLayout->addWidget(hostNickname, mRow, 1);
mRow++;
QFrame *sep1 = new QFrame(machineGroup);
sep1->setFrameStyle(QFrame::HLine + QFrame::Sunken);
mLayout->addWidget(sep1, mRow, 0, 1, 2);
......@@ -3606,6 +3606,9 @@ QvisHostProfileWindow::currentLaunchChanged()
// Jeremy Meredith, Fri Feb 19 13:16:35 EST 2010
// Fix the way we set the host nickname.
//
// Brad Whitlock, Thu Oct 27 14:54:10 PDT 2011
// Set focus on the first thing you'd edit.
//
// ****************************************************************************
void
QvisHostProfileWindow::addMachineProfile()
......@@ -3617,6 +3620,9 @@ QvisHostProfileWindow::addMachineProfile()
profiles->GetNumMachines()-1];
currentMachine->SetHostNickname(currentMachine->GetHost());
Apply();
hostNickname->selectAll();
hostNickname->setFocus();
}
// ****************************************************************************
......@@ -3700,6 +3706,9 @@ QvisHostProfileWindow::copyMachineProfile()
// Jeremy Meredith, Fri Feb 19 13:20:48 EST 2010
// Set the newly added launch profile as the active one.
//
// Brad Whitlock, Thu Oct 27 14:54:28 PDT 2011
// Set focus on the first thing you'd edit.
//
// ****************************************************************************
void
QvisHostProfileWindow::addLaunchProfile()
......@@ -3708,10 +3717,10 @@ QvisHostProfileWindow::addLaunchProfile()
return;
LaunchProfile lp;
QString profileName(tr("New profile"));
QString name(tr("New profile"));
QString num; num.sprintf(" #%d", profileCounter++);
profileName += num;
lp.SetProfileName(profileName.toStdString());
name += num;
lp.SetProfileName(name.toStdString());
currentMachine->AddLaunchProfiles(lp);
if (currentMachine->GetActiveProfile() < 0 ||
......@@ -3723,6 +3732,9 @@ QvisHostProfileWindow::addLaunchProfile()
currentLaunch = (LaunchProfile*)currentMachine->GetLaunchProfiles()[
currentMachine->GetNumLaunchProfiles()-1];
Apply();
profileName->selectAll();
profileName->setFocus();
}
// ****************************************************************************
......
......@@ -685,7 +685,9 @@ QvisSelectionsWindow::UpdateWindow(bool doAll)
// Creation: Wed Dec 29 10:30:14 PST 2010
//
// Modifications:
//
// Brad Whitlock, Wed Oct 26 15:33:08 PDT 2011
// Make sure we read back the variable min/max values.
//
// ****************************************************************************
void
......@@ -729,6 +731,24 @@ QvisSelectionsWindow::GetCurrentValues(int which_widget)
if(err)
ResettingError(tr("time stride"), IntToQString(selectionProps.GetTimeStateStride()));
}
if(which_widget == SelectionProperties::ID_variableMins ||
which_widget == SelectionProperties::ID_variableMaxs || doAll)
{
for(int i = 0; i < cqLimits->getNumVariables(); ++i)
{
float r0, r1;
cqLimits->getVariable(i)->getSelectedRange(r0, r1);
if(i < selectionProps.GetVariableMins().size())
{
selectionProps.GetVariableMins()[i] = r0;
selectionProps.GetVariableMaxs()[i] = r1;
selectionProps.SelectVariableMins();
selectionProps.SelectVariableMaxs();