Commit aea5c5aa authored by Michael Migliore's avatar Michael Migliore
Browse files

Add selection by array

parent 5b9485e2
d86311707f0930cd7a22b3591148df9bdc63a5bd76342d79d5abfe05ed577c0beb53b5c2adf447804f10f5c9c5e79519a86e8449bf67cbcf3eca06887a00653e
......@@ -352,6 +352,7 @@ ExternalData_Expand_Arguments(ParaViewData _
"DATA{${CMAKE_CURRENT_SOURCE_DIR}/../Data/Baseline/SelectCellsTrace.png}"
"DATA{${CMAKE_CURRENT_SOURCE_DIR}/../Data/Baseline/SelectCellsTrace_1.png}"
"DATA{${CMAKE_CURRENT_SOURCE_DIR}/../Data/Baseline/SelectCellsTrace_2.png}"
"DATA{${CMAKE_CURRENT_SOURCE_DIR}/../Data/Baseline/SelectionByArray.png}"
"DATA{${CMAKE_CURRENT_SOURCE_DIR}/../Data/Baseline/SelectionLinkParallelCoordinatesView.png}"
"DATA{${CMAKE_CURRENT_SOURCE_DIR}/../Data/Baseline/SelectPointsFrustumTrace.png}"
"DATA{${CMAKE_CURRENT_SOURCE_DIR}/../Data/Baseline/SelectPointsInteractiveTrace.png}"
......@@ -556,6 +557,7 @@ endif()
SET(TESTS_WITH_BASELINES
DataAxesGrid.xml
MoleculeScalarBar.xml
SelectionByArray.xml
TestHiddenLineRemoval.xml
TestOpacityRendering.xml
)
......
<?xml version="1.0" ?>
<pqevents>
<pqevent object="pqClientMainWindow/menubar/menuSources/Alphabetical" command="activate" arguments="RTAnalyticSource" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/Accept" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/menubar/menuFilters/Alphabetical" command="activate" arguments="DataSetSurfaceFilter" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/Accept" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/menubar/menuFilters/Alphabetical" command="activate" arguments="PVConnectivityFilter" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/Accept" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/menubar/menuFilters/Alphabetical" command="activate" arguments="PassArrays" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/ProxyPanel/PointDataArrays/ArraySelectionWidget" command="setCheckState" arguments="0.0,0" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/ProxyPanel/PointDataArrays/ArraySelectionWidget" command="setCheckState" arguments="1.0,0" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/Accept" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/ViewFrame/ProxyPanel/OrientationAxesVisibility/CheckBox" command="set_boolean" arguments="false" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Container/Frame.0/actionInteractiveSelectSurfaceCellData" command="set_boolean" arguments="true" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Container/Frame.0/CentralWidgetFrame/Viewport" command="mousePress" arguments="(0.502404,0.429688,1,1,0)" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Container/Frame.0/CentralWidgetFrame/Viewport" command="mouseMove" arguments="(0.502404,0.429688,1,0,0)" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Container/Frame.0/CentralWidgetFrame/Viewport" command="mouseRelease" arguments="(0.502404,0.429688,1,0,0)" />
<pqevent object="pqClientMainWindow/menubar/menuFilters/Alphabetical" command="activate" arguments="ExtractSelection" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/Accept" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/representationToolbar/displayRepresentation/comboBox" command="activated" arguments="Surface With Edges" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Container/Frame.0/CentralWidgetFrame/Viewport" command="mousePress" arguments="(0.259615,0.376953,1,1,0)" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Container/Frame.0/CentralWidgetFrame/Viewport" command="mouseMove" arguments="(0.362981,0.402344,1,0,0)" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Container/Frame.0/CentralWidgetFrame/Viewport" command="mouseRelease" arguments="(0.362981,0.402344,1,0,0)" />
<pqevent object="pqClientMainWindow/variableToolbar/actionScalarBarVisibility" command="set_boolean" arguments="false" />
</pqevents>
# Selection by array from the render view
A new button has been added to the render view toolbar.\
It allows to select all the points or cells with the same array values based on the currently active array.\
The active array must be an IdType array.\
If a point data or cell data array is selected, points or cells with the same values will be selected respectively.
......@@ -43,12 +43,18 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "vtkDataObject.h"
#include "vtkIntArray.h"
#include "vtkNew.h"
#include "vtkPVArrayInformation.h"
#include "vtkPVDataInformation.h"
#include "vtkPVDataSetAttributesInformation.h"
#include "vtkPVRenderView.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkSMArrayListDomain.h"
#include "vtkSMInteractiveSelectionPipeline.h"
#include "vtkSMPVRepresentationProxy.h"
#include "vtkSMPropertyHelper.h"
#include "vtkSMRenderViewProxy.h"
#include "vtkSMSourceProxy.h"
#include "vtkSMStringVectorProperty.h"
#include "vtkSMTooltipSelectionPipeline.h"
#include <QSet>
......@@ -80,13 +86,13 @@ pqRenderViewSelectionReaction::pqRenderViewSelectionReaction(
QObject::connect(parentObject, SIGNAL(triggered(bool)), this, SLOT(actionTriggered(bool)));
// if view == NULL, we track the active view.
if (view == NULL)
// if view == nullptr, we track the active view.
if (view == nullptr)
{
QObject::connect(
&pqActiveObjects::instance(), SIGNAL(viewChanged(pqView*)), this, SLOT(setView(pqView*)));
// this ensure that the enabled-state is set correctly.
this->setView(NULL);
this->setView(nullptr);
}
if (this->Mode == CLEAR_SELECTION || this->Mode == GROW_SELECTION ||
......@@ -108,6 +114,15 @@ pqRenderViewSelectionReaction::pqRenderViewSelectionReaction(
this->DisableSelectionModifiers = false;
}
this->setRepresentation(nullptr);
if (this->Mode == SELECT_SURFACE_POINTDATA_INTERACTIVELY ||
this->Mode == SELECT_SURFACE_CELLDATA_INTERACTIVELY)
{
QObject::connect(&pqActiveObjects::instance(),
SIGNAL(representationChanged(pqDataRepresentation*)), this,
SLOT(setRepresentation(pqDataRepresentation*)));
}
this->updateEnableState();
this->MouseMovingTimer.setSingleShot(true);
......@@ -125,13 +140,13 @@ void pqRenderViewSelectionReaction::cleanupObservers()
{
for (size_t i = 0; i < sizeof(this->ObserverIds) / sizeof(this->ObserverIds[0]); ++i)
{
if (this->ObservedObject != NULL && this->ObserverIds[i] > 0)
if (this->ObservedObject != nullptr && this->ObserverIds[i] > 0)
{
this->ObservedObject->RemoveObserver(this->ObserverIds[i]);
}
this->ObserverIds[i] = 0;
}
this->ObservedObject = NULL;
this->ObservedObject = nullptr;
}
//-----------------------------------------------------------------------------
......@@ -192,6 +207,44 @@ void pqRenderViewSelectionReaction::updateEnableState()
paction->setEnabled(false);
}
break;
case SELECT_SURFACE_POINTDATA_INTERACTIVELY:
case SELECT_SURFACE_CELLDATA_INTERACTIVELY:
{
bool state = false;
if (this->Representation)
{
vtkSMProxy* proxy = this->Representation->getProxy();
vtkSMStringVectorProperty* prop =
vtkSMStringVectorProperty::SafeDownCast(proxy->GetProperty("ColorArrayName"));
if (prop)
{
int association = std::atoi(prop->GetElement(3));
const char* arrayName = prop->GetElement(4);
vtkPVDataInformation* dataInfo = this->Representation->getInputDataInformation();
vtkPVDataSetAttributesInformation* info = nullptr;
if (association == vtkDataObject::CELL &&
this->Mode == SELECT_SURFACE_CELLDATA_INTERACTIVELY)
{
info = dataInfo->GetCellDataInformation();
}
if (association == vtkDataObject::POINT &&
this->Mode == SELECT_SURFACE_POINTDATA_INTERACTIVELY)
{
info = dataInfo->GetPointDataInformation();
}
if (info)
{
vtkPVArrayInformation* arrayInfo = info->GetArrayInformation(arrayName);
state = arrayInfo && arrayInfo->GetDataType() == VTK_ID_TYPE;
}
}
}
paction->setEnabled(state);
}
break;
default:
paction->setEnabled(true);
break;
......@@ -210,7 +263,36 @@ void pqRenderViewSelectionReaction::setView(pqView* view)
this->View = qobject_cast<pqRenderView*>(view);
// update enable state.
this->parentAction()->setEnabled(this->View != NULL);
this->parentAction()->setEnabled(this->View != nullptr);
}
//-----------------------------------------------------------------------------
void pqRenderViewSelectionReaction::setRepresentation(pqDataRepresentation* representation)
{
if (this->Representation != representation)
{
// if we are currently in selection, finish that before changing the representation.
this->endSelection();
if (this->Representation != nullptr)
{
QObject::disconnect(this->RepresentationConnection);
}
this->Representation = representation;
if (this->Representation != nullptr)
{
this->RepresentationConnection = QObject::connect(
this->Representation, &pqDataRepresentation::colorArrayNameModified, this, [this]() {
this->endSelection();
this->updateEnableState();
});
}
// update enable state.
this->updateEnableState();
}
}
//-----------------------------------------------------------------------------
......@@ -262,6 +344,8 @@ void pqRenderViewSelectionReaction::beginSelection()
vtkSMPropertyHelper(rmp, "InteractionMode").Set(vtkPVRenderView::INTERACTION_MODE_SELECTION);
break;
case SELECT_SURFACE_POINTDATA_INTERACTIVELY:
case SELECT_SURFACE_CELLDATA_INTERACTIVELY:
case SELECT_SURFACE_CELLS_INTERACTIVELY:
case SELECT_SURFACE_POINTS_INTERACTIVELY:
pqCoreUtilities::promptUser("pqInteractiveSelection", QMessageBox::Information,
......@@ -344,7 +428,7 @@ void pqRenderViewSelectionReaction::beginSelection()
rmp->UpdateVTKObjects();
// Setup observer.
assert(this->ObserverIds[0] == 0 && this->ObservedObject == NULL && this->ObserverIds[1] == 0);
assert(this->ObserverIds[0] == 0 && this->ObservedObject == nullptr && this->ObserverIds[1] == 0);
switch (this->Mode)
{
case ZOOM_TO_BOX:
......@@ -356,6 +440,8 @@ void pqRenderViewSelectionReaction::beginSelection()
case CLEAR_SELECTION:
break;
case SELECT_SURFACE_POINTDATA_INTERACTIVELY:
case SELECT_SURFACE_CELLDATA_INTERACTIVELY:
case SELECT_SURFACE_CELLS_INTERACTIVELY:
case SELECT_SURFACE_POINTS_INTERACTIVELY:
this->ObservedObject = rmp->GetInteractor();
......@@ -399,7 +485,7 @@ void pqRenderViewSelectionReaction::endSelection()
return;
}
pqRenderViewSelectionReaction::ActiveReaction = NULL;
pqRenderViewSelectionReaction::ActiveReaction = nullptr;
vtkSMRenderViewProxy* rmp = this->View->getRenderViewProxy();
vtkSMPropertyHelper(rmp, "InteractionMode").Set(this->PreviousRenderViewMode);
this->PreviousRenderViewMode = -1;
......@@ -496,6 +582,8 @@ void pqRenderViewSelectionReaction::onMouseMove()
this->MouseMoving = true;
VTK_FALLTHROUGH;
case SELECT_SURFACE_POINTDATA_INTERACTIVELY:
case SELECT_SURFACE_CELLDATA_INTERACTIVELY:
case SELECT_SURFACE_CELLS_INTERACTIVELY:
case SELECT_SURFACE_POINTS_INTERACTIVELY:
this->preSelection();
......@@ -517,7 +605,7 @@ void pqRenderViewSelectionReaction::preSelection()
}
vtkSMRenderViewProxy* rmp = this->View->getRenderViewProxy();
assert(rmp != NULL);
assert(rmp != nullptr);
int x = rmp->GetInteractor()->GetEventPosition()[0];
int y = rmp->GetInteractor()->GetEventPosition()[1];
......@@ -526,6 +614,8 @@ void pqRenderViewSelectionReaction::preSelection()
vtkSMPreselectionPipeline* pipeline;
switch (this->Mode)
{
case SELECT_SURFACE_POINTDATA_INTERACTIVELY:
case SELECT_SURFACE_CELLDATA_INTERACTIVELY:
case SELECT_SURFACE_CELLS_INTERACTIVELY:
case SELECT_SURFACE_POINTS_INTERACTIVELY:
pipeline = vtkSMInteractiveSelectionPipeline::GetInstance();
......@@ -557,24 +647,50 @@ void pqRenderViewSelectionReaction::preSelection()
bool status = false;
switch (this->Mode)
{
case SELECT_SURFACE_POINTDATA_INTERACTIVELY:
case SELECT_SURFACE_CELLDATA_INTERACTIVELY:
{
pqDataRepresentation* repr = pqActiveObjects::instance().activeRepresentation();
if (repr)
{
vtkSMStringVectorProperty* prop =
vtkSMStringVectorProperty::SafeDownCast(repr->getProxy()->GetProperty("ColorArrayName"));
if (prop)
{
int association = std::atoi(prop->GetElement(3));
const char* arrayName = prop->GetElement(4);
if (association == vtkDataObject::CELL &&
this->Mode == SELECT_SURFACE_CELLDATA_INTERACTIVELY)
{
status = rmp->SelectSurfaceCells(
region, selectedRepresentations, selectionSources, false, 0, false, arrayName);
}
if (association == vtkDataObject::POINT &&
this->Mode == SELECT_SURFACE_POINTDATA_INTERACTIVELY)
{
status = rmp->SelectSurfacePoints(
region, selectedRepresentations, selectionSources, false, 0, false, arrayName);
}
}
}
}
break;
case SELECT_SURFACE_CELLS_INTERACTIVELY:
status = rmp->SelectSurfaceCells(
region, selectedRepresentations.GetPointer(), selectionSources.GetPointer());
status = rmp->SelectSurfaceCells(region, selectedRepresentations, selectionSources);
break;
case SELECT_SURFACE_POINTS_INTERACTIVELY:
status = rmp->SelectSurfacePoints(
region, selectedRepresentations.GetPointer(), selectionSources.GetPointer());
status = rmp->SelectSurfacePoints(region, selectedRepresentations, selectionSources);
break;
case SELECT_SURFACE_POINTS_TOOLTIP:
status = rmp->SelectSurfacePoints(
region, selectedRepresentations.GetPointer(), selectionSources.GetPointer());
status = rmp->SelectSurfacePoints(region, selectedRepresentations, selectionSources);
break;
case SELECT_SURFACE_CELLS_TOOLTIP:
status = rmp->SelectSurfaceCells(
region, selectedRepresentations.GetPointer(), selectionSources.GetPointer());
status = rmp->SelectSurfaceCells(region, selectedRepresentations, selectionSources);
break;
default:
......@@ -654,7 +770,7 @@ void pqRenderViewSelectionReaction::onLeftButtonRelease()
}
vtkSMRenderViewProxy* viewProxy = this->View->getRenderViewProxy();
assert(viewProxy != NULL);
assert(viewProxy != nullptr);
int x = viewProxy->GetInteractor()->GetEventPosition()[0];
int y = viewProxy->GetInteractor()->GetEventPosition()[1];
......@@ -675,6 +791,32 @@ void pqRenderViewSelectionReaction::onLeftButtonRelease()
switch (this->Mode)
{
case SELECT_SURFACE_POINTDATA_INTERACTIVELY:
case SELECT_SURFACE_CELLDATA_INTERACTIVELY:
{
pqDataRepresentation* repr = pqActiveObjects::instance().activeRepresentation();
if (repr)
{
vtkSMStringVectorProperty* prop =
vtkSMStringVectorProperty::SafeDownCast(repr->getProxy()->GetProperty("ColorArrayName"));
if (prop)
{
int association = std::atoi(prop->GetElement(3));
const char* arrayName = prop->GetElement(4);
if (association == vtkDataObject::CELL)
{
this->View->selectOnSurface(region, selectionModifier, arrayName);
}
else
{
this->View->selectPointsOnSurface(region, selectionModifier, arrayName);
}
}
}
}
break;
case SELECT_SURFACE_CELLS_INTERACTIVELY:
this->View->selectOnSurface(region, selectionModifier);
break;
......@@ -695,7 +837,7 @@ int pqRenderViewSelectionReaction::getSelectionModifier()
int selectionModifier = this->Superclass::getSelectionModifier();
vtkSMRenderViewProxy* rmp = this->View->getRenderViewProxy();
assert(rmp != NULL);
assert(rmp != nullptr);
bool ctrl = rmp->GetInteractor()->GetControlKey() == 1;
bool shift = rmp->GetInteractor()->GetShiftKey() == 1;
......
......@@ -38,6 +38,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QPointer>
#include <QTimer>
class pqDataRepresentation;
class pqRenderView;
class pqView;
class vtkIntArray;
......@@ -72,6 +73,8 @@ public:
CLEAR_SELECTION,
GROW_SELECTION,
SHRINK_SELECTION,
SELECT_SURFACE_POINTDATA_INTERACTIVELY,
SELECT_SURFACE_CELLDATA_INTERACTIVELY,
SELECT_SURFACE_CELLS_INTERACTIVELY,
SELECT_SURFACE_POINTS_INTERACTIVELY,
SELECT_SURFACE_POINTS_TOOLTIP,
......@@ -112,6 +115,11 @@ private slots:
*/
void setView(pqView* view);
/**
* Called when the active representation changes.
*/
void setRepresentation(pqDataRepresentation* representation);
/**
* starts the selection i.e. setup render view in selection mode.
*/
......@@ -165,6 +173,8 @@ private:
private:
Q_DISABLE_COPY(pqRenderViewSelectionReaction)
QPointer<pqRenderView> View;
QPointer<pqDataRepresentation> Representation;
QMetaObject::Connection RepresentationConnection;
SelectionMode Mode;
bool DisableSelectionModifiers;
int PreviousRenderViewMode;
......
......@@ -471,6 +471,37 @@ void pqStandardViewFrameActionsImplementation::addRenderViewActions(
this->connect(selectBlockAction, SIGNAL(toggled(bool)), SLOT(escapeableActionToggled(bool)));
}
if (this->isButtonVisible("InteractiveSelectSurfacePointData", renderView))
{
QAction* interactiveSelectSurfacePointDataAction = frame->addTitleBarAction(
QIcon(":/pqWidgets/Icons/pqSurfaceSelectionPointDataInteractive.png"),
"Interactive Select Point Data On");
interactiveSelectSurfacePointDataAction->setObjectName(
"actionInteractiveSelectSurfacePointData");
interactiveSelectSurfacePointDataAction->setCheckable(true);
new pqRenderViewSelectionReaction(interactiveSelectSurfacePointDataAction, renderView,
pqRenderViewSelectionReaction::SELECT_SURFACE_POINTDATA_INTERACTIVELY, modeGroup);
this->connect(interactiveSelectSurfacePointDataAction, SIGNAL(toggled(bool)),
SLOT(escapeableActionToggled(bool)));
this->connect(interactiveSelectSurfacePointDataAction, SIGNAL(toggled(bool)),
SLOT(interactiveSelectionToggled(bool)));
}
if (this->isButtonVisible("InteractiveSelectSurfaceCellData", renderView))
{
QAction* interactiveSelectSurfaceCellDataAction =
frame->addTitleBarAction(QIcon(":/pqWidgets/Icons/pqSurfaceSelectionCellDataInteractive.png"),
"Interactive Select Cell Data On");
interactiveSelectSurfaceCellDataAction->setObjectName("actionInteractiveSelectSurfaceCellData");
interactiveSelectSurfaceCellDataAction->setCheckable(true);
new pqRenderViewSelectionReaction(interactiveSelectSurfaceCellDataAction, renderView,
pqRenderViewSelectionReaction::SELECT_SURFACE_CELLDATA_INTERACTIVELY, modeGroup);
this->connect(interactiveSelectSurfaceCellDataAction, SIGNAL(toggled(bool)),
SLOT(escapeableActionToggled(bool)));
this->connect(interactiveSelectSurfaceCellDataAction, SIGNAL(toggled(bool)),
SLOT(interactiveSelectionToggled(bool)));
}
if (this->isButtonVisible("InteractiveSelectSurfaceCells", renderView))
{
QAction* interactiveSelectSurfaceCellsAction =
......
......@@ -240,7 +240,9 @@
<file>Icons/pqSurfaceHoveringCell.png</file>
<file>Icons/pqSurfaceHoveringCell@2x.png</file>
<file>Icons/pqSurfaceSelectionCell24.png</file>
<file>Icons/pqSurfaceSelectionCellDataInteractive.png</file>
<file>Icons/pqSurfaceSelectionCellInteractive.png</file>
<file>Icons/pqSurfaceSelectionPointDataInteractive.png</file>
<file>Icons/pqSurfaceSelectionPointInteractive.png</file>
<file>Icons/pqSurfaceSelectionPoint24.png</file>
<file>Icons/pqThreshold24.png</file>
......
......@@ -541,10 +541,10 @@ void pqRenderView::resetViewDirection(
}
//-----------------------------------------------------------------------------
void pqRenderView::selectOnSurface(int rect[4], int selectionModifier)
void pqRenderView::selectOnSurface(int rect[4], int selectionModifier, const char* array)
{
QList<pqOutputPort*> opPorts;
this->selectOnSurfaceInternal(rect, opPorts, false, selectionModifier, false);
this->selectOnSurfaceInternal(rect, opPorts, false, selectionModifier, false, array);
this->emitSelectionSignal(opPorts);
}
......@@ -670,7 +670,7 @@ void pqRenderView::collectSelectionPorts(vtkCollection* selectedRepresentations,
//-----------------------------------------------------------------------------
void pqRenderView::selectOnSurfaceInternal(int rect[4], QList<pqOutputPort*>& pqOutputPorts,
bool select_points, int selectionModifier, bool select_blocks)
bool select_points, int selectionModifier, bool select_blocks, const char* array)
{
BEGIN_UNDO_EXCLUDE();
......@@ -685,12 +685,12 @@ void pqRenderView::selectOnSurfaceInternal(int rect[4], QList<pqOutputPort*>& pq
rectVector[i] = rect[i];
}
vtkSmartPointer<vtkCollection> selectedRepresentations = vtkSmartPointer<vtkCollection>::New();
vtkSmartPointer<vtkCollection> selectionSources = vtkSmartPointer<vtkCollection>::New();
vtkNew<vtkCollection> selectedRepresentations;
vtkNew<vtkCollection> selectionSources;
if (select_points)
{
if (!renderModuleP->SelectSurfacePoints(rect, selectedRepresentations, selectionSources,
this->UseMultipleRepresentationSelection, selectionModifier, select_blocks))
this->UseMultipleRepresentationSelection, selectionModifier, select_blocks, array))
{
END_UNDO_EXCLUDE();
return;
......@@ -704,7 +704,7 @@ void pqRenderView::selectOnSurfaceInternal(int rect[4], QList<pqOutputPort*>& pq
else
{
if (!renderModuleP->SelectSurfaceCells(rect, selectedRepresentations, selectionSources,
this->UseMultipleRepresentationSelection, selectionModifier, select_blocks))
this->UseMultipleRepresentationSelection, selectionModifier, select_blocks, array))
{
END_UNDO_EXCLUDE();
return;
......@@ -733,10 +733,10 @@ void pqRenderView::selectOnSurfaceInternal(int rect[4], QList<pqOutputPort*>& pq
}
//-----------------------------------------------------------------------------
void pqRenderView::selectPointsOnSurface(int rect[4], int selectionModifier)
void pqRenderView::selectPointsOnSurface(int rect[4], int selectionModifier, const char* array)
{
QList<pqOutputPort*> output_ports;
this->selectOnSurfaceInternal(rect, output_ports, true, selectionModifier, false);
this->selectOnSurfaceInternal(rect, output_ports, true, selectionModifier, false, array);
// Fire selection event to let the world know that this view selected
// something.
this->emitSelectionSignal(output_ports);
......
......@@ -186,10 +186,10 @@ public:
* Creates a new surface selection given the rectangle in display
* coordinates.
*/
virtual void selectOnSurface(
int rectangle[4], int selectionModifier = pqView::PV_SELECTION_DEFAULT);
virtual void selectPointsOnSurface(
int rectangle[4], int selectionModifier = pqView::PV_SELECTION_DEFAULT);
virtual void selectOnSurface(int rectangle[4],
int selectionModifier = pqView::PV_SELECTION_DEFAULT, const char* array = nullptr);
virtual void selectPointsOnSurface(int rectangle[4],
int selectionModifier = pqView::PV_SELECTION_DEFAULT, const char* array = nullptr);
/**
* Picks the representation at the given position.
......@@ -355,7 +355,7 @@ protected:
private:
void selectOnSurfaceInternal(int rect[4], QList<pqOutputPort*>&, bool select_points,
int selectionModifier, bool select_blocks);
int selectionModifier, bool select_blocks, const char* array = nullptr);
void selectPolygonInternal(vtkIntArray* polygon, QList<pqOutputPort*>&, bool select_points,
int selectionModifier, bool select_blocks);
......
......@@ -162,12 +162,13 @@ vtkGeometryRepresentation::vtkGeometryRepresentation()
// setup the selection mapper so that we don't need to make any selection
// conversions after rendering.
vtkCompositePolyDataMapper2* mapper = vtkCompositePolyDataMapper2::New();
mapper->SetPointIdArrayName("vtkOriginalPointIds");
mapper->SetCellIdArrayName("vtkOriginalCellIds");
mapper->SetProcessIdArrayName("vtkProcessId");
mapper->SetCompositeIdArrayName("vtkCompositeIndex");
this->Mapper = mapper;
this->SetArrayIdNames(nullptr, nullptr);
this->LODMapper = vtkCompositePolyDataMapper2::New();
this->Actor = vtkPVLODActor::New();
this->Property = vtkProperty::New();
......@@ -1475,3 +1476,11 @@ void vtkGeometryRepresentation::UpdateShaderReplacements()
}
}
}
//----------------------------------------------------------------------------
void vtkGeometryRepresentation::SetArrayIdNames(const char* pointArray, const char* cellArray)
{
vtkCompositePolyDataMapper2* mapper = vtkCompositePolyDataMapper2::SafeDownCast(this->Mapper);
mapper->SetPointIdArrayName(pointArray ? pointArray : "vtkOriginalPointIds");
mapper->SetCellIdArrayName(cellArray ? cellArray : "vtkOriginalCellIds");
}
......@@ -306,6 +306,12 @@ public:
*/
virtual void SetShaderReplacements(const char*);
/**
* Specify the array names used for the selection.
* Use nullptr to use default ones. ("vtkOriginalPointIds" and "vtkOriginalCellIds")
*/
virtual void SetArrayIdNames(const char* pointArray, const char* cellArray);
protected:
vtkGeometryRepresentation();