Skip to content

Commit 8019104

Browse files
author
Timothee Chabat
committed
TableFFT: add backward compatibility for new properties
Changes are : - 'AverageFft' has been renamed 'UseWelchMethod' - 'OptimizeForRealInput' has been renamed 'OneSidedSpectrum' - 'NumberOfBlock' has been removed
1 parent edfe3c6 commit 8019104

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

Remoting/ServerManager/vtkSMStateVersionController.cxx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,6 +1449,39 @@ struct Process_5_10_to_5_11
14491449
}
14501450
};
14511451

1452+
struct Process_5_11_to_5_12
1453+
{
1454+
bool operator()(xml_document& document) { return ConvertTableFFT(document); }
1455+
1456+
static bool ConvertTableFFT(xml_document& document)
1457+
{
1458+
pugi::xpath_node_set xpath_set =
1459+
document.select_nodes("//ServerManagerState/Proxy[@group='filters' and @type='TableFFT']");
1460+
1461+
for (auto xpath_node : xpath_set)
1462+
{
1463+
auto node = xpath_node.node();
1464+
1465+
if (auto averageNode = node.find_child_by_attribute("name", "AverageFft"))
1466+
{
1467+
averageNode.attribute("name").set_value("UseWelchMethod");
1468+
}
1469+
1470+
if (auto optimizeNode = node.find_child_by_attribute("name", "OptimizeForRealInput"))
1471+
{
1472+
optimizeNode.attribute("name").set_value("OneSidedSpectrum");
1473+
}
1474+
1475+
if (auto nblockNode = node.find_child_by_attribute("name", "NumberOfBlock"))
1476+
{
1477+
node.remove_child(nblockNode);
1478+
}
1479+
}
1480+
1481+
return true;
1482+
}
1483+
};
1484+
14521485
} // end of namespace
14531486

14541487
vtkStandardNewMacro(vtkSMStateVersionController);
@@ -1563,6 +1596,13 @@ bool vtkSMStateVersionController::Process(vtkPVXMLElement* parent, vtkSMSession*
15631596
version = vtkSMVersion(5, 11, 0);
15641597
}
15651598

1599+
if (status && (version < vtkSMVersion(5, 12, 0)))
1600+
{
1601+
Process_5_11_to_5_12 converter;
1602+
status = converter(document);
1603+
version = vtkSMVersion(5, 12, 0);
1604+
}
1605+
15661606
if (status)
15671607
{
15681608
std::ostringstream stream2;

Wrapping/Python/paraview/_backwardscompatibilityhelper.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,27 @@ def setattr(proxy, pname, value):
407407
raise NotSupportedException("'StaticMesh' is obsolete. Use 'MeshOverTime' property of " +
408408
proxy.SMProxy.GetXMLName() + " filter instead.")
409409

410+
# 5.11 -> 5.12 breaking changes on "TableFFT" properties
411+
# Renamed AverageFFTperblock into UseWelchMethod
412+
# Renamed OptimizeForRealInput into OneSidedSpectrum
413+
# Removed NumberOfBlock
414+
if proxy.SMProxy and proxy.SMProxy.GetXMLName() == "TableFFT":
415+
isOldVersion = paraview.compatibility.GetVersion() < (5, 12)
416+
if pname == "AverageFFTperblock":
417+
if isOldVersion:
418+
proxy.GetProperty("UseWelchMethod").SetData(value)
419+
raise Continue()
420+
else:
421+
raise NotSupportedException("'AverageFFTperblock' is obsolete. Use 'UseWelchMethod' property instead.")
422+
elif pname == "OptimizeForRealInput":
423+
if isOldVersion:
424+
proxy.GetProperty("OneSidedSpectrum").SetData(value)
425+
raise Continue()
426+
else:
427+
raise NotSupportedException("'OptimizeForRealInput' is obsolete. Use 'OneSidedSpectrum' property instead.")
428+
elif pname == "NumberOfBlock" and not isOldVersion:
429+
raise NotSupportedException("'NumberOfBlock' is obsolete. See 'BlockOverlap' property instead.")
430+
410431
if not hasattr(proxy, pname):
411432
raise AttributeError()
412433
proxy.__dict__[pname] = value
@@ -859,6 +880,25 @@ def getattr(proxy, pname):
859880
raise NotSupportedException(
860881
"Since ParaView 5.11, 'UseGeometryFilter' has been removed. ")
861882

883+
# 5.11 -> 5.12 breaking changes on "TableFFT" properties
884+
# Renamed AverageFFTperblock into UseWelchMethod
885+
# Renamed OptimizeForRealInput into OneSidedSpectrum
886+
# Removed NumberOfBlock
887+
if proxy.SMProxy and proxy.SMProxy.GetXMLName() == "TableFFT":
888+
isOldVersion = paraview.compatibility.GetVersion() < (5, 12)
889+
if pname == "AverageFFTperblock":
890+
if isOldVersion:
891+
return proxy.GetProperty("UseWelchMethod").GetData()
892+
else:
893+
raise NotSupportedException("'AverageFft' is obsolete. Use 'UseWelchMethod' property instead.")
894+
elif pname == "OptimizeForRealInput":
895+
if isOldVersion:
896+
return proxy.GetProperty("OneSidedSpectrum").GetData()
897+
else:
898+
raise NotSupportedException("'OptimizeForRealInput' is obsolete. Use 'OneSidedSpectrum' property instead.")
899+
elif pname == "NumberOfBlock" and not isOldVersion:
900+
raise NotSupportedException("'NumberOfBlock' is obsolete. See 'BlockOverlap' property instead.")
901+
862902
raise Continue()
863903

864904
# Depending on the compatibility version that has been set, older functionalities

0 commit comments

Comments
 (0)