Commit d3578095 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

Added new domain (vtkSMChartUseIndexForAxisDomain).

This new domain is used to set UseIndexForXAxis property's default value
correctly. This removes the hacks to setup default value for the
property in vtkSMChartRepresentationProxy.

Change-Id: I02c3c7aea32a5021e0f22dcee979fc10eb17e00b
parent 6385cfe3
......@@ -38,6 +38,7 @@ set (Module_SRCS
vtkSMChartRepresentationProxy.cxx
vtkSMChartSeriesListDomain.cxx
vtkSMChartSeriesSelectionDomain.cxx
vtkSMChartUseIndexForAxisDomain.cxx
vtkSMComparativeAnimationCueProxy.cxx
vtkSMComparativeAnimationCueUndoElement.cxx
vtkSMComparativeViewProxy.cxx
......@@ -46,8 +47,8 @@ set (Module_SRCS
vtkSMImplicitPlaneRepresentationProxy.cxx
vtkSMMultiSliceViewProxy.cxx
vtkSMNewWidgetRepresentationProxy.cxx
vtkSMPVRepresentationProxy.cxx
vtkSMPlotMatrixViewProxy.cxx
vtkSMPVRepresentationProxy.cxx
vtkSMRenderViewProxy.cxx
vtkSMRepresentationProxy.cxx
vtkSMRepresentationTypeDomain.cxx
......
......@@ -28,7 +28,6 @@ vtkStandardNewMacro(vtkSMChartRepresentationProxy);
vtkSMChartRepresentationProxy::vtkSMChartRepresentationProxy()
{
this->SetSIClassName("vtkSIChartRepresentationProxy");
this->SetDefaults = true;
}
//----------------------------------------------------------------------------
......@@ -78,12 +77,6 @@ int vtkSMChartRepresentationProxy::ReadXMLAttributes(
}
}
}
const char* setDefaults = element->GetAttribute("set_defaults");
if (setDefaults)
{
this->SetDefaults = strcmp(setDefaults, "false") == 0 ? false : true;
}
return 1;
}
......@@ -124,35 +117,3 @@ void vtkSMChartRepresentationProxy::SetPropertyModifiedFlag(
}
this->Superclass::SetPropertyModifiedFlag(name, flag);
}
//----------------------------------------------------------------------------
void vtkSMChartRepresentationProxy::ResetPropertiesToDefault()
{
this->Superclass::ResetPropertiesToDefault();
if (this->SetDefaults)
{
vtkSMProperty* useIndex = this->GetProperty("UseIndexForXAxis");
vtkSMProperty* xarrayName = this->GetProperty("XArrayName");
if (useIndex && xarrayName)
{
vtkSMPropertyHelper helper(xarrayName);
const char* value = helper.GetAsString();
const char** known_names =
vtkSMChartSeriesListDomain::GetKnownSeriesNames();
for (int cc=0; known_names[cc] != NULL && value != NULL; cc++)
{
if (strcmp(known_names[cc], value) == 0)
{
vtkSMPropertyHelper(useIndex).Set(0);
this->UpdateProperty("UseIndexForXAxis");
return;
}
}
}
vtkSMPropertyHelper(useIndex).Set(1);
this->UpdateProperty("UseIndexForXAxis");
}
}
......@@ -39,18 +39,6 @@ public:
// Overridden to handle links with subproxy properties.
int ReadXMLAttributes(vtkSMSessionProxyManager* pm, vtkPVXMLElement* element);
// Description:
// Overridden to handle the default value for "UseIndexForXAxis" property, if
// any. UseIndexForXAxis needs to be OFF by default, if the required property
// i.e. XArrayName property has one of the known types of arrays, otherwise it
// must be ON. Done if SetDefaults is TRUE.
virtual void ResetPropertiesToDefault();
// Description:
// Set/get if the UseIndexForXAxis should be set by ResetPropertiesToDefault.
vtkSetMacro(SetDefaults, bool);
vtkGetMacro(SetDefaults, bool);
//BTX
protected:
vtkSMChartRepresentationProxy();
......@@ -62,8 +50,6 @@ protected:
// of the link to the extract-selection representation).
virtual void SetPropertyModifiedFlag(const char* name, int flag);
bool SetDefaults;
private:
vtkSMChartRepresentationProxy(const vtkSMChartRepresentationProxy&); // Not implemented
void operator=(const vtkSMChartRepresentationProxy&); // Not implemented
......
/*=========================================================================
Program: ParaView
Module: vtkSMChartUseIndexForAxisDomain.cxx
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkSMChartUseIndexForAxisDomain.h"
#include "vtkObjectFactory.h"
#include "vtkSMChartSeriesListDomain.h"
#include "vtkSMPropertyHelper.h"
vtkStandardNewMacro(vtkSMChartUseIndexForAxisDomain);
//----------------------------------------------------------------------------
vtkSMChartUseIndexForAxisDomain::vtkSMChartUseIndexForAxisDomain()
{
}
//----------------------------------------------------------------------------
vtkSMChartUseIndexForAxisDomain::~vtkSMChartUseIndexForAxisDomain()
{
}
//----------------------------------------------------------------------------
void vtkSMChartUseIndexForAxisDomain::Update(vtkSMProperty* requestingProperty)
{
this->Superclass::Update(requestingProperty);
vtkSMProperty* arrayName = this->GetRequiredProperty("ArraySelection");
if (requestingProperty == arrayName)
{
this->DomainModified();
}
}
//----------------------------------------------------------------------------
int vtkSMChartUseIndexForAxisDomain::SetDefaultValues(vtkSMProperty* property)
{
vtkSMProperty* arrayName = this->GetRequiredProperty("ArraySelection");
if (arrayName)
{
vtkSMPropertyHelper helper(arrayName);
const char* value = helper.GetAsString();
const char** known_names =
vtkSMChartSeriesListDomain::GetKnownSeriesNames();
for (int cc=0; known_names[cc] != NULL && value != NULL; cc++)
{
if (strcmp(known_names[cc], value) == 0)
{
vtkSMPropertyHelper(property).Set(0);
return 1;
}
}
vtkSMPropertyHelper(property).Set(1);
return 1;
}
return this->Superclass::SetDefaultValues(property);
}
//----------------------------------------------------------------------------
void vtkSMChartUseIndexForAxisDomain::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
/*=========================================================================
Program: ParaView
Module: vtkSMChartUseIndexForAxisDomain.h
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkSMChartUseIndexForAxisDomain - extends vtkSMBooleanDomain to pick a
// good default for properties such as "UseIndexForXAxis" on chart
// representations.
// .SECTION Description
// vtkSMChartUseIndexForAxisDomain extends vtkSMBooleanDomain to add logic to
// pick an appropriate default e.g. UseIndexForXAxis for bar and line charts
// needs to be set to 0 by default, if the XArrayName is one of the known arrays
// such as "bin_extents", "arc_length", and set to 1 otherwise. This class
// encapsulates that logic.
//
// Supported Required-Property functions:
// \li ArraySelection : (required) refers to the property that dictates the
// array selection.
#ifndef __vtkSMChartUseIndexForAxisDomain_h
#define __vtkSMChartUseIndexForAxisDomain_h
#include "vtkSMBooleanDomain.h"
#include "vtkPVServerManagerRenderingModule.h" // needed for exports
class VTKPVSERVERMANAGERRENDERING_EXPORT vtkSMChartUseIndexForAxisDomain : public vtkSMBooleanDomain
{
public:
static vtkSMChartUseIndexForAxisDomain* New();
vtkTypeMacro(vtkSMChartUseIndexForAxisDomain, vtkSMBooleanDomain);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Set the default values for the property.
// Overridden to handle the default value for "UseIndexForXAxis" property, if
// any. UseIndexForXAxis needs to be OFF by default, if the required property
// e.g. XArrayName property has one of the known types of arrays, otherwise it
// must be ON.
virtual int SetDefaultValues(vtkSMProperty*);
// Description:
// Overridden to fire DomainModified when the required property changes. This ensures
// that SetDefaultValues() is called during proxy post-initialization after the required
// property has been reset to default.
virtual void Update(vtkSMProperty* requestingProperty);
//BTX
protected:
vtkSMChartUseIndexForAxisDomain();
~vtkSMChartUseIndexForAxisDomain();
private:
vtkSMChartUseIndexForAxisDomain(const vtkSMChartUseIndexForAxisDomain&); // Not implemented
void operator=(const vtkSMChartUseIndexForAxisDomain&); // Not implemented
//ETX
};
#endif
......@@ -4990,7 +4990,11 @@
default_values="1"
name="UseIndexForXAxis"
number_of_elements="1">
<BooleanDomain name="bool" />
<ChartUseIndexForAxisDomain name="bool">
<RequiredProperties>
<Property function="ArraySelection" name="XArrayName" />
</RequiredProperties>
</ChartUseIndexForAxisDomain>
<Documentation>When set, the array index will be used for X axis,
otherwise the array identified by XArrayName will be
used.</Documentation>
......@@ -5798,8 +5802,7 @@
<!-- =================================================================== -->
<ChartRepresentationProxy class="vtkPVBagChartRepresentation"
name="XYBagChartRepresentation"
processes="client|dataserver|renderserver"
set_defaults="false">
processes="client|dataserver|renderserver" >
<Documentation>Representation used by XYBagChartView.</Documentation>
<InputProperty command="SetInputConnection"
......@@ -5872,11 +5875,14 @@
</RequiredProperties>
</FieldDataDomain>
</IntVectorProperty>
<IntVectorProperty command="SetUseIndexForXAxis"
default_values="0"
name="UseIndexForXAxis"
number_of_elements="1">
<!-- We deliberately don't use ChartUseIndexForAxisDomain domain here
since we don't want the property's default to be updated at runtime
using the value for XArrayName.
-->
<BooleanDomain name="bool" />
<Documentation>When set, the array index will be used for X axis,
otherwise the array identified by XAxisSeriesName will be
......@@ -6090,7 +6096,11 @@
default_values="1"
name="UseIndexForXAxis"
number_of_elements="1">
<BooleanDomain name="bool" />
<ChartUseIndexForAxisDomain name="bool">
<RequiredProperties>
<Property function="ArraySelection" name="XArrayName" />
</RequiredProperties>
</ChartUseIndexForAxisDomain>
<Documentation>When set, the array index will be used for X axis,
otherwise the array identified by XArrayName will be
used.</Documentation>
......
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