Commit 9989d54a authored by pugmire's avatar pugmire

Add render options on a plot-by-plot basis for pseudocolor plot. Allows for...

Add render options on a plot-by-plot basis for pseudocolor plot. Allows for surface, wireframe, and point rendering. As well as color selection for wireframe and points.

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@28076 18c085ea-50e0-402c-830e-de6fd14e8384
parent 0baf355c
......@@ -119,6 +119,17 @@ avtMapper::avtMapper()
transparencyIndex = -1;
globalAmbient = 0.;
specularIsInappropriate = false;
drawSurfaces = false;
drawWireframe = false;
drawPoints = false;
wireframeColorByScalar = pointsColorByScalar = false;
wireframeColor[0] = 0;
wireframeColor[1] = 0;
wireframeColor[2] = 0;
pointColor[0] = 0;
pointColor[1] = 0;
pointColor[2] = 0;
}
......@@ -400,6 +411,13 @@ avtMapper::SetUpMappers(void)
tree->GetAllLabels(labels);
if (!labels.empty() )
{
int n = labels.size();
if (drawWireframe)
for (int i = 0; i < n; i++)
labels.push_back(labels[i]);
if (drawPoints)
for (int i = 0; i < n; i++)
labels.push_back(labels[i]);
SetLabels(labels, true);
labels.clear();
}
......@@ -407,18 +425,33 @@ avtMapper::SetUpMappers(void)
input->GetInfo().GetAttributes().GetLabels(labels);
if (!labels.empty())
{
int n = labels.size();
if (drawWireframe)
for (int i = 0; i < n; i++)
labels.push_back(labels[i]);
if (drawPoints)
for (int i = 0; i < n; i++)
labels.push_back(labels[i]);
SetLabels(labels, false);
labels.clear();
}
vtkDataSet **children = NULL;
int nChildren = 0;
if (*tree != NULL)
children = tree->GetAllLeaves(nMappers);
else
nMappers = 0;
children = tree->GetAllLeaves(nChildren);
nMappers = nChildren;
//Add mapper/actors for wire/points.
if (drawWireframe)
nMappers += nChildren;
if (drawPoints)
nMappers += nChildren;
mappers = new vtkDataSetMapper*[nMappers];
actors = new vtkActor*[nMappers];
mapperType = new MapperType[nMappers];
for (int j = 0 ; j < nMappers ; j++)
{
......@@ -426,33 +459,95 @@ avtMapper::SetUpMappers(void)
actors[j] = NULL;
}
SetUpFilters(nMappers);
for (int i = 0; i < nMappers; i++)
//Do the regular stuff.
int mi = 0;
if (drawSurfaces)
{
for (int i = 0; i < nChildren; i++, mi++)
{
// We might have some dummy data (SR-mode). If so, just continue.
if (children[i] == NULL)
if (children[i] == NULL || children[i]->GetNumberOfCells() <= 0)
continue;
if (children[i]->GetNumberOfCells() <= 0)
mappers[mi] = CreateMapper();
vtkAlgorithmOutput * outputPort = InsertFilters(children[i], i);
if (outputPort != NULL)
mappers[mi]->SetInputConnection(outputPort);
else
mappers[mi]->SetInputData(children[i]);
if (immediateMode)
mappers[mi]->ImmediateModeRenderingOn();
actors[mi] = vtkActor::New();
actors[mi]->SetMapper(mappers[mi]);
mapperType[mi] = DEFAULT;
}
}
if (drawWireframe)
{
for (int i = 0; i < nChildren; i++, mi++)
{
// We might have some dummy data (SR-mode). If so, just continue.
if (children[i] == NULL || children[i]->GetNumberOfCells() <= 0)
continue;
mappers[i] = CreateMapper();
mappers[mi] = vtkDataSetMapper::New();
//mappers[mi] = CreateMapper();
vtkAlgorithmOutput * outputPort = InsertFilters(children[i], i);
if (outputPort != NULL)
mappers[mi]->SetInputConnection(outputPort);
else
mappers[mi]->SetInputData(children[i]);
if (immediateMode)
mappers[mi]->ImmediateModeRenderingOn();
actors[mi] = vtkActor::New();
actors[mi]->SetMapper(mappers[mi]);
actors[mi]->GetProperty()->SetRepresentationToWireframe();
actors[mi]->GetProperty()->SetAmbient(1.);
actors[mi]->GetProperty()->SetDiffuse(0.);
if (wireframeColorByScalar)
mappers[mi]->ScalarVisibilityOn();
else
{
mappers[mi]->ScalarVisibilityOff();
actors[mi]->GetProperty()->SetColor(wireframeColor);
}
mapperType[mi] = WIREFRAME;
}
}
if (drawPoints)
{
for (int i = 0; i < nChildren; i++, mi++)
{
// We might have some dummy data (SR-mode). If so, just continue.
if (children[i] == NULL || children[i]->GetNumberOfCells() <= 0)
continue;
mappers[mi] = CreateMapper();
vtkAlgorithmOutput * outputPort = InsertFilters(children[i], i);
if (outputPort != NULL)
mappers[i]->SetInputConnection(outputPort);
mappers[mi]->SetInputConnection(outputPort);
else
mappers[i]->SetInputData(children[i]);
mappers[mi]->SetInputData(children[i]);
if (immediateMode)
mappers[mi]->ImmediateModeRenderingOn();
actors[mi] = vtkActor::New();
actors[mi]->SetMapper(mappers[mi]);
actors[mi]->GetProperty()->SetRepresentationToPoints();
actors[mi]->GetProperty()->SetAmbient(1.);
actors[mi]->GetProperty()->SetDiffuse(0.);
if (pointsColorByScalar)
mappers[mi]->ScalarVisibilityOn();
else
{
mappers[i]->ImmediateModeRenderingOn();
mappers[mi]->ScalarVisibilityOff();
actors[mi]->GetProperty()->SetColor(pointColor);
}
mapperType[mi] = POINT;
}
actors[i] = vtkActor::New();
actors[i]->SetMapper(mappers[i]);
}
// this was allocated in GetAllLeaves, need to free it now
if (children != NULL)
delete [] children;
PrepareExtents();
CustomizeMappers();
if (transparencyActor != NULL)
......@@ -1198,6 +1293,9 @@ avtMapper::SetSurfaceRepresentation(int rep)
{
for (int i = 0 ; i < nMappers ; i++)
{
if (mapperType[i] != DEFAULT)
continue;
if (actors[i] != NULL)
{
vtkProperty *prop = actors[i]->GetProperty();
......
......@@ -164,6 +164,25 @@ class PLOTTER_API avtMapper : public avtTerminatingDatasetSink
virtual void ReducedDetailModeOn() {; }
virtual bool ReducedDetailModeOff() { return false; }
virtual void SetDrawSurfaces(bool v) {drawSurfaces=v;}
virtual void SetDrawWireframe(bool v) {drawWireframe=v;}
virtual void SetWireframeColorScalars(){wireframeColorByScalar=true;}
virtual void SetWireframeColor(double r,double g, double b)
{
wireframeColor[0]=r;
wireframeColor[1]=g;
wireframeColor[2]=b;
wireframeColorByScalar=false;
}
virtual void SetDrawPoints(bool v) {drawPoints=v;}
virtual void SetPointsColorScalars() {pointsColorByScalar=true;}
virtual void SetPointsColor(double r,double g, double b)
{
pointColor[0]=r;
pointColor[1]=g;
pointColor[2]=b;
pointsColorByScalar=false;
}
protected:
bool immediateMode;
......@@ -172,8 +191,15 @@ class PLOTTER_API avtMapper : public avtTerminatingDatasetSink
avtTransparencyActor *transparencyActor;
int transparencyIndex;
bool drawSurfaces, drawWireframe, drawPoints;
bool wireframeColorByScalar, pointsColorByScalar;
double wireframeColor[3], pointColor[3];
//DRP. Or call DEFAULT SURFACE??
typedef enum {DEFAULT, WIREFRAME, POINT} MapperType;
vtkDataSetMapper **mappers;
int nMappers;
MapperType *mapperType;
vtkActor **actors;
double globalAmbient;
......
......@@ -123,9 +123,11 @@ PseudocolorAttributes::ChangesRequireRecalculation(const PseudocolorAttributes &
needSecondaryVar ||
geometryChange ||
smoothingLevel != obj.smoothingLevel ||
// renderSurfaces != obj.renderSurfaces ||
// renderWireframe != obj.renderWireframe ||
// renderPoints != obj.renderPoints ||
renderSurfaces != obj.renderSurfaces ||
renderWireframe != obj.renderWireframe ||
renderPoints != obj.renderPoints ||
wireframeColor != obj.wireframeColor ||
pointColor != obj.pointColor ||
0);
}
......@@ -316,3 +318,4 @@ PseudocolorAttributes::ProcessOldVersions(DataNode *parentNode,
}
}
}
......@@ -164,7 +164,7 @@
0.125000
</Field>
<Field name="endPointRadiusBBox" label="Radius (BBox Fraction)" type="double" enabler="endPointRadiusSizeType:FractionOfBBox">
0.05000
0.050000
</Field>
<Field name="endPointResolution" label="End point resolution" type="int">
10
......@@ -198,6 +198,18 @@
<Field name="lightingFlag" label="Lighting" type="bool">
true
</Field>
<Field name="wireframeColor" label="wireframeColor" type="color" length="4">
0
0
0
0
</Field>
<Field name="pointColor" label="pointColor" type="color" length="4">
0
0
0
0
</Field>
<Function name="ChangesRequireRecalculation" user="true" member="true">
</Function>
<Function name="Print" user="true" member="true">
......
......@@ -508,6 +508,8 @@ void PseudocolorAttributes::Copy(const PseudocolorAttributes &obj)
smoothingLevel = obj.smoothingLevel;
legendFlag = obj.legendFlag;
lightingFlag = obj.lightingFlag;
wireframeColor = obj.wireframeColor;
pointColor = obj.pointColor;
PseudocolorAttributes::SelectAll();
}
......@@ -534,7 +536,8 @@ const AttributeGroup::private_tmfs_t PseudocolorAttributes::TmfsStruct = {PSEUDO
PseudocolorAttributes::PseudocolorAttributes() :
AttributeSubject(PseudocolorAttributes::TypeMapFormatString),
colorTableName("hot"), pointSizeVar("default")
colorTableName("hot"), pointSizeVar("default"),
wireframeColor(0, 0, 0, 0), pointColor(0, 0, 0, 0)
{
PseudocolorAttributes::Init();
}
......@@ -556,7 +559,8 @@ PseudocolorAttributes::PseudocolorAttributes() :
PseudocolorAttributes::PseudocolorAttributes(private_tmfs_t tmfs) :
AttributeSubject(tmfs.tmfs),
colorTableName("hot"), pointSizeVar("default")
colorTableName("hot"), pointSizeVar("default"),
wireframeColor(0, 0, 0, 0), pointColor(0, 0, 0, 0)
{
PseudocolorAttributes::Init();
}
......@@ -714,7 +718,9 @@ PseudocolorAttributes::operator == (const PseudocolorAttributes &obj) const
(renderPoints == obj.renderPoints) &&
(smoothingLevel == obj.smoothingLevel) &&
(legendFlag == obj.legendFlag) &&
(lightingFlag == obj.lightingFlag));
(lightingFlag == obj.lightingFlag) &&
(wireframeColor == obj.wireframeColor) &&
(pointColor == obj.pointColor));
}
// ****************************************************************************
......@@ -906,6 +912,8 @@ PseudocolorAttributes::SelectAll()
Select(ID_smoothingLevel, (void *)&smoothingLevel);
Select(ID_legendFlag, (void *)&legendFlag);
Select(ID_lightingFlag, (void *)&lightingFlag);
Select(ID_wireframeColor, (void *)&wireframeColor);
Select(ID_pointColor, (void *)&pointColor);
}
///////////////////////////////////////////////////////////////////////////////
......@@ -1226,6 +1234,22 @@ PseudocolorAttributes::CreateNode(DataNode *parentNode, bool completeSave, bool
node->AddNode(new DataNode("lightingFlag", lightingFlag));
}
DataNode *wireframeColorNode = new DataNode("wireframeColor");
if(wireframeColor.CreateNode(wireframeColorNode, completeSave, true))
{
addToParent = true;
node->AddNode(wireframeColorNode);
}
else
delete wireframeColorNode;
DataNode *pointColorNode = new DataNode("pointColor");
if(pointColor.CreateNode(pointColorNode, completeSave, true))
{
addToParent = true;
node->AddNode(pointColorNode);
}
else
delete pointColorNode;
// Add the node to the parent node.
if(addToParent || forceAdd)
......@@ -1498,6 +1522,10 @@ PseudocolorAttributes::SetFromNode(DataNode *parentNode)
SetLegendFlag(node->AsBool());
if((node = searchNode->GetNode("lightingFlag")) != 0)
SetLightingFlag(node->AsBool());
if((node = searchNode->GetNode("wireframeColor")) != 0)
wireframeColor.SetFromNode(node);
if((node = searchNode->GetNode("pointColor")) != 0)
pointColor.SetFromNode(node);
}
///////////////////////////////////////////////////////////////////////////////
......@@ -1840,6 +1868,20 @@ PseudocolorAttributes::SetLightingFlag(bool lightingFlag_)
Select(ID_lightingFlag, (void *)&lightingFlag);
}
void
PseudocolorAttributes::SetWireframeColor(const ColorAttribute &wireframeColor_)
{
wireframeColor = wireframeColor_;
Select(ID_wireframeColor, (void *)&wireframeColor);
}
void
PseudocolorAttributes::SetPointColor(const ColorAttribute &pointColor_)
{
pointColor = pointColor_;
Select(ID_pointColor, (void *)&pointColor);
}
///////////////////////////////////////////////////////////////////////////////
// Get property methods
///////////////////////////////////////////////////////////////////////////////
......@@ -2162,6 +2204,30 @@ PseudocolorAttributes::GetLightingFlag() const
return lightingFlag;
}
const ColorAttribute &
PseudocolorAttributes::GetWireframeColor() const
{
return wireframeColor;
}
ColorAttribute &
PseudocolorAttributes::GetWireframeColor()
{
return wireframeColor;
}
const ColorAttribute &
PseudocolorAttributes::GetPointColor() const
{
return pointColor;
}
ColorAttribute &
PseudocolorAttributes::GetPointColor()
{
return pointColor;
}
///////////////////////////////////////////////////////////////////////////////
// Select property methods
///////////////////////////////////////////////////////////////////////////////
......@@ -2196,6 +2262,18 @@ PseudocolorAttributes::SelectEndPointRadiusVar()
Select(ID_endPointRadiusVar, (void *)&endPointRadiusVar);
}
void
PseudocolorAttributes::SelectWireframeColor()
{
Select(ID_wireframeColor, (void *)&wireframeColor);
}
void
PseudocolorAttributes::SelectPointColor()
{
Select(ID_pointColor, (void *)&pointColor);
}
///////////////////////////////////////////////////////////////////////////////
// Keyframing methods
///////////////////////////////////////////////////////////////////////////////
......@@ -2268,6 +2346,8 @@ PseudocolorAttributes::GetFieldName(int index) const
case ID_smoothingLevel: return "smoothingLevel";
case ID_legendFlag: return "legendFlag";
case ID_lightingFlag: return "lightingFlag";
case ID_wireframeColor: return "wireframeColor";
case ID_pointColor: return "pointColor";
default: return "invalid index";
}
}
......@@ -2340,6 +2420,8 @@ PseudocolorAttributes::GetFieldType(int index) const
case ID_smoothingLevel: return FieldType_int;
case ID_legendFlag: return FieldType_bool;
case ID_lightingFlag: return FieldType_bool;
case ID_wireframeColor: return FieldType_color;
case ID_pointColor: return FieldType_color;
default: return FieldType_unknown;
}
}
......@@ -2412,6 +2494,8 @@ PseudocolorAttributes::GetFieldTypeName(int index) const
case ID_smoothingLevel: return "int";
case ID_legendFlag: return "bool";
case ID_lightingFlag: return "bool";
case ID_wireframeColor: return "color";
case ID_pointColor: return "color";
default: return "invalid index";
}
}
......@@ -2678,6 +2762,16 @@ PseudocolorAttributes::FieldsEqual(int index_, const AttributeGroup *rhs) const
retval = (lightingFlag == obj.lightingFlag);
}
break;
case ID_wireframeColor:
{ // new scope
retval = (wireframeColor == obj.wireframeColor);
}
break;
case ID_pointColor:
{ // new scope
retval = (pointColor == obj.pointColor);
}
break;
default: retval = false;
}
......@@ -2772,9 +2866,11 @@ PseudocolorAttributes::ChangesRequireRecalculation(const PseudocolorAttributes &
needSecondaryVar ||
geometryChange ||
smoothingLevel != obj.smoothingLevel ||
// renderSurfaces != obj.renderSurfaces ||
// renderWireframe != obj.renderWireframe ||
// renderPoints != obj.renderPoints ||
renderSurfaces != obj.renderSurfaces ||
renderWireframe != obj.renderWireframe ||
renderPoints != obj.renderPoints ||
wireframeColor != obj.wireframeColor ||
pointColor != obj.pointColor ||
0);
}
......
......@@ -41,6 +41,7 @@
#include <string>
#include <AttributeSubject.h>
#include <ColorAttribute.h>
#include <visitstream.h>
// ****************************************************************************
......@@ -151,6 +152,8 @@ public:
void SelectPointSizeVar();
void SelectTubeRadiusVar();
void SelectEndPointRadiusVar();
void SelectWireframeColor();
void SelectPointColor();
// Property setting methods
void SetScaling(Scaling scaling_);
......@@ -201,6 +204,8 @@ public:
void SetSmoothingLevel(int smoothingLevel_);
void SetLegendFlag(bool legendFlag_);
void SetLightingFlag(bool lightingFlag_);
void SetWireframeColor(const ColorAttribute &wireframeColor_);
void SetPointColor(const ColorAttribute &pointColor_);
// Property getting methods
Scaling GetScaling() const;
......@@ -256,6 +261,10 @@ public:
int GetSmoothingLevel() const;
bool GetLegendFlag() const;
bool GetLightingFlag() const;
const ColorAttribute &GetWireframeColor() const;
ColorAttribute &GetWireframeColor();
const ColorAttribute &GetPointColor() const;
ColorAttribute &GetPointColor();
// Persistence methods
virtual bool CreateNode(DataNode *node, bool completeSave, bool forceAdd);
......@@ -369,6 +378,8 @@ public:
ID_smoothingLevel,
ID_legendFlag,
ID_lightingFlag,
ID_wireframeColor,
ID_pointColor,
ID__LAST
};
......@@ -421,11 +432,13 @@ private:
int smoothingLevel;
bool legendFlag;
bool lightingFlag;
ColorAttribute wireframeColor;
ColorAttribute pointColor;
// Static class format string for type map.
static const char *TypeMapFormatString;
static const private_tmfs_t TmfsStruct;
};
#define PSEUDOCOLORATTRIBUTES_TMFS "idibdbdisbisdddbbdibsiiiiiiddbsdiiiddidbsdiiiibb"
#define PSEUDOCOLORATTRIBUTES_TMFS "idibdbdisbisdddbbdibsiiiiiiddbsdiiiddidbsdiiiibbaa"
#endif
......@@ -41,6 +41,7 @@ package llnl.visit.plots;
import llnl.visit.AttributeSubject;
import llnl.visit.CommunicationBuffer;
import llnl.visit.Plugin;
import llnl.visit.ColorAttribute;
// ****************************************************************************
// Class: PseudocolorAttributes
......@@ -59,7 +60,7 @@ import llnl.visit.Plugin;
public class PseudocolorAttributes extends AttributeSubject implements Plugin
{
private static int PseudocolorAttributes_numAdditionalAtts = 48;
private static int PseudocolorAttributes_numAdditionalAtts = 50;
// Enum values
public final static int SCALING_LINEAR = 0;
......@@ -156,6 +157,8 @@ public class PseudocolorAttributes extends AttributeSubject implements Plugin
smoothingLevel = 0;
legendFlag = true;
lightingFlag = true;
wireframeColor = new ColorAttribute(0, 0, 0, 0);
pointColor = new ColorAttribute(0, 0, 0, 0);
}
public PseudocolorAttributes(int nMoreFields)
......@@ -210,6 +213,8 @@ public class PseudocolorAttributes extends AttributeSubject implements Plugin
smoothingLevel = 0;
legendFlag = true;
lightingFlag = true;
wireframeColor = new ColorAttribute(0, 0, 0, 0);
pointColor = new ColorAttribute(0, 0, 0, 0);
}
public PseudocolorAttributes(PseudocolorAttributes obj)
......@@ -264,6 +269,8 @@ public class PseudocolorAttributes extends AttributeSubject implements Plugin
smoothingLevel = obj.smoothingLevel;
legendFlag = obj.legendFlag;
lightingFlag = obj.lightingFlag;
wireframeColor = new ColorAttribute(obj.wireframeColor);
pointColor = new ColorAttribute(obj.pointColor);
SelectAll();
}
......@@ -328,7 +335,9 @@ public class PseudocolorAttributes extends AttributeSubject implements Plugin
(renderPoints == obj.renderPoints) &&
(smoothingLevel == obj.smoothingLevel) &&
(legendFlag == obj.legendFlag) &&
(lightingFlag == obj.lightingFlag));
(lightingFlag == obj.lightingFlag) &&
(wireframeColor == obj.wireframeColor) &&
(pointColor == obj.pointColor));
}
public String GetName() { return "Pseudocolor"; }
......@@ -623,6 +632,18 @@ public class PseudocolorAttributes extends AttributeSubject implements Plugin
Select(47);
}
public void SetWireframeColor(ColorAttribute wireframeColor_)
{
wireframeColor = wireframeColor_;
Select(48);
}
public void SetPointColor(ColorAttribute pointColor_)
{
pointColor = pointColor_;
Select(49);
}
// Property getting methods
public int GetScaling() { return scaling; }
public double GetSkewFactor() { return skewFactor; }
......@@ -672,6 +693,8 @@ public class PseudocolorAttributes extends AttributeSubject implements Plugin
public int GetSmoothingLevel() { return smoothingLevel; }
public boolean GetLegendFlag() { return legendFlag; }