Commit 4679f456 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

cleanup spreadsheet view

This commit was motivated by a fix for BUG #17739. This includes the
following improvements:

1. added properties on SpreadSheetView to control aspects like hidden
   columns. There were two mechanisms at play to control the columns
   that are hidden one in the Qt part and another in the View for
   exporting. Combined those to use a single approach.
2. Simplified pqSpreadSheetViewDecorator to update properties on the
   view for things like cell connectivity, field association etc. This
   make undo/redo, state save/restore work better for several of the
   parameters. A few still remain (see #18388).
3. Changed CSV export to use column labels. Also made CSV export always
   only export visible columns. The toggle we previosly exposed doesn't
   make sense. Export capability is meant to export what is shown in the
   view. The option to export extra columns was unnecessary.
4. Added a mechansim to vtkSMViewProxy subclasses to update their
   properties when representation are hidden/shown via the controller.
   vtkSMSpreadSheetViewProxy uses this mechanism to pick a good field
   association for the visible source.
5. pqExportReaction was messing up undo/redo stack. Fixed that.
   pqExportReaction should not be affecting the undo/redo stack at all.
parent ef2da9ad
......@@ -72,7 +72,8 @@ paraview_add_test_python(
)
paraview_add_test_python(
NO_VALID NO_OUTPUT NO_RT
NO_VALID NO_RT
ExportCSV.py
Plot3DReader.py
)
......
#/usr/bin/env python
from paraview.simple import *
from paraview.vtk.util.misc import vtkGetTempDir
from os.path import join
# This test tests that exporting of CSV from spreadsheet correctly exports column
# labels and respects column visibility, including not exporting internal
# columns.
def get_header(csvfilename):
import csv
reader = csv.reader(open(csvfilename, "r"), delimiter=",")
for row in reader:
return row
return []
Sphere()
GroupDatasets()
UpdatePipeline()
Elevation()
filename = join(vtkGetTempDir(), "data.csv")
v = CreateView("SpreadSheetView")
r = Show()
ExportView(filename)
header = get_header(filename)
assert ("Normals:0" in header and \
"Block Number" in header and \
"Elevation" in header and \
"Point ID" in header and \
"__vtkIsSelected__" not in header)
v.HiddenColumnLabels = ["Normals"]
Render()
ExportView(filename)
header = get_header(filename)
assert ("Normals:0" not in header and \
"Block Number" in header and \
"Elevation" in header and \
"Point ID" in header and \
"__vtkIsSelected__" not in header)
......@@ -14,8 +14,6 @@
<pqevent object="1QMenu0/RTData/CheckBox" command="set_boolean" arguments="true" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Frame.0/CentralWidgetFrame/Viewport/pqSpreadSheetViewDecorator/actionExport" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/FileExportDialog" command="filesSelected" arguments="$PARAVIEW_DATA_ROOT/dummy" />
<pqevent object="pqClientMainWindow/1QDialog0/1pqProxyWidget0/FilterColumnsByVisibility/CheckBox" command="set_boolean" arguments="true" />
<pqevent object="pqClientMainWindow/1QDialog0/1QDialogButtonBox0/1QPushButton0" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/Delete" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/MainControlsToolbar/actionOpenData" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/FileOpenDialog" command="filesSelected" arguments="$PARAVIEW_DATA_ROOT/dummy.csv" />
......@@ -25,8 +23,6 @@
<!-- now try doing the same thing but in a tsv file -->
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Frame.0/CentralWidgetFrame/Viewport/pqSpreadSheetViewDecorator/actionExport" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/FileExportDialog" command="filesSelected" arguments="$PARAVIEW_DATA_ROOT/dummy.tsv" />
<pqevent object="pqClientMainWindow/1QDialog0/1pqProxyWidget0/FilterColumnsByVisibility/CheckBox" command="set_boolean" arguments="true" />
<pqevent object="pqClientMainWindow/1QDialog0/1QDialogButtonBox0/1QPushButton0" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/Delete" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/MainControlsToolbar/actionOpenData" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/FileOpenDialog" command="filesSelected" arguments="$PARAVIEW_DATA_ROOT/dummy.tsv" />
......
......@@ -40,8 +40,6 @@
<pqevent object="pqClientMainWindow/menubar" command="activate" arguments="menu_File" />
<pqevent object="pqClientMainWindow/menubar/menu_File" command="activate" arguments="actionExport" />
<pqevent object="pqClientMainWindow/FileExportDialog" command="filesSelected" arguments="$PARAVIEW_TEST_ROOT/data" />
<pqevent object="pqClientMainWindow/1QDialog0/1pqProxyWidget0/FilterColumnsByVisibility/CheckBox" command="set_boolean" arguments="false" />
<pqevent object="pqClientMainWindow/1QDialog0/1QDialogButtonBox0/1QPushButton0" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/menubar" command="activate" arguments="menu_File" />
<pqevent object="pqClientMainWindow/menubar/menu_File" command="activate" arguments="actionFileOpen" />
<pqevent object="pqClientMainWindow/FileOpenDialog" command="filesSelected" arguments="$PARAVIEW_TEST_ROOT/data.csv" />
......
......@@ -40,8 +40,6 @@
<pqevent object="pqClientMainWindow/menubar" command="activate" arguments="menu_File" />
<pqevent object="pqClientMainWindow/menubar/menu_File" command="activate" arguments="actionExport" />
<pqevent object="pqClientMainWindow/FileExportDialog" command="filesSelected" arguments="$PARAVIEW_TEST_ROOT/data.tsv" />
<pqevent object="pqClientMainWindow/1QDialog0/1pqProxyWidget0/FilterColumnsByVisibility/CheckBox" command="set_boolean" arguments="false" />
<pqevent object="pqClientMainWindow/1QDialog0/1QDialogButtonBox0/1QPushButton0" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/menubar" command="activate" arguments="menu_File" />
<pqevent object="pqClientMainWindow/menubar/menu_File" command="activate" arguments="actionFileOpen" />
<pqevent object="pqClientMainWindow/FileOpenDialog" command="filesSelected" arguments="$PARAVIEW_TEST_ROOT/data.tsv" />
......
......@@ -25,5 +25,4 @@
<pqevent object="pqClientMainWindow/menubar/menu_File" command="activate" arguments="actionExport" />
<pqevent object="pqClientMainWindow/FileExportDialog" command="remove" arguments="$PARAVIEW_TEST_ROOT/ExportSceneSpreadSheetView.csv" />
<pqevent object="pqClientMainWindow/FileExportDialog" command="filesSelected" arguments="$PARAVIEW_TEST_ROOT/ExportSceneSpreadSheetView.csv" />
<pqevent object="pqClientMainWindow/1QDialog0/1QDialogButtonBox0/1QPushButton0" command="activate" arguments="" />
</pqevents>
......@@ -7,7 +7,6 @@
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Frame.0/CentralWidgetFrame/EmptyView/scrollArea/qt_scrollarea_viewport/widgetFoo/ConvertActionsFrame/SpreadSheetView" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Frame.0/CentralWidgetFrame/Viewport/pqSpreadSheetViewDecorator/actionExport" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/FileExportDialog" command="filesSelected" arguments="$PARAVIEW_TEST_ROOT/ExportSceneSpreadSheetView.csv" />
<pqevent object="pqClientMainWindow/1QDialog0/1QDialogButtonBox0/1QPushButton0" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/Delete" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/MainControlsToolbar/actionOpenData" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/FileOpenDialog" command="filesSelected" arguments="$PARAVIEW_TEST_ROOT/ExportSceneSpreadSheetView.csv" />
......
......@@ -19,8 +19,6 @@
<pqevent object="pqClientMainWindow/menubar/menu_File" command="activate" arguments="actionExport" />
<pqevent object="pqClientMainWindow/FileExportDialog" command="remove" arguments="$PARAVIEW_TEST_ROOT/exportedcone.csv" />
<pqevent object="pqClientMainWindow/FileExportDialog" command="filesSelected" arguments="$PARAVIEW_TEST_ROOT/exportedcone.csv" />
<pqevent object="pqClientMainWindow/1QDialog0/1pqProxyWidget0/FilterColumnsByVisibility/CheckBox" command="set_boolean" arguments="false" />
<pqevent object="pqClientMainWindow/1QDialog0/1QDialogButtonBox0/1QPushButton0" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pipelineBrowserDock/pipelineBrowser" command="mousePress" arguments="1,1,0,76,7,/0:0/0:0" />
<pqevent object="pqClientMainWindow/pipelineBrowserDock/pipelineBrowser" command="mouseRelease" arguments="1,0,0,76,7,/0:0/0:0" />
<pqevent object="pqClientMainWindow/menubar" command="activate" arguments="menu_File" />
......@@ -70,7 +68,6 @@
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/ProxyPanel/ZColumn/ComboBox" command="set_string" arguments="Points:2" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/Accept" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/menubar/menuFilters/pqProxyGroupMenuManager0/Glyph" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/ProxyPanel/Scalars/ComboBox" command="set_string" arguments="__vtkIsSelected__" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/Accept" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pipelineBrowserDock/pipelineBrowser" command="mousePress" arguments="1,1,0,96,10,/0:0/1:0/0:0" />
<pqevent object="pqClientMainWindow/pipelineBrowserDock/pipelineBrowser" command="mouseRelease" arguments="1,0,0,96,10,/0:0/1:0/0:0" />
......
......@@ -240,6 +240,30 @@ vtkPVDataSetAttributesInformation* vtkPVDataInformation::GetAttributeInformation
return 0;
}
//----------------------------------------------------------------------------
vtkTypeInt64 vtkPVDataInformation::GetNumberOfElements(int type)
{
switch (type)
{
case vtkDataObject::POINT:
return this->GetNumberOfPoints();
case vtkDataObject::CELL:
return this->GetNumberOfCells();
case vtkDataObject::FIELD:
return this->FieldDataInformation->GetMaximumNumberOfTuples();
case vtkDataObject::VERTEX:
return this->GetNumberOfVertices();
case vtkDataObject::EDGE:
// this is odd, but we're currently accumulating edge counts in
// NumberOfCells. That should be fixed.
return this->GetNumberOfCells();
case vtkDataObject::ROW:
return this->GetNumberOfRows();
default:
return 0;
}
}
//----------------------------------------------------------------------------
void vtkPVDataInformation::Initialize()
{
......@@ -683,7 +707,7 @@ void vtkPVDataInformation::CopyFromTable(vtkTable* data)
this->Bounds[1] = this->Bounds[3] = this->Bounds[5] = -VTK_DOUBLE_MAX;
this->MemorySize = data->GetActualMemorySize();
this->NumberOfCells = data->GetNumberOfRows() * data->GetNumberOfColumns();
this->NumberOfCells = 0;
this->NumberOfPoints = 0;
this->NumberOfRows = data->GetNumberOfRows();
......@@ -863,6 +887,7 @@ void vtkPVDataInformation::AddInformation(vtkPVInformation* pvi, int addingParts
}
if (this->NumberOfPoints == 0 && this->NumberOfCells == 0 && this->NumberOfDataSets == 0 &&
this->NumberOfRows == 0 && this->NumberOfVertices == 0 &&
this->FieldDataInformation->GetNumberOfArrays() == 0)
{
// Just copy the other array information.
......@@ -905,7 +930,8 @@ void vtkPVDataInformation::AddInformation(vtkPVInformation* pvi, int addingParts
}
// Empty data set? Ignore bounds, extent and array info.
if (info->GetNumberOfCells() == 0 && info->GetNumberOfPoints() == 0)
if (info->GetNumberOfCells() == 0 && info->GetNumberOfPoints() == 0 &&
info->GetNumberOfRows() == 0 && info->GetNumberOfVertices() == 0)
{
return;
}
......
......@@ -138,6 +138,12 @@ public:
vtkGetVector6Macro(Bounds, double);
//@}
/**
* Returns the number of elements of the given type where type can
* vtkDataObject::POINT, vtkDataObject::CELL, ... etc.
*/
vtkTypeInt64 GetNumberOfElements(int type);
/**
* Returns a string describing the datatype that can be directly
* shown in a user interface.
......
......@@ -20,6 +20,7 @@
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkProcessModule.h"
#include "vtkSpreadSheetView.h"
vtkStandardNewMacro(vtkSpreadSheetRepresentation);
//----------------------------------------------------------------------------
......@@ -41,15 +42,12 @@ vtkSpreadSheetRepresentation::~vtkSpreadSheetRepresentation()
//----------------------------------------------------------------------------
void vtkSpreadSheetRepresentation::SetFieldAssociation(int val)
{
this->DataConditioner->SetFieldAssociation(val);
this->ExtractedDataConditioner->SetFieldAssociation(val);
this->MarkModified();
}
//----------------------------------------------------------------------------
int vtkSpreadSheetRepresentation::GetFieldAssociation()
{
return this->DataConditioner->GetFieldAssociation();
if (val != this->DataConditioner->GetFieldAssociation())
{
this->DataConditioner->SetFieldAssociation(val);
this->ExtractedDataConditioner->SetFieldAssociation(val);
this->MarkModified();
}
}
//----------------------------------------------------------------------------
......@@ -90,6 +88,27 @@ int vtkSpreadSheetRepresentation::FillInputPortInformation(int port, vtkInformat
return 1;
}
//----------------------------------------------------------------------------
int vtkSpreadSheetRepresentation::ProcessViewRequest(
vtkInformationRequestKey* request, vtkInformation* inInfo, vtkInformation* outInfo)
{
if (this->GetVisibility() == false)
{
return 0;
}
if (request == vtkPVView::REQUEST_UPDATE())
{
if (vtkSpreadSheetView* view = vtkSpreadSheetView::SafeDownCast(inInfo->Get(vtkPVView::VIEW())))
{
this->SetGenerateCellConnectivity(view->GetGenerateCellConnectivity());
this->SetFieldAssociation(view->GetFieldAssociation());
}
}
return this->Superclass::ProcessViewRequest(request, inInfo, outInfo);
}
//----------------------------------------------------------------------------
int vtkSpreadSheetRepresentation::RequestData(
vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector)
......@@ -149,12 +168,10 @@ void vtkSpreadSheetRepresentation::PrintSelf(ostream& os, vtkIndent indent)
//----------------------------------------------------------------------------
void vtkSpreadSheetRepresentation::SetGenerateCellConnectivity(bool v)
{
this->DataConditioner->SetGenerateCellConnectivity(v);
this->ExtractedDataConditioner->SetGenerateCellConnectivity(v);
}
//----------------------------------------------------------------------------
bool vtkSpreadSheetRepresentation::GetGenerateCellConnectivity()
{
return this->ExtractedDataConditioner->GetGenerateCellConnectivity();
if (this->DataConditioner->GetGenerateCellConnectivity() != v)
{
this->DataConditioner->SetGenerateCellConnectivity(v);
this->ExtractedDataConditioner->SetGenerateCellConnectivity(v);
this->MarkModified();
}
}
......@@ -43,6 +43,13 @@ public:
vtkTypeMacro(vtkSpreadSheetRepresentation, vtkPVDataRepresentation);
void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
/**
* Overridden to update state of `GenerateCellConnectivity` and `FieldAssociation`
* which is specified on the view.
*/
int ProcessViewRequest(vtkInformationRequestKey* request_type, vtkInformation* inInfo,
vtkInformation* outInfo) override;
/**
* Since this has no delivery, just mark ourselves modified.
*/
......@@ -52,19 +59,6 @@ public:
vtkAlgorithmOutput* GetExtractedDataProducer();
vtkAlgorithmOutput* GetSelectionProducer();
//@{
/**
* Allow user to enable/disable cell connectivity generation in the datamodel
*/
void SetGenerateCellConnectivity(bool);
bool GetGenerateCellConnectivity();
//@}
//***************************************************************************
// Forwarded to vtkBlockDeliveryPreprocessor.
void SetFieldAssociation(int val);
int GetFieldAssociation();
//@{
/**
* Select the block indices to extract.
......@@ -82,6 +76,15 @@ protected:
vtkSpreadSheetRepresentation();
~vtkSpreadSheetRepresentation() override;
//@{
/**
* This is called in `ProcessViewRequest` during the
* `vtkPVView::REQUEST_UPDATE` pass.
*/
void SetGenerateCellConnectivity(bool);
void SetFieldAssociation(int val);
//@}
/**
* Fill input port information.
*/
......
......@@ -27,12 +27,9 @@
#include "vtkPVClientServerCoreRenderingModule.h" //needed for exports
#include "vtkPVView.h"
#include <map> // For Column Visibilities
class vtkCSVExporter;
class vtkClientServerMoveData;
class vtkMarkSelectedRows;
class vtkPassArrays;
class vtkReductionFilter;
class vtkSortedTableStreamer;
class vtkTable;
......@@ -43,25 +40,25 @@ class VTKPVCLIENTSERVERCORERENDERING_EXPORT vtkSpreadSheetView : public vtkPVVie
public:
static vtkSpreadSheetView* New();
vtkTypeMacro(vtkSpreadSheetView, vtkPVView);
void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
void PrintSelf(ostream& os, vtkIndent indent) override;
/**
* Triggers a high-resolution render.
* \note CallOnAllProcesses
*/
void StillRender() VTK_OVERRIDE { this->StreamToClient(); }
void StillRender() override { this->StreamToClient(); }
/**
* Triggers a interactive render. Based on the settings on the view, this may
* result in a low-resolution rendering or a simplified geometry rendering.
* \note CallOnAllProcesses
*/
void InteractiveRender() VTK_OVERRIDE { this->StreamToClient(); }
void InteractiveRender() override { this->StreamToClient(); }
/**
* Overridden to identify and locate the active-representation.
*/
void Update() VTK_OVERRIDE;
void Update() override;
//@{
/**
......@@ -76,7 +73,7 @@ public:
//@{
/**
* Allow user to enable/disable cell connectivity generation in the datamodel
* Allow user to enable/disable cell connectivity generation.
*/
vtkSetMacro(GenerateCellConnectivity, bool);
vtkGetMacro(GenerateCellConnectivity, bool);
......@@ -85,10 +82,25 @@ public:
//@{
/**
* Manage column visibilities, used only for export
* Specify the field association for the data to be shown in the view.
* This is passed on to the vtkSpreadSheetRepresentation in `Update` pass.
*/
void SetColumnVisibility(int fieldAssociation, const char* column, int visibility);
void ClearColumnVisibilities();
vtkSetMacro(FieldAssociation, int);
vtkGetMacro(FieldAssociation, int);
//@}
//@{
/**
* This API enables the users to hide columns that should be shown.
* Columns can be hidden using their names or labels.
*/
void HideColumnByName(const char* columnName);
bool IsColumnHiddenByName(const char* columnName);
void ClearHiddenColumnsByName();
void HideColumnByLabel(const char* columnLabel);
bool IsColumnHiddenByLabel(const char* columnLabel);
void ClearHiddenColumnsByLabel();
//@}
/**
......@@ -109,6 +121,33 @@ public:
*/
const char* GetColumnName(vtkIdType index);
//@{
/**
* Returns true if the column is internal.
*/
bool IsColumnInternal(vtkIdType index);
bool IsColumnInternal(const char* columnName);
//@}
//@{
/**
* Returns the user-friendly label to use for the column
* in the spreadsheet view.
*
* If `this->IsColumnInternal(..)` is true for the chosen column. Then this
* method will return `nullptr`.
*
* \note CallOnClient
*/
const char* GetColumnLabel(vtkIdType index);
const char* GetColumnLabel(const char* columnName);
//@}
/**
* Returns the visibility for the column at the given index.
*/
bool GetColumnVisibility(vtkIdType index);
//@{
/**
* Returns the value at given location. This may result in collective
......@@ -168,7 +207,7 @@ public:
void ClearCache();
// INTERNAL METHOD. Don't call directly.
vtkTable* FetchBlockCallback(vtkIdType blockindex, bool filterColumnForExport = false);
vtkTable* FetchBlockCallback(vtkIdType blockindex);
protected:
vtkSpreadSheetView();
......@@ -184,7 +223,7 @@ protected:
void OnRepresentationUpdated();
vtkTable* FetchBlock(vtkIdType blockindex, bool filterColumnForExport = false);
vtkTable* FetchBlock(vtkIdType blockindex, bool skipCache = false);
bool ShowExtractedSelection;
bool GenerateCellConnectivity;
......@@ -192,8 +231,6 @@ protected:
vtkMarkSelectedRows* TableSelectionMarker;
vtkReductionFilter* ReductionFilter;
vtkClientServerMoveData* DeliveryFilter;
vtkPassArrays* PassFilter;
vtkIdType NumberOfRows;
enum
......@@ -208,11 +245,10 @@ private:
class vtkInternals;
friend class vtkInternals;
vtkInternals* Internals;
std::map<std::pair<int, std::string>, int> ColumnVisibilities;
bool SomethingUpdated;
unsigned long RMICallbackTag;
int FieldAssociation;
};
#endif
......@@ -14,6 +14,7 @@
=========================================================================*/
#include "vtkSMSpreadSheetRepresentationInitializationHelper.h"
#include "vtkDataObject.h"
#include "vtkNew.h"
#include "vtkObjectFactory.h"
#include "vtkPVArrayInformation.h"
......@@ -60,31 +61,22 @@ void vtkSMSpreadSheetRepresentationInitializationHelper::PostInitializeProxy(
return;
}
vtkSMSourceProxy* inputProxy =
vtkSMSourceProxy::SafeDownCast(vtkSMPropertyHelper(proxy, "Input").GetAsProxy());
vtkSMPropertyHelper inputHelper(proxy, "Input");
auto inputProxy = vtkSMSourceProxy::SafeDownCast(inputHelper.GetAsProxy());
if (inputProxy == nullptr)
{
return;
}
// reset FieldAssociation to a good default first. This is needed since this
// method gets called before the properties have been reset to their domain
// defaults.
vtkSMProperty* fieldAssociationProperty = proxy->GetProperty("FieldAssociation");
if (fieldAssociationProperty && fieldAssociationProperty->GetMTime() < ts)
{
fieldAssociationProperty->ResetToDomainDefaults();
}
unsigned int port = vtkSMPropertyHelper(proxy, "Input").GetOutputPort();
int fieldAssociation = vtkSMPropertyHelper(fieldAssociationProperty).GetAsInt();
// this is a hack to deal with statistic filters that produce a multiblock of
// tables.
unsigned int port = inputHelper.GetOutputPort();
if (vtkPVDataInformation* dataInfo = inputProxy->GetDataInformation(port))
{
vtkPVCompositeDataInformation* cdInfo = dataInfo->GetCompositeDataInformation();
if (!cdInfo->GetDataIsComposite())
if (!cdInfo->GetDataIsComposite() && dataInfo->GetDataSetType() != VTK_TABLE)
{
// data is not a composite dataset, all's good.
// data is not a composite dataset of tables , all's good.
return;
}
......@@ -100,8 +92,7 @@ void vtkSMSpreadSheetRepresentationInitializationHelper::PostInitializeProxy(
continue;
}
vtkPVDataSetAttributesInformation* attrInfo =
currentDataInfo->GetAttributeInformation(fieldAssociation);
auto attrInfo = currentDataInfo->GetAttributeInformation(vtkDataObject::ROW);
for (int cc = 0, max = attrInfo->GetNumberOfArrays(); cc < max; ++cc)
{
if (attrInfo->GetArrayInformation(cc) && !attrInfo->GetArrayInformation(cc)->GetIsPartial())
......
......@@ -64,6 +64,7 @@ set (Module_SRCS
vtkSMSelectionHelper.cxx
vtkSMSelectionLink.cxx
vtkSMSpreadSheetRepresentationProxy.cxx
vtkSMSpreadSheetViewProxy.cxx
vtkSMTextWidgetRepresentationProxy.cxx
vtkSMTransferFunctionManager.cxx
vtkSMTransferFunctionPresets.cxx
......
......@@ -375,7 +375,7 @@ vtkSMProxy* vtkSMParaViewPipelineControllerWithRendering::Show(
vtkSMPropertyHelper(repr, "Visibility").Set(1);
repr->UpdateVTKObjects();
vtkSMViewProxy::RepresentationVisibilityChanged(view, repr, true);
vtkSMViewProxy::HideOtherRepresentationsIfNeeded(view, repr);
return repr;
}
......@@ -425,6 +425,7 @@ vtkSMProxy* vtkSMParaViewPipelineControllerWithRendering::Show(
view->UpdateVTKObjects();
repr->FastDelete();
vtkSMViewProxy::RepresentationVisibilityChanged(view, repr, true);
vtkSMViewProxy::HideOtherRepresentationsIfNeeded(view, repr);
return repr;
}
......@@ -452,6 +453,7 @@ void vtkSMParaViewPipelineControllerWithRendering::ShowAll(vtkSMViewProxy* view)
{
vtkSMPropertyHelper(repr, "Visibility").Set(1);
repr->UpdateVTKObjects();
vtkSMViewProxy::RepresentationVisibilityChanged(view, repr, true);
}
}
}
......@@ -490,6 +492,7 @@ void vtkSMParaViewPipelineControllerWithRendering::Hide(vtkSMProxy* repr, vtkSMV
{
vtkSMPropertyHelper(repr, "Visibility").Set(0);
repr->UpdateVTKObjects();
vtkSMViewProxy::RepresentationVisibilityChanged(view, repr, false);
if (vtkSMParaViewPipelineControllerWithRendering::HideScalarBarOnHide)
{
......
/*=========================================================================
Program: ParaView
Module: vtkSMSpreadSheetViewProxy.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 "vtkSMSpreadSheetViewProxy.h"
#include "vtkDataObject.h"
#include "vtkObjectFactory.h"
#include "vtkPVDataInformation.h"
#include "vtkPVDataSetAttributesInformation.h"
#include "vtkSMPropertyHelper.h"
#include "vtkSMSourceProxy.h"
vtkStandardNewMacro(vtkSMSpreadSheetViewProxy);
//----------------------------------------------------------------------------
vtkSMSpreadSheetViewProxy::vtkSMSpreadSheetViewProxy()
{
}
//----------------------------------------------------------------------------
vtkSMSpreadSheetViewProxy::~vtkSMSpreadSheetViewProxy()
{
}
//----------------------------------------------------------------------------
void vtkSMSpreadSheetViewProxy::RepresentationVisibilityChanged(
vtkSMProxy* repr, bool new_visibility)
{
this->Superclass::RepresentationVisibilityChanged(repr, new_visibility);
if (repr && new_visibility)
{
// when a new representation is being made visible, we try to pick
// FieldAssociation that produces non-empty result.
vtkSMPropertyHelper inputHelper(repr, "Input", true);
if (auto input = vtkSMSourceProxy::SafeDownCast(inputHelper.GetAsProxy()))
{
auto dataInfo = input->GetDataInformation(inputHelper.GetOutputPort());
vtkSMPropertyHelper fieldAssociationHelper(this, "FieldAssociation");
if (dataInfo->GetNumberOfElements(fieldAssociationHelper.GetAsInt()) == 0)
{
// let's try to pick as association with non-empty tuples.
for (int cc = vtkDataObject::POINT; cc < vtkDataObject::NUMBER_OF_ATTRIBUTE_TYPES; ++cc)
{
if (dataInfo->GetNumberOfElements(cc) > 0)
{
fieldAssociationHelper.Set(cc);
this->UpdateVTKObjects();
break;
}
}
}
}
}
}
//----------------------------------------------------------------------------
void vtkSMSpreadSheetViewProxy::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
/*=========================================================================
Program: ParaView
Module: vtkSMSpreadSheetViewProxy.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.
=========================================================================*/
/**
* @class vtkSMSpreadSheetViewProxy
* @brief proxy for "SpreadSheetView"
*
* vtkSMSpreadSheetRepresentationProxy extends vtkSMViewProxy to override a few
* methods that add extra logic specific to this view. Namely, we override
* `RepresentationVisibilityChanged` to ensure that the view picks a default
* attribute type suitable for the visible representation.
*/
#ifndef vtkSMSpreadSheetViewProxy_h
#define vtkSMSpreadSheetViewProxy_h
#include "vtkPVServerManagerRenderingModule.h" // needed for exports
#include "vtkSMViewProxy.h"
class VTKPVSERVERMANAGERRENDERING_EXPORT vtkSMSpreadSheetViewProxy : public vtkSMViewProxy
{
public:
static vtkSMSpreadSheetViewProxy* New();
vtkTypeMacro(vtkSMSpreadSheetViewProxy, vtkSMViewProxy);
void PrintSelf(ostream& os, vtkIndent indent) override;