Commit 4b98f3f6 authored by js9's avatar js9

Adding ability to unify axis extents across all axes.



git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@3182 18c085ea-50e0-402c-830e-de6fd14e8384
parent 67805283
......@@ -181,6 +181,19 @@ ParallelCoordinatesAttributes::AttributesAreConsistent() const
Function: ChangesRequireRecalculation
Declaration: bool ChangesRequireRecalculation(const ParallelCoordinatesAttributes &obj);
Definition:
// ****************************************************************************
// Method: ParallelCoordinatesAttributes::ChangesRequireRecalculation
//
// Purpose: Sets the attributes from another attribute group
//
// Programmer: Jeremy Meredith
// Creation: January 31, 2008
//
// Modifications:
// Jeremy Meredith, Fri Feb 8 12:35:47 EST 2008
// Added unifyAxisExtents.
//
// ****************************************************************************
bool
ParallelCoordinatesAttributes::ChangesRequireRecalculation(
const ParallelCoordinatesAttributes &obj)
......@@ -192,7 +205,8 @@ ParallelCoordinatesAttributes::ChangesRequireRecalculation(
drawLinesOnlyIfExtentsOn != obj.drawLinesOnlyIfExtentsOn ||
contextNumPartitions != obj.contextNumPartitions ||
contextGamma != obj.contextGamma ||
orderedAxisNames != obj.orderedAxisNames)
orderedAxisNames != obj.orderedAxisNames ||
unifyAxisExtents != obj.unifyAxisExtents)
{
return true;
}
......
......@@ -48,6 +48,9 @@
<Field name="drawLinesOnlyIfExtentsOn" label="Draw lines only when extents have been limited" type="bool">
true
</Field>
<Field name="unifyAxisExtents" label="Unify the data extents across all axes" type="bool">
false
</Field>
<Function name="InsertAxis" user="true" member="true">
</Function>
<Function name="DeleteAxis" user="true" member="true">
......
......@@ -52,7 +52,7 @@
// Notes: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Thu Feb 7 17:45:38 PST 2008
// Creation: Fri Feb 8 12:36:04 PDT 2008
//
// Modifications:
//
......@@ -93,6 +93,7 @@ public:
void SetContextNumPartitions(int contextNumPartitions_);
void SetContextColor(const ColorAttribute &contextColor_);
void SetDrawLinesOnlyIfExtentsOn(bool drawLinesOnlyIfExtentsOn_);
void SetUnifyAxisExtents(bool unifyAxisExtents_);
// Property getting methods
const stringVector &GetOrderedAxisNames() const;
......@@ -110,6 +111,7 @@ public:
const ColorAttribute &GetContextColor() const;
ColorAttribute &GetContextColor();
bool GetDrawLinesOnlyIfExtentsOn() const;
bool GetUnifyAxisExtents() const;
// Persistence methods
virtual bool CreateNode(DataNode *node, bool completeSave, bool forceAdd);
......@@ -140,7 +142,8 @@ public:
ID_contextGamma,
ID_contextNumPartitions,
ID_contextColor,
ID_drawLinesOnlyIfExtentsOn
ID_drawLinesOnlyIfExtentsOn,
ID_unifyAxisExtents
};
private:
......@@ -154,6 +157,7 @@ private:
int contextNumPartitions;
ColorAttribute contextColor;
bool drawLinesOnlyIfExtentsOn;
bool unifyAxisExtents;
// Static class format string for type map.
static const char *TypeMapFormatString;
......
......@@ -54,7 +54,7 @@ import llnl.visit.ColorAttribute;
// Notes: Autogenerated by xml2java.
//
// Programmer: xml2java
// Creation: Mon Feb 4 16:04:11 PST 2008
// Creation: Fri Feb 8 09:44:10 PDT 2008
//
// Modifications:
//
......@@ -64,14 +64,11 @@ public class ParallelCoordinatesAttributes extends AttributeSubject implements P
{
public ParallelCoordinatesAttributes()
{
super(10);
super(11);
orderedAxisNames = new Vector();
orderedAxisNames.addElement(new String("default"));
extentMinima = new Vector();
extentMinima.addElement(new Double(0));
extentMaxima = new Vector();
extentMaxima.addElement(new Double(1));
drawLines = true;
linesColor = new ColorAttribute(128, 0, 0);
drawContext = true;
......@@ -79,11 +76,12 @@ public class ParallelCoordinatesAttributes extends AttributeSubject implements P
contextNumPartitions = 128;
contextColor = new ColorAttribute(0, 220, 0);
drawLinesOnlyIfExtentsOn = true;
unifyAxisExtents = false;
}
public ParallelCoordinatesAttributes(ParallelCoordinatesAttributes obj)
{
super(10);
super(11);
int i;
......@@ -112,6 +110,7 @@ public class ParallelCoordinatesAttributes extends AttributeSubject implements P
contextNumPartitions = obj.contextNumPartitions;
contextColor = new ColorAttribute(obj.contextColor);
drawLinesOnlyIfExtentsOn = obj.drawLinesOnlyIfExtentsOn;
unifyAxisExtents = obj.unifyAxisExtents;
SelectAll();
}
......@@ -130,7 +129,8 @@ public class ParallelCoordinatesAttributes extends AttributeSubject implements P
(contextGamma == obj.contextGamma) &&
(contextNumPartitions == obj.contextNumPartitions) &&
(contextColor == obj.contextColor) &&
(drawLinesOnlyIfExtentsOn == obj.drawLinesOnlyIfExtentsOn));
(drawLinesOnlyIfExtentsOn == obj.drawLinesOnlyIfExtentsOn) &&
(unifyAxisExtents == obj.unifyAxisExtents));
}
public String GetName() { return "ParallelCoordinates"; }
......@@ -197,6 +197,12 @@ public class ParallelCoordinatesAttributes extends AttributeSubject implements P
Select(9);
}
public void SetUnifyAxisExtents(boolean unifyAxisExtents_)
{
unifyAxisExtents = unifyAxisExtents_;
Select(10);
}
// Property getting methods
public Vector GetOrderedAxisNames() { return orderedAxisNames; }
public Vector GetExtentMinima() { return extentMinima; }
......@@ -208,6 +214,7 @@ public class ParallelCoordinatesAttributes extends AttributeSubject implements P
public int GetContextNumPartitions() { return contextNumPartitions; }
public ColorAttribute GetContextColor() { return contextColor; }
public boolean GetDrawLinesOnlyIfExtentsOn() { return drawLinesOnlyIfExtentsOn; }
public boolean GetUnifyAxisExtents() { return unifyAxisExtents; }
// Write and read methods.
public void WriteAtts(CommunicationBuffer buf)
......@@ -232,6 +239,8 @@ public class ParallelCoordinatesAttributes extends AttributeSubject implements P
contextColor.Write(buf);
if(WriteSelect(9, buf))
buf.WriteBool(drawLinesOnlyIfExtentsOn);
if(WriteSelect(10, buf))
buf.WriteBool(unifyAxisExtents);
}
public void ReadAtts(int n, CommunicationBuffer buf)
......@@ -273,6 +282,9 @@ public class ParallelCoordinatesAttributes extends AttributeSubject implements P
case 9:
SetDrawLinesOnlyIfExtentsOn(buf.ReadBool());
break;
case 10:
SetUnifyAxisExtents(buf.ReadBool());
break;
}
}
}
......@@ -289,5 +301,6 @@ public class ParallelCoordinatesAttributes extends AttributeSubject implements P
private int contextNumPartitions;
private ColorAttribute contextColor;
private boolean drawLinesOnlyIfExtentsOn;
private boolean unifyAxisExtents;
}
......@@ -51,7 +51,7 @@
// Note: Autogenerated by xml2python. Do not modify by hand!
//
// Programmer: xml2python
// Creation: Mon Feb 4 16:04:18 PST 2008
// Creation: Fri Feb 8 09:44:14 PDT 2008
//
// ****************************************************************************
......@@ -150,6 +150,11 @@ PyParallelCoordinatesAttributes_ToString(const ParallelCoordinatesAttributes *at
else
SNPRINTF(tmpStr, 1000, "%sdrawLinesOnlyIfExtentsOn = 0\n", prefix);
str += tmpStr;
if(atts->GetUnifyAxisExtents())
SNPRINTF(tmpStr, 1000, "%sunifyAxisExtents = 1\n", prefix);
else
SNPRINTF(tmpStr, 1000, "%sunifyAxisExtents = 0\n", prefix);
str += tmpStr;
return str;
}
......@@ -611,6 +616,30 @@ ParallelCoordinatesAttributes_GetDrawLinesOnlyIfExtentsOn(PyObject *self, PyObje
return retval;
}
static PyObject *
ParallelCoordinatesAttributes_SetUnifyAxisExtents(PyObject *self, PyObject *args)
{
ParallelCoordinatesAttributesObject *obj = (ParallelCoordinatesAttributesObject *)self;
int ival;
if(!PyArg_ParseTuple(args, "i", &ival))
return NULL;
// Set the unifyAxisExtents in the object.
obj->data->SetUnifyAxisExtents(ival != 0);
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
ParallelCoordinatesAttributes_GetUnifyAxisExtents(PyObject *self, PyObject *args)
{
ParallelCoordinatesAttributesObject *obj = (ParallelCoordinatesAttributesObject *)self;
PyObject *retval = PyInt_FromLong(obj->data->GetUnifyAxisExtents()?1L:0L);
return retval;
}
static struct PyMethodDef ParallelCoordinatesAttributes_methods[] = {
......@@ -635,6 +664,8 @@ static struct PyMethodDef ParallelCoordinatesAttributes_methods[] = {
{"GetContextColor", ParallelCoordinatesAttributes_GetContextColor, METH_VARARGS},
{"SetDrawLinesOnlyIfExtentsOn", ParallelCoordinatesAttributes_SetDrawLinesOnlyIfExtentsOn, METH_VARARGS},
{"GetDrawLinesOnlyIfExtentsOn", ParallelCoordinatesAttributes_GetDrawLinesOnlyIfExtentsOn, METH_VARARGS},
{"SetUnifyAxisExtents", ParallelCoordinatesAttributes_SetUnifyAxisExtents, METH_VARARGS},
{"GetUnifyAxisExtents", ParallelCoordinatesAttributes_GetUnifyAxisExtents, METH_VARARGS},
{NULL, NULL}
};
......@@ -683,6 +714,8 @@ ParallelCoordinatesAttributes_getattr(PyObject *self, char *name)
return ParallelCoordinatesAttributes_GetContextColor(self, NULL);
if(strcmp(name, "drawLinesOnlyIfExtentsOn") == 0)
return ParallelCoordinatesAttributes_GetDrawLinesOnlyIfExtentsOn(self, NULL);
if(strcmp(name, "unifyAxisExtents") == 0)
return ParallelCoordinatesAttributes_GetUnifyAxisExtents(self, NULL);
return Py_FindMethod(ParallelCoordinatesAttributes_methods, self, name);
}
......@@ -717,6 +750,8 @@ ParallelCoordinatesAttributes_setattr(PyObject *self, char *name, PyObject *args
retval = (ParallelCoordinatesAttributes_SetContextColor(self, tuple) != NULL);
else if(strcmp(name, "drawLinesOnlyIfExtentsOn") == 0)
retval = (ParallelCoordinatesAttributes_SetDrawLinesOnlyIfExtentsOn(self, tuple) != NULL);
else if(strcmp(name, "unifyAxisExtents") == 0)
retval = (ParallelCoordinatesAttributes_SetUnifyAxisExtents(self, tuple) != NULL);
Py_DECREF(tuple);
return retval ? 0 : -1;
......
......@@ -122,6 +122,9 @@ QvisParallelCoordinatesPlotWindow::~QvisParallelCoordinatesPlotWindow()
// Added a checkbox to allow the lines to be hidden when the extents
// tool has not limited the viewing range to a focus.
//
// Jeremy Meredith, Fri Feb 8 12:34:19 EST 2008
// Added ability to unify extents across all axes.
//
// ****************************************************************************
void
......@@ -260,6 +263,12 @@ QvisParallelCoordinatesPlotWindow::CreateWindowContents()
this, SLOT(contextColorChanged(const QColor&)));
contextLayout->addWidget(contextColor, 2,1);
// Unify axis extents
unifyAxisExtents = new QCheckBox("Unify the data extents across all axes",
central, "unifyAxisExtents");
connect(unifyAxisExtents, SIGNAL(toggled(bool)),
this, SLOT(unifyAxisExtentsToggled(bool)));
topLayout->addWidget(unifyAxisExtents);
}
......@@ -281,6 +290,9 @@ QvisParallelCoordinatesPlotWindow::CreateWindowContents()
// For an empty list of axis names, disable critical widgets and
// put in a useful message.
//
// Jeremy Meredith, Fri Feb 8 12:34:19 EST 2008
// Added ability to unify extents across all axes. Also fixed typo.
//
// ****************************************************************************
void
......@@ -321,7 +333,7 @@ QvisParallelCoordinatesPlotWindow::UpdateWindow(bool doAll)
if (atts->GetOrderedAxisNames().size() == 0)
{
axisList->insertItem("(read-only; either no plot");
axisList->insertItem(" is current active or the");
axisList->insertItem(" is currently active or the");
axisList->insertItem(" active plot was created");
axisList->insertItem(" from an array variable)");
}
......@@ -380,6 +392,11 @@ QvisParallelCoordinatesPlotWindow::UpdateWindow(bool doAll)
linesOnlyIfExtents->setChecked(atts->GetDrawLinesOnlyIfExtentsOn());
linesOnlyIfExtents->blockSignals(false);
break;
case ParallelCoordinatesAttributes::ID_unifyAxisExtents:
unifyAxisExtents->blockSignals(true);
unifyAxisExtents->setChecked(atts->GetUnifyAxisExtents());
unifyAxisExtents->blockSignals(false);
break;
}
}
......@@ -900,3 +917,25 @@ QvisParallelCoordinatesPlotWindow::linesOnlyIfExtentsToggled(bool val)
atts->SetDrawLinesOnlyIfExtentsOn(val);
Apply();
}
// ****************************************************************************
// Method: QvisParallelCoordinatesPlotWindow::unifyAxisExtentsToggled
//
// Purpose:
// Executed when the toggle button for unifying data extents across
// all processors is toggled.
//
// Arguments:
// val the new state
//
// Programmer: Jeremy Meredith
// Creation: February 8, 2008
//
// ****************************************************************************
void
QvisParallelCoordinatesPlotWindow::unifyAxisExtentsToggled(bool val)
{
atts->SetUnifyAxisExtents(val);
Apply();
}
......@@ -70,6 +70,8 @@ class QvisVariableButton;
// Notes: initial implementation taken from the ParallelAxis plot window.
//
// Modifications:
// Jeremy Meredith, Fri Feb 8 12:34:19 EST 2008
// Added ability to unify extents across all axes.
//
// ****************************************************************************
......@@ -109,6 +111,7 @@ class QvisParallelCoordinatesPlotWindow : public QvisPostableWindowObserver
void moveAxisUp();
void moveAxisDown();
void linesOnlyIfExtentsToggled(bool);
void unifyAxisExtentsToggled(bool);
private:
int plotType;
......@@ -135,6 +138,8 @@ class QvisParallelCoordinatesPlotWindow : public QvisPostableWindowObserver
QLabel *contextNumPartitionsLabel;
QLabel *contextColorLabel;
QCheckBox *unifyAxisExtents;
ParallelCoordinatesAttributes *atts;
};
......
......@@ -681,6 +681,9 @@ avtParallelCoordinatesFilter::ReleaseData(void)
// Jeremy Meredith, Thu Feb 7 17:46:59 EST 2008
// Handle array variables and bin-defined axis x-positions.
//
// Jeremy Meredith, Fri Feb 8 12:32:36 EST 2008
// Support unifying extents across all axes.
//
// ****************************************************************************
void
......@@ -694,6 +697,9 @@ avtParallelCoordinatesFilter::ComputeCurrentDataExtentsOverAllDomains()
if (isArrayVar)
{
avtDataAttributes &inatts = GetInput()->GetInfo().GetAttributes();
avtDataAttributes &outAtts = GetOutput()->GetInfo().GetAttributes();
// Get the actual extents for the array variable
int dim = inatts.GetVariableDimension(pipelineVariable);
const vector<double> &bins = inatts.GetVariableBinRanges(
pipelineVariable);
......@@ -708,6 +714,30 @@ avtParallelCoordinatesFilter::ComputeCurrentDataExtentsOverAllDomains()
double *varDataExtents = new double[dim*2];
ext->CopyTo(varDataExtents);
// If we're unifying the extents across all axes, update
// with the global limits and store it in the output
if (parCoordsAtts.GetUnifyAxisExtents())
{
double globalMin = DBL_MAX;
double globalMax = -DBL_MAX;
for (axisNum = 0; axisNum < axisCount; axisNum++)
{
if (varDataExtents[2*axisNum + 0] < globalMin)
globalMin = varDataExtents[2*axisNum + 0];
if (varDataExtents[2*axisNum + 1] > globalMax)
globalMax = varDataExtents[2*axisNum + 1];
}
for (axisNum = 0; axisNum < axisMinima.size(); axisNum++)
{
varDataExtents[axisNum*2 + 0] = globalMin;
varDataExtents[axisNum*2 + 1] = globalMax;
}
outAtts.GetVariableComponentExtents(pipelineVariable)->
Set(varDataExtents);
}
// Set the internal data members we need to have set
for (int i=0; i<dim; i++)
{
if (bins.size() > i)
......@@ -718,25 +748,78 @@ avtParallelCoordinatesFilter::ComputeCurrentDataExtentsOverAllDomains()
axisMaxima[i] = varDataExtents[i*2+1];
}
avtDataAttributes &outAtts = GetOutput()->GetInfo().GetAttributes();
// probably not needed, since the things that use this information
// already know to treat array variables specially
outAtts.SetUseForAxis(0, pipelineVariable);
delete[] varDataExtents;
}
else
{
stringVector curAxisVarNames = parCoordsAtts.GetOrderedAxisNames();
avtDataAttributes &outAtts = GetOutput()->GetInfo().GetAttributes();
// Get the actual extents for each axis scalar variable
double *varDataExtents = new double[axisCount*2];
for (axisNum = 0; axisNum < axisCount; axisNum++)
{
string axisVarName = parCoordsAtts.GetOrderedAxisNames()[axisNum];
GetDataExtents(&(varDataExtents[2*axisNum]), axisVarName.c_str());
}
// If we're unifying the extents across all axes, update
// with the global limits before storing it in the output
if (parCoordsAtts.GetUnifyAxisExtents())
{
double globalMin = DBL_MAX;
double globalMax = -DBL_MAX;
for (axisNum = 0; axisNum < axisCount; axisNum++)
{
if (varDataExtents[2*axisNum + 0] < globalMin)
globalMin = varDataExtents[2*axisNum + 0];
if (varDataExtents[2*axisNum + 1] > globalMax)
globalMax = varDataExtents[2*axisNum + 1];
}
for (axisNum = 0; axisNum < axisCount; axisNum++)
{
varDataExtents[2*axisNum + 0] = globalMin;
varDataExtents[2*axisNum + 1] = globalMax;
}
}
// Update the output extents for the variables, and
// update the internal data members we need to have set
for (axisNum = 0; axisNum < axisCount; axisNum++)
{
std::string axisVarName = curAxisVarNames[axisNum];
string axisVarName = parCoordsAtts.GetOrderedAxisNames()[axisNum];
double varDataExtent[2];
avtDataAttributes &outAtts = GetOutput()->GetInfo().GetAttributes();
GetDataExtents(varDataExtent, axisVarName.c_str());
outAtts.GetCumulativeTrueDataExtents(axisVarName.c_str())->Set(varDataExtent);
outAtts.GetCumulativeTrueDataExtents(axisVarName.c_str())->
Set(&(varDataExtents[2*axisNum]));
outAtts.SetUseForAxis(axisNum, axisVarName.c_str());
axisXPositions[axisNum] = axisNum;
axisMinima[axisNum] = varDataExtent[0];
axisMaxima[axisNum] = varDataExtent[1];
axisMinima[axisNum] = varDataExtents[2*axisNum + 0];
axisMaxima[axisNum] = varDataExtents[2*axisNum + 1];
}
delete[] varDataExtents;
}
if (parCoordsAtts.GetUnifyAxisExtents())
{
double globalMin = DBL_MAX;
double globalMax = -DBL_MAX;
for (axisNum = 0; axisNum < axisMinima.size(); axisNum++)
{
double axisMin = axisMinima[axisNum];
double axisMax = axisMaxima[axisNum];
if (axisMin < globalMin)
globalMin = axisMin;
if (axisMax > globalMax)
globalMax = axisMax;
}
for (axisNum = 0; axisNum < axisMinima.size(); axisNum++)
{
axisMinima[axisNum] = globalMin;
axisMaxima[axisNum] = globalMax;
}
}
......
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