Commit 17f6016e authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

Adding 'command' to <SubProxy> element.

It's often that we need to pass the VTK object for a subproxy to the
container proxy using a Set* method. We ended up subclassing vtkSIProxy
for such cases. Adding support to simply specify the command to use to
on the XML definition itself. Hence all such subclasses become
unnecessary!
parent c929ee80
......@@ -620,13 +620,8 @@
"path": "ParaViewCore/ServerImplementation/Rendering",
"include": [
{ "path": "module.cmake" },
{ "class": "vtkSIChartRepresentationProxy" },
{ "class": "vtkSIImageTextureProxy" },
{ "class": "vtkSIPVRepresentationProxy" },
{ "class": "vtkSIScalarBarActorProxy" },
{ "class": "vtkSISelectionRepresentationProxy" },
{ "class": "vtkSITextSourceRepresentationProxy" },
{ "class": "vtkSIUniformGridVolumeRepresentationProxy" },
{ "class": "vtkSIUnstructuredGridVolumeRepresentationProxy" }
],
"replace": [
......
......@@ -34,6 +34,12 @@ public:
void PrintSelf(ostream& os, vtkIndent indent);
void SetSliceRepresentation(int index, vtkPVDataRepresentation*);
void SetSliceRepresentation0(vtkPVDataRepresentation* repr)
{ this->SetSliceRepresentation(0, repr); }
void SetSliceRepresentation1(vtkPVDataRepresentation* repr)
{ this->SetSliceRepresentation(1, repr); }
void SetSliceRepresentation2(vtkPVDataRepresentation* repr)
{ this->SetSliceRepresentation(2, repr); }
// Description:
// Set visibility of the representation.
......
......@@ -77,7 +77,8 @@ vtkTextSourceRepresentation::~vtkTextSourceRepresentation()
void vtkTextSourceRepresentation::SetVisibility(bool val)
{
this->Superclass::SetVisibility(val);
if (this->TextWidgetRepresentation)
if (this->TextWidgetRepresentation &&
this->TextWidgetRepresentation->GetRepresentation())
{
this->TextWidgetRepresentation->GetRepresentation()->SetVisibility(val);
this->TextWidgetRepresentation->SetEnabled(val);
......
......@@ -65,6 +65,9 @@ public:
typedef std::vector<SubProxyInfo> SubProxiesVectorType;
SubProxiesVectorType SubProxyInfoVector;
typedef std::map<std::string, std::string> SubProxyCommandMapType;
SubProxyCommandMapType SubProxyCommands;
};
//****************************************************************************
......@@ -421,17 +424,35 @@ bool vtkSIProxy::ReadXMLAttributes(vtkPVXMLElement* element)
return false;
}
}
else
}
// Process sub-proxy commands.
for (vtkInternals::SubProxyCommandMapType::iterator iter=this->Internals->SubProxyCommands.begin();
iter != this->Internals->SubProxyCommands.end(); ++iter)
{
if (vtkSIProxy* subProxy = this->GetSubSIProxy(iter->first.c_str()))
{
// read property xml
const char* name = propElement->GetAttribute("name");
std::string tagName = propElement->GetName();
if (name && tagName.find("Property") == (tagName.size()-8))
vtkClientServerStream stream;
stream << vtkClientServerStream::Invoke
<< this->GetVTKObject()
<< iter->second.c_str()
<< subProxy->GetVTKObject()
<< vtkClientServerStream::End;
this->Interpreter->ProcessStream(stream);
}
}
for (unsigned int i=0; i < element->GetNumberOfNestedElements(); ++i)
{
vtkPVXMLElement* propElement = element->GetNestedElement(i);
// read property xml
const char* name = propElement->GetAttribute("name");
std::string tagName = propElement->GetName();
if (name && tagName.find("Property") == (tagName.size()-8))
{
if (!this->ReadXMLProperty(propElement))
{
if (!this->ReadXMLProperty(propElement))
{
return false;
}
return false;
}
}
}
......@@ -440,11 +461,24 @@ bool vtkSIProxy::ReadXMLAttributes(vtkPVXMLElement* element)
}
//----------------------------------------------------------------------------
bool vtkSIProxy::ReadXMLSubProxy(vtkPVXMLElement* )
bool vtkSIProxy::ReadXMLSubProxy(vtkPVXMLElement* subproxyElement)
{
// vtkErrorMacro("Not supported yet.");
// Process "command" for the sub proxy, if any. These are used in
// CreateVTKObjects() to pass the sub proxy's VTK object to this proxy's VTK
// object.
const char* command = subproxyElement? subproxyElement->GetAttribute("command") : NULL;
if (command)
{
vtkPVXMLElement* proxyElement = subproxyElement->GetNestedElement(0);
const char* name = proxyElement? proxyElement->GetAttribute("name") : NULL;
if (name)
{
this->Internals->SubProxyCommands[name] = command;
}
}
return true;
}
//----------------------------------------------------------------------------
bool vtkSIProxy::ReadXMLProperty(vtkPVXMLElement* propElement)
{
......
......@@ -29,13 +29,8 @@
#
#==========================================================================
set (Module_SRCS
vtkSIChartRepresentationProxy.cxx
vtkSIImageTextureProxy.cxx
vtkSIPVRepresentationProxy.cxx
vtkSIScalarBarActorProxy.cxx
vtkSISelectionRepresentationProxy.cxx
vtkSITextSourceRepresentationProxy.cxx
vtkSIUniformGridVolumeRepresentationProxy.cxx
vtkSIUnstructuredGridVolumeRepresentationProxy.cxx
vtkSICompositeOrthographicSliceRepresentationProxy.cxx
)
......
/*=========================================================================
Program: ParaView
Module: vtkSIChartRepresentationProxy.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 "vtkSIChartRepresentationProxy.h"
#include "vtkChartRepresentation.h"
#include "vtkChartSelectionRepresentation.h"
#include "vtkObjectFactory.h"
vtkStandardNewMacro(vtkSIChartRepresentationProxy);
//----------------------------------------------------------------------------
vtkSIChartRepresentationProxy::vtkSIChartRepresentationProxy()
{
}
//----------------------------------------------------------------------------
vtkSIChartRepresentationProxy::~vtkSIChartRepresentationProxy()
{
}
//----------------------------------------------------------------------------
void vtkSIChartRepresentationProxy::OnCreateVTKObjects()
{
vtkSIProxy* selectionProxy = this->GetSubSIProxy("SelectionRepresentation");
if (selectionProxy)
{
vtkChartRepresentation* repr = vtkChartRepresentation::SafeDownCast(
this->GetVTKObject());
vtkChartSelectionRepresentation* selRepr =
vtkChartSelectionRepresentation::SafeDownCast(selectionProxy->GetVTKObject());
repr->SetSelectionRepresentation(selRepr);
}
}
//----------------------------------------------------------------------------
void vtkSIChartRepresentationProxy::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
/*=========================================================================
Program: ParaView
Module: $RCSfile$
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 vtkSIChartRepresentationProxy
// .SECTION Description
// vtkSIChartRepresentationProxy is the server-side helper for
// vtkSMChartRepresentationProxy. It initializes the vtkXYChartRepresentation
// instance with the vtkChartSelectionRepresentation instance sub-proxy, if any,
// during CreateVTKObjects().
#ifndef __vtkSIChartRepresentationProxy_h
#define __vtkSIChartRepresentationProxy_h
#include "vtkPVServerImplementationRenderingModule.h" //needed for exports
#include "vtkSISourceProxy.h"
class VTKPVSERVERIMPLEMENTATIONRENDERING_EXPORT vtkSIChartRepresentationProxy : public vtkSISourceProxy
{
public:
static vtkSIChartRepresentationProxy* New();
vtkTypeMacro(vtkSIChartRepresentationProxy, vtkSISourceProxy);
void PrintSelf(ostream& os, vtkIndent indent);
//BTX
protected:
vtkSIChartRepresentationProxy();
~vtkSIChartRepresentationProxy();
// Description;
// Called in CreateVTKObjects() after the vtk-object has been created and
// subproxy-information has been processed, but before the XML is parsed to
// generate properties and initialize their values.
//
// This method is overriden here to set the VTK instance of the
// PlotOptions subProxy to the current VTK representation.
virtual void OnCreateVTKObjects();
private:
vtkSIChartRepresentationProxy(const vtkSIChartRepresentationProxy&); // Not implemented
void operator=(const vtkSIChartRepresentationProxy&); // Not implemented
//ETX
};
#endif
/*=========================================================================
Program: ParaView
Module: vtkSICompositeOrthographicSliceRepresentationProxy.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 "vtkSICompositeOrthographicSliceRepresentationProxy.h"
#include "vtkObjectFactory.h"
#include "vtkPVCompositeOrthographicSliceRepresentation.h"
vtkStandardNewMacro(vtkSICompositeOrthographicSliceRepresentationProxy);
//----------------------------------------------------------------------------
vtkSICompositeOrthographicSliceRepresentationProxy::vtkSICompositeOrthographicSliceRepresentationProxy()
{
}
//----------------------------------------------------------------------------
vtkSICompositeOrthographicSliceRepresentationProxy::~vtkSICompositeOrthographicSliceRepresentationProxy()
{
}
//----------------------------------------------------------------------------
bool vtkSICompositeOrthographicSliceRepresentationProxy::ReadXMLAttributes(vtkPVXMLElement* element)
{
vtkPVCompositeOrthographicSliceRepresentation* pvrepresentation =
vtkPVCompositeOrthographicSliceRepresentation::SafeDownCast(this->GetVTKObject());
pvrepresentation->SetSliceRepresentation(0,
vtkPVDataRepresentation::SafeDownCast(
this->GetSubSIProxy("GeometrySliceRepresentationX")->GetVTKObject()));
pvrepresentation->SetSliceRepresentation(1,
vtkPVDataRepresentation::SafeDownCast(
this->GetSubSIProxy("GeometrySliceRepresentationY")->GetVTKObject()));
pvrepresentation->SetSliceRepresentation(2,
vtkPVDataRepresentation::SafeDownCast(
this->GetSubSIProxy("GeometrySliceRepresentationZ")->GetVTKObject()));
return this->Superclass::ReadXMLAttributes(element);
}
//----------------------------------------------------------------------------
void vtkSICompositeOrthographicSliceRepresentationProxy::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
/*=========================================================================
Program: ParaView
Module: vtkSICompositeOrthographicSliceRepresentationProxy.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 vtkSICompositeOrthographicSliceRepresentationProxy
// .SECTION Description
//
#ifndef __vtkSICompositeOrthographicSliceRepresentationProxy_h
#define __vtkSICompositeOrthographicSliceRepresentationProxy_h
#include "vtkSIPVRepresentationProxy.h"
class VTKPVSERVERIMPLEMENTATIONRENDERING_EXPORT vtkSICompositeOrthographicSliceRepresentationProxy : public vtkSIPVRepresentationProxy
{
public:
static vtkSICompositeOrthographicSliceRepresentationProxy* New();
vtkTypeMacro(vtkSICompositeOrthographicSliceRepresentationProxy, vtkSIPVRepresentationProxy);
void PrintSelf(ostream& os, vtkIndent indent);
//BTX
protected:
vtkSICompositeOrthographicSliceRepresentationProxy();
~vtkSICompositeOrthographicSliceRepresentationProxy();
// Description:
// Parses the XML to create property/subproxy helpers.
// Overridden to process the GeometrySliceRepresentation[X|Y|Z]
// representations.
virtual bool ReadXMLAttributes(vtkPVXMLElement* element);
private:
vtkSICompositeOrthographicSliceRepresentationProxy(const vtkSICompositeOrthographicSliceRepresentationProxy&); // Not implemented
void operator=(const vtkSICompositeOrthographicSliceRepresentationProxy&); // Not implemented
//ETX
};
#endif
/*=========================================================================
Program: ParaView
Module: vtkSIScalarBarActorProxy.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 "vtkSIScalarBarActorProxy.h"
#include "vtkClientServerInterpreter.h"
#include "vtkClientServerStream.h"
#include "vtkObjectFactory.h"
#include <assert.h>
vtkStandardNewMacro(vtkSIScalarBarActorProxy);
//----------------------------------------------------------------------------
vtkSIScalarBarActorProxy::vtkSIScalarBarActorProxy()
{
}
//----------------------------------------------------------------------------
vtkSIScalarBarActorProxy::~vtkSIScalarBarActorProxy()
{
}
//----------------------------------------------------------------------------
bool vtkSIScalarBarActorProxy::CreateVTKObjects(vtkSMMessage* message)
{
bool return_value = this->Superclass::CreateVTKObjects(message);
if(return_value)
{
vtkClientServerStream stream;
// Label Text property
stream << vtkClientServerStream::Invoke
<< this->GetVTKObject()
<< "SetLabelTextProperty"
<< this->GetSubSIProxy("LabelTextProperty")->GetVTKObject()
<< vtkClientServerStream::End;
// Title text property
stream << vtkClientServerStream::Invoke
<< this->GetVTKObject()
<< "SetTitleTextProperty"
<< this->GetSubSIProxy("TitleTextProperty")->GetVTKObject()
<< vtkClientServerStream::End;
// Execute
return (this->Interpreter->ProcessStream(stream) != 0);
}
return return_value;
}
//----------------------------------------------------------------------------
void vtkSIScalarBarActorProxy::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
/*=========================================================================
Program: ParaView
Module: vtkSIScalarBarActorProxy.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 vtkSIScalarBarActorProxy
// .SECTION Description
// vtkSIScalarBarActorProxy is the server-side class used to bind subproxy
// internally
#ifndef __vtkSIScalarBarActorProxy_h
#define __vtkSIScalarBarActorProxy_h
#include "vtkPVServerImplementationRenderingModule.h" //needed for exports
#include "vtkSIProxy.h"
class VTKPVSERVERIMPLEMENTATIONRENDERING_EXPORT vtkSIScalarBarActorProxy : public vtkSIProxy
{
public:
static vtkSIScalarBarActorProxy* New();
vtkTypeMacro(vtkSIScalarBarActorProxy, vtkSIProxy);
void PrintSelf(ostream& os, vtkIndent indent);
//BTX
protected:
vtkSIScalarBarActorProxy();
~vtkSIScalarBarActorProxy();
// Description:
// Creates the VTKObjects. Overridden to add post-filters to the pipeline.
virtual bool CreateVTKObjects(vtkSMMessage* message);
private:
vtkSIScalarBarActorProxy(const vtkSIScalarBarActorProxy&); // Not implemented
void operator=(const vtkSIScalarBarActorProxy&); // Not implemented
//ETX
};
#endif
/*=========================================================================
Program: ParaView
Module: vtkSISelectionRepresentationProxy.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 "vtkSISelectionRepresentationProxy.h"
#include "vtkClientServerStream.h"
#include "vtkObjectFactory.h"
#include "vtkClientServerInterpreter.h"
vtkStandardNewMacro(vtkSISelectionRepresentationProxy);
//----------------------------------------------------------------------------
vtkSISelectionRepresentationProxy::vtkSISelectionRepresentationProxy()
{
}
//----------------------------------------------------------------------------
vtkSISelectionRepresentationProxy::~vtkSISelectionRepresentationProxy()
{
}
//----------------------------------------------------------------------------
bool vtkSISelectionRepresentationProxy::CreateVTKObjects(vtkSMMessage* message)
{
if (this->ObjectsCreated)
{
return true;
}
if (!this->Superclass::CreateVTKObjects(message))
{
return false;
}
vtkSIProxy* label_repr = this->GetSubSIProxy("LabelRepresentation");
vtkClientServerStream stream;
stream << vtkClientServerStream::Invoke
<< this->GetVTKObject()
<< "SetLabelRepresentation"
<< label_repr->GetVTKObject()
<< vtkClientServerStream::End;
return (this->Interpreter->ProcessStream(stream) != 0);
}
//----------------------------------------------------------------------------
void vtkSISelectionRepresentationProxy::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
/*=========================================================================
Program: ParaView
Module: vtkSISelectionRepresentationProxy.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 vtkSISelectionRepresentationProxy
// .SECTION Description
// Representation use to show selection. This shows only the selection i.e.
// output of ExtractSelection filter.
#ifndef __vtkSISelectionRepresentationProxy_h
#define __vtkSISelectionRepresentationProxy_h
#include "vtkPVServerImplementationRenderingModule.h" //needed for exports
#include "vtkSIProxy.h"
class vtkSMDataLabelRepresentationProxy;
class VTKPVSERVERIMPLEMENTATIONRENDERING_EXPORT vtkSISelectionRepresentationProxy : public vtkSIProxy
{
public:
static vtkSISelectionRepresentationProxy* New();
vtkTypeMacro(vtkSISelectionRepresentationProxy, vtkSIProxy);
void PrintSelf(ostream& os, vtkIndent indent);
//BTX
protected:
vtkSISelectionRepresentationProxy();
~vtkSISelectionRepresentationProxy();
// Description:
virtual bool CreateVTKObjects(vtkSMMessage* message);
private:
vtkSISelectionRepresentationProxy(const vtkSISelectionRepresentationProxy&); // Not implemented
void operator=(const vtkSISelectionRepresentationProxy&); // Not implemented
//ETX
};
#endif
/*=========================================================================
Program: ParaView
Module: vtkSITextSourceRepresentationProxy.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 "vtkSITextSourceRepresentationProxy.h"
#include "vtkClientServerInterpreter.h"
#include "vtkClientServerStream.h"
#include "vtkObjectFactory.h"
vtkStandardNewMacro(vtkSITextSourceRepresentationProxy);
//----------------------------------------------------------------------------
vtkSITextSourceRepresentationProxy::vtkSITextSourceRepresentationProxy()
{
}
//----------------------------------------------------------------------------
vtkSITextSourceRepresentationProxy::~vtkSITextSourceRepresentationProxy()
{
}
//----------------------------------------------------------------------------
bool vtkSITextSourceRepresentationProxy::CreateVTKObjects(vtkSMMessage* message)
{
if (this->ObjectsCreated)
{
return true;
}
if (!this->Superclass::CreateVTKObjects(message))
{
return false;
}
vtkClientServerStream stream;
stream << vtkClientServerStream::Invoke
<< this->GetVTKObject() << "SetTextWidgetRepresentation"
<< this->GetSubSIProxy("TextWidgetRepresentation")->GetVTKObject()
<< vtkClientServerStream::End;
this->Interpreter->ProcessStream(stream);
return true;
}
//----------------------------------------------------------------------------
void vtkSITextSourceRepresentationProxy::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
/*=========================================================================
Program: ParaView
Module: vtkSITextSourceRepresentationProxy.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 vtkSITextSourceRepresentationProxy
// .SECTION Description
// vtkSITextSourceRepresentationProxy is the proxy for
// (representations, TextSourceRepresentation). Merely overrides
// CreateVTKObjects to ensure that the subproxies are passed to the
// vtkTextSourceRepresentation correctly.
#ifndef __vtkSITextSourceRepresentationProxy_h
#define __vtkSITextSourceRepresentationProxy_h
#include "vtkPVServerImplementationRenderingModule.h" //needed for exports
#include "vtkSIProxy.h"
class vtkSMViewProxy;
class VTKPVSERVERIMPLEMENTATIONRENDERING_EXPORT vtkSITextSourceRepresentationProxy : public vtkSIProxy
{
public:
static vtkSITextSourceRepresentationProxy* New();
vtkTypeMacro(vtkSITextSourceRepresentationProxy, vtkSIProxy);
void PrintSelf(ostream& os, vtkIndent indent);
// BTX
protected:
vtkSITextSourceRepresentationProxy();
~vtkSITextSourceRepresentationProxy();
// Description:
virtual bool CreateVTKObjects(vtkSMMessage* message);
private:
vtkSITextSourceRepresentationProxy(const vtkSITextSourceRepresentationProxy&); // Not implemented
void operator=(const vtkSITextSourceRepresentationProxy&); // Not implemented
//ETX
};
#endif