Commit 4b3cb34b authored by hrchilds's avatar hrchilds

Update from July 26, 2004

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@287 18c085ea-50e0-402c-830e-de6fd14e8384
parent fdd4b89a
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -49,6 +49,10 @@ struct DBATTS_API avtMeshMetaData : public AttributeSubject
std::string yUnits;
std::string zUnits;
std::string xLabel;
std::string yLabel;
std::string zLabel;
bool validVariable;
public:
......@@ -82,6 +86,8 @@ struct DBATTS_API avtScalarMetaData : public AttributeSubject
bool validVariable;
bool treatAsASCII;
bool hasUnits;
std::string units;
public:
avtScalarMetaData();
avtScalarMetaData(std::string, std::string, avtCentering);
......@@ -112,6 +118,8 @@ struct DBATTS_API avtVectorMetaData : public AttributeSubject
bool validVariable;
bool hasUnits;
std::string units;
public:
avtVectorMetaData();
avtVectorMetaData(std::string, std::string, avtCentering, int);
......@@ -136,7 +144,8 @@ struct DBATTS_API avtTensorMetaData : public AttributeSubject
int dim;
avtCentering centering;
bool validVariable;
bool hasUnits;
std::string units;
public:
avtTensorMetaData();
avtTensorMetaData(std::string, std::string, avtCentering, int);
......@@ -159,6 +168,8 @@ struct DBATTS_API avtSymmetricTensorMetaData : public AttributeSubject
bool validVariable;
bool hasUnits;
std::string units;
public:
avtSymmetricTensorMetaData();
avtSymmetricTensorMetaData(std::string, std::string, avtCentering, int);
......@@ -242,8 +253,11 @@ protected:
struct DBATTS_API avtCurveMetaData : public AttributeSubject
{
std::string name;
std::string xUnits;
std::string xLabel;
std::string yUnits;
std::string yLabel;
bool validVariable;
public:
avtCurveMetaData();
avtCurveMetaData(std::string);
......@@ -378,6 +392,7 @@ class DBATTS_API avtDatabaseMetaData : public AttributeSubject
std::string databaseName;
std::string fileFormat;
std::string databaseComment;
ExpressionList exprList;
......@@ -447,6 +462,10 @@ public:
void SetTimeStepNames(const stringVector &tsn);
const stringVector &GetTimeStepNames() const { return timeStepNames; };
void SetDatabaseComment(const std::string &comment)
{ databaseComment = comment; };
const std::string &GetDatabaseComment() const { return databaseComment; };
void Add(avtMeshMetaData *);
void Add(avtScalarMetaData *);
void Add(avtVectorMetaData *);
......
......@@ -256,6 +256,10 @@ avtDatabase::GetOutput(const char *var, int ts)
// Kathleen Bonnell, Thu Jul 22 12:10:19 PDT 2004
// Set avtDataAttributes::treatAsASCII from ScalarMetaData::treatAsASCII.
//
// Brad Whitlock, Tue Jul 20 13:35:38 PST 2004
// Added units for scalar, vector, tensor, symmetric tensor, and curve
// vars. I also added labels for meshes.
//
// ****************************************************************************
void
......@@ -282,6 +286,9 @@ avtDatabase::PopulateDataObjectInformation(avtDataObject_p &dob,
atts.SetXUnits(mmd->xUnits);
atts.SetYUnits(mmd->yUnits);
atts.SetZUnits(mmd->zUnits);
atts.SetXLabel(mmd->xLabel);
atts.SetYLabel(mmd->yLabel);
atts.SetZLabel(mmd->zLabel);
atts.SetContainsGhostZones(mmd->containsGhostZones);
atts.SetContainsOriginalCells(mmd->containsOriginalCells);
atts.SetContainsOriginalNodes(mmd->containsOriginalNodes);
......@@ -329,7 +336,10 @@ avtDatabase::PopulateDataObjectInformation(avtDataObject_p &dob,
const avtScalarMetaData *smd = GetMetaData(ts)->GetScalar(var_list[i]);
if (smd != NULL)
{
atts.AddVariable(var_list[i]);
if (smd->hasUnits)
atts.AddVariable(var_list[i], smd->units);
else
atts.AddVariable(var_list[i]);
atts.SetVariableDimension(1, var_list[i]);
atts.SetCentering(smd->centering, var_list[i]);
atts.SetTreatAsASCII(smd->treatAsASCII, var_list[i]);
......@@ -351,7 +361,10 @@ avtDatabase::PopulateDataObjectInformation(avtDataObject_p &dob,
const avtVectorMetaData *vmd = GetMetaData(ts)->GetVector(var_list[i]);
if (vmd != NULL)
{
atts.AddVariable(var_list[i]);
if (vmd->hasUnits)
atts.AddVariable(var_list[i], vmd->units);
else
atts.AddVariable(var_list[i]);
atts.SetVariableDimension(vmd->varDim, var_list[i]);
atts.SetCentering(vmd->centering, var_list[i]);
......@@ -372,7 +385,10 @@ avtDatabase::PopulateDataObjectInformation(avtDataObject_p &dob,
const avtTensorMetaData *tmd = GetMetaData(ts)->GetTensor(var_list[i]);
if (tmd != NULL)
{
atts.AddVariable(var_list[i]);
if (tmd->hasUnits)
atts.AddVariable(var_list[i], tmd->units);
else
atts.AddVariable(var_list[i]);
atts.SetVariableDimension(9, var_list[i]);
atts.SetCentering(tmd->centering, var_list[i]);
}
......@@ -381,7 +397,10 @@ avtDatabase::PopulateDataObjectInformation(avtDataObject_p &dob,
GetMetaData(ts)->GetSymmTensor(var_list[i]);
if (stmd != NULL)
{
atts.AddVariable(var_list[i]);
if (tmd->hasUnits)
atts.AddVariable(var_list[i], tmd->units);
else
atts.AddVariable(var_list[i]);
atts.SetVariableDimension(9, var_list[i]);
atts.SetCentering(stmd->centering, var_list[i]);
}
......@@ -405,6 +424,10 @@ avtDatabase::PopulateDataObjectInformation(avtDataObject_p &dob,
{
atts.SetTopologicalDimension(1);
atts.SetSpatialDimension(2);
atts.SetXUnits(cmd->xUnits);
atts.SetXLabel(cmd->xLabel);
atts.SetYUnits(cmd->yUnits);
atts.SetYLabel(cmd->yLabel);
}
}
atts.SetActiveVariable(var);
......
......@@ -222,7 +222,7 @@ vtkDataSet *
avtExpressionFilter::ExecuteData(vtkDataSet *in_ds, int index,
std::string label)
{
int i, j;
int i;
//
// Start off by having the derived type calculate the derived variable.
......@@ -368,7 +368,6 @@ avtExpressionFilter::ExecuteData(vtkDataSet *in_ds, int index,
// Creation: June 7, 2002
//
// Modifications:
//
// Akira Haddox, Mon Aug 19 16:41:12 PDT 2002
// Modified to set the centering of the variable to cell or point
// based on IsPointVariable().
......@@ -376,13 +375,32 @@ avtExpressionFilter::ExecuteData(vtkDataSet *in_ds, int index,
// Hank Childs, Fri Feb 20 15:08:58 PST 2004
// Account for data attributes using multiple variables.
//
// Brad Whitlock, Tue Jul 20 17:08:42 PST 2004
// Added code to propagate units.
//
// ****************************************************************************
void
avtExpressionFilter::RefashionDataObjectInfo(void)
{
avtDataAttributes &inputAtts = GetInput()->GetInfo().GetAttributes();
avtDataAttributes &outAtts = GetOutput()->GetInfo().GetAttributes();
outAtts.AddVariable(outputVariableName);
if (inputAtts.ValidActiveVariable())
{
//
// Expressions should really do some kind of transformation on
// the units. For example if you multiply a variable that has
// Newtons (N) times a variable that is in Meters (m), the resulting
// units for the output variable should be Nm (Newton meters).
// Since we don't have that kind of knowhow in the expressions code
// yet, preserve the units of the active variable even though that's
// not really the correct thing to do.
//
outAtts.AddVariable(outputVariableName, inputAtts.GetVariableUnits());
}
else
outAtts.AddVariable(outputVariableName);
outAtts.SetActiveVariable(outputVariableName);
outAtts.SetVariableDimension(GetVariableDimension());
outAtts.SetCentering(IsPointVariable()?AVT_NODECENT:AVT_ZONECENT);
......
......@@ -14,7 +14,6 @@
#include <ImproperUseException.h>
#include <InvalidMergeException.h>
using std::string;
using std::vector;
using std::sort;
......@@ -249,6 +248,9 @@ avtDataAttributes::DestructSelf(void)
// Kathleen Bonnell, Thu Jul 22 12:10:19 PDT 2004
// Print VarInfo's treatAsASCII.
//
// Brad Whitlock, Wed Jul 21 15:25:11 PST 2004
// Added variable units.
//
// ****************************************************************************
void
......@@ -374,6 +376,8 @@ avtDataAttributes::Print(ostream &out)
for (int i = 0 ; i < variables.size() ; i++)
{
out << "Variable = " << variables[i].varname.c_str() << endl;
if(variables[i].varunits != "")
out << "Units = " << variables[i].varunits.c_str() << endl;
out << "Dimension = " << variables[i].dimension << endl;
switch (variables[i].centering)
{
......@@ -483,6 +487,9 @@ avtDataAttributes::Print(ostream &out)
// Kathleen Bonnell, Thu Jul 22 12:10:19 PDT 2004
// Copy varinfo's treatAsASCII.
//
// Brad Whitlock, Tue Jul 20 14:02:32 PST 2004
// Copied variable units.
//
// ****************************************************************************
void
......@@ -530,7 +537,7 @@ avtDataAttributes::Copy(const avtDataAttributes &di)
for (int i = 0 ; i < di.variables.size() ; i++)
{
const char *vname = di.variables[i].varname.c_str();
AddVariable(vname);
AddVariable(vname, di.variables[i].varunits);
SetVariableDimension(di.variables[i].dimension, vname);
SetCentering(di.variables[i].centering, vname);
SetTreatAsASCII(di.variables[i].treatAsASCII, vname);
......@@ -1537,6 +1544,9 @@ avtDataAttributes::SetTime(double d)
// Kathleen Bonnell, Thu Jul 22 12:10:19 PDT 2004
// Write treatAsASCII.
//
// Brad Whitlock, Tue Jul 20 14:13:37 PST 2004
// Added units.
//
// ****************************************************************************
void
......@@ -1580,10 +1590,22 @@ avtDataAttributes::Write(avtDataObjectString &str,
for (i = 0 ; i < variables.size() ; i++)
{
// Write the variable name
wrtr->WriteInt(str, variables[i].varname.size());
str.Append((char *) variables[i].varname.c_str(),
variables[i].varname.size(),
avtDataObjectString::DATA_OBJECT_STRING_SHOULD_MAKE_COPY);
// Write the units name.
int unitlen = variables[i].varunits.size();
wrtr->WriteInt(str, unitlen);
if(unitlen > 0)
{
str.Append((char *) variables[i].varunits.c_str(),
unitlen,
avtDataObjectString::DATA_OBJECT_STRING_SHOULD_MAKE_COPY);
}
variables[i].trueData->Write(str, wrtr);
variables[i].cumulativeTrueData->Write(str, wrtr);
variables[i].effectiveData->Write(str, wrtr);
......@@ -1678,6 +1700,9 @@ avtDataAttributes::Write(avtDataObjectString &str,
// Kathleen Bonnell, Thu Jul 22 12:10:19 PDT 2004
// Read treatAsASCII.
//
// Brad Whitlock, Tue Jul 20 14:03:19 PST 2004
// Added units.
//
// ****************************************************************************
int
......@@ -1786,13 +1811,34 @@ avtDataAttributes::Read(char *input)
for (i = 0 ; i < numVars ; i++)
{
// Get the name of the variable
int varname_length;
memcpy(&varname_length, input, sizeof(int));
input += sizeof(int); size += sizeof(int);
string varname(input, varname_length);
size += varname_length;
input += varname_length;
AddVariable(varname.c_str());
// Get the length of the name of the units.
int unit_length;
memcpy(&unit_length, input, sizeof(int));
input += sizeof(int); size += sizeof(int);
// Add the variable.
if(unit_length > 0)
{
string units(input, unit_length);
AddVariable(varname, units);
}
else
AddVariable(varname);
// Adjust the size and input pointer in accordance with the
// size of the units that we had. We do it here in case
// we didn't have any units.
size += unit_length;
input += unit_length;
SetCentering(centerings[i], varname.c_str());
SetVariableDimension(varDims[i], varname.c_str());
SetTreatAsASCII(ascii[i], varname.c_str());
......@@ -2211,6 +2257,64 @@ avtDataAttributes::GetVariableName(int index) const
return variables[index].varname;
}
// ****************************************************************************
// Method: avtDataAttributes::GetVariableUnits
//
// Purpose:
// Returns the active variable's units.
//
// Returns: A reference to the active variable's units.
//
// Programmer: Brad Whitlock
// Creation: Tue Jul 20 16:36:00 PST 2004
//
// Modifications:
//
// ****************************************************************************
const std::string &
avtDataAttributes::GetVariableUnits(void) const
{
if (activeVariable < 0)
{
string reason = "Attempting to retrieve non-existent"
" active variable.\n";
EXCEPTION1(ImproperUseException, reason);
}
return variables[activeVariable].varunits;
}
// ****************************************************************************
// Method: avtDataAttributes::GetVariableUnits
//
// Purpose:
// Returns the units for the variable at an index.
//
// Arguments:
// index : The index of the variable whose units we want.
//
// Returns: A reference to the variable units.
//
// Note:
//
// Programmer: Brad Whitlock
// Creation: Tue Jul 20 12:22:22 PDT 2004
//
// Modifications:
//
// ****************************************************************************
const std::string &
avtDataAttributes::GetVariableUnits(int index) const
{
if (index < 0 || index >= variables.size())
{
EXCEPTION2(BadIndexException, index, variables.size());
}
return variables[index].varunits;
}
// ****************************************************************************
// Method: avtDataAttributes::GetNumberOfVariables
......@@ -2268,10 +2372,19 @@ avtDataAttributes::SetActiveVariable(const char *v)
// Kathleen Bonnell, Thu Jul 22 12:10:19 PDT 2004
// Initialize treatAsASCII.
//
// Brad Whitlock, Tue Jul 20 12:24:28 PDT 2004
// Added the units argument so units can be passed in if they are known.
//
// ****************************************************************************
void
avtDataAttributes::AddVariable(const std::string &s)
{
AddVariable(s, "");
}
void
avtDataAttributes::AddVariable(const std::string &s, const std::string &units)
{
for (int i = 0 ; i < variables.size() ; i++)
{
......@@ -2286,6 +2399,7 @@ avtDataAttributes::AddVariable(const std::string &s)
VarInfo new_var;
new_var.varname = s;
new_var.varunits = units;
new_var.dimension = -1;
new_var.centering = AVT_UNKNOWN_CENT;
new_var.treatAsASCII = false;
......@@ -2297,7 +2411,6 @@ avtDataAttributes::AddVariable(const std::string &s)
variables.push_back(new_var);
}
// ****************************************************************************
// Method: avtDataAttributes::ValidVariable
//
......
......@@ -116,6 +116,9 @@ class avtExtents;
// Kathleen Bonnell, Thu Jul 22 12:10:19 PDT 2004
// Added treatAsASCII to VarInfo struct, and Set/Get methods.
//
// Brad Whitlock, Tue Jul 20 12:19:38 PDT 2004
// Added support for units on variables.
//
// ****************************************************************************
class PIPELINE_API avtDataAttributes
......@@ -219,9 +222,13 @@ class PIPELINE_API avtDataAttributes
const std::string &GetVariableName(void) const;
const std::string &GetVariableName(int) const;
const std::string &GetVariableUnits(void) const;
const std::string &GetVariableUnits(int) const;
int GetNumberOfVariables(void) const;
void SetActiveVariable(const char *);
void AddVariable(const std::string &s);
void AddVariable(const std::string &s,
const std::string &units);
void RemoveVariable(const std::string &s);
bool ValidVariable(const std::string &s) const;
bool ValidActiveVariable(void) const;
......@@ -287,6 +294,7 @@ class PIPELINE_API avtDataAttributes
typedef struct
{
std::string varname;
std::string varunits;
int dimension;
avtCentering centering;
bool treatAsASCII;
......
......@@ -20,6 +20,9 @@
// Eric Brugger, Mon Jul 14 15:50:29 PDT 2003
// Added fontHeight, title, databaseInfo, varName and message.
//
// Brad Whitlock, Tue Jul 20 16:41:11 PST 2004
// Added varUnits.
//
// ****************************************************************************
avtLegend::avtLegend()
......@@ -35,6 +38,7 @@ avtLegend::avtLegend()
title = NULL;
databaseInfo = NULL;
varName = NULL;
varUnits = NULL;
message = NULL;
}
......@@ -50,6 +54,9 @@ avtLegend::avtLegend()
// Eric Brugger, Mon Jul 14 15:50:29 PDT 2003
// Added minFontSize, fontHeight, title, databaseInfo, varName and message.
//
// Brad Whitlock, Tue Jul 20 16:41:43 PST 2004
// Added varUnits.
//
// ****************************************************************************
avtLegend::~avtLegend()
......@@ -75,6 +82,10 @@ avtLegend::~avtLegend()
{
delete [] varName;
}
if (varUnits != NULL)
{
delete [] varUnits;
}
if (message != NULL)
{
delete [] message;
......@@ -420,6 +431,37 @@ avtLegend::SetVarName(const char *str)
}
}
// ****************************************************************************
// Method: avtLegend::SetVarUnits
//
// Purpose:
// Sets the variable units.
//
// Arguments:
// str : The units.
//
// Programmer: Brad Whitlock
// Creation: Tue Jul 20 16:46:40 PST 2004
//
// Modifications:
//
// ****************************************************************************
void
avtLegend::SetVarUnits(const char *str)
{
if (varUnits != NULL) delete [] varUnits;
if (str != NULL)
{
varUnits = new char[strlen(str)+1];
strcpy(varUnits, str);
}
else
{
varUnits = NULL;
}
}
// ****************************************************************************
// Method: avtLegend::SetMessage
......@@ -461,6 +503,10 @@ avtLegend::SetMessage(const char *str)
// Programmer: Eric Brugger
// Creation: July 14, 2003
//
// Modifications:
// Brad Whitlock, Tue Jul 20 16:48:56 PST 2004
// Added varUnits.
//
// ****************************************************************************
void
......@@ -478,6 +524,7 @@ avtLegend::Update()
if (title != NULL) len += strlen(title) + 1;
if (databaseInfo != NULL) len += strlen(databaseInfo) + 1;
if (varName != NULL) len += strlen(varName) + 6;
if (varUnits != NULL) len += strlen(varUnits) + 8;
if (message != NULL) len += strlen(message) + 1;
if (len != 0)
......@@ -503,6 +550,12 @@ avtLegend::Update()
strcat(tmpstr, varName);
tmpstr += strlen(tmpstr);
}
if (varUnits != NULL)
{
strcpy(tmpstr, "\nUnits: ");
strcat(tmpstr, varUnits);
tmpstr += strlen(tmpstr);
}
if (message != NULL)
{
strcpy(tmpstr, "\n");
......
......@@ -38,6 +38,9 @@ class vtkRenderer;
// Eric Brugger, Thu Jul 17 08:13:45 PDT 2003
// Added maxSize argument to GetLegendSize.
//
// Brad Whitlock, Tue Jul 20 16:40:37 PST 2004
// Added SetVarUnits.
//
// ****************************************************************************
class PLOTTER_API avtLegend
......@@ -62,6 +65,7 @@ class PLOTTER_API avtLegend
void SetTitle(const char *);
void SetDatabaseInfo(const char *);
void SetVarName(const char *);
void SetVarUnits(const char *);
void SetMessage(const char *);
void Update();
......@@ -78,6 +82,7 @@ class PLOTTER_API avtLegend
char *title;
char *databaseInfo;
char *varName;
char *varUnits;
char *message;
virtual void ChangePosition(float, float) = 0;
......
......@@ -73,6 +73,9 @@
// Jeremy Meredith, Tue Dec 10 09:15:35 PST 2002
// Initialize avtSmoothPolyDataFilter.
//
// Brad Whitlock, Tue Jul 20 16:10:51 PST 2004
// Added variable units.
//
// ****************************************************************************
avtPlot::avtPlot()
......@@ -87,6 +90,7 @@ avtPlot::avtPlot()
vertexNormalsFilter = new avtVertexNormalsFilter;
smooth = new avtSmoothPolyDataFilter();
varname = NULL;
varunits = NULL;
silr = NULL;
index = -1;
intermediateDataObject = NULL;
......@@ -113,7 +117,7 @@ avtPlot::avtPlot()
// Kathleen Bonnell, Wed Sep 19 12:55:57 PDT 2001
// Added compactTreeFilter.
//
// Kathleen Bonnell, Thu Oct 4 16:28:16 PDT 2001j
// Kathleen Bonnell, Thu Oct 4 16:28:16 PDT 2001
// Added currentExtentFilter.
//
// Hank Childs, Mon Dec 31 11:36:28 PST 2001
......@@ -122,6 +126,9 @@ avtPlot::avtPlot()
// Jeremy Meredith, Tue Dec 10 09:16:39 PST 2002
// Added poly data smoothing filter.
//
// Brad Whitlock, Tue Jul 20 16:11:26 PST 2004
// Added variable units.
//
// ****************************************************************************
avtPlot::~avtPlot()
......@@ -166,6 +173,11 @@ avtPlot::~avtPlot()
delete [] varname;
varname = NULL;
}
if (varunits != NULL)
{
delete [] varunits;
varunits = NULL;
}
}
......@@ -245,6 +257,42 @@ avtPlot::SetVarName(const char *name)
needsRecalculation = true;
}
// ****************************************************************************
// Method: avtPlot::SetVarUnits
//
// Purpose:
// Sets the units for the plot.
//
// Arguments:
// name : The name of the units.
//
// Programmer: Brad Whitlock
// Creation: Tue Jul 20 16:12:30 PST 2004
//
// Modifications:
//
// ****************************************************************************
void
avtPlot::SetVarUnits(const char *name)
{
if (varunits != NULL)
{
delete [] varunits;
varunits = NULL;
}
if (name != NULL)
{
varunits = new char[strlen(name)+1];
strcpy(varunits, name);
}
avtLegend_p legend = GetLegend();
if (*legend != NULL)
{
legend->SetVarUnits(varunits);
legend->Update();
}
}
// ****************************************************************************
// Method: avtPlot::Execute
......@@ -329,6 +377,9 @@ avtPlot::Execute(avtDataObject_p input, avtPipelineSpecification_p spec,
// now totally subsumed by scalable rendering. Also set the name of the
// variable for this plot.
//
// Brad Whitlock, Tue Jul 20 16:39:07 PST 2004
// Added code to set the units for the plot.