Commit d83043ba authored by Amy Squillacote's avatar Amy Squillacote
Browse files

using SM properties with vtkPVScale

parent ac0752b1
......@@ -143,10 +143,10 @@ The Cell Data to Point Data filter averages the values of the cell attributes of
trace_name="PieceInvariant"
property="PieceInvariant"
help="Turn this on to remove seams when running in parallel."/>
<Scale variable="Tolerance"
<Scale label="Tolerance"
trace_name="Tolerance"
property="Tolerance"
help="The tolerance in terms of fraction of bounding box length."
default_value="0.0"
resolution="0.01" range="0 1"
display_entry="1"
entry_and_label_on_top="0" display_value="0"/>
......@@ -283,9 +283,8 @@ The Curvature filter computes the curvature at each point in a polygonal data se
input_name="Input"/>
<Scale label="Reduction target"
trace_name="TargetReduction"
variable="TargetReduction"
property="TargetReduction"
help="Value between 0 and 1. Desired reduction of the total number of triangles."
default_value="0.90"
resolution="0.01" range="0 1"
display_entry="1"
entry_and_label_on_top="0" display_value="0"/>
......@@ -295,9 +294,8 @@ The Curvature filter computes the curvature at each point in a polygonal data se
help="If off, better reduction can occur, but model may break up."/>
<Scale label="Feature angle"
trace_name="FeatureAngle"
variable="FeatureAngle"
property="FeatureAngle"
help="This angle is used to define a feature edge. (i.e., if the surface normal between two adjacent triangles is >= Feature angle, an edge exists). Topology can be split along feature edges."
default_value="15.0"
resolution="0.01" range="0 180"
display_entry="1"
entry_and_label_on_top="0"
......@@ -595,9 +593,8 @@ The Calculator filter is available on the Toolbar.
help="Turn this off if you do not want to color the edges by type."/>
<Scale label="Feature angle"
trace_name="FeatureAngle"
variable="FeatureAngle"
property="FeatureAngle"
help="This angle is used to define a feature edge. (i.e., if the surface normal between two adjacent triangles is >= Feature angle, an edge exists).."
default_value="30.0"
resolution="0.01"
range="0 180"
display_entry="1"
......@@ -748,9 +745,8 @@ The Piece invariant check box determines whether the output will be the same reg
input_name="Input"/>
<Scale label="Number of divisions"
trace_name="NumberOfSubdivisions"
variable="NumberOfSubdivisions"
property="NumberOfSubdivisions"
help="Each subdivision changes single triangles into four triangles."
default_value="1"
resolution="1" range="1 4"
display_entry="1"
entry_and_label_on_top="0"
......@@ -846,9 +842,8 @@ The Median filter operates on uniform rectilinear (image or volume) data and pro
input_name="Input"/>
<Scale label="Feature angle"
trace_name="FeatureAngle"
variable="FeatureAngle"
property="FeatureAngle"
help="Points are duplicated along features over this angle (0->180)"
default_value="30.0"
resolution="0.01" range="0 180"
display_entry="1"
entry_and_label_on_top="0" display_value="0"/>
......@@ -945,9 +940,8 @@ The Outline filter generates an axis-aligned bounding box for the input data set
input_name="Input"/>
<Scale label="Corner factor"
trace_name="CornerFactor"
variable="CornerFactor"
property="CornerFactor"
help="The relative size of the corners to the length of the corresponding bounds. (0.001 -> 0.5)"
default_value="0.2"
resolution="0.001"
range="0.001 0.5"
display_entry="1"
......@@ -1188,10 +1182,10 @@ The Reflection filter reflects the input data set across the specified plane. If
type="float"
scale_factor="0.01"
help="The half width of the ribbon (or minimum)."/>
<Scale variable="Angle"
<Scale label="Angle"
trace_name="Angle"
property="Angle"
help="The offset angle of the ribbon from the line normal (0->360)."
default_value="0.0"
resolution="0.01"
range="0 360"
display_entry="1"
......@@ -1278,9 +1272,8 @@ The Capping check box controls whether to close the open ends of the swept surfa
input_name="Input"/>
<Scale label="Shrink factor"
trace_name="ShrinkFactor"
variable="ShrinkFactor"
property="ShrinkFactor"
help="Set the amount to shrink by"
default_value="0.5"
resolution="0.01"
range="0 1"
display_entry="1"
......@@ -1331,10 +1324,10 @@ The Shrink filter causes the individual cells of a data set to break apart from
resolution="1"
minimum_value="0"
help="Number of iterations. More iterations produce better smoothing."/>
<Scale variable="Convergence"
<Scale label="Convergence"
trace_name="Convergence"
property="Convergence"
help="Convergence criterion for the iteration process. Smaller numbers result in more smoothing iterations (0->1)."
default_value="0.0"
resolution="0.01"
range="0 1"
display_entry="1"
......@@ -1360,9 +1353,8 @@ The Smooth filter operates on a polygonal data set by iteratively adjusting the
input_name="Input"/>
<Scale label="Max. length"
trace_name="MaximumLength"
variable="MaximumLength"
property="MaximumLength"
help="Stop stripping after this many triangles."
default_value="1000"
resolution="1"
range="4 100000"
display_entry="1"
......@@ -1379,9 +1371,8 @@ The Triangle Strips filter converts triangles into triangle strips and lines int
short_help="Creates a surface with more triangles than the input.">
<Scale label="Num. divisions"
trace_name="NumberOfSubdivisions"
variable="NumberOfSubdivisions"
property="NumberOfSubdivisions"
help="Set the number of subdivisions"
default_value="1"
resolution="1"
range="1 4"
display_entry="1"
......@@ -1408,9 +1399,9 @@ The Subdivide filter iteratively divides each triangle in the data set into 4 ne
help="Set the input to this filter."
input_name="Input"/>
<Scale label="Output Dimension" trace_name="OutputDimension"
variable="OutputDimension" type="int"
property="OutputDimension"
help="Maximum dimensionality of output tessellation. Cells of higher dimension will be reduced to their boundaries."
default_value="2" display_entry="0" entry_and_label_on_top="1" display_value="1"
display_entry="0" entry_and_label_on_top="1" display_value="1"
range="1 3"/>
<VectorEntry label="Max Chord Error"
trace_name="ChordError"
......
......@@ -444,8 +444,9 @@
help="An XML file containing part and material descriptions and mapping to element blocks." />
<Scale variable="TimeStep"
type="int"
<Scale label="TimeStep"
trace_name="TimeStep"
property="TimeStep"
label="Time step" trace_name="TimeStep"
help="Set the current timestep."
range_source="TimeStepRange" />
......@@ -511,7 +512,9 @@
module_type="Reader" extensions=".saf"
file_description="SAF Reader">
<Source class="vtkSAFPVReader"/>
<Scale variable="TimeStep"
<Scale label="TimeStep"
trace_name="TimeStep"
property="TimeStep"
type="int"
label="Time step" trace_name="TimeStep"
help="Set the current timestep."
......
......@@ -75,45 +75,40 @@ The output of the 3D Text source is polygonal data.
<Source class="vtkPVArrowSource"/>
<!-- Scales are used here because vtkArrowSource sets these ranges for these parameters. -->
<Scale label="Tip resolution" trace_name="TipResolution"
variable="TipResolution"
property="TipResolution"
help="Set the number of faces on the tip."
default_value="6"
resolution="1"
range="1 128"
display_entry="1"
entry_and_label_on_top="0"
display_value="0"/>
<Scale label="Tip radius" trace_name="TipRadius"
variable="TipRadius"
property="TipRadius"
help="Set the radius of the widest part of the tip."
default_value="0.1"
resolution="0.01"
range="0 10"
display_entry="1"
entry_and_label_on_top="0"
display_value="0"/>
<Scale label="Tip length" trace_name="TipLength"
variable="TipLength"
property="TipLength"
help="Set the length of the tip (the whole arrow is length 1)"
default_value="0.35"
resolution="0.01"
range="0 1"
display_entry="1"
entry_and_label_on_top="0"
display_value="0"/>
<Scale label="Shaft resolution" trace_name="ShaftResolution"
variable="ShaftResolution"
property="ShaftResolution"
help="Set the number of faces on shaft"
default_value="6"
resolution="1"
range="0 128"
display_entry="1"
entry_and_label_on_top="0"
display_value="0"/>
<Scale label="Shaft radius" trace_name="ShaftRadius"
variable="ShaftRadius"
property="ShaftRadius"
help="Set the radius of the shaft"
default_value="0.03"
resolution="0.01"
range="0 5"
display_entry="1"
......@@ -183,8 +178,8 @@ The output of the Box source is polygonal data containing both normals and textu
long_help="3D cone of a given radius and height."
short_help="Create a 3D cone of a given radius and height">
<Source class="vtkConeSource"/>
<Scale variable="Resolution" trace_name="Resolution"
default_value="6" resolution="1" range="0 512"
<Scale label="Resolution" trace_name="Resolution" property="Resolution"
resolution="1" range="0 512"
display_entry="1" display_value="0" entry_and_label_on_top="0"
help="Set the number of faces on this cone" />
<ThumbWheel label="Radius" trace_name="Radius" property="Radius"
......@@ -210,8 +205,8 @@ The output of the Cone source is polygonal data.
long_help="3D cylinder of a given radius and height."
short_help="Create a 3D cylinder of a given radius and height">
<Source class="vtkCylinderSource"/>
<Scale variable="Resolution" trace_name="Resolution"
default_value="6" resolution="1" range="2 512"
<Scale label="Resolution" trace_name="Resolution" property="Resolution"
resolution="1" range="2 512"
display_entry="1" entry_and_label_on_top="0" display_value="0"
help="The number of facets used to define the cylinder." />
<ThumbWheel label="Height" trace_name="Height" property="Height"
......@@ -277,8 +272,8 @@ The output of the Line source is polygonal data.
length="4"
help="Set the inaginary and real values for the world size of the volume for C (constant) and X (initial value)" />
<Scale label="Max. iterations" trace_name="MaxIterations"
variable="MaximumNumberOfIterations"
default_value="100" resolution="1" range="1 5000"
property="MaximumNumberOfIterations"
resolution="1" range="1 5000"
display_entry="1" display_value="0" entry_and_label_on_top="0"
help="The limit on computational iterations. Values less than 2.0 after this many iterations are considered in the set."/>
<Documentation>
......@@ -372,30 +367,30 @@ The output of the Plane source is polygonal data.
resolution="0.01" minimum_value="0"
help="Set the radius of the sphere" />
<Scale label="Theta Resolution" trace_name="Theta Resolution"
variable="ThetaResolution"
default_value="8" resolution="1" range="3 1024"
property="ThetaResolution"
resolution="1" range="3 1024"
display_entry="1" display_value="0" entry_and_label_on_top="0"
help="Set the number of points in the longitude direction (ranging from Start Theta to End Theta)" />
<Scale label="Start Theta" trace_name="Start Theta"
variable="StartTheta"
default_value="0.0" resolution="0.01" range="0 360"
property="StartTheta"
resolution="0.01" range="0 360"
display_entry="1" display_value="0" entry_and_label_on_top="0"
help="Set the starting angle in the longitude direction" />
<Scale label="End Theta" trace_name="End Theta" variable="EndTheta"
default_value="360.0" resolution="0.01" range="0 360"
<Scale label="End Theta" trace_name="End Theta" property="EndTheta"
resolution="0.01" range="0 360"
display_entry="1" display_value="0" entry_and_label_on_top="0"
help="Set the ending angle in the longitude direction" />
<Scale label="Phi Resolution" trace_name="Phi Resolution"
variable="PhiResolution" default_value="8" resolution="1"
property="PhiResolution" resolution="1"
range="3 1024" display_entry="1" display_value="0"
entry_and_label_on_top="0"
help="Set the number of points in the latitude direction (ranging from Start Phi to End Phi)" />
<Scale label="Start Phi" trace_name="Start Phi" variable="StartPhi"
default_value="0.0" resolution="0.01" range="0 180"
<Scale label="Start Phi" trace_name="Start Phi" property="StartPhi"
resolution="0.01" range="0 180"
display_entry="1" display_value="0" entry_and_label_on_top="0"
help="Set the starting angle in the latitude direction" />
<Scale label="End Phi" trace_name="End Phi" variable="EndPhi"
default_value="180.0" resolution="0.01" range="0 180"
<Scale label="End Phi" trace_name="End Phi" property="EndPhi"
resolution="0.01" range="0 180"
display_entry="1" display_value="0" entry_and_label_on_top="0"
help="Set the ending angle in the latitude direction" />
<Documentation>
......@@ -424,27 +419,25 @@ The output of the Sphere source is polygonal data with point normals defined.
length="3"
help="Set the scale of the superquadric" />
<Scale label="Theta resolution" trace_name="ThetaResolution"
variable="ThetaResolution" default_value="16" resolution="1"
property="ThetaResolution" resolution="1"
range="8 1024" display_entry="1" display_value="0"
entry_and_label_on_top="0"
help="The number of points in the longitude direction."/>
<Scale label="Phi resolution" variable="PhiResolution"
trace_name="PhiResolution" default_value="16" resolution="1"
<Scale label="Phi resolution" property="PhiResolution"
trace_name="PhiResolution" resolution="1"
range="4 1024" display_entry="1" display_value="0"
entry_and_label_on_top="0"
help="The number of points in the latitude direction." />
<Scale variable="Thickness" trace_name="Thickness" type="float"
resolution="0.001" range="0.0001 1" default_value="0.3333"
<Scale label="Thickness" trace_name="Thickness" property="Thickness"
resolution="0.001" range="0.0001 1"
display_entry="1" display_value="0" entry_and_label_on_top="0"
help="Changing thickness maintains the outside diameter of the toroid."/>
<Scale label="Theta roundness" trace_name="ThetaRoundness"
variable="ThetaRoundness" type="float"
resolution="0.01" range="0.01 10" default_value="1"
property="ThetaRoundness" resolution="0.01" range="0.01 10"
display_entry="1" display_value="0" entry_and_label_on_top="0"
help="Values range from 0 (rectangular) to 1 (circular) to higher order." />
<Scale label="Phi roundness" trace_name="PhiRoundness"
variable="PhiRoundness" type="float"
resolution="0.01" range="0.01 10" default_value="1"
property="PhiRoundness" resolution="0.01" range="0.01 10"
display_entry="1" display_value="0" entry_and_label_on_top="0"
help="Values range from 0 (rectangular) to 1 (circular) to higher order."/>
<VectorEntry label="Size" property="Size" trace_name="Size"
......
......@@ -24,16 +24,19 @@
#include "vtkPVAnimationInterfaceEntry.h"
#include "vtkPVApplication.h"
#include "vtkPVProcessModule.h"
#include "vtkPVScalarListWidgetProperty.h"
#include "vtkPVSource.h"
#include "vtkPVXMLElement.h"
#include "vtkClientServerStream.h"
#include "vtkSMDoubleRangeDomain.h"
#include "vtkSMDoubleVectorProperty.h"
#include "vtkSMIntRangeDomain.h"
#include "vtkSMIntVectorProperty.h"
#include <vtkstd/string>
//----------------------------------------------------------------------------
vtkStandardNewMacro(vtkPVScale);
vtkCxxRevisionMacro(vtkPVScale, "1.41");
vtkCxxRevisionMacro(vtkPVScale, "1.42");
//----------------------------------------------------------------------------
vtkPVScale::vtkPVScale()
......@@ -41,12 +44,9 @@ vtkPVScale::vtkPVScale()
this->EntryLabel = 0;
this->LabelWidget = vtkKWLabel::New();
this->Scale = vtkKWScale::New();
this->Round = 0;
this->RangeSourceVariable = 0;
this->Property = 0;
this->DefaultValue = 0.0;
this->AcceptedValueInitialized = 0;
this->EntryFlag = 0;
this->Round = 0;
this->EntryAndLabelOnTopFlag = 1;
this->DisplayValueFlag = 1;
this->TraceSliderMovement = 0;
......@@ -60,16 +60,17 @@ vtkPVScale::~vtkPVScale()
this->Scale = NULL;
this->LabelWidget->Delete();
this->LabelWidget = NULL;
this->SetProperty(NULL);
this->SetRangeSourceVariable(0);
}
//----------------------------------------------------------------------------
void vtkPVScale::SetLabel(const char* label)
{
this->SetEntryLabel(label);
this->LabelWidget->SetLabel(label);
}
//----------------------------------------------------------------------------
void vtkPVScale::SetBalloonHelpString(const char *str)
{
......@@ -217,14 +218,16 @@ void vtkPVScale::Create(vtkKWApplication *pvApp)
this->Scale->GetWidgetName());
}
//----------------------------------------------------------------------------
void vtkPVScale::SetValue(float val)
{
float newVal;
float oldVal;
if(this->Round)
vtkSMIntVectorProperty *ivp = vtkSMIntVectorProperty::SafeDownCast(
this->GetSMProperty());
if(ivp || this->Round)
{
newVal = this->RoundValue(val);
}
......@@ -233,12 +236,6 @@ void vtkPVScale::SetValue(float val)
newVal = val;
}
if (this->Property && !this->AcceptedValueInitialized)
{
this->Property->SetScalars(1, &newVal);
this->AcceptedValueInitialized = 1;
}
oldVal = this->Scale->GetValue();
if (newVal == oldVal)
{
......@@ -251,62 +248,78 @@ void vtkPVScale::SetValue(float val)
this->ModifiedCallback();
}
//-----------------------------------------------------------------------------
void vtkPVScale::SaveInBatchScript(ofstream *file)
{
float scalar, scaleValue = this->GetValue();
if(this->Round)
vtkClientServerID sourceID = this->PVSource->GetVTKSourceID(0);
if (sourceID.ID == 0 || !this->SMPropertyName)
{
scalar = this->RoundValue(scaleValue);
vtkErrorMacro("Sanity check failed. " << this->GetClassName());
return;
}
else
vtkSMDoubleVectorProperty *dvp = vtkSMDoubleVectorProperty::SafeDownCast(
this->GetSMProperty());
vtkSMIntVectorProperty *ivp = vtkSMIntVectorProperty::SafeDownCast(
this->GetSMProperty());
*file << " [$pvTemp" << sourceID << " GetProperty "
<< this->SMPropertyName << "] SetElement 0 ";
if (ivp || this->Round)
{
scalar = scaleValue;
*file << this->RoundValue(this->GetValue()) << endl;
}
else if (dvp)
{
*file << this->GetValue() << endl;
}
*file << " if { [[$pvTemp" << this->PVSource->GetVTKSourceID(0)
<< " GetProperty " << this->VariableName
<< "] GetClassName] == \"vtkSMIntVectorProperty\"} {" << endl;
*file << " set value [expr round(" << scalar << ")]" << endl;
*file << " } else {" << endl;
*file << " set value " << scalar << endl;
*file << " }" << endl;
*file << " [$pvTemp" << this->PVSource->GetVTKSourceID(0)
<< " GetProperty " << this->VariableName << "] SetElements1 $value"
<< endl;
}
//----------------------------------------------------------------------------
void vtkPVScale::AcceptInternal(vtkClientServerID sourceID)
void vtkPVScale::Accept()
{
if (sourceID.ID && this->VariableName)
{
float scalar, scaleValue = this->GetValue();
if (this->EntryFlag)
{
float entryValue;
entryValue = this->Scale->GetEntry()->GetValueAsFloat();
if (entryValue != scaleValue)
{
scaleValue = entryValue;
this->Scale->SetValue(entryValue);
}
}
if(this->Round)
int modFlag = this->GetModifiedFlag();
vtkSMDoubleVectorProperty *dvp = vtkSMDoubleVectorProperty::SafeDownCast(
this->GetSMProperty());
vtkSMIntVectorProperty *ivp = vtkSMIntVectorProperty::SafeDownCast(
this->GetSMProperty());
if (this->EntryFlag)
{
float entryValue;
entryValue = this->Scale->GetEntry()->GetValueAsFloat();
if (entryValue != this->GetValue())
{
scalar = this->RoundValue(scaleValue);
this->Scale->SetValue(entryValue);
}
else
}
if (dvp)
{
dvp->SetElement(0, this->GetValue());
}
else if (ivp)
{
ivp->SetElement(0, this->RoundValue(this->GetValue()));
}
this->ModifiedFlag = 0;
// I put this after the accept internal, because
// vtkPVGroupWidget inactivates and builds an input list ...
// Putting this here simplifies subclasses AcceptInternal methods.
if (modFlag)
{
vtkPVApplication *pvApp = this->GetPVApplication();
ofstream* file = pvApp->GetTraceFile();
if (file)
{
scalar = scaleValue;
this->Trace(file);
}
this->UpdateVTKSourceInternal(sourceID, scalar);
}
this->ModifiedFlag = 0;
this->AcceptCalled = 1;
}
//---------------------------------------------------------------------------
......@@ -330,14 +343,14 @@ void vtkPVScale::Trace(ofstream *file)
<< this->Scale->GetValue() << endl;
}
//----------------------------------------------------------------------------
void vtkPVScale::ResetInternal()
{
if (this->Property)
{
this->SetValue(this->Property->GetScalar(0));
}
vtkSMDoubleVectorProperty *dvp = vtkSMDoubleVectorProperty::SafeDownCast(
this->GetSMProperty());
vtkSMIntVectorProperty *ivp = vtkSMIntVectorProperty::SafeDownCast(
this->GetSMProperty());
if ( this->ObjectID.ID != 0 && this->RangeSourceVariable )
{
vtkPVProcessModule* pm = this->GetPVApplication()->GetProcessModule();
......@@ -346,10 +359,18 @@ void vtkPVScale::ResetInternal()
pm->GetStream() << vtkClientServerStream::Invoke << this->ObjectID
<< str.str() << vtkClientServerStream::End;
pm->SendStream(vtkProcessModule::DATA_SERVER_ROOT);
int range[2] = { 0, 0 };
double range[2] = { 0, 0 };
pm->GetLastServerResult().GetArgument(0,0, range, 2);
this->Script("eval %s SetRange %i %i", this->Scale->GetTclName(),
range[0], range[1]);
this->Scale->SetRange(range);
}
if (dvp)
{
this->SetValue(dvp->GetElement(0));
}
else if (ivp)
{
this->SetValue(ivp->GetElement(0));
}
if (this->AcceptCalled)
......@@ -377,11 +398,11 @@ void vtkPVScale::CopyProperties(vtkPVWidget* clone, vtkPVSource* pvSource,
float min, max;
this->Scale->GetRange(min, max);
pvs->SetRange(min, max);
pvs->SetDefaultValue(this->GetDefaultValue());
pvs->SetResolution(this->Scale->GetResolution());
pvs->SetLabel(this->EntryLabel);
pvs->SetRangeSourceVariable(this->RangeSourceVariable);
pvs->SetEntryFlag(this->EntryFlag);
pvs->SetRound(this->Round);
pvs->SetEntryAndLabelOnTopFlag(this->EntryAndLabelOnTopFlag);
pvs->SetDisplayValueFlag(this->DisplayValueFlag);
pvs->SetTraceSliderMovement(this->GetTraceSliderMovement());
......@@ -433,28 +454,6 @@ int vtkPVScale::ReadXMLAttributes(vtkPVXMLElement* element,
}
this->SetRange(range[0], range[1]);
// Setup the default value.
float default_value;
if(!element->GetScalarAttribute("default_value",&default_value))
{
this->SetDefaultValue(range[0]);
}
else
{
if (default_value < range[0] )
{
this->SetDefaultValue(range[0]);
}
else if (default_value > range[1])
{
this->SetDefaultValue(range[1]);
}
else
{
this->SetDefaultValue(default_value);
}
}
const char* range_source = element->GetAttribute("range_source");
if(range_source)
{
......@@ -493,8 +492,8 @@ int vtkPVScale::ReadXMLAttributes(vtkPVXMLElement* element,
void vtkPVScale::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
os << indent << "Round: " << this->Round << endl;
os << indent << "EntryFlag: " << this->EntryFlag << endl;
os << indent << "Round: " << this->Round << endl;
os << indent << "EntryAndLabelOnTopFlag: " << this->EntryAndLabelOnTopFlag
<< endl;
os << indent << "DisplayValueFlag: " << this->DisplayValueFlag << endl;
......@@ -511,31 +510,55 @@ void vtkPVScale::AddAnimationScriptsToMenu(vtkKWMenu *menu,