Commit 3e0ae595 authored by hrchilds's avatar hrchilds

Vector plot changes:

(1) add option for glyph placement
(2) reorg Qt window


git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@12291 18c085ea-50e0-402c-830e-de6fd14e8384
parent 95d981e4
......@@ -77,6 +77,21 @@ PyVectorAttributes_ToString(const VectorAttributes *atts, const char *prefix)
std::string str;
char tmpStr[1000];
const char *glyphLocation_names = "AdaptsToMeshResolution, UniformInSpace";
switch (atts->GetGlyphLocation())
{
case VectorAttributes::AdaptsToMeshResolution:
SNPRINTF(tmpStr, 1000, "%sglyphLocation = %sAdaptsToMeshResolution # %s\n", prefix, prefix, glyphLocation_names);
str += tmpStr;
break;
case VectorAttributes::UniformInSpace:
SNPRINTF(tmpStr, 1000, "%sglyphLocation = %sUniformInSpace # %s\n", prefix, prefix, glyphLocation_names);
str += tmpStr;
break;
default:
break;
}
if(atts->GetUseStride())
SNPRINTF(tmpStr, 1000, "%suseStride = 1\n", prefix);
else
......@@ -227,6 +242,39 @@ VectorAttributes_Notify(PyObject *self, PyObject *args)
return Py_None;
}
/*static*/ PyObject *
VectorAttributes_SetGlyphLocation(PyObject *self, PyObject *args)
{
VectorAttributesObject *obj = (VectorAttributesObject *)self;
int ival;
if(!PyArg_ParseTuple(args, "i", &ival))
return NULL;
// Set the glyphLocation in the object.
if(ival >= 0 && ival < 2)
obj->data->SetGlyphLocation(VectorAttributes::GlyphLocation(ival));
else
{
fprintf(stderr, "An invalid glyphLocation value was given. "
"Valid values are in the range of [0,1]. "
"You can also use the following names: "
"AdaptsToMeshResolution, UniformInSpace.");
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
}
/*static*/ PyObject *
VectorAttributes_GetGlyphLocation(PyObject *self, PyObject *args)
{
VectorAttributesObject *obj = (VectorAttributesObject *)self;
PyObject *retval = PyInt_FromLong(long(obj->data->GetGlyphLocation()));
return retval;
}
/*static*/ PyObject *
VectorAttributes_SetUseStride(PyObject *self, PyObject *args)
{
......@@ -929,6 +977,8 @@ VectorAttributes_GetGlyphType(PyObject *self, PyObject *args)
PyMethodDef PyVectorAttributes_methods[VECTORATTRIBUTES_NMETH] = {
{"Notify", VectorAttributes_Notify, METH_VARARGS},
{"SetGlyphLocation", VectorAttributes_SetGlyphLocation, METH_VARARGS},
{"GetGlyphLocation", VectorAttributes_GetGlyphLocation, METH_VARARGS},
{"SetUseStride", VectorAttributes_SetUseStride, METH_VARARGS},
{"GetUseStride", VectorAttributes_GetUseStride, METH_VARARGS},
{"SetStride", VectorAttributes_SetStride, METH_VARARGS},
......@@ -1007,6 +1057,13 @@ VectorAttributes_compare(PyObject *v, PyObject *w)
PyObject *
PyVectorAttributes_getattr(PyObject *self, char *name)
{
if(strcmp(name, "glyphLocation") == 0)
return VectorAttributes_GetGlyphLocation(self, NULL);
if(strcmp(name, "AdaptsToMeshResolution") == 0)
return PyInt_FromLong(long(VectorAttributes::AdaptsToMeshResolution));
if(strcmp(name, "UniformInSpace") == 0)
return PyInt_FromLong(long(VectorAttributes::UniformInSpace));
if(strcmp(name, "useStride") == 0)
return VectorAttributes_GetUseStride(self, NULL);
if(strcmp(name, "stride") == 0)
......@@ -1109,7 +1166,9 @@ PyVectorAttributes_setattr(PyObject *self, char *name, PyObject *args)
Py_INCREF(args);
PyObject *obj = NULL;
if(strcmp(name, "useStride") == 0)
if(strcmp(name, "glyphLocation") == 0)
obj = VectorAttributes_SetGlyphLocation(self, tuple);
else if(strcmp(name, "useStride") == 0)
obj = VectorAttributes_SetUseStride(self, tuple);
else if(strcmp(name, "stride") == 0)
obj = VectorAttributes_SetStride(self, tuple);
......
......@@ -44,7 +44,7 @@
//
// Functions exposed to the VisIt module.
//
#define VECTORATTRIBUTES_NMETH 52
#define VECTORATTRIBUTES_NMETH 54
void PyVectorAttributes_StartUp(VectorAttributes *subj, void *data);
void PyVectorAttributes_CloseDown();
PyMethodDef * PyVectorAttributes_GetMethodTable(int *nMethods);
......
This diff is collapsed.
......@@ -47,6 +47,7 @@ class QCheckBox;
class QComboBox;
class QLabel;
class QLineEdit;
class QRadioButton;
class QvisColorButton;
class QvisColorTableButton;
class QvisLineStyleWidget;
......@@ -96,8 +97,11 @@ class VectorAttributes;
// Allen Sanderson, Sun Mar 7 12:49:56 PST 2010
// Change layout of window for 2.0 interface changes.
//
// Dave Pugmire, Mon Jul 19 09:38:17 EDT 2010
// Add ellipsoid glyphing.
// Dave Pugmire, Mon Jul 19 09:38:17 EDT 2010
// Add ellipsoid glyphing.
//
// Hank Childs, Tue Aug 24 07:37:27 PDT 2010
// Add option for glyph location.
//
// ****************************************************************************
......@@ -128,6 +132,7 @@ private slots:
void autoScaleToggled(bool);
void processHeadSizeText();
void reduceMethodChanged(int index);
void locationMethodChanged(int index);
void processNVectorsText();
void processStrideText();
void legendToggled(bool);
......@@ -162,9 +167,11 @@ private:
QCheckBox *scaleByMagnitudeToggle;
QCheckBox *autoScaleToggle;
QButtonGroup *locationButtonGroup;
QButtonGroup *reduceButtonGroup;
QLineEdit *nVectorsLineEdit;
QLineEdit *strideLineEdit;
QRadioButton *strideRB;
QButtonGroup *geometryQualityButtons;
QCheckBox *legendToggle;
......
......@@ -18,10 +18,17 @@
Arrow
Ellipsoid
</Enum>
<Field name="useStride" label="Use stride" type="bool">
<Enum name="GlyphLocation">
AdaptsToMeshResolution
UniformInSpace
</Enum>
<Field name="glyphLocation" label="Glyph Location" type="enum" subtype="GlyphLocation">
AdaptsToMeshResolution
</Field>
<Field name="useStride" label="Use stride" type="bool" enabler="glyphLocation:AdaptsToMeshResolution">
false
</Field>
<Field name="stride" label="Stride" type="int">
<Field name="stride" label="Stride" type="int" enabler="glyphLocation:AdaptsToMeshResolution">
1
</Field>
<Field name="nVectors" label="Num vectors" type="int">
......
......@@ -188,6 +188,43 @@ VectorAttributes::GlyphType_FromString(const std::string &s, VectorAttributes::G
return false;
}
//
// Enum conversion methods for VectorAttributes::GlyphLocation
//
static const char *GlyphLocation_strings[] = {
"AdaptsToMeshResolution", "UniformInSpace"};
std::string
VectorAttributes::GlyphLocation_ToString(VectorAttributes::GlyphLocation t)
{
int index = int(t);
if(index < 0 || index >= 2) index = 0;
return GlyphLocation_strings[index];
}
std::string
VectorAttributes::GlyphLocation_ToString(int t)
{
int index = (t < 0 || t >= 2) ? 0 : t;
return GlyphLocation_strings[index];
}
bool
VectorAttributes::GlyphLocation_FromString(const std::string &s, VectorAttributes::GlyphLocation &val)
{
val = VectorAttributes::AdaptsToMeshResolution;
for(int i = 0; i < 2; ++i)
{
if(s == GlyphLocation_strings[i])
{
val = (GlyphLocation)i;
return true;
}
}
return false;
}
// ****************************************************************************
// Method: VectorAttributes::VectorAttributes
//
......@@ -205,6 +242,7 @@ VectorAttributes::GlyphType_FromString(const std::string &s, VectorAttributes::G
void VectorAttributes::Init()
{
glyphLocation = AdaptsToMeshResolution;
useStride = false;
stride = 1;
nVectors = 400;
......@@ -249,6 +287,7 @@ void VectorAttributes::Init()
void VectorAttributes::Copy(const VectorAttributes &obj)
{
glyphLocation = obj.glyphLocation;
useStride = obj.useStride;
stride = obj.stride;
nVectors = obj.nVectors;
......@@ -433,7 +472,8 @@ bool
VectorAttributes::operator == (const VectorAttributes &obj) const
{
// Create the return value
return ((useStride == obj.useStride) &&
return ((glyphLocation == obj.glyphLocation) &&
(useStride == obj.useStride) &&
(stride == obj.stride) &&
(nVectors == obj.nVectors) &&
(lineStyle == obj.lineStyle) &&
......@@ -601,6 +641,7 @@ VectorAttributes::NewInstance(bool copy) const
void
VectorAttributes::SelectAll()
{
Select(ID_glyphLocation, (void *)&glyphLocation);
Select(ID_useStride, (void *)&useStride);
Select(ID_stride, (void *)&stride);
Select(ID_nVectors, (void *)&nVectors);
......@@ -658,6 +699,12 @@ VectorAttributes::CreateNode(DataNode *parentNode, bool completeSave, bool force
// Create a node for VectorAttributes.
DataNode *node = new DataNode("VectorAttributes");
if(completeSave || !FieldsEqual(ID_glyphLocation, &defaultObject))
{
addToParent = true;
node->AddNode(new DataNode("glyphLocation", GlyphLocation_ToString(glyphLocation)));
}
if(completeSave || !FieldsEqual(ID_useStride, &defaultObject))
{
addToParent = true;
......@@ -846,6 +893,22 @@ VectorAttributes::SetFromNode(DataNode *parentNode)
return;
DataNode *node;
if((node = searchNode->GetNode("glyphLocation")) != 0)
{
// Allow enums to be int or string in the config file
if(node->GetNodeType() == INT_NODE)
{
int ival = node->AsInt();
if(ival >= 0 && ival < 2)
SetGlyphLocation(GlyphLocation(ival));
}
else if(node->GetNodeType() == STRING_NODE)
{
GlyphLocation value;
if(GlyphLocation_FromString(node->AsString(), value))
SetGlyphLocation(value);
}
}
if((node = searchNode->GetNode("useStride")) != 0)
SetUseStride(node->AsBool());
if((node = searchNode->GetNode("stride")) != 0)
......@@ -958,6 +1021,13 @@ VectorAttributes::SetFromNode(DataNode *parentNode)
// Set property methods
///////////////////////////////////////////////////////////////////////////////
void
VectorAttributes::SetGlyphLocation(VectorAttributes::GlyphLocation glyphLocation_)
{
glyphLocation = glyphLocation_;
Select(ID_glyphLocation, (void *)&glyphLocation);
}
void
VectorAttributes::SetUseStride(bool useStride_)
{
......@@ -975,6 +1045,7 @@ VectorAttributes::SetStride(int stride_)
void
VectorAttributes::SetNVectors(int nVectors_)
{
cerr << "Setting nvecs as " << nVectors_ << endl;
nVectors = nVectors_;
Select(ID_nVectors, (void *)&nVectors);
}
......@@ -1137,6 +1208,12 @@ VectorAttributes::SetGlyphType(VectorAttributes::GlyphType glyphType_)
// Get property methods
///////////////////////////////////////////////////////////////////////////////
VectorAttributes::GlyphLocation
VectorAttributes::GetGlyphLocation() const
{
return GlyphLocation(glyphLocation);
}
bool
VectorAttributes::GetUseStride() const
{
......@@ -1339,6 +1416,7 @@ VectorAttributes::GetFieldName(int index) const
{
switch (index)
{
case ID_glyphLocation: return "glyphLocation";
case ID_useStride: return "useStride";
case ID_stride: return "stride";
case ID_nVectors: return "nVectors";
......@@ -1388,6 +1466,7 @@ VectorAttributes::GetFieldType(int index) const
{
switch (index)
{
case ID_glyphLocation: return FieldType_enum;
case ID_useStride: return FieldType_bool;
case ID_stride: return FieldType_int;
case ID_nVectors: return FieldType_int;
......@@ -1437,6 +1516,7 @@ VectorAttributes::GetFieldTypeName(int index) const
{
switch (index)
{
case ID_glyphLocation: return "enum";
case ID_useStride: return "bool";
case ID_stride: return "int";
case ID_nVectors: return "int";
......@@ -1488,6 +1568,11 @@ VectorAttributes::FieldsEqual(int index_, const AttributeGroup *rhs) const
bool retval = false;
switch (index_)
{
case ID_glyphLocation:
{ // new scope
retval = (glyphLocation == obj.glyphLocation);
}
break;
case ID_useStride:
{ // new scope
retval = (useStride == obj.useStride);
......@@ -1628,6 +1713,7 @@ VectorAttributes::ChangesRequireRecalculation(const VectorAttributes &obj)
{
return ((useStride != obj.useStride) ||
(stride != obj.stride) ||
(glyphLocation != obj.glyphLocation) ||
(nVectors != obj.nVectors) ||
(origOnly != obj.origOnly));
}
......
......@@ -44,6 +44,7 @@ VectorAttributes::ChangesRequireRecalculation(const VectorAttributes &obj)
{
return ((useStride != obj.useStride) ||
(stride != obj.stride) ||
(glyphLocation != obj.glyphLocation) ||
(nVectors != obj.nVectors) ||
(origOnly != obj.origOnly));
}
......
......@@ -82,6 +82,11 @@ public:
Arrow,
Ellipsoid
};
enum GlyphLocation
{
AdaptsToMeshResolution,
UniformInSpace
};
// These constructors are for objects of this class
VectorAttributes();
......@@ -112,6 +117,7 @@ public:
void SelectColorTableName();
// Property setting methods
void SetGlyphLocation(GlyphLocation glyphLocation_);
void SetUseStride(bool useStride_);
void SetStride(int stride_);
void SetNVectors(int nVectors_);
......@@ -139,6 +145,7 @@ public:
void SetGlyphType(GlyphType glyphType_);
// Property getting methods
GlyphLocation GetGlyphLocation() const;
bool GetUseStride() const;
int GetStride() const;
int GetNVectors() const;
......@@ -192,6 +199,11 @@ public:
protected:
static std::string GlyphType_ToString(int);
public:
static std::string GlyphLocation_ToString(GlyphLocation);
static bool GlyphLocation_FromString(const std::string &, GlyphLocation &);
protected:
static std::string GlyphLocation_ToString(int);
public:
// Keyframing methods
virtual std::string GetFieldName(int index) const;
......@@ -204,7 +216,8 @@ public:
// IDs that can be used to identify fields in case statements
enum {
ID_useStride = 0,
ID_glyphLocation = 0,
ID_useStride,
ID_stride,
ID_nVectors,
ID_lineStyle,
......@@ -233,6 +246,7 @@ public:
};
private:
int glyphLocation;
bool useStride;
int stride;
int nVectors;
......@@ -263,6 +277,6 @@ private:
static const char *TypeMapFormatString;
static const private_tmfs_t TmfsStruct;
};
#define VECTORATTRIBUTES_TMFS "biiiidbbdbbbasibbiddbidbi"
#define VECTORATTRIBUTES_TMFS "ibiiiidbbdbbbasibbiddbidbi"
#endif
This diff is collapsed.
......@@ -46,6 +46,7 @@
#include <avtGhostZoneFilter.h>
#include <avtLookupTable.h>
#include <avtResampleFilter.h>
#include <avtVariableLegend.h>
#include <avtVectorFilter.h>
#include <avtVectorGlyphMapper.h>
......@@ -74,6 +75,9 @@
// Hank Childs, Wed Dec 27 13:49:15 PST 2006
// Tell ghost filter to always remove ghost data.
//
// Hank Childs, Wed Aug 25 09:42:13 PDT 2010
// Initialize resample filter.
//
// ****************************************************************************
avtVectorPlot::avtVectorPlot()
......@@ -81,6 +85,7 @@ avtVectorPlot::avtVectorPlot()
colorsInitialized = false;
glyph = vtkVectorGlyph::New();
vectorFilter = new avtVectorFilter(true, 10);
resampleFilter = NULL;
ghostFilter = new avtGhostZoneFilter();
ghostFilter->GhostDataMustBeRemoved();
glyphMapper = new avtVectorGlyphMapper(glyph->GetOutput());
......@@ -110,6 +115,9 @@ avtVectorPlot::avtVectorPlot()
// Kathleen Bonnell, Thu Aug 30 10:47:07 PDT 2001
// Delete avtLUT.
//
// Hank Childs, Wed Aug 25 09:42:13 PDT 2010
// Delete resample filter.
//
// ****************************************************************************
avtVectorPlot::~avtVectorPlot()
......@@ -124,6 +132,11 @@ avtVectorPlot::~avtVectorPlot()
delete vectorFilter;
vectorFilter = NULL;
}
if (resampleFilter != NULL)
{
delete resampleFilter;
resampleFilter = NULL;
}
if (ghostFilter != NULL)
{
delete ghostFilter;
......@@ -235,6 +248,9 @@ avtVectorPlot::GetMapper(void)
// Added code to create a name for the magnitude scalar variable.
// Tell the vectorFilter to create that scalar var.
//
// Hank Childs, Wed Aug 25 09:42:13 PDT 2010
// Insert resample filter when we are doing uniform locations.
//
// ****************************************************************************
avtDataObject_p
......@@ -242,7 +258,13 @@ avtVectorPlot::ApplyOperators(avtDataObject_p input)
{
ghostFilter->SetInput(input);
ComputeMagVarName(varname);
vectorFilter->SetInput(ghostFilter->GetOutput());
avtDataObject_p dob = ghostFilter->GetOutput();
if (atts.GetGlyphLocation() == VectorAttributes::UniformInSpace)
{
resampleFilter->SetInput(dob);
dob = resampleFilter->GetOutput();
}
vectorFilter->SetInput(dob);
vectorFilter->SetMagVarName(magVarName);
return vectorFilter->GetOutput();
}
......@@ -423,6 +445,9 @@ avtVectorPlot::CustomizeMapper(avtDataObjectInformation &doi)
// Fix problem where color table wouldn't update when transitioning between
// color-by-magnitude settings.
//
// Hank Childs, Wed Aug 25 09:42:13 PDT 2010
// Set attributes for resample filter.
//
// ****************************************************************************
void
......@@ -452,6 +477,14 @@ avtVectorPlot::SetAtts(const AttributeGroup *a)
}
vectorFilter->SetLimitToOriginal(atts.GetOrigOnly());
if (resampleFilter != NULL)
delete resampleFilter;
InternalResampleAttributes resatts;
resatts.SetUseTargetVal(true);
resatts.SetDistributedResample(true);
resatts.SetTargetVal(atts.GetNVectors());
resampleFilter = new avtResampleFilter(&resatts);
glyph->SetArrow(atts.GetGlyphType() == VectorAttributes::Arrow);
glyph->SetMakeHead(atts.GetHeadOn());
......@@ -645,6 +678,11 @@ avtVectorPlot::SetLegendRanges()
// Programmer: Hank Childs
// Creation: September 12, 2002
//
// Modifications:
//
// Hank Childs, Wed Aug 25 09:42:13 PDT 2010
// Release data for resample filter.
//
// ****************************************************************************
void
......@@ -656,6 +694,10 @@ avtVectorPlot::ReleaseData(void)
{
vectorFilter->ReleaseData();
}
if (resampleFilter != NULL)
{
resampleFilter->ReleaseData();
}
if (ghostFilter != NULL)
{
ghostFilter->ReleaseData();
......
......@@ -51,6 +51,7 @@
class vtkVectorGlyph;
class avtGhostZoneFilter;
class avtResampleFilter;
class avtVectorGlyphMapper;
class avtVariableLegend;
class avtVectorFilter;
......@@ -98,6 +99,9 @@ class avtLookupTable;
// Turn on NeedZBufferToCompositeEvenIn2D, as vector glyphs can bleed
// into other processor's portion of image space.
//
// Hank Childs, Tue Aug 24 22:31:43 PDT 2010
// Add resample operator for uniform glyph placement.
//
// ****************************************************************************
class avtVectorPlot : public avtPointDataPlot
......@@ -126,6 +130,7 @@ class avtVectorPlot : public avtPointDataPlot
avtVariableLegend *varLegend;
avtLegend_p varLegendRefPtr;
avtVectorFilter *vectorFilter;
avtResampleFilter *resampleFilter;
avtGhostZoneFilter *ghostFilter;
avtLookupTable *avtLUT;
......
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