Commit 2b00e492 authored by Joachim Pouderoux's avatar Joachim Pouderoux

Introduce box, bag and functional bag plots in ParaView.

ExtractBagPlots and TransposeTable filters are introduced too.

Change-Id: Ia296ce78d892777c0ce38ed6edd557a9f90dbea3
parent a001976f
......@@ -41,6 +41,11 @@
<Proxy group="filters" name="PlotOnIntersectionCurves" omit_from_toolbar="1"/>
<Proxy group="filters" name="ProgrammableFilter"
icon=":/pqWidgets/Icons/pqProgrammableFilter24.png" omit_from_toolbar="1"/>
<Proxy group="filters" name="TransposeTable" omit_from_toolbar="1"/>
<Proxy group="filters" name="ComputeQuartiles"
icon=":/pqWidgets/Icons/pqBoxChart16.png" omit_from_toolbar="1"/>
<Proxy group="filters" name="ExtractBagPlots"
icon=":/pqWidgets/Icons/pqFunctionalBagChart16.png" omit_from_toolbar="1"/>
</Category>
<Category name="Statistics" menu_label="&amp;Statistics">
......
......@@ -22,7 +22,9 @@
#include "vtkOutlineRepresentation.h"
#include "vtkPVAlgorithmPortsInformation.h"
#include "vtkPVArrayInformation.h"
#include "vtkPVBagChartView.h"
#include "vtkPVBarChartView.h"
#include "vtkPVBoxChartView.h"
#include "vtkPVCacheKeeper.h"
#include "vtkPVCacheKeeperPipeline.h"
#include "vtkPVCacheSizeInformation.h"
......@@ -43,6 +45,7 @@
#include "vtkPVExtractSelection.h"
#include "vtkPVFileInformation.h"
#include "vtkPVFileInformationHelper.h"
#include "vtkPVFunctionalBagChartView.h"
#include "vtkPVGenericAttributeInformation.h"
#include "vtkPVImplicitPlaneRepresentation.h"
#include "vtkPVInformation.h"
......@@ -130,7 +133,9 @@ int main(int, char**)
PRINT_SELF(vtkOutlineRepresentation);
PRINT_SELF(vtkPVAlgorithmPortsInformation);
PRINT_SELF(vtkPVArrayInformation);
//PRINT_SELF(vtkPVBagChartView);
//PRINT_SELF(vtkPVBarChartView);
//PRINT_SELF(vtkPVBoxChartView);
PRINT_SELF(vtkPVCacheKeeper);
PRINT_SELF(vtkPVCacheKeeperPipeline);
PRINT_SELF(vtkPVCacheSizeInformation);
......@@ -151,6 +156,7 @@ int main(int, char**)
PRINT_SELF(vtkPVExtractSelection);
PRINT_SELF(vtkPVFileInformation);
PRINT_SELF(vtkPVFileInformationHelper);
//PRINT_SELF(vtkPVFunctionalBagChartView);
PRINT_SELF(vtkPVGenericAttributeInformation);
PRINT_SELF(vtkPVImplicitPlaneRepresentation);
PRINT_SELF(vtkPVInformation);
......
......@@ -50,7 +50,11 @@ set (Module_SRCS
vtkMoleculeRepresentation.cxx
vtkMPIMoveData.cxx
vtkOutlineRepresentation.cxx
vtkPVBagChartView.cxx
vtkPVBagChartRepresentation.cxx
vtkPVBarChartView.cxx
vtkPVBoxChartRepresentation.cxx
vtkPVBoxChartView.cxx
vtkPVCacheKeeper.cxx
vtkPVCacheKeeperPipeline.cxx
vtkPVCacheSizeInformation.cxx
......@@ -61,6 +65,7 @@ set (Module_SRCS
vtkPVDataRepresentation.cxx
vtkPVDataRepresentationPipeline.cxx
vtkPVDisplayInformation.cxx
vtkPVFunctionalBagChartView.cxx
vtkPVHardwareSelector.cxx
vtkPVImageSliceMapper.cxx
vtkPVImplicitPlaneRepresentation.cxx
......
......@@ -55,6 +55,7 @@ vtkChartRepresentation::vtkChartRepresentation()
this->CacheKeeper = vtkPVCacheKeeper::New();
this->EnableServerSideRendering = false;
this->FlattenTable = 1;
}
//----------------------------------------------------------------------------
......@@ -208,7 +209,7 @@ int vtkChartRepresentation::RequestData(vtkInformation* request,
vtkNew<vtkBlockDeliveryPreprocessor> preprocessor;
// tell the preprocessor to flatten multicomponent arrays i.e. extract each
// component into a separate array.
preprocessor->SetFlattenTable(1);
preprocessor->SetFlattenTable(this->FlattenTable);
preprocessor->SetFieldAssociation(this->FieldAssociation);
preprocessor->SetInputData(data);
preprocessor->Update();
......
......@@ -98,6 +98,12 @@ public:
static vtkStdString GetDefaultSeriesLabel(
const vtkStdString& tableName, const vtkStdString& columnName);
// Description:
// Flatten the table, i.e. split any multicomponent columns into separate
// components.
vtkSetMacro(FlattenTable, int);
vtkGetMacro(FlattenTable, int);
//BTX
protected:
vtkChartRepresentation();
......@@ -160,6 +166,7 @@ protected:
vtkPVCacheKeeper* CacheKeeper;
vtkWeakPointer<vtkPVContextView> ContextView;
bool EnableServerSideRendering;
int FlattenTable;
vtkSmartPointer<vtkMultiBlockDataSet> LocalOutput;
std::set<unsigned int> CompositeIndices; //the selected blocks
......
/*=========================================================================
Program: ParaView
Module: vtkPVBagChartRepresentation.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 "vtkPVBagChartRepresentation.h"
#include "vtkBrush.h"
#include "vtkChartXY.h"
#include "vtkColor.h"
#include "vtkCommand.h"
#include "vtkContextView.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkObjectFactory.h"
#include "vtkPen.h"
#include "vtkPlotBag.h"
#include "vtkPVContextView.h"
#include "vtkTable.h"
#include <string>
vtkStandardNewMacro(vtkPVBagChartRepresentation);
//----------------------------------------------------------------------------
vtkPVBagChartRepresentation::vtkPVBagChartRepresentation() :
LineThickness(1),
LineStyle(0),
Opacity(1.),
PointSize(5),
XAxisSeriesName(NULL),
YAxisSeriesName(NULL),
DensitySeriesName(NULL),
UseIndexForXAxis(true)
{
this->BagColor[0] = 1.0;
this->BagColor[1] = this->BagColor[2] = 0.0;
this->LineColor[0] = this->LineColor[1] = this->LineColor[2] = 0.0;
this->PointColor[0] = this->PointColor[1] = this->PointColor[2] = 0.0;
}
//----------------------------------------------------------------------------
vtkPVBagChartRepresentation::~vtkPVBagChartRepresentation()
{
}
//----------------------------------------------------------------------------
void vtkPVBagChartRepresentation::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
//----------------------------------------------------------------------------
bool vtkPVBagChartRepresentation::AddToView(vtkView* view)
{
if (!this->Superclass::AddToView(view))
{
return false;
}
if (this->GetChart())
{
this->GetChart()->SetVisible(this->GetVisibility());
}
return true;
}
//----------------------------------------------------------------------------
bool vtkPVBagChartRepresentation::RemoveFromView(vtkView* view)
{
if (this->GetChart())
{
this->GetChart()->GetPlot(0)->SetInputData(0);
this->GetChart()->SetVisible(false);
}
return this->Superclass::RemoveFromView(view);
}
//----------------------------------------------------------------------------
void vtkPVBagChartRepresentation::SetVisibility(bool visible)
{
this->Superclass::SetVisibility(visible);
vtkChartXY* chart = this->GetChart();
if (chart && !visible)
{
// Refer to vtkChartRepresentation::PrepareForRendering() documentation to
// know why this is cannot be done in PrepareForRendering();
chart->SetVisible(false);
}
this->Modified();
}
//----------------------------------------------------------------------------
vtkChartXY* vtkPVBagChartRepresentation::GetChart()
{
if (this->ContextView)
{
return vtkChartXY::SafeDownCast(
this->ContextView->GetContextItem());
}
return 0;
}
//----------------------------------------------------------------------------
void vtkPVBagChartRepresentation::PrepareForRendering()
{
this->Superclass::PrepareForRendering();
vtkChartXY* chart = this->GetChart();
vtkPlotBag* plot = 0;
for (int i = 0; i < chart->GetNumberOfPlots() && !plot; i++)
{
// Search for the first bag plot of the chart. For now
// the chart only manage one bag plot
plot = vtkPlotBag::SafeDownCast(chart->GetPlot(i));
}
if (!plot)
{
// Create and add a bag plot to the chart
plot = vtkPlotBag::SafeDownCast(chart->AddPlot(vtkChart::BAG));
}
vtkTable* plotInput = this->GetLocalOutput();
chart->SetVisible(plotInput != NULL && this->GetVisibility());
// Set line (bag boundaries) pen properties
plot->GetLinePen()->SetWidth(this->LineThickness);
plot->GetLinePen()->SetLineType(this->LineStyle);
plot->GetLinePen()->SetColorF(this->LineColor);
plot->GetLinePen()->SetOpacityF(this->Opacity);
// Set bag (polygons) brush properties
plot->GetBrush()->SetColorF(this->BagColor);
plot->GetBrush()->SetOpacityF(this->Opacity);
// Set point pen properties
plot->GetPen()->SetWidth(this->PointSize);
plot->GetPen()->SetLineType(this->LineStyle);
plot->GetPen()->SetColorF(this->PointColor);
plot->GetPen()->SetOpacityF(1.0);
if (plotInput)
{
// We only consider the first vtkTable.
if (this->YAxisSeriesName && this->DensitySeriesName)
{
plot->SetUseIndexForXSeries(this->UseIndexForXAxis);
if (this->UseIndexForXAxis)
{
plot->SetInputData(plotInput,
this->YAxisSeriesName, this->DensitySeriesName);
}
else
{
plot->SetInputData(plotInput, this->XAxisSeriesName,
this->YAxisSeriesName, this->DensitySeriesName);
}
}
}
}
/*=========================================================================
Program: ParaView
Module: vtkPVBagChartRepresentation.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.
=========================================================================*/
// .NAME vtkPVBagChartRepresentation
// .SECTION Description
// vtkPVagChartRepresentation is the vtkChartRepresentation
// subclass for bag plots representation. It exposes API from
// underlying vtkXYChart and vtkPlotBag.
#ifndef __vtkPVBagChartRepresentation_h
#define __vtkPVBagChartRepresentation_h
#include "vtkChartRepresentation.h"
class vtkChartXY;
class VTKPVCLIENTSERVERCORERENDERING_EXPORT vtkPVBagChartRepresentation : public vtkChartRepresentation
{
public:
static vtkPVBagChartRepresentation* New();
vtkTypeMacro(vtkPVBagChartRepresentation, vtkChartRepresentation);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Set visibility of the representation.
virtual void SetVisibility(bool visible);
// Description:
// Provides access to the underlying VTK representation.
vtkChartXY* GetChart();
// Description:
// Set/get the line thickness for the plot.
vtkSetMacro(LineThickness, int);
vtkGetMacro(LineThickness, int);
// Description:
// Set/get the line style for the plot.
vtkSetMacro(LineStyle, int);
vtkGetMacro(LineStyle, int);
// Description:
// Set/get the color to used for the points in the plot.
vtkSetVector3Macro(LineColor, double);
vtkGetVector3Macro(LineColor, double);
// Description:
// Set/get the color to used for the bag in the plot.
vtkSetVector3Macro(BagColor, double);
vtkGetVector3Macro(BagColor, double);
// Description:
// Set/get the opacity for the bag in the plot.
vtkSetMacro(Opacity, double);
vtkGetMacro(Opacity, double);
// Description:
// Set/get the point size in the plot.
vtkSetMacro(PointSize, int);
vtkGetMacro(PointSize, int);
// Description:
// Set/get the color to used for the points in the plot.
vtkSetVector3Macro(PointColor, double);
vtkGetVector3Macro(PointColor, double);
// Description:
// Set/get the series to use as the X-axis.
vtkSetStringMacro(XAxisSeriesName);
vtkGetStringMacro(XAxisSeriesName);
// Description:
// Set/get whether the index should be used for the x axis. When true, XSeriesName
// is ignored.
vtkSetMacro(UseIndexForXAxis, bool);
vtkGetMacro(UseIndexForXAxis, bool);
// Description:
// Set/get the series to use as the density
vtkSetStringMacro(DensitySeriesName);
vtkGetStringMacro(DensitySeriesName);
// Description:
// Set/get the series to use as the Y-axis
vtkSetStringMacro(YAxisSeriesName);
vtkGetStringMacro(YAxisSeriesName);
//BTX
protected:
vtkPVBagChartRepresentation();
~vtkPVBagChartRepresentation();
// Description:
// Overridden to pass information about changes to series visibility etc. to
// the plot-matrix.
virtual void PrepareForRendering();
virtual bool AddToView(vtkView* view);
// Description:
// Removes the representation to the view. This is called from
// vtkView::RemoveRepresentation(). Subclasses should override this method.
// Returns true if the removal succeeds.
virtual bool RemoveFromView(vtkView* view);
private:
vtkPVBagChartRepresentation(const vtkPVBagChartRepresentation&); // Not implemented
void operator=(const vtkPVBagChartRepresentation&); // Not implemented
int LineThickness;
int LineStyle;
double LineColor[3];
double BagColor[3];
double Opacity;
int PointSize;
double PointColor[3];
char* XAxisSeriesName;
char* YAxisSeriesName;
char* DensitySeriesName;
bool UseIndexForXAxis;
//ETX
};
#endif
/*=========================================================================
Program: ParaView
Module: vtkPVBagChartView.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 "vtkPVBagChartView.h"
#include "vtkObjectFactory.h"
vtkStandardNewMacro(vtkPVBagChartView);
//----------------------------------------------------------------------------
vtkPVBagChartView::vtkPVBagChartView()
{
this->SetChartType("Bag");
}
//----------------------------------------------------------------------------
vtkPVBagChartView::~vtkPVBagChartView()
{
}
//----------------------------------------------------------------------------
void vtkPVBagChartView::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
/*=========================================================================
Program: ParaView
Module: vtkPVBagChartView.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.
=========================================================================*/
// .NAME vtkPVBagChartView
// .SECTION Description
// Subclass for vtkPVXYChartView that calls
// vtkPVXYChartView::SetChartType("Bag") in the constructor.
#ifndef __vtkPVBagChartView_h
#define __vtkPVBagChartView_h
#include "vtkPVClientServerCoreRenderingModule.h" //needed for exports
#include "vtkPVXYChartView.h"
class VTKPVCLIENTSERVERCORERENDERING_EXPORT vtkPVBagChartView : public vtkPVXYChartView
{
public:
static vtkPVBagChartView* New();
vtkTypeMacro(vtkPVBagChartView, vtkPVXYChartView);
void PrintSelf(ostream& os, vtkIndent indent);
//BTX
protected:
vtkPVBagChartView();
~vtkPVBagChartView();
private:
vtkPVBagChartView(const vtkPVBagChartView&); // Not implemented
void operator=(const vtkPVBagChartView&); // Not implemented
//ETX
};
#endif
/*=========================================================================
Program: ParaView
Module: vtkPVBoxChartRepresentation.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 "vtkPVBoxChartRepresentation.h"
#include "vtkAxis.h"
#include "vtkChartBox.h"
#include "vtkObjectFactory.h"
#include "vtkPen.h"
#include "vtkPlot.h"
#include "vtkPlotBox.h"
#include "vtkPVContextView.h"
#include "vtkTable.h"
#include "vtkStdString.h"
#include <map>
#include <string>
class vtkPVBoxChartRepresentation::vtkInternals
{
public:
// Refer to vtkPVPlotMatrixRepresentation when time comes to update this
// representation to respect the order in which the series are listed.
std::map<std::string, bool> SeriesVisibilities;
std::map<std::string, vtkColor3d> SeriesColors;
};
vtkStandardNewMacro(vtkPVBoxChartRepresentation);
//----------------------------------------------------------------------------
vtkPVBoxChartRepresentation::vtkPVBoxChartRepresentation()
: LineThickness(2),
LineStyle(0),
Legend(true)
{
this->Internals = new vtkInternals();
this->Color[0] = this->Color[1] = this->Color[2] = 0.0;
}
//----------------------------------------------------------------------------
vtkPVBoxChartRepresentation::~vtkPVBoxChartRepresentation()
{
delete this->Internals;
this->Internals = NULL;
}
//----------------------------------------------------------------------------
void vtkPVBoxChartRepresentation::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
//----------------------------------------------------------------------------
bool vtkPVBoxChartRepresentation::AddToView(vtkView* view)
{
if (!this->Superclass::AddToView(view))
{
return false;
}
if (this->GetChart())
{
this->GetChart()->SetVisible(this->GetVisibility());
}
return true;
}
//----------------------------------------------------------------------------
bool vtkPVBoxChartRepresentation::RemoveFromView(vtkView* view)
{
if (this->GetChart())
{
this->GetChart()->GetPlot(0)->SetInputData(0);
this->GetChart()->SetVisible(false);
}
return this->Superclass::RemoveFromView(view);
}
//----------------------------------------------------------------------------
vtkChartBox* vtkPVBoxChartRepresentation::GetChart()
{
if (this->ContextView)
{
return vtkChartBox::SafeDownCast(
this->ContextView->GetContextItem());
}
return 0;
}
//----------------------------------------------------------------------------
void vtkPVBoxChartRepresentation::SetVisibility(bool visible)
{
this->Superclass::SetVisibility(visible);
vtkChartBox* chart = this->GetChart();
if (chart && !visible)
{
// Refer to vtkChartRepresentation::PrepareForRendering() documentation to
// know why this is cannot be done in PrepareForRendering();
chart->SetVisible(false);
}
this->Modified();
}
//----------------------------------------------------------------------------
void vtkPVBoxChartRepresentation::SetSeriesVisibility(
const char* series, bool visibility)
{
assert(series != NULL);
this->Internals->SeriesVisibilities[series] = visibility;
this->Modified();
}
//----------------------------------------------------------------------------
void vtkPVBoxChartRepresentation::SetSeriesColor(const char* seriesname,
double r, double g, double b)
{
assert(seriesname != NULL);
this->Internals->SeriesColors[seriesname] = vtkColor3d(r, g, b);
this->Modified();
}
//----------------------------------------------------------------------------
void vtkPVBoxChartRepresentation::ClearSeriesVisibilities()
{
this->Internals->SeriesVisibilities.clear();
this->Modified();
}
//----------------------------------------------------------------------------
void vtkPVBoxChartRepresentation::ClearSeriesColors()
{
this->Internals->SeriesColors.clear();
this->Modified();
}
//----------------------------------------------------------------------------
void vtkPVBoxChartRepresentation::PrepareForRendering()
{
this->Superclass::PrepareForRendering();
vtkChartBox* chart = this->GetChart();
vtkPlotBox* plot = vtkPlotBox::SafeDownCast(chart->GetPlot(0));
assert(plot);
vtkTable* plotInput = this->GetLocalOutput();
chart->SetVisible(plotInput != NULL && this->GetVisibility());
chart->SetShowLegend(this->Legend);
plot->GetPen()->SetWidth(this->LineThickness);
plot->GetPen()->SetLineType(this->LineStyle);
plot->GetPen()->SetColorF(this->Color[0], this->Color[1], this->Color[2]);
plot->GetPen()->SetOpacityF(1.0);
if (plotInput)
{
// only consider the first vtkTable.
plot->SetInputData(plotInput);
chart->SetColumnVisibilityAll(true);
vtkIdType numCols = plotInput->GetNumberOfColumns();
for (vtkIdType cc = 0; cc < numCols; cc++)
{
std::string name = plotInput->GetColumnName(cc);
std::map<std::string, bool>::iterator iter =
this->Internals->SeriesVisibilities.find(name);
if (iter != this->Internals->SeriesVisibilities.end() &&
iter->second == true)