Commit 560268e6 authored by Amy Squillacote's avatar Amy Squillacote
Browse files

using SM properties with vtkPVStringEntry

parent e486c92f
......@@ -329,7 +329,7 @@ The Decimate filter reduces the number of triangles in a polygonal data set. Bec
<Item name="Duplicate cells" value="1"/>
<Item name="Divide cells" value="2"/>
</SelectionList>
<StringEntry label="Global Id Array Name" variable="GlobalIdArrayName"
<StringEntry label="Global Id Array Name" property="GlobalIdArrayName"
trace_name="GlobalIdArrayName"
help="Provide name of global node ID array so redistributed data does not duplicate node IDs" />
<LabeledToggle label="Minimal memory"
......@@ -515,11 +515,10 @@ The Extract Surface filter extracts the polygons forming the outer surface of th
<InputMenu trace_name="Input" label="Input" property="Input"
help="Set the input to this filter."
input_name="Input"/>
<StringEntry variable="ResultArrayName"
<StringEntry property="ResultArrayName"
trace_name="ResultArray"
label="Result Array Name"
help="Set the name of the array to hold the results of this computation"
default_value="Result"/>
help="Set the name of the array to hold the results of this computation"/>
<CalculatorWidget trace_name="Equation"
help="Enter the equation for the new array."/>
<Documentation>
......
......@@ -330,8 +330,7 @@
<Source class="vtkImageReader"/>
<StringEntry label="File pattern"
trace_name="FilePattern"
variable="FilePattern"
default_value="%s"
property="FilePattern"
help="Set the format string for building filename. In creating the filename, %s will be replaced by the prefix and %d by a digit which represents the slice number in Z"/>
<SelectionList label="Data type"
trace_name="DataScalarType"
......@@ -387,9 +386,8 @@
help="How many componenets does each pixel have. (i.e. RGB would be 3.)"/>
<StringEntry label="Array name"
trace_name="ArrayName"
variable="ScalarArrayName"
help="Name to assign to array read"
default_value="ImageFile"/>
property="ScalarArrayName"
help="Name to assign to array read"/>
</Module>
#ifdef PARAVIEW_LINK_XDMF
<Module name="XdmfReader"
......@@ -420,12 +418,12 @@
module_type="Reader"
extensions=".g .e .ex2 .exo .gen .0 .00 .000 .0000"
file_description="Exodus">
<StringEntry variable="FilePrefix"
extension="*" label="File prefix"
<StringEntry property="FilePrefix"
label="File prefix"
init_source="FilePrefix"
trace_name="file_prefix"
help="Set the file root. Used with file pattern to format a file name." />
<StringEntry variable="FilePattern"
<StringEntry property="FilePattern"
label="File Pattern"
init_source="FilePattern"
trace_name="file_pattern"
......@@ -437,7 +435,7 @@
trace_name="file_range"
length="2"
help="Range of files that are loaded" />
<StringEntry variable="XMLFileName"
<StringEntry property="XMLFileName"
label="XML File"
init_source="XMLFileName"
trace_name="xml_file"
......
......@@ -57,9 +57,8 @@ The output of the 2D Glyph source is polygonal data.
long_help="3D geometric representation of a text string."
short_help="Create a 3D text object">
<Source class="vtkVectorText"/>
<StringEntry variable="Text" trace_name="Text"
help="Enter the text to display"
default_value="3D Text"/>
<StringEntry label="Text" trace_name="Text" property="Text"
help="Enter the text to display"/>
<Documentation>
The 3D Text source displays a text string as polygonal text. There is only one parameter for 3D Text.
Text: Specify the text string to be displayed. The ASCII alphanumeric characters a-z, A-Z, and 0-9 are supported; so are ASCII punctuation marks. The only supported control character is "\n", which inserts a new line in the text string. The default value is "3D Text".
......
......@@ -15,21 +15,21 @@
#include "vtkPVStringEntry.h"
#include "vtkArrayMap.txx"
#include "vtkClientServerStream.h"
#include "vtkKWEntry.h"
#include "vtkKWLabel.h"
#include "vtkObjectFactory.h"
#include "vtkPVApplication.h"
#include "vtkPVStringWidgetProperty.h"
#include "vtkPVXMLElement.h"
#include "vtkPVProcessModule.h"
#include "vtkPVSource.h"
#include "vtkClientServerStream.h"
#include "vtkSMStringVectorProperty.h"
#include <vtkstd/string>
//----------------------------------------------------------------------------
vtkStandardNewMacro(vtkPVStringEntry);
vtkCxxRevisionMacro(vtkPVStringEntry, "1.33");
vtkCxxRevisionMacro(vtkPVStringEntry, "1.34");
//----------------------------------------------------------------------------
vtkPVStringEntry::vtkPVStringEntry()
......@@ -39,8 +39,6 @@ vtkPVStringEntry::vtkPVStringEntry()
this->Entry = vtkKWEntry::New();
this->Entry->SetParent(this);
this->EntryLabel = 0;
this->DefaultValue = 0;
this->Property = 0;
this->InitSourceVariable = 0;
}
......@@ -53,17 +51,17 @@ vtkPVStringEntry::~vtkPVStringEntry()
this->LabelWidget->Delete();
this->LabelWidget = NULL;
this->SetEntryLabel(0);
this->SetProperty(0);
this->SetInitSourceVariable(0);;
this->SetDefaultValue(0);
}
//----------------------------------------------------------------------------
void vtkPVStringEntry::SetLabel(const char* label)
{
this->SetEntryLabel(label);
this->LabelWidget->SetLabel(label);
}
//----------------------------------------------------------------------------
void vtkPVStringEntry::SetBalloonHelpString(const char *str)
{
......@@ -136,10 +134,8 @@ void vtkPVStringEntry::Create(vtkKWApplication *pvApp)
}
this->Script("pack %s -side left -fill x -expand t",
this->Entry->GetWidgetName());
this->SetValue(this->Property->GetString());
}
//----------------------------------------------------------------------------
void vtkPVStringEntry::SetValue(const char* fileName)
{
......@@ -161,23 +157,36 @@ void vtkPVStringEntry::SetValue(const char* fileName)
this->Entry->SetValue(fileName);
if (!this->AcceptCalled && this->Property)
{
this->Property->SetString(fileName);
}
this->ModifiedCallback();
}
//----------------------------------------------------------------------------
void vtkPVStringEntry::AcceptInternal(vtkClientServerID sourceID)
void vtkPVStringEntry::Accept()
{
int modFlag = this->GetModifiedFlag();
vtkSMStringVectorProperty *svp = vtkSMStringVectorProperty::SafeDownCast(
this->GetSMProperty());
if (svp)
{
svp->SetElement(0, this->GetValue());
}
this->ModifiedFlag = 0;
this->Property->SetString(this->GetValue());
this->Property->SetVTKSourceID(sourceID);
this->Property->AcceptInternal();
// 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;
}
//---------------------------------------------------------------------------
......@@ -190,7 +199,6 @@ void vtkPVStringEntry::Trace(ofstream *file)
}
}
//----------------------------------------------------------------------------
void vtkPVStringEntry::ResetInternal()
{
......@@ -199,10 +207,10 @@ void vtkPVStringEntry::ResetInternal()
return;
}
// Command to update the UI.
this->SetValue(this->Property->GetString());
if ( this->ObjectID.ID && this->InitSourceVariable )
vtkSMStringVectorProperty *svp = vtkSMStringVectorProperty::SafeDownCast(
this->GetSMProperty());
if ( this->ObjectID.ID && this->InitSourceVariable && !this->AcceptCalled)
{
vtkstd::string method = "Get";
method += this->InitSourceVariable;
......@@ -223,6 +231,11 @@ void vtkPVStringEntry::ResetInternal()
}
}
if (svp)
{
this->SetValue(svp->GetElement(0));
}
if (this->AcceptCalled)
{
this->ModifiedFlag = 0;
......@@ -237,6 +250,7 @@ vtkPVStringEntry* vtkPVStringEntry::ClonePrototype(vtkPVSource* pvSource,
return vtkPVStringEntry::SafeDownCast(clone);
}
//----------------------------------------------------------------------------
void vtkPVStringEntry::CopyProperties(vtkPVWidget* clone,
vtkPVSource* pvSource,
vtkArrayMap<vtkPVWidget*, vtkPVWidget*>* map)
......@@ -246,7 +260,6 @@ void vtkPVStringEntry::CopyProperties(vtkPVWidget* clone,
if (pvse)
{
pvse->SetLabel(this->EntryLabel);
pvse->SetDefaultValue(this->DefaultValue);
pvse->SetInitSourceVariable(this->InitSourceVariable);
}
else
......@@ -278,10 +291,6 @@ int vtkPVStringEntry::ReadXMLAttributes(vtkPVXMLElement* element,
this->SetInitSourceVariable(init_source);
}
// Set the default value.
const char* defaultValue = element->GetAttribute("default_value");
this->SetDefaultValue(defaultValue);
return 1;
}
......@@ -291,40 +300,19 @@ const char* vtkPVStringEntry::GetValue()
return this->Entry->GetValue();
}
//-----------------------------------------------------------------------------
void vtkPVStringEntry::SaveInBatchScript(ofstream *file)
{
const char* str = this->Property->GetString();
*file << " [$pvTemp" << this->PVSource->GetVTKSourceID(0)
<< " GetProperty " << this->VariableName << "] SetElement 0 {"
<< str << "}" << endl;
}
//----------------------------------------------------------------------------
void vtkPVStringEntry::SetProperty(vtkPVWidgetProperty *prop)
{
this->Property = vtkPVStringWidgetProperty::SafeDownCast(prop);
if (this->Property)
vtkClientServerID sourceID = this->PVSource->GetVTKSourceID(0);
if (sourceID.ID == 0 || !this->SMPropertyName)
{
this->Property->SetString(this->DefaultValue);
char *cmd = new char[strlen(this->VariableName)+4];
sprintf(cmd, "Set%s", this->VariableName);
this->Property->SetVTKCommand(cmd);
delete [] cmd;
vtkErrorMacro("Sanity check failed. " << this->GetClassName());
return;
}
}
//----------------------------------------------------------------------------
vtkPVWidgetProperty* vtkPVStringEntry::GetProperty()
{
return this->Property;
}
//----------------------------------------------------------------------------
vtkPVWidgetProperty* vtkPVStringEntry::CreateAppropriateProperty()
{
return vtkPVStringWidgetProperty::New();
*file << " [$pvTemp" << sourceID << " GetProperty " << this->SMPropertyName
<< "] SetElement 0 " << this->GetValue() << endl;
}
//----------------------------------------------------------------------------
......
......@@ -23,7 +23,6 @@
class vtkKWEntry;
class vtkKWLabel;
class vtkPVStringWidgetProperty;
class VTK_EXPORT vtkPVStringEntry : public vtkPVObjectWidget
{
......@@ -63,7 +62,7 @@ public:
// Called when accept button is pushed.
// Sets objects variable to the widgets value.
// Side effect is to turn modified flag off.
virtual void AcceptInternal(vtkClientServerID);
virtual void Accept();
//ETX
// Description:
......@@ -76,15 +75,6 @@ public:
// This serves a dual purpose. For tracing and 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 object and its internal parts.
// Depending on different Ivars (this->Enabled, the application's
......@@ -112,16 +102,10 @@ protected:
vtkGetStringMacro(EntryLabel);
char* EntryLabel;
char* DefaultValue;
vtkSetStringMacro(DefaultValue);
vtkGetStringMacro(DefaultValue);
vtkSetStringMacro(InitSourceVariable);
vtkGetStringMacro(InitSourceVariable);
char* InitSourceVariable;
vtkPVStringWidgetProperty *Property;
//BTX
virtual void CopyProperties(vtkPVWidget* clone, vtkPVSource* pvSource,
vtkArrayMap<vtkPVWidget*, vtkPVWidget*>* map);
......
......@@ -530,7 +530,7 @@
name="ResultArrayName"
command="SetResultArrayName"
number_of_elements="1"
default_values="result" />
default_values="Result" />
<StringVectorProperty
name="Function"
......
......@@ -22,7 +22,7 @@
#include "vtkStdString.h"
vtkStandardNewMacro(vtkSMStringVectorProperty);
vtkCxxRevisionMacro(vtkSMStringVectorProperty, "1.11");
vtkCxxRevisionMacro(vtkSMStringVectorProperty, "1.12");
struct vtkSMStringVectorPropertyInternals
{
......@@ -248,6 +248,13 @@ int vtkSMStringVectorProperty::ReadXMLAttributes(vtkSMProxy* proxy,
}
delete[] eTypes;
int numElems = this->GetNumberOfElements();
if (numElems > 0)
{
const char *initVal = element->GetAttribute("default_values");
this->SetElement(0, initVal); // what to do with > 1 element?
}
return 1;
}
......
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