Commit 4fab76b7 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit Committed by Kitware Robot

Merge topic 'better-spreadsheet-header'

eff1085f update SpreadSheetNullArrayName
31010e74 Support multi-component arrays in spreadsheet
851d36d4 ensure array information is copied in vtkSortedTableStreamer.
66f5c83b remove "SelectedComponent" from Spreadsheet view
b627e50e remove unnecessary addins from pqSpreadSheetViewWidget.
da6806eb cleanup vtkAttributeDataToTableFilter
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Reviewed-by: Cory Quammen's avatarCory Quammen <cory.quammen@kitware.com>
Merge-request: !2743
parents fd39ef33 eff1085f
Pipeline #121843 failed with stage
in 0 seconds
......@@ -25,7 +25,8 @@ r = Show()
ExportView(filename)
header = get_header(filename)
assert ("Normals:0" in header and \
print(header)
assert ("Normals_0" in header and \
"Block Number" in header and \
"Elevation" in header and \
"Point ID" in header and \
......@@ -36,7 +37,7 @@ Render()
ExportView(filename)
header = get_header(filename)
assert ("Normals:0" not in header and \
assert ("Normals_0" not in header and \
"Block Number" in header and \
"Elevation" in header and \
"Point ID" in header and \
......
......@@ -13,10 +13,10 @@
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Splitter.0/Splitter.2/Frame.6/CentralWidgetFrame/Viewport/pqSpreadSheetViewDecorator/Attribute" command="set_string" arguments="Cell Data" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Splitter.0/Splitter.2/Frame.6/CentralWidgetFrame/Viewport/pqSpreadSheetViewDecorator/Attribute" command="set_string" arguments="Point Data" />
<!-- begin sort by RTData -->
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Splitter.0/Splitter.2/Frame.6/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0/1QHeaderView1" command="mousePress" arguments="1,1,0,0,0,0" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Splitter.0/Splitter.2/Frame.6/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0/1QHeaderView1" command="mouseRelease" arguments="1,0,0,0,0,0" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Splitter.0/Splitter.2/Frame.6/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0/1QHeaderView1" command="mousePress" arguments="1,1,0,0,0,0" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Splitter.0/Splitter.2/Frame.6/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0/1QHeaderView1" command="mouseRelease" arguments="1,0,0,0,0,0" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Splitter.0/Splitter.2/Frame.6/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0/Header" command="mousePress" arguments="1,1,0,0,0,0" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Splitter.0/Splitter.2/Frame.6/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0/Header" command="mouseRelease" arguments="1,0,0,0,0,0" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Splitter.0/Splitter.2/Frame.6/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0/Header" command="mousePress" arguments="1,1,0,0,0,0" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Splitter.0/Splitter.2/Frame.6/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0/Header" command="mouseRelease" arguments="1,0,0,0,0,0" />
<!-- end sort by RTData -->
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Splitter.0/Splitter.2/Frame.6/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0" command="mousePress" arguments="1,1,0,51,14,/0:0" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Splitter.0/Splitter.2/Frame.6/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0" command="mouseRelease" arguments="1,0,0,51,14,/0:0" />
......
......@@ -19,8 +19,4 @@
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget2/Frame.0/CentralWidgetFrame/Viewport/pqSpreadSheetViewDecorator/Attribute" command="activated" arguments="Cell Data" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget2/Frame.0/CentralWidgetFrame/Viewport/pqSpreadSheetViewDecorator/Source" command="activated" arguments="ProgrammableFilter1" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget2/Frame.0/CentralWidgetFrame/Viewport/pqSpreadSheetViewDecorator/Attribute" command="activated" arguments="Point Data" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget2/Frame.0/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0/1QHeaderView1" command="mousePress" arguments="1,1,0,0,0,1" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget2/Frame.0/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0/1QHeaderView1" command="mouseRelease" arguments="1,0,0,0,0,1" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget2/Frame.0/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0/1QHeaderView1" command="mousePress" arguments="1,1,0,0,0,1" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget2/Frame.0/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0/1QHeaderView1" command="mouseRelease" arguments="1,0,0,0,0,1" />
</pqevents>
......@@ -64,9 +64,9 @@
<pqevent object="pqClientMainWindow/pipelineBrowserDock/pipelineBrowser" command="mouseRelease" arguments="1,0,0,63,8,/0:0/0:0" />
<pqevent object="pqClientMainWindow/menubar" command="activate" arguments="menuFilters" />
<pqevent object="pqClientMainWindow/menubar/menuFilters/Recent" command="activate" arguments="TableToPolyData" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/ProxyPanel/XColumn/ComboBox" command="set_string" arguments="Points:0" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/ProxyPanel/YColumn/ComboBox" command="set_string" arguments="Points:1" />
<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/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/ProxyPanel/XColumn/ComboBox" command="set_string" arguments="Points_0" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/ProxyPanel/YColumn/ComboBox" command="set_string" arguments="Points_1" />
<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/Accept" command="activate" arguments="" />
......
# Improvements to viewing multi-component arrays in the Spreadsheet View
* Spreadsheet view can now show mutli-component arrays as multi-columns with a
joined header. Individual component columns are still user-resizable, just
like any other column.
......@@ -28,9 +28,15 @@ vtkSpreadSheetRepresentation::vtkSpreadSheetRepresentation()
{
this->SetNumberOfInputPorts(3);
this->DataConditioner->SetGenerateOriginalIds(1);
this->DataConditioner->SetFlattenTable(true);
this->DataConditioner->SetSplitComponentsNamingMode(
vtkSplitColumnComponents::NUMBERS_WITH_UNDERSCORES);
this->CleanArrays->SetInputConnection(this->DataConditioner->GetOutputPort());
this->ExtractedDataConditioner->SetGenerateOriginalIds(0);
this->ExtractedDataConditioner->SetFlattenTable(true);
this->ExtractedDataConditioner->SetSplitComponentsNamingMode(
vtkSplitColumnComponents::NUMBERS_WITH_UNDERSCORES);
this->ExtractedCleanArrays->SetInputConnection(this->ExtractedDataConditioner->GetOutputPort());
}
......
......@@ -27,6 +27,8 @@
#include "vtkPVClientServerCoreRenderingModule.h" //needed for exports
#include "vtkPVView.h"
#include <string> // for std::string
class vtkCSVExporter;
class vtkClientServerMoveData;
class vtkMarkSelectedRows;
......@@ -99,7 +101,7 @@ public:
void ClearHiddenColumnsByName();
void HideColumnByLabel(const char* columnLabel);
bool IsColumnHiddenByLabel(const char* columnLabel);
bool IsColumnHiddenByLabel(const std::string& columnLabel);
void ClearHiddenColumnsByLabel();
//@}
......@@ -139,8 +141,8 @@ public:
*
* \note CallOnClient
*/
const char* GetColumnLabel(vtkIdType index);
const char* GetColumnLabel(const char* columnName);
std::string GetColumnLabel(vtkIdType index);
std::string GetColumnLabel(const char* columnName);
//@}
/**
......@@ -178,12 +180,6 @@ public:
void SetColumnNameToSort(const char*);
void SetColumnNameToSort() { this->SetColumnNameToSort(NULL); }
/**
* Get/Set the component to sort with. Use -1 (default) for magnitude.
* \note CallOnAllProcesses
*/
void SetComponentToSort(int val);
/**
* Get/Set whether the sort order must be Max to Min rather than Min to Max.
* \note CallOnAllProcesses
......@@ -223,7 +219,7 @@ protected:
void OnRepresentationUpdated();
vtkTable* FetchBlock(vtkIdType blockindex, bool skipCache = false);
vtkTable* FetchBlock(vtkIdType blockindex);
bool ShowExtractedSelection;
bool GenerateCellConnectivity;
......
......@@ -3530,13 +3530,6 @@
number_of_elements="1"
panel_visibility="never">
</StringVectorProperty>
<IntVectorProperty command="SetComponentToSort"
default_values="-1"
name="SelectedComponent"
number_of_elements="1"
panel_visibility="advanced">
<IntRangeDomain name="range" />
</IntVectorProperty>
<IntVectorProperty command="SetInvertSortOrder"
default_values="0"
name="InvertOrder"
......
......@@ -29,6 +29,7 @@
#include "vtkPVVTKExtensionsRenderingModule.h" // needed for export macro
#include "vtkTableAlgorithm.h"
class vtkDataSet;
class vtkFieldData;
class vtkIdTypeArray;
......@@ -105,19 +106,13 @@ protected:
*/
vtkExecutive* CreateDefaultExecutive() VTK_OVERRIDE;
/**
* Internal method to return the chosen field from the input. May return 0 is
* the chosen field is not applicable for the current data object or not
* present.
*/
vtkFieldData* GetSelectedField(vtkDataObject* input);
/**
* Called when AddMetaData is true. Adds meta-data to the output.
*/
void Decorate(vtkTable* output, vtkDataObject* input);
void PassFieldData(vtkFieldData* output, vtkFieldData* input);
void AddCellTypeAndConnectivity(vtkTable* output, vtkDataSet* ds);
int FieldAssociation;
bool AddMetaData;
......
......@@ -15,7 +15,6 @@
#include "vtkBlockDeliveryPreprocessor.h"
#include "vtkAttributeDataToTableFilter.h"
#include "vtkCompositeDataPipeline.h"
#include "vtkExtractBlock.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
......@@ -25,7 +24,6 @@
#include "vtkSelection.h"
#include "vtkSelectionNode.h"
#include "vtkSmartPointer.h"
#include "vtkSplitColumnComponents.h"
#include "vtkTable.h"
#include "vtkUniformGridAMRDataIterator.h"
......@@ -38,18 +36,20 @@ class vtkBlockDeliveryPreprocessor::CompositeDataSetIndicesType : public std::se
vtkStandardNewMacro(vtkBlockDeliveryPreprocessor);
//----------------------------------------------------------------------------
vtkBlockDeliveryPreprocessor::vtkBlockDeliveryPreprocessor()
: FieldAssociation(vtkDataObject::FIELD_ASSOCIATION_POINTS)
, FlattenTable(0)
, GenerateOriginalIds(true)
, GenerateCellConnectivity(false)
, SplitComponentsNamingMode(vtkSplitColumnComponents::NAMES_WITH_UNDERSCORES)
, CompositeDataSetIndices(new vtkBlockDeliveryPreprocessor::CompositeDataSetIndicesType())
{
this->FieldAssociation = vtkDataObject::FIELD_ASSOCIATION_POINTS;
this->FlattenTable = 0;
this->GenerateOriginalIds = true;
this->GenerateCellConnectivity = false;
this->CompositeDataSetIndices = new CompositeDataSetIndicesType();
}
//----------------------------------------------------------------------------
vtkBlockDeliveryPreprocessor::~vtkBlockDeliveryPreprocessor()
{
delete this->CompositeDataSetIndices;
this->CompositeDataSetIndices = nullptr;
}
//----------------------------------------------------------------------------
......@@ -129,8 +129,7 @@ int vtkBlockDeliveryPreprocessor::RequestData(
return 1;
}
vtkSmartPointer<vtkAttributeDataToTableFilter> adtf =
vtkSmartPointer<vtkAttributeDataToTableFilter>::New();
vtkNew<vtkAttributeDataToTableFilter> adtf;
adtf->SetInputData(inputDO);
adtf->SetAddMetaData(true);
adtf->SetGenerateCellConnectivity(this->GenerateCellConnectivity);
......@@ -140,19 +139,16 @@ int vtkBlockDeliveryPreprocessor::RequestData(
// Create a pointer of the base class type, so that later stages need not be
// concerned with whether the data was flattened or not.
vtkAlgorithm* filter = adtf;
vtkSmartPointer<vtkAlgorithm> filter;
filter = adtf;
vtkSmartPointer<vtkSplitColumnComponents> split;
if (this->FlattenTable)
{
split = vtkSmartPointer<vtkSplitColumnComponents>::New();
vtkCompositeDataPipeline* pipeline = vtkCompositeDataPipeline::New();
split->SetExecutive(pipeline);
pipeline->Delete();
filter = split;
vtkNew<vtkSplitColumnComponents> split;
split->SetInputConnection(adtf->GetOutputPort());
split->SetNamingModeToNamesWithUnderscores();
split->SetNamingMode(this->SplitComponentsNamingMode);
split->Update();
filter = split;
}
vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast(outputDO);
......@@ -202,12 +198,6 @@ int vtkBlockDeliveryPreprocessor::RequestData(
return 1;
}
//----------------------------------------------------------------------------
vtkExecutive* vtkBlockDeliveryPreprocessor::CreateDefaultExecutive()
{
return vtkCompositeDataPipeline::New();
}
//----------------------------------------------------------------------------
void vtkBlockDeliveryPreprocessor::PrintSelf(ostream& os, vtkIndent indent)
{
......
......@@ -27,6 +27,7 @@
#include "vtkDataObjectAlgorithm.h"
#include "vtkPVVTKExtensionsRenderingModule.h" // needed for export macro
#include "vtkSplitColumnComponents.h" // needed for enum
class VTKPVVTKEXTENSIONSRENDERING_EXPORT vtkBlockDeliveryPreprocessor
: public vtkDataObjectAlgorithm
......@@ -78,6 +79,17 @@ public:
vtkGetMacro(FlattenTable, int);
//@}
//@{
/**
* Corresponds to `vtkSplitColumnComponents::NamingMode`. Pick which mode to
* use to name arrays when `FlattenTable` is true. Default is
* `vtkSplitColumnComponents::NAMES_WITH_UNDERSCORES`.
*/
vtkSetClampMacro(SplitComponentsNamingMode, int, vtkSplitColumnComponents::NUMBERS_WITH_PARENS,
vtkSplitColumnComponents::NAMES_WITH_UNDERSCORES);
vtkGetMacro(SplitComponentsNamingMode, int);
//@}
//@{
/**
* When set (default) the vtkOriginalIndices array will be added to the
......@@ -92,8 +104,6 @@ protected:
vtkBlockDeliveryPreprocessor();
~vtkBlockDeliveryPreprocessor() override;
vtkExecutive* CreateDefaultExecutive() VTK_OVERRIDE;
/**
* This is called by the superclass.
* This is the method you should override.
......@@ -107,6 +117,7 @@ protected:
int FlattenTable;
bool GenerateOriginalIds;
bool GenerateCellConnectivity;
int SplitComponentsNamingMode;
private:
vtkBlockDeliveryPreprocessor(const vtkBlockDeliveryPreprocessor&) = delete;
......
......@@ -105,6 +105,10 @@ public:
dstArray->SetNumberOfComponents(otherArray->GetNumberOfComponents());
dstArray->SetName(otherArray->GetName());
dstArray->Allocate(minSize * otherArray->GetNumberOfComponents());
if (auto oinfo = otherArray->GetInformation())
{
dstArray->CopyInformation(oinfo);
}
}
for (vtkIdType idx = 0; idx < otherArray->GetNumberOfTuples(); ++idx)
......@@ -1067,6 +1071,11 @@ public:
subArray->SetNumberOfComponents(srcArray->GetNumberOfComponents());
subArray->SetName(srcArray->GetName());
subArray->Allocate(size * srcArray->GetNumberOfComponents());
if (auto sinfo = srcArray->GetInformation())
{
subArray->CopyInformation(sinfo);
}
vtkIdType max = size + offset;
if (sorter != NULL && sorter->Array != NULL)
{
......
......@@ -26,5 +26,8 @@
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Frame.0/Close" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Frame.0/CentralWidgetFrame/EmptyView/scrollArea/qt_scrollarea_viewport/widgetFoo/ConvertActionsFrame/SpreadSheetView" command="activate" arguments="" />
<pqcheck object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Frame.0/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0" property="modelItemData" arguments="0.1,13" />
<pqcheck object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Frame.0/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0" property="modelItemData" arguments="0.2,1920, 0, 0" />
<pqcheck object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Frame.0/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0" property="modelItemData" arguments="0.2,1920" />
<pqcheck object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Frame.0/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0" property="modelItemData" arguments="0.3,0" />
<pqcheck object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Frame.0/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0" property="modelItemData" arguments="0.4,0" />
</pqevents>
......@@ -29,7 +29,12 @@
<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/1pqSpreadSheetViewWidget0" command="setCurrent" arguments="0.1" />
<pqcheck object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Frame.0/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0" property="modelItemData" arguments="0.1,17" />
<pqcheck object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Frame.0/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0" property="modelItemData" arguments="0.2,1920, 0, 0" />
<pqcheck object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Frame.0/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0" property="modelItemData" arguments="1.2,1920, 0, 0" />
<pqcheck object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Frame.0/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0" property="modelItemData" arguments="0.2,1920" />
<pqcheck object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Frame.0/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0" property="modelItemData" arguments="0.3,0" />
<pqcheck object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Frame.0/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0" property="modelItemData" arguments="0.4,0" />
<pqcheck object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Frame.0/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0" property="modelItemData" arguments="1.1,17" />
<pqcheck object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Frame.0/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0" property="modelItemData" arguments="1.2,1920" />
<pqcheck object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Frame.0/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0" property="modelItemData" arguments="1.3,0" />
<pqcheck object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Frame.0/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0" property="modelItemData" arguments="1.4,0" />
</pqevents>
......@@ -13165,10 +13165,6 @@
<Property name="Representations" id="43681.Representations" number_of_elements="1">
<Proxy value="43670"/>
</Property>
<Property name="SelectedComponent" id="43681.SelectedComponent" number_of_elements="1">
<Element index="0" value="-1"/>
<Domain name="range" id="43681.SelectedComponent.range"/>
</Property>
<Property name="SelectionOnly" id="43681.SelectionOnly" number_of_elements="1">
<Element index="0" value="0"/>
<Domain name="bool" id="43681.SelectionOnly.bool"/>
......
......@@ -147,8 +147,10 @@ static void populateMenu(pqSpreadSheetView* view, QMenu* menu)
model->headerData(col, Qt::Horizontal, Qt::DisplayRole).toString().toLatin1().data();
bool checked =
model->headerData(col, Qt::Horizontal, pqSpreadSheetViewModel::SectionVisible).toBool();
columnLabels.push_back(std::make_pair(label, checked));
columnLabelsSet.insert(label);
if (columnLabelsSet.insert(label).second == true)
{
columnLabels.push_back(std::make_pair(label, checked));
}
}
}
columnLabels.push_back(std::make_pair(std::string(), false));
......@@ -160,10 +162,9 @@ static void populateMenu(pqSpreadSheetView* view, QMenu* menu)
for (unsigned int cc = 0, max = svp->GetNumberOfElements(); cc < max; ++cc)
{
auto txt = svp->GetElement(cc);
if (columnLabelsSet.find(txt) == columnLabelsSet.end())
if (columnLabelsSet.insert(txt).second == true)
{
columnLabels.push_back(std::make_pair(txt, false));
columnLabelsSet.insert(txt);
}
}
......
......@@ -72,12 +72,6 @@ public:
this->Table->setCornerButtonEnabled(false);
this->Table->setSelectionBehavior(QAbstractItemView::SelectRows);
this->Table->setSelectionModel(&this->SelectionModel);
#if QT_VERSION >= 0x050000
this->Table->horizontalHeader()->setSectionsMovable(true);
#else
this->Table->horizontalHeader()->setMovable(true);
#endif
this->SingleColumnMode = false;
// Do not show the sorting arrow as default
this->Table->setSortingEnabled(false);
......@@ -93,8 +87,6 @@ public:
// We use EmptySelectionModel as the selection model for the view when in
// SelectionOnly mode i.e. when we showing only the selected elements.
QItemSelectionModel EmptySelectionModel;
bool SingleColumnMode;
};
//-----------------------------------------------------------------------------
......
......@@ -456,7 +456,7 @@ QVariant pqSpreadSheetViewModel::headerData(
switch (role)
{
case Qt::DisplayRole:
return view->GetColumnLabel(section);
return QString(view->GetColumnLabel(section).c_str());
case SectionInternal:
return view->IsColumnInternal(section);
case SectionVisible:
......
......@@ -34,6 +34,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pqNonEditableStyledItemDelegate.h"
#include "pqSpreadSheetViewModel.h"
#include "pqMultiColumnHeaderView.h"
#include <QApplication>
#include <QHeaderView>
#include <QItemDelegate>
......@@ -46,6 +48,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QVBoxLayout>
//-----------------------------------------------------------------------------
/*
* This delegate helps us keep track of rows that are being painted,
* that way we can control which blocks of data to request from the server side
*/
class pqSpreadSheetViewWidget::pqDelegate : public pqNonEditableStyledItemDelegate
{
typedef pqNonEditableStyledItemDelegate Superclass;
......@@ -65,131 +71,42 @@ public:
void paint(
QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override
{
const_cast<pqDelegate*>(this)->Top =
(this->Top.isValid() && this->Top < index) ? this->Top : index;
const_cast<pqDelegate*>(this)->Bottom =
(this->Bottom.isValid() && index < this->Bottom) ? this->Bottom : index;
QString text = index.data().toString();
if (text.isEmpty())
return;
// Make sure the text color is appropriate when selection
QPalette::ColorGroup cg =
(option.state & QStyle::State_Enabled) ? QPalette::Normal : QPalette::Disabled;
if (cg == QPalette::Normal && !(option.state & QStyle::State_Active))
{
cg = QPalette::Inactive;
}
if (option.state & QStyle::State_Selected)
{
painter->fillRect(option.rect, option.palette.brush(QPalette::Highlight));
painter->setPen(option.palette.color(cg, QPalette::HighlightedText));
}
else
{
painter->setPen(option.palette.color(cg, QPalette::Text));
}
const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;
QRect textRect = option.rect.adjusted(textMargin, 0, -textMargin, 0);
this->TextOption.setWrapMode(QTextOption::ManualWrap);
this->TextOption.setTextDirection(option.direction);
this->TextOption.setAlignment(
QStyle::visualAlignment(option.direction, option.displayAlignment));
int split = text.split("\t").length();
this->TextOption.setTabStop(option.rect.width() / split);
this->TextLayout.setTextOption(this->TextOption);
this->TextLayout.setFont(option.font);
this->TextLayout.setText(text);
QSizeF textLayoutSize = this->doTextLayout(textRect.width());
if (textRect.width() < textLayoutSize.width() || textRect.height() < textLayoutSize.height())
{
QString elided;
int start = 0;
int end = text.indexOf(QChar::LineSeparator, start);
if (end == -1)
{
elided += option.fontMetrics.elidedText(text, option.textElideMode, textRect.width());
}
else
while (end != -1)
{
elided += option.fontMetrics.elidedText(
text.mid(start, end - start), option.textElideMode, textRect.width());
start = end + 1;
end = text.indexOf(QChar::LineSeparator, start);
}
this->TextLayout.setText(elided);
textLayoutSize = this->doTextLayout(textRect.width());
}
const QSize layoutSize(textRect.width(), int(textLayoutSize.height()));
const QRect layoutRect =
QStyle::alignedRect(option.direction, option.displayAlignment, layoutSize, textRect);
this->TextLayout.draw(
painter, layoutRect.topLeft(), QVector<QTextLayout::FormatRange>(), layoutRect);
this->Top = (this->Top.isValid() && this->Top < index) ? this->Top : index;
this->Bottom = (this->Bottom.isValid() && index < this->Bottom) ? this->Bottom : index;
this->Superclass::paint(painter, option, index);
}
QSizeF doTextLayout(int lineWidth) const
{
QFontMetrics fontMetrics(this->TextLayout.font());
int leading = fontMetrics.leading();
qreal height = 0;
qreal widthUsed = 0;
this->TextLayout.beginLayout();
for (;;)
{
QTextLine line = this->TextLayout.createLine();
if (!line.isValid())
break;
line.setLineWidth(lineWidth);
height += leading;
line.setPosition(QPointF(0, height));
height += line.height();
widthUsed = qMax(widthUsed, line.naturalTextWidth());
}
this->TextLayout.endLayout();
return QSizeF(widthUsed, height);
}
QModelIndex Top;
QModelIndex Bottom;
mutable QTextLayout TextLayout;
mutable QTextOption TextOption;
mutable QModelIndex Top;
mutable QModelIndex Bottom;
};
//-----------------------------------------------------------------------------
pqSpreadSheetViewWidget::pqSpreadSheetViewWidget(QWidget* parentObject)
: Superclass(parentObject)
, SingleColumnMode(false)
, OldColumnCount(0)
{
// setup some defaults.
this->setAlternatingRowColors(true);
this->setCornerButtonEnabled(false);
this->setSelectionBehavior(QAbstractItemView::SelectRows);
#if QT_VERSION >= 0x050000
this->horizontalHeader()->setSectionsMovable(true);
#else
this->horizontalHeader()->setMovable(true);
#endif
this->horizontalHeader()->setHighlightSections(false);
this->SingleColumnMode = false;
// setup the delegate.
this->setItemDelegate(new pqDelegate(this));
auto hheader = new pqMultiColumnHeaderView(Qt::Horizontal, this);
hheader->setObjectName("Header");
hheader->setSectionsClickable(true);
hheader->setSectionsMovable(false);
hheader->setHighlightSections(false);
// limit to using 100 columns when resizing. This addresses performance issues with
// large data. Note visible columns only (0) is not adequate since the widget may
// not be visible at all when being resized and we e
hheader->setResizeContentsPrecision(100);
this->setHorizontalHeader(hheader);
QObject::connect(this->horizontalHeader(), SIGNAL(sectionDoubleClicked(int)), this,
SLOT(onSectionDoubleClicked(int)), Qt::QueuedConnection);
// setup the delegate.
this->setItemDelegate(new pqNonEditableStyledItemDelegate(this));
QObject::connect(this->horizontalHeader(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), this,
SLOT(onSortIndicatorChanged(int, Qt::SortOrder)));
// limit to using 10 columns when resizing. This addresses performance issues with
// large data. Note visible columns only (0) is not adequate since the widget may
// not be visible at all when being resized and we e
this->horizontalHeader()->setResizeContentsPrecision(10);
}
//-----------------------------------------------------------------------------
......@@ -219,13 +136,21 @@ void pqSpreadSheetViewWidget::onHeaderDataChanged()
{
if (auto amodel = this->model())
{
for (int cc = 0, max = amodel->columnCount(); cc < max; cc++)
const int colcount = amodel->columnCount();
for (int cc = 0; cc < colcount; cc++)
{
bool visible =
amodel->headerData(cc, Qt::Horizontal, pqSpreadSheetViewModel::SectionVisible).toBool();
this->setColumnHidden(cc, !visible);
}
this->resizeColumnsToContents();
if (this->OldColumnCount != colcount)
{
// don't resize column unless the column count really changed.
// this overcomes #18430.
this->resizeColumnsToContents();
this->OldColumnCount = colcount;
}
}
}
......@@ -256,37 +181,6 @@ void pqSpreadSheetViewWidget::paintEvent(QPaintEvent* pevent)
}
}
//-----------------------------------------------------------------------------
/// Called when user double clicks on a column header.
void pqSpreadSheetViewWidget::onSectionDoubleClicked(int logicalindex)
{
int numcols = this->model()->columnCount();
if (logicalindex < 0 || logicalindex >= numcols)
{
return;
}
QHeaderView* header = this->horizontalHeader();
this->SingleColumnMode = !this->SingleColumnMode;
for (int cc = 0; cc < numcols; cc++)
{
this->setColumnHidden(cc, (this->SingleColumnMode && cc != logicalindex));
if (this->SingleColumnMode && cc == logicalindex)
{
header->setSectionResizeMode(cc, QHeaderView::Stretch);
}
else if (!this->SingleColumnMode)
{
header->setSectionResizeMode(cc, QHeaderView::Interactive);
}
}
if (!this->SingleColumnMode)
{
// re-load column visibility from the data model.
this->onHeaderDataChanged();
}
}
//-----------------------------------------------------------------------------
/// Called when user clicks on a column header for sorting purpose.
void pqSpreadSheetViewWidget::onSortIndicatorChanged(int section, Qt::SortOrder order)
......
......@@ -68,12 +68,6 @@ public:
pqSpreadSheetViewModel* spreadSheetViewModel() const;
protected slots:
/**
* called when a header section is double-clicked. It results in that column
* being stretched over the full view for better viewing.
*/
void onSectionDoubleClicked(int);
/**