Commit e95d3a94 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

Reverting 261c698e to bring back extract selection API.

parent 56816c1c
......@@ -57,6 +57,7 @@ struct vtkSMSourceProxyInternals
{
typedef vtkstd::vector<vtkSMSourceProxyOutputPort> VectorOfPorts;
VectorOfPorts OutputPorts;
vtkstd::vector<vtkSmartPointer<vtkSMSourceProxy> > SelectionProxies;
// Resizes output ports and ensures that Name for each port is initialized to
// the default.
......@@ -95,6 +96,8 @@ vtkSMSourceProxy::vtkSMSourceProxy()
this->ExecutiveName = 0;
this->SetExecutiveName("vtkCompositeDataPipeline");
this->SelectionProxiesCreated = false;
this->NumberOfAlgorithmOutputPorts = VTK_UNSIGNED_INT_MAX;
this->NumberOfAlgorithmRequiredInputPorts = VTK_UNSIGNED_INT_MAX;
this->ProcessSupport = vtkSMSourceProxy::BOTH;
......@@ -414,6 +417,23 @@ void vtkSMSourceProxy::PostUpdateData()
this->Superclass::PostUpdateData();
}
//----------------------------------------------------------------------------
void vtkSMSourceProxy::MarkDirty(vtkSMProxy* modifiedProxy)
{
// Mark the extract selection proxies modified as well.
// This is needed to be done explicitly since we don't use vtkSMInputProperty
// to connect this proxy to the input of the extract selection filter.
vtkstd::vector<vtkSmartPointer<vtkSMSourceProxy> >::iterator iter;
for (iter = this->PInternals->SelectionProxies.begin();
iter != this->PInternals->SelectionProxies.end(); ++iter)
{
iter->GetPointer()->MarkDirty(modifiedProxy);
}
this->Superclass::MarkDirty(modifiedProxy);
// this->InvalidateDataInformation();
}
//----------------------------------------------------------------------------
vtkPVDataInformation* vtkSMSourceProxy::GetDataInformation(
unsigned int idx)
......@@ -441,6 +461,147 @@ void vtkSMSourceProxy::InvalidateDataInformation()
}
}
//---------------------------------------------------------------------------
void vtkSMSourceProxy::CreateSelectionProxies()
{
if (this->SelectionProxiesCreated)
{
return;
}
this->CreateOutputPorts();
#ifdef FIXME_COLLABORATION
vtkClientServerStream stream;
vtkSMProxyManager* pxm = vtkSMProxyManager::GetProxyManager();
unsigned int numOutputPorts = this->GetNumberOfOutputPorts();
for (unsigned int cc=0; cc < numOutputPorts; cc++)
{
vtkSmartPointer<vtkSMSourceProxy> esProxy;
esProxy.TakeReference(vtkSMSourceProxy::SafeDownCast(
pxm->NewProxy("filters", "PVExtractSelection")));
if (esProxy)
{
esProxy->SetServers(this->Servers);
esProxy->SetConnectionID(this->ConnectionID);
esProxy->SelectionProxiesCreated = true;
esProxy->UpdateVTKObjects();
vtkSMOutputPort* port = this->GetOutputPort(cc);
// We don't use input property since that leads to reference loop cycles
// and I don't feel like doing the garbage collection thing right now.
stream << vtkClientServerStream::Invoke
<< port->GetProducerID() /* we use a crooked means of getting at
the ID so that this code works for
vtkSMCompoundSourceProxy*/
<< "GetOutputPort"
<< port->GetPortIndex()
<< vtkClientServerStream::End;
stream << vtkClientServerStream::Invoke
<< esProxy->GetID()
<< "SetInputConnection"
<< vtkClientServerStream::LastResult
<< vtkClientServerStream::End;
}
this->PInternals->SelectionProxies.push_back(esProxy);
}
vtkProcessModule::GetProcessModule()->SendStream(
this->ConnectionID, this->Servers, stream);
#endif
this->SelectionProxiesCreated = true;
}
//---------------------------------------------------------------------------
void vtkSMSourceProxy::SetSelectionInput(unsigned int portIndex,
vtkSMSourceProxy* input, unsigned int outputport)
{
this->CreateSelectionProxies();
if (this->PInternals->SelectionProxies.size() <= portIndex)
{
return;
}
vtkSMSourceProxy* esProxy = this->PInternals->SelectionProxies[portIndex];
if (esProxy)
{
vtkSMInputProperty* pp = vtkSMInputProperty::SafeDownCast(
esProxy->GetProperty("Selection"));
pp->RemoveAllProxies();
pp->AddInputConnection(input, outputport);
esProxy->UpdateVTKObjects();
this->InvokeEvent(vtkCommand::SelectionChangedEvent,&portIndex);
}
}
//---------------------------------------------------------------------------
vtkSMSourceProxy* vtkSMSourceProxy::GetSelectionInput(unsigned int portIndex)
{
if (this->PInternals->SelectionProxies.size() > portIndex)
{
vtkSMSourceProxy* esProxy = this->PInternals->SelectionProxies[portIndex];
if (esProxy)
{
vtkSMInputProperty* pp = vtkSMInputProperty::SafeDownCast(
esProxy->GetProperty("Selection"));
if (pp->GetNumberOfProxies() == 1)
{
return vtkSMSourceProxy::SafeDownCast(pp->GetProxy(0));
}
}
}
return 0;
}
//---------------------------------------------------------------------------
unsigned int vtkSMSourceProxy::GetSelectionInputPort(unsigned int portIndex)
{
if (this->PInternals->SelectionProxies.size() > portIndex)
{
vtkSMSourceProxy* esProxy = this->PInternals->SelectionProxies[portIndex];
if (esProxy)
{
vtkSMInputProperty* pp = vtkSMInputProperty::SafeDownCast(
esProxy->GetProperty("Selection"));
if (pp->GetNumberOfProxies() == 1)
{
return pp->GetOutputPortForConnection(portIndex);
}
}
}
return 0;
}
//---------------------------------------------------------------------------
void vtkSMSourceProxy::CleanSelectionInputs(unsigned int portIndex)
{
if (this->PInternals->SelectionProxies.size() <= portIndex)
{
return;
}
vtkSMSourceProxy* esProxy = this->PInternals->SelectionProxies[portIndex];
if (esProxy)
{
vtkSMInputProperty* pp = vtkSMInputProperty::SafeDownCast(
esProxy->GetProperty("Selection"));
pp->RemoveAllProxies();
esProxy->UpdateVTKObjects();
this->InvokeEvent(vtkCommand::SelectionChangedEvent,&portIndex);
}
}
//---------------------------------------------------------------------------
vtkSMSourceProxy* vtkSMSourceProxy::GetSelectionOutput(unsigned int portIndex)
{
if (this->PInternals->SelectionProxies.size() > portIndex)
{
return this->PInternals->SelectionProxies[portIndex];
}
return 0;
}
//---------------------------------------------------------------------------
void vtkSMSourceProxy::PrintSelf(ostream& os, vtkIndent indent)
{
......
......@@ -122,6 +122,31 @@ public:
}
vtkPVDataInformation* GetDataInformation(unsigned int outputIdx);
// Description:
// Creates extract selection proxies for each output port if not already
// created.
void CreateSelectionProxies();
// Description:
// Set/Get the selection input. This is used to set the selection input to the
// extarction proxy for the output port identified by \c portIndex.
// If no extraction proxies are present, this method has no effect.
void SetSelectionInput(unsigned int portIndex, vtkSMSourceProxy* input,
unsigned int outputPort);
// Description:
// API to query selection input set using SetSelectionInput.
vtkSMSourceProxy* GetSelectionInput(unsigned int portIndex);
unsigned int GetSelectionInputPort(unsigned int portIndex);
// Description:
// Clean all selection inputs for the given port.
void CleanSelectionInputs(unsigned int portIndex);
// Description:
// Returns the source proxy which provides the selected data from the given
// output port.
vtkSMSourceProxy* GetSelectionOutput(unsigned int portIndex);
// Description:
// This returns information about whether the VTK algorithm supports
......@@ -149,6 +174,10 @@ public:
BOTH
};
// Description:
// Marks the selection proxies dirty as well as chain to superclass.
virtual void MarkDirty(vtkSMProxy* modifiedProxy);
protected:
vtkSMSourceProxy();
~vtkSMSourceProxy();
......@@ -192,6 +221,7 @@ protected:
// Overwritten from superclass to invoke
virtual void PostUpdateData();
bool SelectionProxiesCreated;
private:
vtkSMSourceProxyInternals* PInternals;
......
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