Commit 464a797c authored by hrchilds's avatar hrchilds
Browse files

Update from April 24, 2007

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@890 18c085ea-50e0-402c-830e-de6fd14e8384
parent 5d6f7a28
/*****************************************************************************
*
* Copyright (c) 2000 - 2007, The Regents of the University of California
* Produced at the Lawrence Livermore National Laboratory
* All rights reserved.
*
* This file is part of VisIt. For details, see http://www.llnl.gov/visit/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer (as noted below) in the
* documentation and/or materials provided with the distribution.
* - Neither the name of the UC/LLNL nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OF THE UNIVERSITY OF
* CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/
// ************************************************************************* //
// avtColorComposeFilter.C //
// ************************************************************************* //
#include <avtColorComposeFilter.h>
#include <math.h>
#include <vtkCellData.h>
#include <vtkPointData.h>
#include <vtkDataArray.h>
#include <vtkDataSet.h>
#include <ExpressionException.h>
// ****************************************************************************
// Method: avtColorComposeFilter constructor
//
// Purpose:
// Defines the constructor. Note: this should not be inlined in the
// header because it causes problems for certain compilers.
//
// Programmer: Brad Whitlock
// Creation: Mon Apr 23 17:09:37 PST 2007
//
// ****************************************************************************
avtColorComposeFilter::avtColorComposeFilter(int nc)
{
ncomp = nc;
}
// ****************************************************************************
// Method: avtColorComposeFilter destructor
//
// Purpose:
// Defines the destructor. Note: this should not be inlined in the header
// because it causes problems for certain compilers.
//
// Programmer: Brad Whitlock
// Creation: Mon Apr 23 17:09:37 PST 2007
//
// ****************************************************************************
avtColorComposeFilter::~avtColorComposeFilter()
{
;
}
// ****************************************************************************
// Method: avtColorComposeFilter::DeriveVariable
//
// Purpose:
// Creates a vector variable from components.
//
// Arguments:
// inDS The input dataset.
//
// Returns: The derived variable. The calling class must free this
// memory.
//
// Notes: Mostly taken from avtVectorComposeFilter.C
//
// Programmer: Brad Whitlock
// Creation: Mon Apr 23 17:09:37 PST 2007
//
// Modifications:
//
// ****************************************************************************
inline unsigned char
ClampColor(const double c)
{
int ic = (int)c;
if(ic < 0) ic = 0;
if(ic > 255) ic = 255;
return (unsigned char)ic;
}
vtkDataArray *
avtColorComposeFilter::DeriveVariable(vtkDataSet *in_ds)
{
int numinputs = varnames.size();
//
// Our first operand is in the active variable. We don't know if it's
// point data or cell data, so check which one is non-NULL.
//
vtkDataArray *cell_data1 = in_ds->GetCellData()->GetArray(varnames[0]);
vtkDataArray *point_data1 = in_ds->GetPointData()->GetArray(varnames[0]);
vtkDataArray *data1 = NULL, *data2 = NULL, *data3 = NULL, *data4 = NULL;
avtCentering centering;
if (cell_data1 != NULL)
{
data1 = cell_data1;
centering = AVT_ZONECENT;
}
else
{
data1 = point_data1;
centering = AVT_NODECENT;
}
if (data1 != NULL && data1->GetNumberOfComponents() != 1)
{
EXCEPTION1(ExpressionException,
"The first variable is not a scalar.");
}
// Get the second variable.
if (centering == AVT_ZONECENT)
data2 = in_ds->GetCellData()->GetArray(varnames[1]);
else
data2 = in_ds->GetPointData()->GetArray(varnames[1]);
if (data2 == NULL)
{
EXCEPTION1(ExpressionException,
"The first two variables have different centering.");
}
if (data2->GetNumberOfComponents() != 1)
{
EXCEPTION1(ExpressionException,
"The second variable is not a scalar.");
}
if (numinputs >= 3)
{
// Get the third variable.
if (centering == AVT_ZONECENT)
data3 = in_ds->GetCellData()->GetArray(varnames[2]);
else
data3 = in_ds->GetPointData()->GetArray(varnames[2]);
if (data3 == NULL)
{
EXCEPTION1(ExpressionException,
"The first and third variables have different centering.");
}
if (data3->GetNumberOfComponents() != 1)
{
EXCEPTION1(ExpressionException,
"The third variable is not a scalar.");
}
}
if (numinputs == 4)
{
// Get the fourth variable.
if (centering == AVT_ZONECENT)
data4 = in_ds->GetCellData()->GetArray(varnames[3]);
else
data4 = in_ds->GetPointData()->GetArray(varnames[3]);
if (data4 == NULL)
{
EXCEPTION1(ExpressionException,
"The first and fourth variables have different centering.");
}
if (data4->GetNumberOfComponents() != 1)
{
EXCEPTION1(ExpressionException,
"The fourth variable is not a scalar.");
}
}
vtkIdType nvals = data1->GetNumberOfTuples();
vtkDataArray *dv = data1->NewInstance();
dv->SetNumberOfComponents(4);
dv->SetNumberOfTuples(data1->GetNumberOfTuples());
if(numinputs == 1)
{
for(vtkIdType id = 0; id < nvals; ++id)
{
double val1 = ClampColor(data1->GetTuple1(id));
dv->SetTuple4(id, val1, 0., 0., 255.);
}
}
else if(numinputs == 2)
{
for(vtkIdType id = 0; id < nvals; ++id)
{
double val1 = ClampColor(data1->GetTuple1(id));
double val2 = ClampColor(data2->GetTuple1(id));
dv->SetTuple4(id, val1, val2, 0., 255.);
}
}
else if(numinputs == 3)
{
for(vtkIdType id = 0; id < nvals; ++id)
{
double val1 = ClampColor(data1->GetTuple1(id));
double val2 = ClampColor(data2->GetTuple1(id));
double val3 = ClampColor(data3->GetTuple1(id));
dv->SetTuple4(id, val1, val2, val3, 255.);
}
}
else if(numinputs == 4)
{
for(vtkIdType id = 0; id < nvals; ++id)
{
double val1 = ClampColor(data1->GetTuple1(id));
double val2 = ClampColor(data2->GetTuple1(id));
double val3 = ClampColor(data3->GetTuple1(id));
double val4 = ClampColor(data4->GetTuple1(id));
dv->SetTuple4(id, val1, val2, val3, val4);
}
}
return dv;
}
/*****************************************************************************
*
* Copyright (c) 2000 - 2007, The Regents of the University of California
* Produced at the Lawrence Livermore National Laboratory
* All rights reserved.
*
* This file is part of VisIt. For details, see http://www.llnl.gov/visit/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer (as noted below) in the
* documentation and/or materials provided with the distribution.
* - Neither the name of the UC/LLNL nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OF THE UNIVERSITY OF
* CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/
// ************************************************************************* //
// avtColorComposeFilter.h //
// ************************************************************************* //
#ifndef AVT_COLOR_COMPOSE_FILTER_H
#define AVT_COLOR_COMPOSE_FILTER_H
#include <avtMultipleInputExpressionFilter.h>
// ****************************************************************************
// Class: avtColorComposeFilter
//
// Purpose:
// Creates a vector variable out of three components.
//
// Programmer: Brad Whitlock
// Creation: Mon Apr 23 17:08:08 PST 2007
//
// Modifications:
//
// ****************************************************************************
class EXPRESSION_API avtColorComposeFilter
: public avtMultipleInputExpressionFilter
{
public:
avtColorComposeFilter(int nc);
virtual ~avtColorComposeFilter();
virtual const char *GetType(void)
{ return "avtColorComposeFilter"; }
virtual const char *GetDescription(void)
{return "Creating a color vector from components";};
virtual int NumVariableArguments() { return ncomp; }
protected:
int ncomp;
virtual vtkDataArray *DeriveVariable(vtkDataSet *);
virtual int GetVariableDimension(void) { return 3; }
};
#endif
......@@ -195,6 +195,9 @@
# Thomas R. Treadway, Tue Mar 27 12:52:26 PDT 2007
# Added $(MESA_LIBS)
#
# Brad Whitlock, Mon Apr 23 17:29:50 PST 2007
# Added avtColorComposeFilter.C
#
##############################################################################
@SET_MAKE@
......@@ -261,6 +264,7 @@ General_src= \
General/avtArrayComposeFilter.C \
General/avtArrayComposeWithBinsFilter.C \
General/avtArrayDecomposeFilter.C \
General/avtColorComposeFilter.C \
General/avtConnComponentsExpression.C \
General/avtCurlFilter.C \
General/avtDataIdFilter.C \
......
......@@ -46,6 +46,7 @@
#include <avtBinaryDivideFilter.h>
#include <avtBinaryPowerFilter.h>
#include <avtCeilingFilter.h>
#include <avtColorComposeFilter.h>
#include <avtFloorFilter.h>
#include <avtModuloFilter.h>
#include <avtRoundFilter.h>
......@@ -440,7 +441,10 @@ avtVectorExpr::CreateFilters(ExprPipelineState *state)
//
// Cyrus Harrison, Wed Feb 21 09:37:38 PST 2007
// Added conn_components
//
//
// Brad Whitlock, Mon Apr 23 17:32:14 PST 2007
// Added color.
//
// ****************************************************************************
avtExpressionFilter *
......@@ -820,6 +824,11 @@ avtFunctionExpr::CreateFilters(string functionName)
mm->SetDoMinimum(false);
return mm;
}
if (functionName == "color")
return new avtColorComposeFilter(3);
if (functionName == "color4")
return new avtColorComposeFilter(4);
return NULL;
}
......
......@@ -85,6 +85,9 @@
// Brad Whitlock, Mon Sep 18 11:28:35 PDT 2006
// Added colorTexturingFlag.
//
// Brad Whitlock, Tue Apr 24 16:01:09 PST 2007
// Added colorTexturingFlagAllowed.
//
// ****************************************************************************
avtVariableMapper::avtVariableMapper()
......@@ -97,6 +100,7 @@ avtVariableMapper::avtVariableMapper()
lineStyle = SOLID;
limitsMode = 0; // use original data extents
colorTexturingFlag = true;
colorTexturingFlagAllowed = true;
}
......@@ -920,6 +924,31 @@ avtVariableMapper::GetLighting()
return lighting;
}
// ****************************************************************************
// Method: avtVariableMapper::SetColorTexturingFlagAllowed
//
// Purpose:
// Sets whether we're allowed to change the color texturing flag.
//
// Arguments:
// val : True if we can use color texturing and we're allowed to change the
// flag for color texturing.
//
// Programmer: Brad Whitlock
// Creation: Tue Apr 24 16:01:51 PST 2007
//
// Modifications:
//
// ****************************************************************************
void
avtVariableMapper::SetColorTexturingFlagAllowed(bool val)
{
colorTexturingFlagAllowed = val;
if(!val)
colorTexturingFlag = false;
}
// ****************************************************************************
// Method: avtVariableMapper::SetColorTexturingFlag
//
......@@ -933,13 +962,15 @@ avtVariableMapper::GetLighting()
// Creation: Mon Sep 18 11:32:24 PDT 2006
//
// Modifications:
//
// Brad Whitlock, Tue Apr 24 16:02:43 PST 2007
// Return if setting the color texturing flag is not allowed.
//
// ****************************************************************************
void
avtVariableMapper::SetColorTexturingFlag(bool val)
{
if (mappers == NULL)
if (mappers == NULL || !colorTexturingFlagAllowed)
return;
colorTexturingFlag = val;
......
......@@ -101,6 +101,11 @@ class vtkLookupTable;
// Brad Whitlock, Mon Sep 18 11:26:26 PDT 2006
// Added SetColorTexturingFlag.
//
// Brad Whitlock, Tue Apr 24 15:59:01 PST 2007
// Added SetColorTexturingFlagAllowed to disable color texturing from
// ever taking place if this mapper is being used for a plot should not
// ever use color texturing.
//
// ****************************************************************************
class PLOTTER_API avtVariableMapper : public avtMapper
......@@ -129,6 +134,7 @@ class PLOTTER_API avtVariableMapper : public avtMapper
void SetPointSize(double);
virtual void SetColorTexturingFlag(bool);
void SetColorTexturingFlagAllowed(bool);
protected:
double min, max;
......@@ -139,6 +145,7 @@ class PLOTTER_API avtVariableMapper : public avtMapper
double opacity;
int limitsMode;
bool colorTexturingFlag;
bool colorTexturingFlagAllowed;
vtkLookupTable *lut;
virtual void CustomizeMappers(void);
......
......@@ -4348,31 +4348,25 @@ int VisitExtentsTool::AxisClosestToTipOfArrow(double arrowTipX)
//
// Modifications:
//
// Mark Blair, Mon Apr 23 18:53:27 PDT 2007
// Simplified format conventions. Now also consistent with Threshold op.
//
// *****************************************************************************
void VisitExtentsTool::MakeAxisTitleText(
char titleText[], const std::string &axisTitle, int maxTitleChars)
{
int rawTitleLen;
char *secondPart;
char rawTitle[121];
strncpy(rawTitle, axisTitle.c_str(), 120);
if ((rawTitleLen = strlen(rawTitle)) <= maxTitleChars)
{
strcpy(titleText, rawTitle);
}
else
{
if ((secondPart = strrchr(rawTitle, '/')) == NULL)
secondPart = &rawTitle[rawTitleLen-3];
else if (strlen(secondPart) > 4)
secondPart[4] = '0';
rawTitle[maxTitleChars-strlen(secondPart)-2] = '\0';
sprintf(titleText, "%s..%s", rawTitle, secondPart);
rawTitle[maxTitleChars-3] = '\0';
sprintf(titleText,"%s..%s", rawTitle, &rawTitle[rawTitleLen-2]);
}
}
......
......@@ -213,6 +213,8 @@ const char *expr_trig[] = {
};
const char *expr_vector[] = {
"color",
"color4",
"cross",
"dot",
"magnitude",
......@@ -1024,6 +1026,9 @@ QvisExpressionsWindow::displayAllVarsChanged()
// Hank Childs, Sat Mar 17 15:33:54 PDT 2007
// Fix problem with specmf.
//
// Brad Whitlock, Mon Apr 23 17:35:13 PST 2007
// Added color expression.
//
// ****************************************************************************
void
......@@ -1099,6 +1104,16 @@ QvisExpressionsWindow::insertFunction(int id)
definitionEdit->insert("(<var-LHS>, <var-RHS>)");
doParens = false;
}
else if(str == "color4")
{
definitionEdit->insert("(<var1>, <var2>, <var3>, <var4>)");
doParens = false;
}
else if(str == "color")
{
definitionEdit->insert("(<var1>, <var2>, <var3>)");
doParens = false;
}
if (doParens)
{
......
../../components/Expressions/General/avtColorComposeFilter.h
\ No newline at end of file
......@@ -48,7 +48,7 @@
// Note: Autogenerated by xml2python. Do not modify by hand!
//
// Programmer: xml2python
// Creation: Tue Mar 27 20:21:50 PST 2007
// Creation: Wed Apr 18 19:26:29 PST 2007
//
// ****************************************************************************
......@@ -92,8 +92,6 @@ PyThresholdAttributes_ToString(const ThresholdAttributes *atts, const char *pref
SNPRINTF(tmpStr, 1000, ")\n");
str += tmpStr;
}
SNPRINTF(tmpStr, 1000, "%sshownVarPosition = %d\n", prefix, atts->GetShownVarPosition());
str += tmpStr;
{ const intVector &zonePortions = atts->GetZonePortions();
SNPRINTF(tmpStr, 1000, "%szonePortions = (", prefix);
str += tmpStr;
......@@ -234,30 +232,6 @@ ThresholdAttributes_GetListedVarNames(PyObject *self, PyObject *args)
return retval;
}
static PyObject *
ThresholdAttributes_SetShownVarPosition(PyObject *self, PyObject *args)
{
ThresholdAttributesObject *obj = (ThresholdAttributesObject *)self;
int ival;
if(!PyArg_ParseTuple(args, "i", &ival))
return NULL;
// Set the shownVarPosition in the object.
obj->data->SetShownVarPosition((int)ival);
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
ThresholdAttributes_GetShownVarPosition(PyObject *self, PyObject *args)
{
ThresholdAttributesObject *obj = (ThresholdAttributesObject *)self;
PyObject *retval = PyInt_FromLong(long(obj->data->GetShownVarPosition()));
return retval;
}
static PyObject *
ThresholdAttributes_SetZonePortions(PyObject *self, PyObject *args)
{
......@@ -503,8 +477,6 @@ static struct PyMethodDef ThresholdAttributes_methods[] = {
{"GetOutputMeshType", ThresholdAttributes_GetOutputMeshType