Commit 5b15b139 authored by Marcus Hanwell's avatar Marcus Hanwell
Browse files

ENH: Added parallel coordinates to ParaView.

Getting selections into the parallel coordinates chart is working,
getting them back out is a work in progress. Hopefully a general
mechanism for all charts can be used in the pqContextView.
parent c3156199
......@@ -75,6 +75,7 @@ QT4_WRAP_CPP(MOC_BUILT_SOURCES
pqOutputWindow.h
pqOutputWindowAdapter.h
pqOutputPort.h
pqParallelCoordinatesChartView.h
pqPickHelper.h
pqPipelineSource.h
pqPipelineFilter.h
......@@ -266,6 +267,8 @@ ADD_LIBRARY(pqCore
pqOutputWindowAdapter.h
pqOutputPort.cxx
pqOutputPort.h
pqParallelCoordinatesChartView.cxx
pqParallelCoordinatesChartView.h
pqPickHelper.cxx
pqPickHelper.h
pqPipelineFilter.cxx
......
......@@ -48,10 +48,31 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "vtkChartXY.h"
#include "vtkSMSourceProxy.h"
#include "vtkCommand.h"
#include "QVTKWidget.h"
#include <QDebug>
// Command implementation
class pqContextView::command : public vtkCommand
{
public:
static command* New(pqContextView &view)
{
return new command(view);
}
command(pqContextView &view) : Target(view) { }
virtual void Execute(vtkObject*, unsigned long, void*)
{
Target.selectionChanged();
}
pqContextView& Target;
};
//-----------------------------------------------------------------------------
pqContextView::pqContextView(
const QString& type, const QString& group,
......@@ -62,11 +83,14 @@ pqContextView::pqContextView(
: Superclass(type, group, name, viewProxy, server, parentObject)
{
viewProxy->GetID(); // this results in calling CreateVTKObjects().
this->Command = command::New(*this);
viewProxy->AddObserver(vtkCommand::SelectionChangedEvent, this->Command);
}
//-----------------------------------------------------------------------------
pqContextView::~pqContextView()
{
this->Command->Delete();
}
//-----------------------------------------------------------------------------
......@@ -222,3 +246,7 @@ bool pqContextView::canDisplay(pqOutputPort* opPort) const
return (dataInfo && dataInfo->DataSetTypeIsA("vtkTable"));
}
void pqContextView::selectionChanged()
{
qDebug() << "Selection changed!";
}
......@@ -104,6 +104,12 @@ protected:
/// Overridden to set up some default signal-slot connections.
virtual void initialize();
/// Listen for new selection events, and pass them back to ParaView
void selectionChanged();
class command;
command* Command;
private:
pqContextView(const pqContextView&); // Not implemented.
void operator=(const pqContextView&); // Not implemented.
......
/*=========================================================================
Program: ParaView
Module: pqParallelCoordinatesChartView.cxx
Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
========================================================================*/
#include "pqParallelCoordinatesChartView.h"
#include "vtkSMProperty.h"
#include "vtkSMContextViewProxy.h"
#include "pqSMAdaptor.h"
//-----------------------------------------------------------------------------
pqParallelCoordinatesChartView::pqParallelCoordinatesChartView(const QString& group,
const QString& name,
vtkSMContextViewProxy* viewModule,
pqServer* server,
QObject* parent/*=NULL*/):
Superclass(chartViewType(), group, name, viewModule, server, parent)
{
}
//-----------------------------------------------------------------------------
pqParallelCoordinatesChartView::~pqParallelCoordinatesChartView()
{
}
//-----------------------------------------------------------------------------
void pqParallelCoordinatesChartView::setDefaultPropertyValues()
{
this->Superclass::setDefaultPropertyValues();
}
/*=========================================================================
Program: ParaView
Module: pqParallelCoordinatesChartView.h
Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
========================================================================*/
#ifndef __pqParallelCoordinatesChartView_h
#define __pqParallelCoordinatesChartView_h
#include "pqContextView.h"
class vtkSMSourceProxy;
class pqDataRepresentation;
/// Bar chart view
class PQCORE_EXPORT pqParallelCoordinatesChartView : public pqContextView
{
Q_OBJECT
typedef pqContextView Superclass;
public:
static QString chartViewType() { return "ParallelCoordinatesChartView"; }
static QString chartViewTypeName() { return "Parallel Coordinates View"; }
public:
pqParallelCoordinatesChartView(const QString& group,
const QString& name,
vtkSMContextViewProxy* viewModule,
pqServer* server,
QObject* parent=NULL);
virtual ~pqParallelCoordinatesChartView();
/// Set property values.
virtual void setDefaultPropertyValues();
private:
pqParallelCoordinatesChartView(const pqParallelCoordinatesChartView&); // Not implemented.
void operator=(const pqParallelCoordinatesChartView&); // Not implemented.
};
#endif
......@@ -45,6 +45,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pqScatterPlotView.h"
#include "pqXYChartView.h"
#include "pqXYBarChartView.h"
#include "pqParallelCoordinatesChartView.h"
#include "vtkSMChartViewProxy.h"
#include "vtkSMContextViewProxy.h"
#include "vtkSMXYChartViewProxy.h"
......@@ -73,6 +74,7 @@ QStringList pqStandardViewModules::viewTypes() const
pqScatterPlotView::scatterPlotViewType() <<
pqXYChartView::XYChartViewType() <<
pqXYBarChartView::XYBarChartViewType() <<
pqParallelCoordinatesChartView::chartViewType() <<
pqComparativeRenderView::comparativeRenderViewType() <<
pqComparativeBarChartView::comparativeBarChartViewType() <<
pqComparativeLineChartView::comparativeLineChartViewType();
......@@ -128,6 +130,10 @@ QString pqStandardViewModules::viewTypeName(const QString& type) const
{
return pqXYBarChartView::XYBarChartViewTypeName();
}
else if (type == pqParallelCoordinatesChartView::chartViewType())
{
return pqParallelCoordinatesChartView::chartViewTypeName();
}
return QString();
}
......@@ -182,6 +188,10 @@ vtkSMProxy* pqStandardViewModules::createViewProxy(const QString& viewtype,
{
root_xmlname = "XYBarChartView";
}
else if (viewtype == pqParallelCoordinatesChartView::chartViewType())
{
root_xmlname = "ParallelCoordinatesChartView";
}
if (root_xmlname)
{
......@@ -262,6 +272,13 @@ pqView* pqStandardViewModules::createView(const QString& viewtype,
vtkSMXYChartViewProxy::SafeDownCast(viewmodule),
server, p);
}
else if (viewmodule->IsA("vtkSMXYChartViewProxy") &&
viewtype == "ParallelCoordinatesChartView")
{
return new pqParallelCoordinatesChartView(group, viewname,
vtkSMXYChartViewProxy::SafeDownCast(viewmodule),
server, p);
}
qDebug() << "Failed to create a proxy" << viewmodule->GetClassName();
return NULL;
......
......@@ -237,6 +237,7 @@ IF (VTK_USE_QVTK)
vtkSMContextArraysInformationHelper.cxx
vtkSMContextViewProxy.cxx
vtkSMLineChartViewProxy.cxx
vtkSMParallelCoordinatesRepresentationProxy.cxx
vtkSMXYChartRepresentationProxy.cxx
vtkSMXYChartViewProxy.cxx
)
......
......@@ -4915,6 +4915,24 @@
</XYChartViewProxy>
<XYChartViewProxy name="ParallelCoordinatesChartView"
base_proxygroup="views"
base_proxyname="ViewBase"
representation_name="ParallelCoordinatesRepresentation">
<Documentation>
This is the proxy for parallel coordinates chart view.
</Documentation>
<StringVectorProperty
name="ChartType"
command="SetChartType"
update_self="1"
number_of_elements="1"
default_values="ParallelCoordinates" >
</StringVectorProperty>
</XYChartViewProxy>
<LineChartViewProxy name="XYPlotView"
base_proxygroup="views"
base_proxyname="ViewBase"
......@@ -8832,6 +8850,54 @@
<!-- End of XYPlotRepresentation -->
</XYChartRepresentationProxy>
<ParallelCoordinatesRepresentationProxy name="ParallelCoordinatesRepresentation"
base_proxygroup="representations" >
<Documentation>
Representation used by ParallelCoordinatesChartView.
</Documentation>
<InputProperty name="Input"
command="SetInput-not-used" >
<Documentation>
Data input for the representation.
</Documentation>
<DataTypeDomain name="input_type">
<DataType value="vtkDataObject"/>
</DataTypeDomain>
</InputProperty>
<IntVectorProperty name="Visibility"
command="SetVisibility"
update_self="1"
number_of_elements="1"
default_values="1" >
<BooleanDomain name="bool" />
<Documentation>
Visibility of the representation.
</Documentation>
</IntVectorProperty>
<SubProxy>
<Proxy name="PreProcessor"
proxygroup="extended_filters"
proxyname="XYChartRepresentationPreprocessor">
</Proxy>
<!-- TODO: Change Domain of CompositeDataSetIndex so that one can select
a single leaf in the composite dataset alone -->
<ExposedProperties>
<Property name="FieldAssociation" exposed_name="AttributeType" />
<Property name="CompositeDataSetIndex" />
</ExposedProperties>
</SubProxy>
<SubProxy>
<Proxy name="SelectionRepresentation"
proxygroup="representations"
proxyname="ClientDeliveryRepresentation">
</Proxy>
</SubProxy>
</ParallelCoordinatesRepresentationProxy>
!-- New representation for ContextView based charts. -->
<XYChartRepresentationProxy name="XYChartRepresentation"
base_proxygroup="representations"
......
......@@ -42,7 +42,7 @@ public:
};
vtkCxxRevisionMacro(vtkSMContextViewProxy, "1.8");
vtkCxxRevisionMacro(vtkSMContextViewProxy, "1.9");
//----------------------------------------------------------------------------
vtkSMContextViewProxy::vtkSMContextViewProxy()
{
......@@ -96,6 +96,12 @@ vtkContextView* vtkSMContextViewProxy::GetChartView()
return this->ChartView;
}
//----------------------------------------------------------------------------
vtkChart* vtkSMContextViewProxy::GetChart()
{
return NULL;
}
//-----------------------------------------------------------------------------
vtkImageData* vtkSMContextViewProxy::CaptureWindow(int magnification)
{
......
......@@ -23,6 +23,7 @@
#include "vtkSMViewProxy.h"
class vtkContextView;
class vtkChart;
class vtkImageData;
//BTX
class QVTKWidget;
......@@ -47,6 +48,10 @@ public:
// Description:
// Provides access to the vtk chart view.
vtkContextView* GetChartView();
// Description:
// Provides access to the vtk chart.
virtual vtkChart* GetChart();
//ETX
// Description:
......
/*=========================================================================
Program: ParaView
Module: vtkSMParallelCoordinatesRepresentationProxy.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 "vtkSMParallelCoordinatesRepresentationProxy.h"
#include "vtkDataObject.h"
#include "vtkObjectFactory.h"
#include "vtkSMSourceProxy.h"
#include "vtkSMXYChartViewProxy.h"
#include "vtkContextView.h"
#include "vtkChartParallelCoordinates.h"
#include "vtkPlot.h"
#include "vtkTable.h"
#include "vtkAnnotationLink.h"
#include "vtkSelection.h"
#include "vtkCommand.h"
// Command implementation
class vtkSMParallelCoordinatesRepresentationProxy::CommandImpl : public vtkCommand
{
public:
static CommandImpl* New(vtkSMParallelCoordinatesRepresentationProxy *proxy)
{
return new CommandImpl(proxy);
}
CommandImpl(vtkSMParallelCoordinatesRepresentationProxy* proxy)
: Target(proxy), Initialized(false)
{ }
virtual void Execute(vtkObject*, unsigned long, void*)
{
Target->SelectionChanged();
}
vtkSMParallelCoordinatesRepresentationProxy* Target;
bool Initialized;
};
vtkStandardNewMacro(vtkSMParallelCoordinatesRepresentationProxy);
vtkCxxRevisionMacro(vtkSMParallelCoordinatesRepresentationProxy, "1.1");
//----------------------------------------------------------------------------
vtkSMParallelCoordinatesRepresentationProxy::vtkSMParallelCoordinatesRepresentationProxy()
{
this->Visibility = 1;
this->AnnLink = vtkAnnotationLink::New();
this->Command = CommandImpl::New(this);
}
//----------------------------------------------------------------------------
vtkSMParallelCoordinatesRepresentationProxy::~vtkSMParallelCoordinatesRepresentationProxy()
{
this->AnnLink->Delete();
this->Command->Delete();
}
//----------------------------------------------------------------------------
void vtkSMParallelCoordinatesRepresentationProxy::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
//-----------------------------------------------------------------------------
bool vtkSMParallelCoordinatesRepresentationProxy::BeginCreateVTKObjects()
{
if (!this->Superclass::BeginCreateVTKObjects())
{
return false;
}
this->SelectionRepresentation =
vtkSMClientDeliveryRepresentationProxy::SafeDownCast(
this->GetSubProxy("SelectionRepresentation"));
if (!this->SelectionRepresentation)
{
vtkErrorMacro("SelectionRepresentation must be defined in the xml configuration.");
return false;
}
return true;
}
//-----------------------------------------------------------------------------
void vtkSMParallelCoordinatesRepresentationProxy::CreatePipeline(vtkSMSourceProxy* input,
int outputport)
{
this->Superclass::CreatePipeline(input, outputport);
// Connect the selection output from the input to the SelectionRepresentation.
vtkSMSourceProxy* realInput = this->GetInputProxy();
// Ensure that the source proxy has created extract selection filters.
realInput->CreateSelectionProxies();
vtkSMSourceProxy* esProxy = realInput->GetSelectionOutput(outputport);
if (!esProxy)
{
vtkErrorMacro("Input proxy does not support selection extraction.");
return;
}
// esProxy port 1 is the input vtkSelection. That's the one we are
// interested in.
this->Connect(esProxy, this->SelectionRepresentation, "Input", 1);
}
//----------------------------------------------------------------------------
bool vtkSMParallelCoordinatesRepresentationProxy::EndCreateVTKObjects()
{
if (!this->Superclass::EndCreateVTKObjects())
{
return false;
}
// The reduction type for all chart representation is TABLE_MERGE since charts
// always deliver tables.
this->SetReductionType(vtkSMClientDeliveryRepresentationProxy::TABLE_MERGE);
if (this->GetChart())
{
this->GetChart()->AddObserver(vtkCommand::SelectionChangedEvent,
this->Command);
this->Command->Initialized = true;
}
return true;
}
//----------------------------------------------------------------------------
vtkChartParallelCoordinates* vtkSMParallelCoordinatesRepresentationProxy::GetChart()
{
if (this->ChartViewProxy)
{
return vtkChartParallelCoordinates::SafeDownCast(
this->ChartViewProxy->GetChart());
}
else
{
return 0;
}
}
//----------------------------------------------------------------------------
bool vtkSMParallelCoordinatesRepresentationProxy::AddToView(vtkSMViewProxy* view)
{
if (!this->Superclass::AddToView(view))
{
return false;
}
vtkSMXYChartViewProxy* chartView = vtkSMXYChartViewProxy::SafeDownCast(view);
if (!chartView || chartView == this->ChartViewProxy)
{
return false;
}
this->ChartViewProxy = chartView;
return this->Superclass::AddToView(view);
}
//----------------------------------------------------------------------------
bool vtkSMParallelCoordinatesRepresentationProxy::RemoveFromView(vtkSMViewProxy* view)
{
vtkSMXYChartViewProxy* chartView = vtkSMXYChartViewProxy::SafeDownCast(view);
if (!chartView || chartView != this->ChartViewProxy)
{
return false;
}
this->ChartViewProxy = 0;
return this->Superclass::RemoveFromView(view);
}
//----------------------------------------------------------------------------
void vtkSMParallelCoordinatesRepresentationProxy::SetVisibility(int visible)
{
if (this->Visibility != visible)
{
this->Visibility = visible;
}
}
//----------------------------------------------------------------------------
void vtkSMParallelCoordinatesRepresentationProxy::Update(vtkSMViewProxy* view)
{
this->Superclass::Update(view);
// Update our selection
this->SelectionRepresentation->Update(view);
if (this->GetChart())
{
vtkSelection *sel =
vtkSelection::SafeDownCast(this->SelectionRepresentation->GetOutput());
this->AnnLink->SetCurrentSelection(sel);
this->GetChart()->SetAnnotationLink(AnnLink);
if (!this->Command->Initialized)
{
this->GetChart()->AddObserver(vtkCommand::SelectionChangedEvent,
this->Command);
this->Command->Initialized = true;