Commit 2b16ad91 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

Added ability for selection representations to use original selection.

There are cases (e.g. Histogram View/Representation) where the
selection-representation needs the original input selection (and not the
selection converted to IDs). Added mechanism for that.

vtkPVExtractSelection now has a 3rd output which is simply the same as
its inputs. vtkSMChartRepresentationProxy can pass either the 2nd or 3rd
output from vtkPVExtractSelection to the selection representation proxy
based on how the property was named.

Change-Id: I06ebeef9e9ff8168dacafe520e6c7d1202f2de59
parent e05fd379
......@@ -52,7 +52,7 @@ vtkStandardNewMacro(vtkPVExtractSelection);
//----------------------------------------------------------------------------
vtkPVExtractSelection::vtkPVExtractSelection()
{
this->SetNumberOfOutputPorts(2);
this->SetNumberOfOutputPorts(3);
}
//----------------------------------------------------------------------------
......@@ -68,7 +68,7 @@ int vtkPVExtractSelection::FillOutputPortInformation(
{
info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkDataObject");
}
else
else // for port 1, 2
{
info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkSelection");
}
......@@ -127,6 +127,12 @@ int vtkPVExtractSelection::RequestData(
return 1;
}
if (vtkSelection* output2 = vtkSelection::GetData(outputVector, 2))
{
// See vtkPVSingleOutputExtractSelection to know why this check is needed.
output2->ShallowCopy(sel);
}
if (sel->GetNumberOfNodes() >= 1 && sel->GetNode(0)->GetContentType() == vtkSelectionNode::QUERY)
{
#ifdef PARAVIEW_ENABLE_PYTHON
......@@ -178,8 +184,7 @@ int vtkPVExtractSelection::RequestData(
// so to add support for vtkGraph selection in ParaView the filter will have
// to be extended. This requires test cases in ParaView to confirm it functions
// as expected.
vtkSelection *output = vtkSelection::SafeDownCast(
outputVector->GetInformationObject(1)->Get(vtkDataObject::DATA_OBJECT()));
vtkSelection *output = vtkSelection::GetData(outputVector, 1);
output->Initialize();
......
......@@ -12,8 +12,9 @@
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkPVExtractSelection - Adds a second port to vtkExtractSelection,
// the second port contains an id selection.
// .NAME vtkPVExtractSelection - Adds a two more output ports to vtkExtractSelection,
// the second port contains an id selection and the third is simply the input
// selection.
// .SECTION Description
// vtkPVExtractSelection adds a second port to vtkExtractSelection.
// \li Output port 0 -- is the output from the superclass. It's nothing but the
......@@ -28,6 +29,11 @@
// This second output is useful for correlating particular
// cells in the subset with the original data set. This is used, for instance,
// by Chart representations to show selections.
//
// \li Output port 2 -- is simply the input vtkSelection. We currently use this
// for Histogram View/Representation. Since that view cannot show arbitrary ID
// based selections, it needs to get to the original vtkSelection to determine
// if the particular selection can be shown in the view at all.
// .SECTION See Also
// vtkExtractSelection vtkSelection
......@@ -45,6 +51,10 @@ public:
vtkTypeMacro(vtkPVExtractSelection,vtkExtractSelection);
void PrintSelf(ostream& os, vtkIndent indent);
static const int OUTPUT_PORT_EXTRACTED_DATASET = 0;
static const int OUTPUT_PORT_SELECTION_IDS = 1;
static const int OUTPUT_PORT_SELECTION_ORIGINAL = 2;
// Description:
// Constructor
static vtkPVExtractSelection *New();
......
......@@ -17,6 +17,7 @@
#include "vtkChartRepresentation.h"
#include "vtkClientServerStream.h"
#include "vtkObjectFactory.h"
#include "vtkPVExtractSelection.h"
#include "vtkPVXMLElement.h"
#include "vtkSMChartSeriesListDomain.h"
#include "vtkSMDomain.h"
......@@ -108,7 +109,15 @@ void vtkSMChartRepresentationProxy::SetPropertyModifiedFlag(
{
// We use these internal properties since we need to add consumer dependecy
// on this proxy so that MarkModified() is called correctly.
vtkSMPropertyHelper(selectionReprProxy, "SelectionInput").Set(esProxy, 1);
// Based on the name of the Property, we either pass the id-based
// selection generated by vtkPVExtractSelection or the original
// input selection to the selection representation.
vtkSMPropertyHelper(selectionReprProxy, "SelectionInput", /*quiet*/ true).Set(
esProxy, vtkPVExtractSelection::OUTPUT_PORT_SELECTION_IDS);
vtkSMPropertyHelper(selectionReprProxy, "OriginalSelectionInput", /*quiet*/ true).Set(
esProxy, vtkPVExtractSelection::OUTPUT_PORT_SELECTION_ORIGINAL);
selectionReprProxy->UpdateVTKObjects();
}
}
......
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