Commit f5afa3a9 authored by whitlocb's avatar whitlocb

I changed CQ selections to the histogram variable can be selected from any DB...

I changed CQ selections to the histogram variable can be selected from any DB variable instead of requiring that it be in the range variables.



git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@16408 18c085ea-50e0-402c-830e-de6fd14e8384
parent c2fa22ff
This diff is collapsed.
......@@ -78,6 +78,12 @@ public:
HistogramID,
HistogramVariable
};
enum IDVariableType
{
UseZoneIDForID,
UseGlobalZoneIDForID,
UseVariableForID
};
// These constructors are for objects of this class
SelectionProperties();
......@@ -106,14 +112,18 @@ public:
virtual void SelectAll();
void SelectName();
void SelectSource();
void SelectIdVariable();
void SelectVariables();
void SelectVariableMins();
void SelectVariableMaxs();
void SelectHistogramVariable();
// Property setting methods
void SetName(const std::string &name_);
void SetSource(const std::string &source_);
void SetSelectionType(SelectionType selectionType_);
void SetIdVariableType(IDVariableType idVariableType_);
void SetIdVariable(const std::string &idVariable_);
void SetVariables(const stringVector &variables_);
void SetVariableMins(const doubleVector &variableMins_);
void SetVariableMaxs(const doubleVector &variableMaxs_);
......@@ -125,7 +135,7 @@ public:
void SetHistogramNumBins(int histogramNumBins_);
void SetHistogramStartBin(int histogramStartBin_);
void SetHistogramEndBin(int histogramEndBin_);
void SetHistogramVariableIndex(int histogramVariableIndex_);
void SetHistogramVariable(const std::string &histogramVariable_);
// Property getting methods
const std::string &GetName() const;
......@@ -133,6 +143,9 @@ public:
const std::string &GetSource() const;
std::string &GetSource();
SelectionType GetSelectionType() const;
IDVariableType GetIdVariableType() const;
const std::string &GetIdVariable() const;
std::string &GetIdVariable();
const stringVector &GetVariables() const;
stringVector &GetVariables();
const doubleVector &GetVariableMins() const;
......@@ -147,7 +160,8 @@ public:
int GetHistogramNumBins() const;
int GetHistogramStartBin() const;
int GetHistogramEndBin() const;
int GetHistogramVariableIndex() const;
const std::string &GetHistogramVariable() const;
std::string &GetHistogramVariable();
// Persistence methods
virtual bool CreateNode(DataNode *node, bool completeSave, bool forceAdd);
......@@ -169,6 +183,11 @@ public:
protected:
static std::string HistogramType_ToString(int);
public:
static std::string IDVariableType_ToString(IDVariableType);
static bool IDVariableType_FromString(const std::string &, IDVariableType &);
protected:
static std::string IDVariableType_ToString(int);
public:
// Keyframing methods
virtual std::string GetFieldName(int index) const;
......@@ -185,6 +204,8 @@ public:
ID_name = 0,
ID_source,
ID_selectionType,
ID_idVariableType,
ID_idVariable,
ID_variables,
ID_variableMins,
ID_variableMaxs,
......@@ -196,7 +217,7 @@ public:
ID_histogramNumBins,
ID_histogramStartBin,
ID_histogramEndBin,
ID_histogramVariableIndex,
ID_histogramVariable,
ID__LAST
};
......@@ -204,6 +225,8 @@ private:
std::string name;
std::string source;
int selectionType;
int idVariableType;
std::string idVariable;
stringVector variables;
doubleVector variableMins;
doubleVector variableMaxs;
......@@ -215,12 +238,12 @@ private:
int histogramNumBins;
int histogramStartBin;
int histogramEndBin;
int histogramVariableIndex;
std::string histogramVariable;
// Static class format string for type map.
static const char *TypeMapFormatString;
static const private_tmfs_t TmfsStruct;
};
#define SELECTIONPROPERTIES_TMFS "ssis*d*d*iiiiiiiii"
#define SELECTIONPROPERTIES_TMFS "ssiiss*d*d*iiiiiiiis"
#endif
......@@ -14,6 +14,11 @@
HistogramID
HistogramVariable
</Enum>
<Enum name="IDVariableType">
UseZoneIDForID
UseGlobalZoneIDForID
UseVariableForID
</Enum>
<Field name="name" label="Name of the selection" type="string">
</Field>
<Field name="source" label="The source of data that defines the selection. This is a plot name or a database name." type="string">
......@@ -21,6 +26,11 @@
<Field name="selectionType" label="Selection type" type="enum" subtype="SelectionType">
BasicSelection
</Field>
<Field name="idVariableType" label="ID variable type" type="enum" subtype="IDVariableType">
UseZoneIDForID
</Field>
<Field name="idVariable" label="ID variable" type="string">
</Field>
<Field name="variables" label="Variables" type="stringVector">
</Field>
<Field name="variableMins" label="Variable minimums" type="doubleVector">
......@@ -51,8 +61,7 @@
<Field name="histogramEndBin" label="Ending bin for histogram selection" type="int">
9
</Field>
<Field name="histogramVariableIndex" label="Histogram variable index" type="int">
-1
<Field name="histogramVariable" label="Histogram variable" type="string">
</Field>
<Function name="GetOriginatingPlot" user="true" member="true">
</Function>
......
......@@ -587,7 +587,9 @@ CumulativeQuery::CreateSelection(const SelectionProperties &props,
// Creation: Fri May 20 14:33:41 PDT 2011
//
// Modifications:
//
// Brad Whitlock, Wed Oct 12 12:08:16 PDT 2011
// I made histogram variable be a string instead of an index.
//
// ****************************************************************************
void
......@@ -607,14 +609,7 @@ CumulativeQuery::CalculateFrequency(const SelectionProperties &props,
std::string histVar;
if(props.GetHistogramType() == SelectionProperties::HistogramVariable)
{
// We need to extract another variable.
if(props.GetHistogramVariableIndex() < 0 ||
props.GetHistogramVariableIndex() >= int(props.GetVariables().size()))
{
EXCEPTION1(ImproperUseException, "An invalid histogram variable was specified");
}
histVar = props.GetVariables()[props.GetHistogramVariableIndex()];
histVar = props.GetHistogramVariable();
debug5 << "We're doing histogram by variable " << histVar << endl;
}
......@@ -1267,7 +1262,9 @@ CQFilter::ExecuteAllTimesteps(std::vector<avtDataTree_p> &timesteps)
// Creation: Thu Jun 9 10:50:51 PDT 2011
//
// Modifications:
//
// Brad Whitlock, Wed Oct 12 12:09:52 PDT 2011
// I changed histogram variable from an index to a string.
//
// ****************************************************************************
avtContract_p
......@@ -1278,13 +1275,7 @@ CQFilter::ModifyContract(avtContract_p contract)
// We may need to extract another variable.
if(props.GetHistogramType() == SelectionProperties::HistogramVariable)
{
if(props.GetHistogramVariableIndex() < 0 ||
props.GetHistogramVariableIndex() >= int(props.GetVariables().size()))
{
EXCEPTION1(ImproperUseException, "An invalid histogram variable was specified");
}
std::string histVar = props.GetVariables()[props.GetHistogramVariableIndex()];
const std::string &histVar = props.GetHistogramVariable();
debug5 << "We're doing histogram by variable " << histVar << endl;
std::string origvar(newContract->GetDataRequest()->GetOriginalVariable());
......@@ -1506,7 +1497,9 @@ CumulativeQueryNamedSelectionExtension::CreateSelectionKey(const SelectionProper
// Creation: Wed Sep 7 15:06:55 PDT 2011
//
// Modifications:
//
// Brad Whitlock, Wed Oct 12 12:11:01 PDT 2011
// I changed histogram variable to a string from an index.
//
// ****************************************************************************
bool
......@@ -1529,7 +1522,7 @@ CumulativeQueryNamedSelectionExtension::CheckProperties(const SelectionPropertie
if(newProps.GetHistogramType() == oldProps.GetHistogramType())
{
if(newProps.GetHistogramType() == SelectionProperties::HistogramVariable &&
newProps.GetHistogramVariableIndex() != oldProps.GetHistogramVariableIndex())
newProps.GetHistogramVariable() != oldProps.GetHistogramVariable())
{
typeCloseEnough = false;
}
......
......@@ -450,7 +450,9 @@ QvisSelectionsWindow::CreateTimeControls(QWidget *parent)
// Creation: Fri May 20 16:06:09 PDT 2011
//
// Modifications:
//
// Brad Whitlock, Wed Oct 12 12:23:00 PDT 2011
// Change cqHistogramVariable into a variable button.
//
// ****************************************************************************
QWidget *
......@@ -507,10 +509,14 @@ QvisSelectionsWindow::CreateCQHistogramControls(QWidget *parent)
aLayout->addWidget(matches, 0, 2);
aLayout->addWidget(cqHistogramVariableButton, 1, 2);
cqHistogramVariable = new QComboBox(axisGroup);
cqHistogramVariable = new QvisVariableButton(axisGroup);
cqHistogramVariable->setAddExpr(true);
cqHistogramVariable->setAddDefault(false);
cqHistogramVariable->setVarTypes(QvisVariableButton::Scalars);
cqHistogramVariable->setChangeTextOnVariableChange(true);
aLayout->addWidget(cqHistogramVariable, 1, 3);
connect(cqHistogramVariable, SIGNAL(activated(int)),
this, SLOT(histogramVariableChanged(int)));
connect(cqHistogramVariable, SIGNAL(activated(const QString &)),
this, SLOT(histogramVariableChanged(const QString &)));
cqHistogramNumBinsLabel = new QLabel(tr("Number of bins"), axisGroup);
aLayout->addWidget(cqHistogramNumBinsLabel, 2, 0);
......@@ -1051,10 +1057,6 @@ QvisSelectionsWindow::UpdateSelectionProperties()
cqHistogramType->blockSignals(false);
cqHistogramVariableButton->setEnabled(true);
cqHistogramVariable->blockSignals(true);
cqHistogramVariable->clear();
cqHistogramVariable->blockSignals(false);
SelectionProperties defaults;
cqHistogramNumBins->blockSignals(true);
cqHistogramNumBins->setValue(defaults.GetHistogramNumBins());
......@@ -1165,14 +1167,7 @@ QvisSelectionsWindow::UpdateSelectionProperties()
cqHistogramVariableButton->setEnabled(!selectionProps.GetVariables().empty());
cqHistogramVariable->blockSignals(true);
cqHistogramVariable->clear();
for(size_t v = 0; v < selectionProps.GetVariables().size(); ++v)
cqHistogramVariable->addItem(QString(selectionProps.GetVariables()[v].c_str()));
if(selectionProps.GetHistogramVariableIndex() > 0 &&
selectionProps.GetHistogramVariableIndex() < 4)
{
cqHistogramVariable->setCurrentIndex(selectionProps.GetHistogramVariableIndex());
}
cqHistogramVariable->setVariable(selectionProps.GetHistogramVariable().c_str());
cqHistogramVariable->blockSignals(false);
cqHistogramVariable->setEnabled(!selectionProps.GetVariables().empty() &&
selectionProps.GetHistogramType() == SelectionProperties::HistogramVariable);
......@@ -1859,7 +1854,9 @@ QvisSelectionsWindow::initializeVariableList()
// Creation: Thu Jun 9 16:06:27 PDT 2011
//
// Modifications:
//
// Brad Whitlock, Wed Oct 12 12:27:41 PDT 2011
// I removed some error checking that was no longer needed.
//
// ****************************************************************************
void
......@@ -1877,27 +1874,7 @@ QvisSelectionsWindow::histogramTypeChanged(int value)
selectionProps.SetHistogramType(SelectionProperties::HistogramID);
break;
case 3:
{ // new scope.
bool err = false;
if(selectionProps.GetHistogramVariableIndex() < 0)
{
if(selectionProps.GetVariables().size() > 0)
{
// Select the first variable in the list.
selectionProps.SetHistogramVariableIndex(0);
}
else
{
Error(tr("Variable display is not supported when the selection "
"does not have any variables."));
err = true;
}
}
if(!err)
selectionProps.SetHistogramType(SelectionProperties::HistogramVariable);
}
selectionProps.SetHistogramType(SelectionProperties::HistogramVariable);
break;
}
......@@ -1924,19 +1901,21 @@ QvisSelectionsWindow::histogramTypeChanged(int value)
// This Qt slot function is called when we change the histogram variable.
//
// Arguments:
// index : The histogram variable.
// var : The histogram variable.
//
// Programmer: Brad Whitlock
// Creation: Thu Jun 9 16:08:26 PDT 2011
//
// Modifications:
//
// Brad Whitlock, Wed Oct 12 12:25:54 PDT 2011
// I changed the histogram variable to a string.
//
// ****************************************************************************
void
QvisSelectionsWindow::histogramVariableChanged(int index)
QvisSelectionsWindow::histogramVariableChanged(const QString &var)
{
selectionProps.SetHistogramVariableIndex(index);
selectionProps.SetHistogramVariable(var.toStdString());
Apply(DEFAULT_FORCE_UPDATE, DEFAULT_UPDATE_PLOTS, DONT_ALLOW_CACHING);
}
......
......@@ -77,6 +77,8 @@ class WindowInformation;
// Creation: Fri Aug 6 15:35:12 PDT 2010
//
// Modifications:
// Brad Whitlock, Wed Oct 12 12:18:09 PDT 2011
// Make histogram variable into a variable button instead of combo box.
//
// ****************************************************************************
......@@ -136,7 +138,7 @@ private slots:
void histogramTypeChanged(int value);
void summationChanged(int);
void histogramVariableChanged(int);
void histogramVariableChanged(const QString &);
void histogramNumBinsChanged(int);
void histogramStartChanged(int);
void histogramEndChanged(int);
......@@ -178,7 +180,7 @@ private:
QLabel *cqHistogramTitle;
QButtonGroup *cqHistogramType;
QRadioButton *cqHistogramVariableButton;
QComboBox *cqHistogramVariable;
QvisVariableButton *cqHistogramVariable;
QLabel *cqHistogramNumBinsLabel;
QSpinBox *cqHistogramNumBins;
QLabel *cqHistogramMinLabel;
......
This diff is collapsed.
......@@ -95,6 +95,27 @@ PySelectionProperties_ToString(const SelectionProperties *atts, const char *pref
break;
}
const char *idVariableType_names = "UseZoneIDForID, UseGlobalZoneIDForID, UseVariableForID";
switch (atts->GetIdVariableType())
{
case SelectionProperties::UseZoneIDForID:
SNPRINTF(tmpStr, 1000, "%sidVariableType = %sUseZoneIDForID # %s\n", prefix, prefix, idVariableType_names);
str += tmpStr;
break;
case SelectionProperties::UseGlobalZoneIDForID:
SNPRINTF(tmpStr, 1000, "%sidVariableType = %sUseGlobalZoneIDForID # %s\n", prefix, prefix, idVariableType_names);
str += tmpStr;
break;
case SelectionProperties::UseVariableForID:
SNPRINTF(tmpStr, 1000, "%sidVariableType = %sUseVariableForID # %s\n", prefix, prefix, idVariableType_names);
str += tmpStr;
break;
default:
break;
}
SNPRINTF(tmpStr, 1000, "%sidVariable = \"%s\"\n", prefix, atts->GetIdVariable().c_str());
str += tmpStr;
{ const stringVector &variables = atts->GetVariables();
SNPRINTF(tmpStr, 1000, "%svariables = (", prefix);
str += tmpStr;
......@@ -193,7 +214,7 @@ PySelectionProperties_ToString(const SelectionProperties *atts, const char *pref
str += tmpStr;
SNPRINTF(tmpStr, 1000, "%shistogramEndBin = %d\n", prefix, atts->GetHistogramEndBin());
str += tmpStr;
SNPRINTF(tmpStr, 1000, "%shistogramVariableIndex = %d\n", prefix, atts->GetHistogramVariableIndex());
SNPRINTF(tmpStr, 1000, "%shistogramVariable = \"%s\"\n", prefix, atts->GetHistogramVariable().c_str());
str += tmpStr;
return str;
}
......@@ -288,6 +309,63 @@ SelectionProperties_GetSelectionType(PyObject *self, PyObject *args)
return retval;
}
/*static*/ PyObject *
SelectionProperties_SetIdVariableType(PyObject *self, PyObject *args)
{
SelectionPropertiesObject *obj = (SelectionPropertiesObject *)self;
int ival;
if(!PyArg_ParseTuple(args, "i", &ival))
return NULL;
// Set the idVariableType in the object.
if(ival >= 0 && ival < 3)
obj->data->SetIdVariableType(SelectionProperties::IDVariableType(ival));
else
{
fprintf(stderr, "An invalid idVariableType value was given. "
"Valid values are in the range of [0,2]. "
"You can also use the following names: "
"UseZoneIDForID, UseGlobalZoneIDForID, UseVariableForID.");
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
}
/*static*/ PyObject *
SelectionProperties_GetIdVariableType(PyObject *self, PyObject *args)
{
SelectionPropertiesObject *obj = (SelectionPropertiesObject *)self;
PyObject *retval = PyInt_FromLong(long(obj->data->GetIdVariableType()));
return retval;
}
/*static*/ PyObject *
SelectionProperties_SetIdVariable(PyObject *self, PyObject *args)
{
SelectionPropertiesObject *obj = (SelectionPropertiesObject *)self;
char *str;
if(!PyArg_ParseTuple(args, "s", &str))
return NULL;
// Set the idVariable in the object.
obj->data->SetIdVariable(std::string(str));
Py_INCREF(Py_None);
return Py_None;
}
/*static*/ PyObject *
SelectionProperties_GetIdVariable(PyObject *self, PyObject *args)
{
SelectionPropertiesObject *obj = (SelectionPropertiesObject *)self;
PyObject *retval = PyString_FromString(obj->data->GetIdVariable().c_str());
return retval;
}
/*static*/ PyObject *
SelectionProperties_SetVariables(PyObject *self, PyObject *args)
{
......@@ -674,26 +752,26 @@ SelectionProperties_GetHistogramEndBin(PyObject *self, PyObject *args)
}
/*static*/ PyObject *
SelectionProperties_SetHistogramVariableIndex(PyObject *self, PyObject *args)
SelectionProperties_SetHistogramVariable(PyObject *self, PyObject *args)
{
SelectionPropertiesObject *obj = (SelectionPropertiesObject *)self;
int ival;
if(!PyArg_ParseTuple(args, "i", &ival))
char *str;
if(!PyArg_ParseTuple(args, "s", &str))
return NULL;
// Set the histogramVariableIndex in the object.
obj->data->SetHistogramVariableIndex((int)ival);
// Set the histogramVariable in the object.
obj->data->SetHistogramVariable(std::string(str));
Py_INCREF(Py_None);
return Py_None;
}
/*static*/ PyObject *
SelectionProperties_GetHistogramVariableIndex(PyObject *self, PyObject *args)
SelectionProperties_GetHistogramVariable(PyObject *self, PyObject *args)
{
SelectionPropertiesObject *obj = (SelectionPropertiesObject *)self;
PyObject *retval = PyInt_FromLong(long(obj->data->GetHistogramVariableIndex()));
PyObject *retval = PyString_FromString(obj->data->GetHistogramVariable().c_str());
return retval;
}
......@@ -707,6 +785,10 @@ PyMethodDef PySelectionProperties_methods[SELECTIONPROPERTIES_NMETH] = {
{"GetSource", SelectionProperties_GetSource, METH_VARARGS},
{"SetSelectionType", SelectionProperties_SetSelectionType, METH_VARARGS},
{"GetSelectionType", SelectionProperties_GetSelectionType, METH_VARARGS},
{"SetIdVariableType", SelectionProperties_SetIdVariableType, METH_VARARGS},
{"GetIdVariableType", SelectionProperties_GetIdVariableType, METH_VARARGS},
{"SetIdVariable", SelectionProperties_SetIdVariable, METH_VARARGS},
{"GetIdVariable", SelectionProperties_GetIdVariable, METH_VARARGS},
{"SetVariables", SelectionProperties_SetVariables, METH_VARARGS},
{"GetVariables", SelectionProperties_GetVariables, METH_VARARGS},
{"SetVariableMins", SelectionProperties_SetVariableMins, METH_VARARGS},
......@@ -729,8 +811,8 @@ PyMethodDef PySelectionProperties_methods[SELECTIONPROPERTIES_NMETH] = {
{"GetHistogramStartBin", SelectionProperties_GetHistogramStartBin, METH_VARARGS},
{"SetHistogramEndBin", SelectionProperties_SetHistogramEndBin, METH_VARARGS},
{"GetHistogramEndBin", SelectionProperties_GetHistogramEndBin, METH_VARARGS},
{"SetHistogramVariableIndex", SelectionProperties_SetHistogramVariableIndex, METH_VARARGS},
{"GetHistogramVariableIndex", SelectionProperties_GetHistogramVariableIndex, METH_VARARGS},
{"SetHistogramVariable", SelectionProperties_SetHistogramVariable, METH_VARARGS},
{"GetHistogramVariable", SelectionProperties_GetHistogramVariable, METH_VARARGS},
{NULL, NULL}
};
......@@ -770,6 +852,17 @@ PySelectionProperties_getattr(PyObject *self, char *name)
if(strcmp(name, "CumulativeQuerySelection") == 0)
return PyInt_FromLong(long(SelectionProperties::CumulativeQuerySelection));
if(strcmp(name, "idVariableType") == 0)
return SelectionProperties_GetIdVariableType(self, NULL);
if(strcmp(name, "UseZoneIDForID") == 0)
return PyInt_FromLong(long(SelectionProperties::UseZoneIDForID));
if(strcmp(name, "UseGlobalZoneIDForID") == 0)
return PyInt_FromLong(long(SelectionProperties::UseGlobalZoneIDForID));
if(strcmp(name, "UseVariableForID") == 0)
return PyInt_FromLong(long(SelectionProperties::UseVariableForID));
if(strcmp(name, "idVariable") == 0)
return SelectionProperties_GetIdVariable(self, NULL);
if(strcmp(name, "variables") == 0)
return SelectionProperties_GetVariables(self, NULL);
if(strcmp(name, "variableMins") == 0)
......@@ -806,8 +899,8 @@ PySelectionProperties_getattr(PyObject *self, char *name)
return SelectionProperties_GetHistogramStartBin(self, NULL);
if(strcmp(name, "histogramEndBin") == 0)
return SelectionProperties_GetHistogramEndBin(self, NULL);
if(strcmp(name, "histogramVariableIndex") == 0)
return SelectionProperties_GetHistogramVariableIndex(self, NULL);
if(strcmp(name, "histogramVariable") == 0)
return SelectionProperties_GetHistogramVariable(self, NULL);
return Py_FindMethod(PySelectionProperties_methods, self, name);
}
......@@ -828,6 +921,10 @@ PySelectionProperties_setattr(PyObject *self, char *name, PyObject *args)
obj = SelectionProperties_SetSource(self, tuple);
else if(strcmp(name, "selectionType") == 0)
obj = SelectionProperties_SetSelectionType(self, tuple);
else if(strcmp(name, "idVariableType") == 0)
obj = SelectionProperties_SetIdVariableType(self, tuple);
else if(strcmp(name, "idVariable") == 0)
obj = SelectionProperties_SetIdVariable(self, tuple);
else if(strcmp(name, "variables") == 0)
obj = SelectionProperties_SetVariables(self, tuple);
else if(strcmp(name, "variableMins") == 0)
......@@ -850,8 +947,8 @@ PySelectionProperties_setattr(PyObject *self, char *name, PyObject *args)
obj = SelectionProperties_SetHistogramStartBin(self, tuple);
else if(strcmp(name, "histogramEndBin") == 0)
obj = SelectionProperties_SetHistogramEndBin(self, tuple);
else if(strcmp(name, "histogramVariableIndex") == 0)
obj = SelectionProperties_SetHistogramVariableIndex(self, tuple);
else if(strcmp(name, "histogramVariable") == 0)
obj = SelectionProperties_SetHistogramVariable(self, tuple);
if(obj != NULL)
Py_DECREF(obj);
......
......@@ -45,7 +45,7 @@
//
// Functions exposed to the VisIt module.
//
#define SELECTIONPROPERTIES_NMETH 32
#define SELECTIONPROPERTIES_NMETH 36
void VISITPY_API PySelectionProperties_StartUp(SelectionProperties *subj, void *data);
void VISITPY_API PySelectionProperties_CloseDown();
VISITPY_API PyMethodDef * PySelectionProperties_GetMethodTable(int *nMethods);
......
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