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

using SM properties with vtkPVThumbWheel

parent 595acc85
......@@ -151,11 +151,10 @@ The Cell Data to Point Data filter averages the values of the cell attributes of
display_entry="1"
entry_and_label_on_top="0" display_value="0"/>
<ThumbWheel label="Absolute tolerance"
variable="AbsoluteTolerance"
property="AbsoluteTolerance"
trace_name="AbsoluteTolerance"
resolution="0.01"
minimum_value="0"
default_value="1.0"
help="The tolerance in absolute terms."/>
<LabeledToggle label="Tolerance is absolute"
trace_name="ToleranceIsAbsolute"
......@@ -775,23 +774,21 @@ The Loop Subdivision filter increases the granularity of a polygonal mesh. It wo
input_name="Input"/>
<ThumbWheel label="On ratio"
trace_name="OnRatio"
variable="OnRatio"
property="OnRatio"
resolution="1"
default_value="2"
minimum_value="1"
help="The ratio of points retained."/>
<ThumbWheel label="Max. points"
trace_name="MaximumNumberOfPoints"
variable="MaximumNumberOfPoints"
property="MaximumNumberOfPoints"
help="Limit the number of points."
resolution="1"
minimum_value="0"
default_value="5000"/>
<ThumbWheel variable="Offset"
minimum_value="0"/>
<ThumbWheel label="Offset"
trace_name="Offset"
proeprty="Offset"
resolution="1"
minimum_value="0"
default_value="0"
help="Start with this point."/>
<LabeledToggle label="Random" trace_name="Random"
property="RandomMode"
......@@ -1088,17 +1085,15 @@ The Copy cell data toggle controls whether cell-centered data from the input sho
input_name="Input"/>
<ThumbWheel label="Min. speed"
trace_name="MinimumSpeed"
variable="MinimumSpeed"
property="MinimumSpeed"
resolution="0.01"
minimum_value="0"
default_value="0"
help="The minimum size of the random point vectors generated."/>
<ThumbWheel label="Max. speed"
trace_name="MaximumSpeed"
variable="MaximumSpeed"
property="MaximumSpeed"
resolution="0.01"
minimum_value="0"
default_value="1"
help="The maximum size of the random point vectors generated."/>
<Documentation>
The Random Vectors filter generates a point-centered array of random vectors. It uses a random number generator to determine the components of the vectors. The Min. speed and Max. speed values determine the range of the vector magnitudes. This filter operates on any type of data set, and the output data set will be of the same type as the input.
......@@ -1237,11 +1232,11 @@ The Width entry box specifies half the width of the ribbons. If Vary width is on
label="Input"
help="Set the input to this filter."
input_name="Input"/>
<ThumbWheel variable="Resolution"
<ThumbWheel label="Resolution"
trace_name="Resolution"
property="Resolution"
resolution="1"
minimum_value="1"
default_value="12"/>
minimum_value="1"/>
<LabeledToggle label="Capping"
trace_name="Capping"
property="Capping"/>
......@@ -1332,10 +1327,9 @@ The Shrink filter causes the individual cells of a data set to break apart from
input_name="Input"/>
<ThumbWheel label="Num. iterations"
trace_name="NumberOfIterations"
variable="NumberOfIterations"
property="NumberOfIterations"
resolution="1"
minimum_value="0"
default_value="20"
help="Number of iterations. More iterations produce better smoothing."/>
<Scale variable="Convergence"
trace_name="Convergence"
......@@ -1523,11 +1517,10 @@ The Transform filter allows you to specify the position, size, and orientation o
help="Set the input to this filter."
input_name="Input"/>
<ThumbWheel label="Num. sides"
variable="NumberOfSides"
property="NumberOfSides"
trace_name="NumberOfSides"
resolution="1"
minimum_value="3"
default_value="6"
help="Set the number of sides for the tube"/>
<LabeledToggle label="Capping"
trace_name="Capping"
......@@ -1936,10 +1929,9 @@ The Contour filter operates on any type of data set, but the input is required t
default_scale_mode ="1"/>
<ThumbWheel label="Max. Number of Glyphs"
trace_name="Max Glyphs"
variable="MaximumNumberOfPoints"
property="MaximumNumberOfPoints"
resolution="1"
minimum_value="0"
default_value="5000"
help="Set the maximum number of points to glyph"/>
<LabeledToggle label="Mask Points"
trace_name="MaskPoints"
......@@ -2251,29 +2243,26 @@ This filter operates on any type of data set, provided it has point-centered vec
<ContainerWidget pack_direction="left" trace_name="SampleRate">
<Item>
<ThumbWheel label="Sample Rate"
variable="SampleRateI"
property="SampleRateI"
trace_name="SampleRateI"
resolution="1"
minimum_value="1"
default_value="1"
help="Set the sampling rate for each dimension."/>
</Item>
<Item>
<ThumbWheel label=""
variable="SampleRateJ"
property="SampleRateJ"
trace_name="SampleRateJ"
resolution="1"
minimum_value="1"
default_value="1"
help="Set the sampling rate for each dimension."/>
</Item>
<Item>
<ThumbWheel label=""
variable="SampleRateK"
property="SampleRateK"
trace_name="SampleRateK"
resolution="1"
minimum_value="1"
default_value="1"
help="Set the sampling rate for each dimension."/>
</Item>
</ContainerWidget>
......
......@@ -156,14 +156,14 @@ The output of the Axes source is polygonal data. This polygonal data has a scala
long_help="3D box with specified X, Y, and Z lengths."
short_help="Create a box with specified X, Y, and Z lengths.">
<Source class="vtkCubeSource"/>
<ThumbWheel label="X length" trace_name="XLength" variable="XLength"
resolution="0.01" minimum_value="0" default_value="1"
<ThumbWheel label="X length" trace_name="XLength" property="XLength"
resolution="0.01" minimum_value="0"
help="The length of the cube in the x direction." />
<ThumbWheel label="Y length" trace_name="YLength" variable="YLength"
resolution="0.01" minimum_value="0" default_value="1"
<ThumbWheel label="Y length" trace_name="YLength" property="YLength"
resolution="0.01" minimum_value="0"
help="The length of the cube in the y direction." />
<ThumbWheel label="Z length" trace_name="ZLength" variable="ZLength"
resolution="0.01" minimum_value="0" default_value="1"
<ThumbWheel label="Z length" trace_name="ZLength" property="ZLength"
resolution="0.01" minimum_value="0"
help="The length of the cube in the z direction." />
<VectorEntry label="Center" property="Center" trace_name="Center" length="3"
type="float"
......@@ -187,11 +187,11 @@ The output of the Box source is polygonal data containing both normals and textu
default_value="6" 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 variable="Radius" trace_name="Radius"
resolution="0.01" minimum_value="0" default_value="0.5"
<ThumbWheel label="Radius" trace_name="Radius" property="Radius"
resolution="0.01" minimum_value="0"
help="Set the radius of the widget part of the cone" />
<ThumbWheel variable="Height" trace_name="Height"
resolution="0.01" minimum_value="0" default_value="1"
<ThumbWheel label="Height" trace_name="Height" property="Height"
resolution="0.01" minimum_value="0"
help="Set the height of the cone" />
<LabeledToggle label="Capping" trace_name="Capping" property="Capping"
help="Set whether to draw the base of the cone" />
......@@ -214,11 +214,11 @@ The output of the Cone source is polygonal data.
default_value="6" 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 variable="Height" trace_name="Height"
resolution="0.01" minimum_value="0" default_value="1"
<ThumbWheel label="Height" trace_name="Height" property="Height"
resolution="0.01" minimum_value="0"
help="The height of the cylinder (along the y axis)." />
<ThumbWheel variable="Radius" trace_name="Radius"
resolution="0.01" minimum_value="0" default_value="0.5"
<ThumbWheel label="Radius" trace_name="Radius" property="Radius"
resolution="0.01" minimum_value="0"
help="The radius of the cylinder." />
<VectorEntry label="Center" property="Center" trace_name="Center"
type="float" length="3"
......@@ -246,8 +246,8 @@ The output of the Cylinder source is polygonal data containing both normals and
point1_label="Point 1" point2_label="Point 2"
show_resolution="0"
help="Set the start and end point for the line"/>
<ThumbWheel variable="Resolution" trace_name="Resolution"
resolution="1" minimum_value="1" default_value="1"
<ThumbWheel label="Resolution" trace_name="Resolution" property="Resolution"
resolution="1" minimum_value="1"
help="The number of pieces to divide the line into." />
<Documentation>
The Line source can be used to interactively (using a 3D widget) or manually (using the entries on the user interface) add a line to the 3D scene. The Line source has the following parameters.
......@@ -296,14 +296,14 @@ The output of the Mandelbrot source is image (uniform rectilinear) data.
long_help="2D Maze of lines."
short_help="Random maze">
<Source class="vtkMazeSource"/>
<ThumbWheel label="X Size" variable="XSize" trace_name="XSize"
resolution="1" minimum_value="1" default_value="20"
<ThumbWheel label="X Size" property="XSize" trace_name="XSize"
resolution="1" minimum_value="1"
help="Width of the maze." />
<ThumbWheel label="Y Size" variable="YSize" trace_name="YSize"
resolution="1" minimum_value="1" default_value="20"
<ThumbWheel label="Y Size" property="YSize" trace_name="YSize"
resolution="1" minimum_value="1"
help="Height of the maze." />
<ThumbWheel label="Run Factor" variable="RunFactor" trace_name="RunLength"
resolution="1" minimum_value="1" default_value="20"
<ThumbWheel label="Run Factor" property="RunFactor" trace_name="RunLength"
resolution="1" minimum_value="1"
help="A value that influences the run length and branching of the maze." />
<VectorEntry label="Magnet Factor" property="MagnetFactor"
trace_name="MagnetFactor"
......@@ -342,12 +342,12 @@ The output of the Maze source is polygonal data.
type="float" length="3"
help="Set the position of the point defining the second axis."/>
<ThumbWheel label="X resolution" trace_name="XResolution"
variable="XResolution"
resolution="1" minimum_value="1" default_value="1"
property="XResolution"
resolution="1" minimum_value="1"
help="The number os x pieces to divide the plane into."/>
<ThumbWheel label="Y resolution" trace_name="YResolution"
variable="YResolution"
resolution="1" minimum_value="1" default_value="1"
property="YResolution"
resolution="1" minimum_value="1"
help="The number of y pieces to divide the plane into."/>
<Documentation>
The Plane source can be used to add a polygonal parallelogram to the 3D scene. Unlike the sphere, cone, and cylinder sources, the parallelogram is exactly represented at the lowest resolution, but higher resolutions may be desired if this plane is to be used as an input to a filter. The Plane source has the following parameters.
......@@ -368,8 +368,8 @@ The output of the Plane source is polygonal data.
<VectorEntry label="Center" property="Center" trace_name="Center"
type="float" length="3"
help="Set the coordinates for the center of the sphere." />
<ThumbWheel variable="Radius" trace_name="Radius"
resolution="0.01" minimum_value="0" default_value="0.5"
<ThumbWheel label="Radius" trace_name="Radius" property="Radius"
resolution="0.01" minimum_value="0"
help="Set the radius of the sphere" />
<Scale label="Theta Resolution" trace_name="Theta Resolution"
variable="ThetaResolution"
......
......@@ -22,14 +22,17 @@
#include "vtkObjectFactory.h"
#include "vtkPVAnimationInterfaceEntry.h"
#include "vtkPVApplication.h"
#include "vtkPVScalarListWidgetProperty.h"
#include "vtkPVSource.h"
#include "vtkPVXMLElement.h"
#include "vtkPVXMLPackageParser.h"
#include "vtkSMDoubleRangeDomain.h"
#include "vtkSMDoubleVectorProperty.h"
#include "vtkSMIntRangeDomain.h"
#include "vtkSMIntVectorProperty.h"
//-----------------------------------------------------------------------------
vtkStandardNewMacro(vtkPVThumbWheel);
vtkCxxRevisionMacro(vtkPVThumbWheel, "1.5");
vtkCxxRevisionMacro(vtkPVThumbWheel, "1.6");
//-----------------------------------------------------------------------------
vtkPVThumbWheel::vtkPVThumbWheel()
......@@ -38,9 +41,6 @@ vtkPVThumbWheel::vtkPVThumbWheel()
this->Label->SetParent(this);
this->ThumbWheel = vtkKWThumbWheel::New();
this->ThumbWheel->SetParent(this);
this->Property = NULL;
this->AcceptedValueInitialized = 0;
this->DefaultValue = 0.0;
}
//-----------------------------------------------------------------------------
......@@ -48,7 +48,6 @@ vtkPVThumbWheel::~vtkPVThumbWheel()
{
this->Label->Delete();
this->ThumbWheel->Delete();
this->SetProperty(NULL);
}
//-----------------------------------------------------------------------------
......@@ -94,20 +93,11 @@ void vtkPVThumbWheel::Create(vtkKWApplication *pvApp)
void vtkPVThumbWheel::SetValue(float val)
{
float oldVal = static_cast<float>(this->ThumbWheel->GetValue());
if (oldVal == val)
{
return;
}
if (this->Property && !this->AcceptedValueInitialized)
this->ThumbWheel->SetValue(val);
if (oldVal != val)
{
this->Property->SetScalars(1, &val);
this->AcceptedValueInitialized = 1;
this->ModifiedCallback();
}
this->ThumbWheel->SetValue(val);
this->ModifiedCallback();
}
//-----------------------------------------------------------------------------
......@@ -186,11 +176,24 @@ vtkPVThumbWheel* vtkPVThumbWheel::ClonePrototype(
//-----------------------------------------------------------------------------
void vtkPVThumbWheel::SaveInBatchScript(ofstream *file)
{
float scalar = this->ThumbWheel->GetValue();
*file << " [$pvTemp" << this->PVSource->GetVTKSourceID(0)
<< " GetProperty " << this->VariableName << "] SetElements1 "
<< scalar << endl;
vtkClientServerID sourceID = this->PVSource->GetVTKSourceID(0);
if (sourceID.ID == 0 || !this->SMPropertyName)
{
vtkErrorMacro("Sanity check failed. " << this->GetClassName());
return;
}
*file << " if { [[$pvTemp" << sourceID << " GetProperty "
<< this->SMPropertyName
<< "] GetClassName] == \"vtkSMIntVectorProperty\"} {" << endl;
*file << " set value [expr round(" << this->GetValue() << ")]" << endl;
*file << " } else {" << endl;
*file << " set value " << this->GetValue() << endl;
*file << " }" << endl;
*file << " [$pvTemp" << sourceID << " GetProperty "
<< this->SMPropertyName << "] SetElement 0 $value" << endl;
}
//-----------------------------------------------------------------------------
......@@ -213,19 +216,47 @@ void vtkPVThumbWheel::AnimationMenuCallback(vtkPVAnimationInterfaceEntry *ai)
}
ai->SetLabelAndScript(this->Label->GetLabel(), NULL, this->GetTraceName());
ai->SetCurrentProperty(this->Property);
ai->SetTimeStart(this->ThumbWheel->GetMinimumValue());
ai->SetTimeEnd(this->ThumbWheel->GetMinimumValue());
vtkSMProperty *prop = this->GetSMProperty();
vtkSMDomain *rangeDomain = prop->GetDomain("range");
ai->SetCurrentSMProperty(prop);
ai->SetCurrentSMDomain(rangeDomain);
if (rangeDomain)
{
vtkSMDoubleRangeDomain *drd =
vtkSMDoubleRangeDomain::SafeDownCast(rangeDomain);
vtkSMIntRangeDomain *ird =
vtkSMIntRangeDomain::SafeDownCast(rangeDomain);
int minExists = 0;
if (drd)
{
double min = drd->GetMinimum(0, minExists);
if (minExists)
{
ai->SetTimeStart(min);
ai->SetTimeEnd(min);
}
}
else if (ird)
{
int min = ird->GetMinimum(0, minExists);
if (minExists)
{
ai->SetTimeStart(min);
ai->SetTimeEnd(min);
}
}
}
ai->Update();
}
//-----------------------------------------------------------------------------
void vtkPVThumbWheel::AcceptInternal(vtkClientServerID sourceID)
void vtkPVThumbWheel::Accept()
{
if (!sourceID.ID)
{
return;
}
int modFlag = this->GetModifiedFlag();
float scalar = this->ThumbWheel->GetValue();
float entryValue = this->ThumbWheel->GetEntry()->GetValueAsFloat();
......@@ -234,18 +265,59 @@ void vtkPVThumbWheel::AcceptInternal(vtkClientServerID sourceID)
scalar = entryValue;
this->ThumbWheel->SetValue(entryValue);
}
this->Property->SetScalars(1, &scalar);
this->Property->SetVTKSourceID(sourceID);
this->Property->AcceptInternal();
vtkSMDoubleVectorProperty *dvp = vtkSMDoubleVectorProperty::SafeDownCast(
this->GetSMProperty());
vtkSMIntVectorProperty *ivp = vtkSMIntVectorProperty::SafeDownCast(
this->GetSMProperty());
if (dvp)
{
dvp->SetElement(0, this->GetValue());
}
else if (ivp)
{
ivp->SetElement(0, static_cast<int>(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)
{
this->Trace(file);
}
}
this->AcceptCalled = 1;
}
//-----------------------------------------------------------------------------
void vtkPVThumbWheel::ResetInternal()
{
if (this->Property)
vtkSMDoubleVectorProperty *dvp = vtkSMDoubleVectorProperty::SafeDownCast(
this->GetSMProperty());
vtkSMIntVectorProperty *ivp = vtkSMIntVectorProperty::SafeDownCast(
this->GetSMProperty());
if (dvp)
{
this->SetValue(dvp->GetElement(0));
}
else if (ivp)
{
this->SetValue(this->Property->GetScalar(0));
this->SetValue(ivp->GetElement(0));
}
if (this->AcceptCalled)
{
this->ModifiedFlag = 0;
}
}
......@@ -261,33 +333,6 @@ void vtkPVThumbWheel::Trace(ofstream *file)
<< this->GetValue() << endl;
}
//-----------------------------------------------------------------------------
void vtkPVThumbWheel::SetProperty(vtkPVWidgetProperty *prop)
{
this->Property = vtkPVScalarListWidgetProperty::SafeDownCast(prop);
if (this->Property)
{
this->Property->SetScalars(1, &this->DefaultValue);
char *cmd = new char[strlen(this->VariableName)+4];
sprintf(cmd, "Set%s", this->VariableName);
int numVars = 1;
this->Property->SetVTKCommands(1, &cmd, &numVars);
delete [] cmd;
}
}
//-----------------------------------------------------------------------------
vtkPVWidgetProperty* vtkPVThumbWheel::GetProperty()
{
return this->Property;
}
//-----------------------------------------------------------------------------
vtkPVWidgetProperty* vtkPVThumbWheel::CreateAppropriateProperty()
{
return vtkPVScalarListWidgetProperty::New();
}
//-----------------------------------------------------------------------------
void vtkPVThumbWheel::UpdateEnableState()
{
......@@ -306,7 +351,6 @@ void vtkPVThumbWheel::CopyProperties(vtkPVWidget *clone, vtkPVSource *source,
if (pvtw)
{
pvtw->SetMinimumValue(this->ThumbWheel->GetMinimumValue());
pvtw->SetDefaultValue(this->GetDefaultValue());
pvtw->SetResolution(this->ThumbWheel->GetResolution());
pvtw->SetLabel(this->Label->GetLabel());
}
......@@ -352,24 +396,6 @@ int vtkPVThumbWheel::ReadXMLAttributes(vtkPVXMLElement *element,
}
this->SetMinimumValue(min);
// Setup the default value.
float default_value;
if (!element->GetScalarAttribute("default_value", &default_value))
{
this->SetDefaultValue(min);
}
else
{
if (default_value < min)
{
this->SetDefaultValue(min);
}
else
{
this->SetDefaultValue(default_value);
}
}
return 1;
}
......
......@@ -22,7 +22,6 @@
class vtkKWLabel;
class vtkKWThumbWheel;
class vtkPVScalarListWidgetProperty;
class VTK_EXPORT vtkPVThumbWheel : public vtkPVObjectWidget
{
......@@ -65,7 +64,7 @@ public:
// Description:
// Move widget state to vtk object or back.
virtual void AcceptInternal(vtkClientServerID);
virtual void Accept();
virtual void ResetInternal();
//ETX
......@@ -73,15 +72,6 @@ public:
// For saving state.
virtual void Trace(ofstream *file);
// Description:
// Set/get the property to use with this widget.
virtual void SetProperty(vtkPVWidgetProperty *prop);
virtual vtkPVWidgetProperty* GetProperty();
// Description:
// Create the right property for use with this widget.
virtual vtkPVWidgetProperty* CreateAppropriateProperty();
// Description:
// Update the "enable" state of the widget and its internal parts.
// Depending on different Ivars (this->Enabled, the application's
......@@ -111,14 +101,6 @@ protected:
vtkKWLabel *Label;
vtkKWThumbWheel *ThumbWheel;
vtkPVScalarListWidgetProperty *Property;
int AcceptedValueInitialized;
float DefaultValue;
vtkSetMacro(DefaultValue, float);
vtkGetMacro(DefaultValue, float);
//BTX
virtual void CopyProperties(vtkPVWidget *clone, vtkPVSource *source,
vtkArrayMap<vtkPVWidget*, vtkPVWidget*>* map);
......
......@@ -136,6 +136,7 @@
command="SetAbsoluteTolerance"
number_of_elements="1"
default_values="1.0" >
<DoubleRangeDomain name="range" min="0"/>
</DoubleVectorProperty>
<IntVectorProperty
......@@ -1936,7 +1937,7 @@
command="SetMaximumNumberOfPoints"
number_of_elements="1"
default_values="5000" >
<IntRangeDomain name="range"/>
<IntRangeDomain name="range" min="0"/>
</IntVectorProperty>
<IntVectorProperty
......@@ -1980,17 +1981,23 @@
<IntVectorProperty
name="SampleRateI"
command="SetSampleRateI"
number_of_elements="1"/>
number_of_elements="1">
<IntRangeDomain name="range" min="1"/>
</IntVectorProperty>
<IntVectorProperty
name="SampleRateJ"
command="SetSampleRateJ"
number_of_elements="1"/>
number_of_elements="1">
<IntRangeDomain name="range" min="1"/>
</IntVectorProperty>
<IntVectorProperty
name="SampleRateK"
command="SetSampleRateK"
number_of_elements="1"/>
number_of_elements="1">
<IntRangeDomain name="range" min="1"/>
</IntVectorProperty>
<IntVectorProperty
name="IncludeBoundary"
......