Commit bf1e16e5 authored by Sebastien Jourdain's avatar Sebastien Jourdain

Add support for inline subproxy

This fix the CSVWriter did not check other case yet.
parent 258afc94
......@@ -60,7 +60,8 @@ int main(int argc, char* argv[])
vtkPVXMLElement* def = pxm->GetProxyDefinitionManager()->
GetCollapsedProxyDefinition( "representations",
"GeometryRepresentation"); // GeometryRepresentation Glyph3DRepresentation
"GeometryRepresentation",
NULL); // GeometryRepresentation Glyph3DRepresentation
def->PrintXML();
cout << "Exiting..." << endl;
......
......@@ -63,7 +63,7 @@ message DefinitionHeader
}
}
// Extension ProxyState *********************************************** [20-23]
// Extension ProxyState *********************************************** [20-24]
message ProxyState
{
......@@ -80,10 +80,11 @@ message ProxyState
}
extend Message {
required string xml_group = 20;
required string xml_name = 21;
repeated Property property = 22;
repeated SubProxy subproxy = 23;
required string xml_group = 20;
required string xml_name = 21;
optional string xml_sub_proxy_name = 22;
repeated Property property = 23;
repeated SubProxy subproxy = 24;
}
}
......
......@@ -252,17 +252,25 @@ bool vtkPMProxy::CreateVTKObjects(vtkSMMessage* message)
!message->HasExtension(ProxyState::xml_name))
{
vtkErrorMacro("Incorrect message received. "
"Missing xml_group and xml_name information.");
message->PrintDebugString();
<< "Missing xml_group and xml_name information." << endl
<< message->DebugString().c_str() << endl);
return false;
}
vtkSMProxyDefinitionManager* pdm = this->GetProxyDefinitionManager();
vtkPVXMLElement* element = pdm->GetCollapsedProxyDefinition(
message->GetExtension(ProxyState::xml_group).c_str(),
message->GetExtension(ProxyState::xml_name).c_str());
message->GetExtension(ProxyState::xml_name).c_str(),
(message->HasExtension(ProxyState::xml_sub_proxy_name) ?
message->GetExtension(ProxyState::xml_sub_proxy_name).c_str() :
NULL));
if (!element)
{
vtkErrorMacro("Definition not found for xml_group: "
<< message->GetExtension(ProxyState::xml_group).c_str()
<< " and xml_name: "
<< message->GetExtension(ProxyState::xml_name).c_str()
<< endl << message->DebugString().c_str() << endl );
return false;
}
......@@ -306,11 +314,21 @@ bool vtkPMProxy::CreateVTKObjects(vtkSMMessage* message)
this->GetPMObject(subproxyMsg.global_id()));
if (subproxy == NULL)
{
vtkErrorMacro("Failed to locate subproxy with global-id: " <<
subproxyMsg.global_id());
return false;
// This code has been commented to support ImplicitPlaneWidgetRepresentation
// which as a widget as SubProxy which stay on the client side.
// Therefore, when ParaView is running on Client/Server mode, that SubProxy
// does NOT exist on the Server side. This case should not fail the current
// proxy creation.
// vtkErrorMacro("Failed to locate subproxy with global-id: "
// << subproxyMsg.global_id() << endl
// << message->DebugString().c_str());
// return false;
}
else
{
this->Internals->SubProxyHelpers[subproxyMsg.name()] = subproxy;
}
this->Internals->SubProxyHelpers[subproxyMsg.name()] = subproxy;
}
// Allow subclasses to do some initialization if needed. Note this is called
......
......@@ -101,6 +101,7 @@ vtkSMProxy::vtkSMProxy()
this->XMLGroup = 0;
this->XMLName = 0;
this->XMLLabel = 0;
this->XMLSubProxyName = 0;
this->ObjectsCreated = 0;
this->XMLElement = 0;
......@@ -136,6 +137,7 @@ vtkSMProxy::~vtkSMProxy()
this->SetXMLGroup(0);
this->SetXMLName(0);
this->SetXMLLabel(0);
this->SetXMLSubProxyName(0);
this->SetXMLElement(0);
if (this->SubProxyObserver)
{
......@@ -684,6 +686,10 @@ void vtkSMProxy::CreateVTKObjects()
message.SetExtension(DefinitionHeader::server_class, this->GetKernelClassName());
message.SetExtension(ProxyState::xml_group, this->GetXMLGroup());
message.SetExtension(ProxyState::xml_name, this->GetXMLName());
if(this->XMLSubProxyName)
{
message.SetExtension(ProxyState::xml_sub_proxy_name, this->XMLSubProxyName);
}
// Create sub-proxies first.
vtkSMProxyInternals::ProxyMap::iterator it2 =
......@@ -1296,18 +1302,15 @@ int vtkSMProxy::ReadXMLAttributes( vtkSMProxyManager* pm,
this->SetKernelClassName(kernelClass);
}
const char* xmlname = element->GetAttribute("name");
if(xmlname)
{
this->SetXMLName(xmlname);
this->SetXMLLabel(xmlname);
}
const char* xmllabel = element->GetAttribute("label");
if (xmllabel)
{
this->SetXMLLabel(xmllabel);
}
else
{
this->SetXMLLabel(this->GetXMLName());
}
const char* processes = element->GetAttribute("processes");
if (processes)
......@@ -1406,12 +1409,14 @@ int vtkSMProxy::CreateSubProxiesAndProperties(vtkSMProxyManager* pm,
}
else
{
subproxy = pm->NewProxy(subElement, "inline-proxy", name); // FIXME !!!!
gname = this->XMLGroup;
pname = this->XMLName;
subproxy = pm->NewProxy(subElement, gname, pname, name);
}
if (!subproxy)
{
vtkErrorMacro("Failed to create subproxy: "
<< (pname?pname:"(none"));
vtkErrorMacro( "Failed to create subproxy: "
<< (pname?pname:"(none"));
return 0;
}
this->AddSubProxy(name, subproxy, override);
......
......@@ -442,6 +442,14 @@ protected:
// proxy.
vtkSetStringMacro(XMLLabel);
// Description:
// Assigned by the XML parser. It is used to figure out the origin
// of the definition of that proxy.
// By default, it stay NULL, only in-line subProxy do specify
// this field so when the definition is sent to the server, it can
// retreive the in-line definition of that proxy.
vtkSetStringMacro(XMLSubProxyName);
// Description:
// Given a class name (by setting VTKClassName) and server ids (by
// setting ServerIDs), this methods instantiates the objects on the
......@@ -592,6 +600,7 @@ protected:
char* XMLGroup;
char* XMLName;
char* XMLLabel;
char* XMLSubProxyName;
int ObjectsCreated;
int DoNotUpdateImmediately;
int DoNotModifyProperty;
......
......@@ -776,14 +776,41 @@ void vtkSMProxyDefinitionManager::InvalidateCollapsedDefinition()
this->InternalsFlatten->CoreDefinitions.clear();
}
//---------------------------------------------------------------------------
vtkPVXMLElement* vtkSMProxyDefinitionManager::GetCollapsedProxyDefinition(const char* group, const char* name, bool throwError)
vtkPVXMLElement* vtkSMProxyDefinitionManager::ExtractSubProxy(
vtkPVXMLElement* proxyDefinition, const char* subProxyName)
{
if(!subProxyName)
{
return proxyDefinition;
}
// Extract just the sub-proxy in-line definition
for(unsigned int cc=0;cc<proxyDefinition->GetNumberOfNestedElements();cc++)
{
if(strcmp(proxyDefinition->GetNestedElement(cc)->GetName(), "SubProxy") == 0)
{
vtkPVXMLElement* subProxyDef =
proxyDefinition->GetNestedElement(cc)->FindNestedElementByName("Proxy");
if( subProxyDef && strcmp( subProxyDef->GetAttribute("name"), subProxyName) == 0)
{
return subProxyDef;
}
}
}
return NULL;
}
//---------------------------------------------------------------------------
vtkPVXMLElement* vtkSMProxyDefinitionManager::GetCollapsedProxyDefinition(
const char* group, const char* name, const char* subProxyName, bool throwError)
{
// Look in the cache
vtkPVXMLElement* flattenDefinition = this->InternalsFlatten->GetProxyElement(group,name);
if (flattenDefinition)
{
// Found it, so return it...
return flattenDefinition;
return ExtractSubProxy(flattenDefinition, subProxyName);
}
// Not found in the cache, look if the definition exists
......@@ -831,12 +858,12 @@ vtkPVXMLElement* vtkSMProxyDefinitionManager::GetCollapsedProxyDefinition(const
// Register it in the cache
this->InternalsFlatten->CoreDefinitions[group][name] = newElement.GetPointer();
return newElement.GetPointer();
return ExtractSubProxy(newElement.GetPointer(), subProxyName);
}
}
// Could be either the original definition or a NULL pointer if not found
return originalDefinition;
return ExtractSubProxy(originalDefinition, subProxyName);
}
//---------------------------------------------------------------------------
void vtkSMProxyDefinitionManager::MergeProxyDefinition(vtkPVXMLElement* element,
......
......@@ -58,10 +58,15 @@ public:
// Returns the same thing as GetProxyDefinition in a flatten manner.
// By flatten, we mean that the class hierarchy has been walked and merged
// into a single vtkPVXMLElement definition.
vtkPVXMLElement* GetCollapsedProxyDefinition(const char* group, const char* name, bool throwError);
vtkPVXMLElement* GetCollapsedProxyDefinition(const char* group, const char* name)
vtkPVXMLElement* GetCollapsedProxyDefinition(const char* group,
const char* name,
const char* subProxyName,
bool throwError);
vtkPVXMLElement* GetCollapsedProxyDefinition(const char* group,
const char* name,
const char* subProxyName)
{
return this->GetCollapsedProxyDefinition(group, name, true);
return this->GetCollapsedProxyDefinition(group, name, subProxyName, true);
}
......@@ -189,6 +194,12 @@ protected:
vtkPVXMLElement* GetProxyElement(const char* groupName,
const char* proxyName);
// Description:
// Convenient method used to extract sub-proxy definition inside a proxy
// definition. If (subProxyName == NULL) return proxyDefinition;
vtkPVXMLElement* ExtractSubProxy(vtkPVXMLElement* proxyDefinition,
const char* subProxyName);
private:
vtkSMProxyDefinitionManager(const vtkSMProxyDefinitionManager&); // Not implemented
void operator=(const vtkSMProxyDefinitionManager&); // Not implemented
......
......@@ -323,7 +323,7 @@ void vtkSMProxyManager::AddElement(const char* groupName,
//----------------------------------------------------------------------------
vtkSMProxy* vtkSMProxyManager::NewProxy(
const char* groupName, const char* proxyName)
const char* groupName, const char* proxyName, const char* subProxyName)
{
if (!groupName || !proxyName)
{
......@@ -331,18 +331,21 @@ vtkSMProxy* vtkSMProxyManager::NewProxy(
}
// Find the XML element from which the proxy can be instantiated and
// initialized
vtkPVXMLElement* element = this->GetProxyElement(groupName, proxyName);
vtkPVXMLElement* element = this->GetProxyElement( groupName, proxyName,
subProxyName);
if (element)
{
return this->NewProxy(element, groupName, proxyName);
return this->NewProxy(element, groupName, proxyName, subProxyName);
}
return 0;
}
//---------------------------------------------------------------------------
vtkSMProxy* vtkSMProxyManager::NewProxy(vtkPVXMLElement* pelement,
const char* groupname,
const char* proxyname)
const char* proxyname,
const char* subProxyName)
{
vtkObject* object = 0;
vtksys_ios::ostringstream cname;
......@@ -352,10 +355,13 @@ vtkSMProxy* vtkSMProxyManager::NewProxy(vtkPVXMLElement* pelement,
vtkSMProxy* proxy = vtkSMProxy::SafeDownCast(object);
if (proxy)
{
// XMLName/XMLGroup should be set before ReadXMLAttributes so sub proxy
// can be found based on their names when sent to the PM Side
proxy->SetXMLGroup(groupname);
proxy->SetXMLName(proxyname);
proxy->SetXMLSubProxyName(subProxyName);
proxy->SetSession(this->GetSession());
proxy->ReadXMLAttributes(this, pelement);
proxy->SetXMLName(proxyname);
proxy->SetXMLGroup(groupname);
}
else
{
......@@ -411,11 +417,14 @@ int vtkSMProxyManager::ProxyElementExists(const char* groupName,
//---------------------------------------------------------------------------
vtkPVXMLElement* vtkSMProxyManager::GetProxyElement(const char* groupName,
const char* proxyName)
const char* proxyName,
const char* subProxyName)
{
assert(this->ProxyDefinitionManager != 0);
return this->ProxyDefinitionManager->GetCollapsedProxyDefinition(
groupName, proxyName, true);
return this->ProxyDefinitionManager->GetCollapsedProxyDefinition( groupName,
proxyName,
subProxyName,
true);
}
//---------------------------------------------------------------------------
......@@ -459,7 +468,7 @@ vtkSMProxy* vtkSMProxyManager::GetPrototypeProxy(const char* groupname,
// silently ask for the definition. If not found return NULL.
vtkPVXMLElement* xmlElement =
this->ProxyDefinitionManager->GetCollapsedProxyDefinition(
groupname, name, false);
groupname, name, NULL, false);
if (xmlElement == NULL)
{
// No definition was located for the requested proxy.
......
......@@ -90,7 +90,8 @@ public:
// The VTK wrappers handle New and Delete specially and may not allow
// the deletion of object created through other methods. Use
// UnRegister instead.
vtkSMProxy* NewProxy(const char* groupName, const char* proxyName);
vtkSMProxy* NewProxy(const char* groupName, const char* proxyName,
const char* subProxyName = NULL);
// Description:
// Returns a vtkSMDocumentation object with the documentation
......@@ -485,14 +486,15 @@ protected:
// Description:
// Given an XML element and group name create a proxy
// and all of it's properties.
vtkSMProxy* NewProxy(vtkPVXMLElement* element,
const char* groupname, const char* proxyname);
vtkSMProxy* NewProxy(vtkPVXMLElement* element, const char* groupname,
const char* proxyname, const char* subProxyName = NULL);
// Description:
// Given the proxy name and group name, returns the XML element for
// the proxy.
vtkPVXMLElement* GetProxyElement(const char* groupName,
const char* proxyName);
vtkPVXMLElement* GetProxyElement( const char* groupName,
const char* proxyName,
const char* subProxyName = NULL);
// Description:
// Handles events.
......
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