Commit 9989d54a authored by pugmire's avatar pugmire
Browse files

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() ...@@ -119,6 +119,17 @@ avtMapper::avtMapper()
transparencyIndex = -1; transparencyIndex = -1;
globalAmbient = 0.; globalAmbient = 0.;
specularIsInappropriate = false; 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) ...@@ -400,6 +411,13 @@ avtMapper::SetUpMappers(void)
tree->GetAllLabels(labels); tree->GetAllLabels(labels);
if (!labels.empty() ) 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); SetLabels(labels, true);
labels.clear(); labels.clear();
} }
...@@ -407,18 +425,33 @@ avtMapper::SetUpMappers(void) ...@@ -407,18 +425,33 @@ avtMapper::SetUpMappers(void)
input->GetInfo().GetAttributes().GetLabels(labels); input->GetInfo().GetAttributes().GetLabels(labels);
if (!labels.empty()) 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); SetLabels(labels, false);
labels.clear(); labels.clear();
} }
vtkDataSet **children = NULL; vtkDataSet **children = NULL;
int nChildren = 0;
if (*tree != NULL) if (*tree != NULL)
children = tree->GetAllLeaves(nMappers); children = tree->GetAllLeaves(nChildren);
else
nMappers = 0; nMappers = nChildren;
//Add mapper/actors for wire/points.
if (drawWireframe)
nMappers += nChildren;
if (drawPoints)
nMappers += nChildren;
mappers = new vtkDataSetMapper*[nMappers]; mappers = new vtkDataSetMapper*[nMappers];
actors = new vtkActor*[nMappers]; actors = new vtkActor*[nMappers];
mapperType = new MapperType[nMappers];
for (int j = 0 ; j < nMappers ; j++) for (int j = 0 ; j < nMappers ; j++)
{ {
...@@ -426,33 +459,95 @@ avtMapper::SetUpMappers(void) ...@@ -426,33 +459,95 @@ avtMapper::SetUpMappers(void)
actors[j] = NULL; actors[j] = NULL;
} }
SetUpFilters(nMappers); 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. // 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; 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; continue;
mappers[mi] = vtkDataSetMapper::New();
mappers[i] = CreateMapper(); //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); vtkAlgorithmOutput * outputPort = InsertFilters(children[i], i);
if (outputPort != NULL) if (outputPort != NULL)
mappers[i]->SetInputConnection(outputPort); mappers[mi]->SetInputConnection(outputPort);
else else
mappers[i]->SetInputData(children[i]); mappers[mi]->SetInputData(children[i]);
if (immediateMode) 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 // this was allocated in GetAllLeaves, need to free it now
if (children != NULL) if (children != NULL)
delete [] children; delete [] children;
PrepareExtents(); PrepareExtents();
CustomizeMappers(); CustomizeMappers();
if (transparencyActor != NULL) if (transparencyActor != NULL)
...@@ -1198,6 +1293,9 @@ avtMapper::SetSurfaceRepresentation(int rep) ...@@ -1198,6 +1293,9 @@ avtMapper::SetSurfaceRepresentation(int rep)
{ {
for (int i = 0 ; i < nMappers ; i++) for (int i = 0 ; i < nMappers ; i++)
{ {
if (mapperType[i] != DEFAULT)
continue;
if (actors[i] != NULL) if (actors[i] != NULL)
{ {
vtkProperty *prop = actors[i]->GetProperty(); vtkProperty *prop = actors[i]->GetProperty();
......
...@@ -164,6 +164,25 @@ class PLOTTER_API avtMapper : public avtTerminatingDatasetSink ...@@ -164,6 +164,25 @@ class PLOTTER_API avtMapper : public avtTerminatingDatasetSink
virtual void ReducedDetailModeOn() {; } virtual void ReducedDetailModeOn() {; }
virtual bool ReducedDetailModeOff() { return false; } 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: protected:
bool immediateMode; bool immediateMode;
...@@ -172,8 +191,15 @@ class PLOTTER_API avtMapper : public avtTerminatingDatasetSink ...@@ -172,8 +191,15 @@ class PLOTTER_API avtMapper : public avtTerminatingDatasetSink
avtTransparencyActor *transparencyActor; avtTransparencyActor *transparencyActor;
int transparencyIndex; 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; vtkDataSetMapper **mappers;
int nMappers; int nMappers;
MapperType *mapperType;
vtkActor **actors; vtkActor **actors;
double globalAmbient; double globalAmbient;
......
...@@ -123,9 +123,11 @@ PseudocolorAttributes::ChangesRequireRecalculation(const PseudocolorAttributes & ...@@ -123,9 +123,11 @@ PseudocolorAttributes::ChangesRequireRecalculation(const PseudocolorAttributes &
needSecondaryVar || needSecondaryVar ||
geometryChange || geometryChange ||
smoothingLevel != obj.smoothingLevel || smoothingLevel != obj.smoothingLevel ||
// renderSurfaces != obj.renderSurfaces || renderSurfaces != obj.renderSurfaces ||
// renderWireframe != obj.renderWireframe || renderWireframe != obj.renderWireframe ||
// renderPoints != obj.renderPoints || renderPoints != obj.renderPoints ||
wireframeColor != obj.wireframeColor ||
pointColor != obj.pointColor ||
0); 0);
} }
...@@ -316,3 +318,4 @@ PseudocolorAttributes::ProcessOldVersions(DataNode *parentNode, ...@@ -316,3 +318,4 @@ PseudocolorAttributes::ProcessOldVersions(DataNode *parentNode,
} }
} }
} }
...@@ -164,7 +164,7 @@ ...@@ -164,7 +164,7 @@
0.125000 0.125000
</Field> </Field>
<Field name="endPointRadiusBBox" label="Radius (BBox Fraction)" type="double" enabler="endPointRadiusSizeType:FractionOfBBox"> <Field name="endPointRadiusBBox" label="Radius (BBox Fraction)" type="double" enabler="endPointRadiusSizeType:FractionOfBBox">
0.05000 0.050000
</Field> </Field>
<Field name="endPointResolution" label="End point resolution" type="int"> <Field name="endPointResolution" label="End point resolution" type="int">
10 10
...@@ -198,6 +198,18 @@ ...@@ -198,6 +198,18 @@
<Field name="lightingFlag" label="Lighting" type="bool"> <Field name="lightingFlag" label="Lighting" type="bool">
true true
</Field> </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 name="ChangesRequireRecalculation" user="true" member="true">
</Function> </Function>
<Function name="Print" user="true" member="true"> <Function name="Print" user="true" member="true">
......
...@@ -508,6 +508,8 @@ void PseudocolorAttributes::Copy(const PseudocolorAttributes &obj) ...@@ -508,6 +508,8 @@ void PseudocolorAttributes::Copy(const PseudocolorAttributes &obj)
smoothingLevel = obj.smoothingLevel; smoothingLevel = obj.smoothingLevel;
legendFlag = obj.legendFlag; legendFlag = obj.legendFlag;
lightingFlag = obj.lightingFlag; lightingFlag = obj.lightingFlag;
wireframeColor = obj.wireframeColor;
pointColor = obj.pointColor;
PseudocolorAttributes::SelectAll(); PseudocolorAttributes::SelectAll();
} }
...@@ -534,7 +536,8 @@ const AttributeGroup::private_tmfs_t PseudocolorAttributes::TmfsStruct = {PSEUDO ...@@ -534,7 +536,8 @@ const AttributeGroup::private_tmfs_t PseudocolorAttributes::TmfsStruct = {PSEUDO
PseudocolorAttributes::PseudocolorAttributes() : PseudocolorAttributes::PseudocolorAttributes() :
AttributeSubject(PseudocolorAttributes::TypeMapFormatString), AttributeSubject(PseudocolorAttributes::TypeMapFormatString),
colorTableName("hot"), pointSizeVar("default") colorTableName("hot"), pointSizeVar("default"),
wireframeColor(0, 0, 0, 0), pointColor(0, 0, 0, 0)
{ {
PseudocolorAttributes::Init(); PseudocolorAttributes::Init();
} }
...@@ -556,7 +559,8 @@ PseudocolorAttributes::PseudocolorAttributes() : ...@@ -556,7 +559,8 @@ PseudocolorAttributes::PseudocolorAttributes() :
PseudocolorAttributes::PseudocolorAttributes(private_tmfs_t tmfs) : PseudocolorAttributes::PseudocolorAttributes(private_tmfs_t tmfs) :
AttributeSubject(tmfs.tmfs), AttributeSubject(tmfs.tmfs),
colorTableName("hot"), pointSizeVar("default") colorTableName("hot"), pointSizeVar("default"),
wireframeColor(0, 0, 0, 0), pointColor(0, 0, 0, 0)
{ {
PseudocolorAttributes::Init(); PseudocolorAttributes::Init();
} }
...@@ -714,7 +718,9 @@ PseudocolorAttributes::operator == (const PseudocolorAttributes &obj) const ...@@ -714,7 +718,9 @@ PseudocolorAttributes::operator == (const PseudocolorAttributes &obj) const
(renderPoints == obj.renderPoints) && (renderPoints == obj.renderPoints) &&
(smoothingLevel == obj.smoothingLevel) && (smoothingLevel == obj.smoothingLevel) &&
(legendFlag == obj.legendFlag) && (legendFlag == obj.legendFlag) &&
(lightingFlag == obj.lightingFlag)); (lightingFlag == obj.lightingFlag) &&
(wireframeColor == obj.wireframeColor) &&
(pointColor == obj.pointColor));
} }
// **************************************************************************** // ****************************************************************************
...@@ -906,6 +912,8 @@ PseudocolorAttributes::SelectAll() ...@@ -906,6 +912,8 @@ PseudocolorAttributes::SelectAll()
Select(ID_smoothingLevel, (void *)&smoothingLevel); Select(ID_smoothingLevel, (void *)&smoothingLevel);
Select(ID_legendFlag, (void *)&legendFlag); Select(ID_legendFlag, (void *)&legendFlag);
Select(ID_lightingFlag, (void *)&lightingFlag); 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 ...@@ -1226,6 +1234,22 @@ PseudocolorAttributes::CreateNode(DataNode *parentNode, bool completeSave, bool
node->AddNode(new DataNode("lightingFlag", lightingFlag)); 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. // Add the node to the parent node.
if(addToParent || forceAdd) if(addToParent || forceAdd)
...@@ -1498,6 +1522,10 @@ PseudocolorAttributes::SetFromNode(DataNode *parentNode) ...@@ -1498,6 +1522,10 @@ PseudocolorAttributes::SetFromNode(DataNode *parentNode)
SetLegendFlag(node->AsBool()); SetLegendFlag(node->AsBool());
if((node = searchNode->GetNode("lightingFlag")) != 0) if((node = searchNode->GetNode("lightingFlag")) != 0)
SetLightingFlag(node->AsBool()); 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_) ...@@ -1840,6 +1868,20 @@ PseudocolorAttributes::SetLightingFlag(bool lightingFlag_)
Select(ID_lightingFlag, (void *)&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 // Get property methods
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
...@@ -2162,6 +2204,30 @@ PseudocolorAttributes::GetLightingFlag() const ...@@ -2162,6 +2204,30 @@ PseudocolorAttributes::GetLightingFlag() const
return lightingFlag; 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 // Select property methods
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
...@@ -2196,6 +2262,18 @@ PseudocolorAttributes::SelectEndPointRadiusVar() ...@@ -2196,6 +2262,18 @@ PseudocolorAttributes::SelectEndPointRadiusVar()
Select(ID_endPointRadiusVar, (void *)&endPointRadiusVar); Select(ID_endPointRadiusVar, (void *)&endPointRadiusVar);
} }
void
PseudocolorAttributes::SelectWireframeColor()
{
Select(ID_wireframeColor, (void *)&wireframeColor);
}
void
PseudocolorAttributes::SelectPointColor()
{
Select(ID_pointColor, (void *)&pointColor);
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Keyframing methods // Keyframing methods
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
...@@ -2268,6 +2346,8 @@ PseudocolorAttributes::GetFieldName(int index) const ...@@ -2268,6 +2346,8 @@ PseudocolorAttributes::GetFieldName(int index) const
case ID_smoothingLevel: return "smoothingLevel"; case ID_smoothingLevel: return "smoothingLevel";
case ID_legendFlag: return "legendFlag"; case ID_legendFlag: return "legendFlag";
case ID_lightingFlag: return "lightingFlag"; case ID_lightingFlag: return "lightingFlag";
case ID_wireframeColor: return "wireframeColor";
case ID_pointColor: return "pointColor";
default: return "invalid index"; default: return "invalid index";
} }
} }
...@@ -2340,6 +2420,8 @@ PseudocolorAttributes::GetFieldType(int index) const ...@@ -2340,6 +2420,8 @@ PseudocolorAttributes::GetFieldType(int index) const
case ID_smoothingLevel: return FieldType_int; case ID_smoothingLevel: return FieldType_int;
case ID_legendFlag: return FieldType_bool; case ID_legendFlag: return FieldType_bool;
case ID_lightingFlag: 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; default: return FieldType_unknown;
} }
} }
...@@ -2412,6 +2494,8 @@ PseudocolorAttributes::GetFieldTypeName(int index) const ...@@ -2412,6 +2494,8 @@ PseudocolorAttributes::GetFieldTypeName(int index) const
case ID_smoothingLevel: return "int"; case ID_smoothingLevel: return "int";
case ID_legendFlag: return "bool"; case ID_legendFlag: return "bool";
case ID_lightingFlag: return "bool"; case ID_lightingFlag: return "bool";
case ID_wireframeColor: return "color";
case ID_pointColor: return "color";
default: return "invalid index"; default: return "invalid index";
} }
} }
...@@ -2678,6 +2762,16 @@ PseudocolorAttributes::FieldsEqual(int index_, const AttributeGroup *rhs) const ...@@ -2678,6 +2762,16 @@ PseudocolorAttributes::FieldsEqual(int index_, const AttributeGroup *rhs) const
retval = (lightingFlag == obj.lightingFlag); retval = (lightingFlag == obj.lightingFlag);
} }
break; break;
case ID_wireframeColor:
{ // new scope
retval = (wireframeColor == obj.wireframeColor);
}
break;
case ID_pointColor:
{ // new scope
retval = (pointColor == obj.pointColor);
}
break;
default: retval = false; default: retval = false;
} }
...@@ -2772,9 +2866,11 @@ PseudocolorAttributes::ChangesRequireRecalculation(const PseudocolorAttributes & ...@@ -2772,9 +2866,11 @@ PseudocolorAttributes::ChangesRequireRecalculation(const PseudocolorAttributes &
needSecondaryVar || needSecondaryVar ||
geometryChange || geometryChange ||
smoothingLevel != obj.smoothingLevel || smoothingLevel != obj.smoothingLevel ||
// renderSurfaces != obj.renderSurfaces ||