Commit 996850e4 authored by Marcus Hanwell's avatar Marcus Hanwell
Browse files

ENH: Adding my first pass at an experimental vtkContextView based XY chart.

Added a new view to ParaView based on the new vtkContextView work I have been
doing in VTK.  This code is experimental, and currently only works with the
line plot filter. I am actively working on this code, the API may change a
little and the interface and view options will certainly be improved.

The ContextView proxies are intended to remain very general so that further
context view based charts can be added to ParaView more easily. Feedback would
be appreciated, I am currently working on adding the proxies to choose the
columns to be plotted and to customize the plots (color, thickness, symbols).
parent c3500356
......@@ -349,7 +349,7 @@ SET(VTK_INCLUDE_DIR
${ParaView_SOURCE_DIR}/VTK/Wrapping
${ParaView_BINARY_DIR}/VTK/Wrapping
)
SET(kits Common Filtering GenericFiltering IO Imaging Rendering Parallel Graphics Hybrid VolumeRendering Widgets)
SET(kits Common Charts Filtering GenericFiltering IO Imaging Rendering Parallel Graphics Hybrid VolumeRendering Widgets)
FOREACH(kit ${kits})
SET(VTK_INCLUDE_DIR ${VTK_INCLUDE_DIR}
${ParaView_SOURCE_DIR}/VTK/${kit}
......
......@@ -43,6 +43,7 @@ QT4_WRAP_CPP(MOC_BUILT_SOURCES
pqBrandPluginsLoader.h
pqChartRepresentation.h
pqChartView.h
pqContextView.h
pqColorButtonEventPlayer.h
pqColorButtonEventTranslator.h
pqCommandServerStartup.h
......@@ -117,6 +118,7 @@ QT4_WRAP_CPP(MOC_BUILT_SOURCES
pqWriterFactory.h
pqXMLEventObserver.h
pqXMLEventSource.h
pqXYChartView.h
${PYTHON_MOC_SRCS}
)
SET_DIRECTORY_PROPERTIES(PROPERTIES INCLUDE_DIRECTORIES "${include_dirs_tmp}")
......@@ -183,6 +185,8 @@ ADD_LIBRARY(pqCore
pqChartRepresentation.h
pqChartView.cxx
pqChartView.h
pqContextView.cxx
pqContextView.h
pqColorButtonEventPlayer.cxx
pqColorButtonEventPlayer.h
pqColorButtonEventTranslator.cxx
......@@ -367,6 +371,8 @@ ADD_LIBRARY(pqCore
pqXMLEventSource.h
pqXMLUtil.cxx
pqXMLUtil.h
pqXYChartView.cxx
pqXYChartView.h
${MOC_BUILT_SOURCES}
${RCS_SOURCES}
......@@ -385,6 +391,7 @@ TARGET_LINK_LIBRARIES(pqCore
pqWidgets
QVTK
vtkQtChart
vtkCharts
vtkPVServerManager
)
......
/*=========================================================================
Program: ParaView
Module: pqContextView.cxx
Copyright (c) 2005,2006 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 "pqContextView.h"
#include "pqEventDispatcher.h"
#include "pqImageUtil.h"
#include "pqOutputPort.h"
#include "pqPipelineSource.h"
#include "pqServer.h"
#include "vtkImageData.h"
#include "vtkPVDataInformation.h"
#include "vtkPVXMLElement.h"
#include "vtkContextView.h"
// #include "vtkQtChartArea.h"
// #include "vtkQtChartContentsSpace.h"
// #include "vtkQtChartView.h"
// #include "vtkQtChartWidget.h"
#include "vtkSMContextViewProxy.h"
#include "vtkSMSourceProxy.h"
#include "QVTKWidget.h"
//-----------------------------------------------------------------------------
pqContextView::pqContextView(
const QString& type, const QString& group,
const QString& name,
vtkSMViewProxy* viewProxy,
pqServer* server,
QObject* parentObject)
: Superclass(type, group, name, viewProxy, server, parentObject)
{
viewProxy->GetID(); // this results in calling CreateVTKObjects().
}
//-----------------------------------------------------------------------------
pqContextView::~pqContextView()
{
}
//-----------------------------------------------------------------------------
void pqContextView::initialize()
{
this->Superclass::initialize();
}
//-----------------------------------------------------------------------------
/// Return a widget associated with this view.
QWidget* pqContextView::getWidget()
{
vtkSMContextViewProxy *proxy =
vtkSMContextViewProxy::SafeDownCast(this->getProxy());
return proxy ? proxy->GetChartWidget() : NULL;
}
//-----------------------------------------------------------------------------
/// Returns the internal vtkQtChartView which provide the implementation for
/// the chart rendering.
vtkContextView* pqContextView::getVTKContextView() const
{
return vtkSMContextViewProxy::SafeDownCast(this->getProxy())->GetChartView();
}
//-----------------------------------------------------------------------------
/// This view does not support saving to image.
bool pqContextView::saveImage(int width, int height, const QString& filename)
{
return false;
}
//-----------------------------------------------------------------------------
/// Capture the view image into a new vtkImageData with the given magnification
/// and returns it. The caller is responsible for freeing the returned image.
vtkImageData* pqContextView::captureImage(int magnification)
{
return NULL;
}
//-----------------------------------------------------------------------------
/// Capture the view image of the given size and returns it. The caller is
/// responsible for freeing the returned image.
vtkImageData* pqContextView::captureImage(const QSize& asize)
{
return NULL;
}
//-----------------------------------------------------------------------------
/// Called to undo interaction.
void pqContextView::undo()
{
}
//-----------------------------------------------------------------------------
/// Called to redo interaction.
void pqContextView::redo()
{
}
//-----------------------------------------------------------------------------
/// Returns true if undo can be done.
bool pqContextView::canUndo() const
{
return false;
}
//-----------------------------------------------------------------------------
/// Returns true if redo can be done.
bool pqContextView::canRedo() const
{
return false;
}
//-----------------------------------------------------------------------------
/// Resets the zoom level to 100%.
void pqContextView::resetDisplay()
{
}
//-----------------------------------------------------------------------------
/// Returns true if data on the given output port can be displayed by this view.
bool pqContextView::canDisplay(pqOutputPort* opPort) const
{
pqPipelineSource* source = opPort? opPort->getSource() :0;
vtkSMSourceProxy* sourceProxy = source ?
vtkSMSourceProxy::SafeDownCast(source->getProxy()) : 0;
if(!opPort || !source ||
opPort->getServer()->GetConnectionID() !=
this->getServer()->GetConnectionID() || !sourceProxy ||
sourceProxy->GetOutputPortsCreated()==0)
{
return false;
}
if (sourceProxy->GetHints() &&
sourceProxy->GetHints()->FindNestedElementByName("Plotable"))
{
return true;
}
vtkPVDataInformation* dataInfo = opPort->getDataInformation();
return (dataInfo && dataInfo->DataSetTypeIsA("vtkTable"));
}
/*=========================================================================
Program: ParaView
Module: pqContextView.h
Copyright (c) 2005,2006 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 __pqContextView_h
#define __pqContextView_h
#include "pqView.h"
class vtkSMContextViewProxy;
class vtkContextView;
/// pqContextView is an abstract base class for all charting views based on the
/// VTK context charting library.
class PQCORE_EXPORT pqContextView : public pqView
{
Q_OBJECT
typedef pqView Superclass;
public:
virtual ~pqContextView();
/// Return a widget associated with this view.
virtual QWidget* getWidget();
/// Returns the internal vtkContextView which provides the implementation for
/// the chart rendering.
virtual vtkContextView* getVTKContextView() const;
/// This view does not support saving to image.
virtual bool saveImage(int width, int height, const QString& filename);
/// Capture the view image into a new vtkImageData with the given magnification
/// and returns it. The caller is responsible for freeing the returned image.
virtual vtkImageData* captureImage(int magnification);
/// Capture the view image of the given size and return it. The caller is
/// responsible for freeing the returned image.
virtual vtkImageData* captureImage(const QSize& asize);
/// This view supports undo so this method always returns true.
virtual bool supportsUndo() const {return true;}
/// Called to undo interaction.
virtual void undo();
/// Called to redo interaction.
virtual void redo();
/// Returns true if undo can be done.
virtual bool canUndo() const;
/// Returns true if redo can be done.
virtual bool canRedo() const;
/// Resets the zoom level to 100%.
virtual void resetDisplay();
/// Returns true if data on the given output port can be displayed by this view.
virtual bool canDisplay(pqOutputPort* opPort) const;
protected:
/// Constructor:
/// \c type :- view type.
/// \c group :- SManager registration group.
/// \c name :- SManager registration name.
/// \c view :- View proxy.
/// \c server:- server on which the proxy is created.
/// \c parent:- QObject parent.
pqContextView(const QString& type,
const QString& group,
const QString& name,
vtkSMViewProxy* view,
pqServer* server,
QObject* parent=NULL);
/// Overridden to set up some default signal-slot connections.
virtual void initialize();
private:
pqContextView(const pqContextView&); // Not implemented.
void operator=(const pqContextView&); // Not implemented.
};
#endif
......@@ -583,6 +583,11 @@ void pqPropertyLinks::addPropertyLink(QObject* qObject, const char* qProperty,
if(!Proxy || !Property || !qObject || !qProperty || !signal)
{
qWarning("Invalid parameters to add link\n");
qDebug() << "Proxy:" << Proxy << Proxy->GetClassName();
qDebug() << "Property:" << Property;
qDebug() << "qObject:" << qObject;
qDebug() << "qProperty:" << qProperty;
qDebug() << "signal:" << signal;
return;
}
......
......@@ -7,7 +7,7 @@
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.
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
......@@ -45,11 +45,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pqTextRepresentation.h"
#include "pqTwoDRenderView.h"
#include "pqScatterPlotView.h"
#include "pqXYChartView.h"
#include "vtkSMChartViewProxy.h"
#include "vtkSMContextViewProxy.h"
#include "vtkSMXYChartViewProxy.h"
#include "vtkSMComparativeViewProxy.h"
#include "vtkSMProxyManager.h"
#include "vtkSMRenderViewProxy.h"
#include <QDebug>
pqStandardViewModules::pqStandardViewModules(QObject* o)
: QObject(o)
{
......@@ -61,22 +66,23 @@ pqStandardViewModules::~pqStandardViewModules()
QStringList pqStandardViewModules::viewTypes() const
{
return QStringList() <<
pqRenderView::renderViewType() <<
return QStringList() <<
pqRenderView::renderViewType() <<
pqTwoDRenderView::twoDRenderViewType() <<
pqBarChartView::barChartViewType() <<
pqLineChartView::lineChartViewType() <<
pqBarChartView::barChartViewType() <<
pqLineChartView::lineChartViewType() <<
pqTableView::tableType() <<
pqComparativeRenderView::comparativeRenderViewType() <<
pqComparativeBarChartView::comparativeBarChartViewType() <<
pqComparativeLineChartView::comparativeLineChartViewType() <<
pqSpreadSheetView::spreadsheetViewType() <<
pqScatterPlotView::scatterPlotViewType();
pqScatterPlotView::scatterPlotViewType() <<
pqXYChartView::XYChartViewType();
}
QStringList pqStandardViewModules::displayTypes() const
{
return QStringList()
return QStringList()
<< "BarChartRepresentation"
<< "XYPlotRepresentation"
<< "TextSourceRepresentation";
......@@ -124,6 +130,10 @@ QString pqStandardViewModules::viewTypeName(const QString& type) const
{
return pqScatterPlotView::scatterPlotViewTypeName();
}
else if (type == pqXYChartView::XYChartViewType())
{
return pqXYChartView::XYChartViewTypeName();
}
return QString();
}
......@@ -178,6 +188,10 @@ vtkSMProxy* pqStandardViewModules::createViewProxy(const QString& viewtype,
{
root_xmlname = "ScatterPlotRenderView";
}
else if (viewtype == pqXYChartView::XYChartViewType())
{
root_xmlname = "XYChartView";
}
if (root_xmlname)
{
......@@ -210,7 +224,7 @@ pqView* pqStandardViewModules::createView(const QString& viewtype,
else if (viewtype == pqLineChartView::lineChartViewType() &&
viewmodule->IsA("vtkSMChartViewProxy"))
{
return new pqLineChartView(group, viewname,
return new pqLineChartView(group, viewname,
vtkSMChartViewProxy::SafeDownCast(viewmodule), server, p);
}
else if(viewtype == "TableView")
......@@ -231,13 +245,15 @@ pqView* pqStandardViewModules::createView(const QString& viewtype,
&& viewmodule->IsA("vtkSMComparativeViewProxy"))
{
return new pqComparativeBarChartView(
group, viewname, vtkSMComparativeViewProxy::SafeDownCast(viewmodule), server, p);
group, viewname, vtkSMComparativeViewProxy::SafeDownCast(viewmodule),
server, p);
}
else if (viewtype == pqComparativeLineChartView::comparativeLineChartViewType()
&& viewmodule->IsA("vtkSMComparativeViewProxy"))
{
return new pqComparativeLineChartView(
group, viewname, vtkSMComparativeViewProxy::SafeDownCast(viewmodule), server, p);
group, viewname, vtkSMComparativeViewProxy::SafeDownCast(viewmodule),
server, p);
}
else if (viewmodule->IsA("vtkSMComparativeViewProxy"))
{
......@@ -248,19 +264,25 @@ pqView* pqStandardViewModules::createView(const QString& viewtype,
else if (viewmodule->IsA("vtkSMTwoDRenderViewProxy"))
{
return new pqTwoDRenderView(
group, viewname, viewmodule, server, p);
group, viewname, viewmodule, server, p);
}
else if (viewmodule->IsA("vtkSMScatterPlotViewProxy"))
{
return new pqScatterPlotView(
group, viewname, viewmodule, server, p);
group, viewname, viewmodule, server, p);
}
else if (viewmodule->IsA("vtkSMXYChartViewProxy"))
{
return new pqXYChartView(group, viewname,
vtkSMXYChartViewProxy::SafeDownCast(viewmodule),
server, p);
}
qDebug() << "Failed to create a proxy" << viewmodule->GetClassName();
return NULL;
}
pqDataRepresentation* pqStandardViewModules::createDisplay(const QString& display_type,
pqDataRepresentation* pqStandardViewModules::createDisplay(const QString& display_type,
const QString& group,
const QString& n,
vtkSMProxy* proxy,
......
/*=========================================================================
Program: ParaView
Module: pqXYChartView.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 "pqXYChartView.h"
#include "vtkSMProperty.h"
#include "vtkSMContextViewProxy.h"
#include "pqSMAdaptor.h"
//-----------------------------------------------------------------------------
pqXYChartView::pqXYChartView(const QString& group,
const QString& name,
vtkSMContextViewProxy* viewModule,
pqServer* server,
QObject* parent/*=NULL*/):
Superclass(XYChartViewType(), group, name, viewModule, server, parent)
{
}
//-----------------------------------------------------------------------------
pqXYChartView::~pqXYChartView()
{
}
//-----------------------------------------------------------------------------
void pqXYChartView::setDefaultPropertyValues()
{
this->Superclass::setDefaultPropertyValues();
}
/*=========================================================================
Program: ParaView
Module: pqXYChartView.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 __pqXYChartView_h
#define __pqXYChartView_h
#include "pqContextView.h"
class vtkSMSourceProxy;
class pqDataRepresentation;
/// Bar chart view
class PQCORE_EXPORT pqXYChartView : public pqContextView
{
Q_OBJECT
typedef pqContextView Superclass;
public:
static QString XYChartViewType() { return "XYChartView"; }
static QString XYChartViewTypeName() { return "XY Chart (EXPERIMENTAL)"; }
public:
pqXYChartView(const QString& group,
const QString& name,
vtkSMContextViewProxy* viewModule,
pqServer* server,
QObject* parent=NULL);
virtual ~pqXYChartView();
/// Set property values.
virtual void setDefaultPropertyValues();
private:
pqXYChartView(const pqXYChartView&); // Not implemented.
void operator=(const pqXYChartView&); // Not implemented.
};
#endif
......@@ -226,12 +226,17 @@ IF (VTK_USE_QVTK)
vtkSMChartOptionsProxy.cxx
vtkSMChartRepresentationProxy.cxx
vtkSMChartViewProxy.cxx
# vtkSMContextNamedOptionsModelProxy.cxx
vtkSMContextViewProxy.cxx
vtkSMLineChartViewProxy.cxx
vtkSMXYChartRepresentationProxy.cxx
vtkSMXYChartViewProxy.cxx
)
FIND_PACKAGE(Qt4)
INCLUDE(${QT_USE_FILE})
INCLUDE_DIRECTORIES(
${QT_INCLUDE_DIR}