Commit 92f9c0f6 authored by Jeff Baumes's avatar Jeff Baumes

ENH: Qt view re-architecting.

Use vtkQtView as a base class for all vtkQtXXXViews.

 - Add record and column views types.

 - Update examples that use qt views.

 - Update paraview bar chart to use the new API.

 - Update OverView plugins that use qt views.

 - Update test using qt views.

 - Changing GetChartWidget to GetWidget.

 - Adding stubs for getting chart options for stacked chart and
   statistical box plot.
parent ab6917de
...@@ -50,11 +50,19 @@ EasyView::EasyView() ...@@ -50,11 +50,19 @@ EasyView::EasyView()
this->TableView = vtkSmartPointer<vtkQtTableView>::New(); this->TableView = vtkSmartPointer<vtkQtTableView>::New();
this->ColumnView = vtkSmartPointer<vtkQtTreeView>::New(); this->ColumnView = vtkSmartPointer<vtkQtTreeView>::New();
// Set widgets for the tree and table views // Set widgets for the tree and table views
this->TreeView->SetItemView(this->ui->treeView); QVBoxLayout *layout1 = new QVBoxLayout;
this->TableView->SetItemView(this->ui->tableView); layout1->addWidget(this->TreeView->GetWidget());
this->ColumnView->SetItemView(this->ui->columnView); this->ui->treeFrame->setLayout(layout1);
QVBoxLayout *layout2 = new QVBoxLayout;
layout2->addWidget(this->TableView->GetWidget());
this->ui->tableFrame->setLayout(layout2);
QVBoxLayout *layout3 = new QVBoxLayout;
layout3->addWidget(this->ColumnView->GetWidget());
this->ui->columnFrame->setLayout(layout3);
// Graph View needs to get my render window // Graph View needs to get my render window
this->GraphView->SetupRenderWindow(this->ui->vtkGraphViewWidget->GetRenderWindow()); this->GraphView->SetupRenderWindow(this->ui->vtkGraphViewWidget->GetRenderWindow());
...@@ -144,7 +152,7 @@ void EasyView::slotOpenXMLFile() ...@@ -144,7 +152,7 @@ void EasyView::slotOpenXMLFile()
// Now hand off tree to the tree view // Now hand off tree to the tree view
this->TreeView->SetRepresentationFromInputConnection(this->XMLReader->GetOutputPort()); this->TreeView->SetRepresentationFromInputConnection(this->XMLReader->GetOutputPort());
this->ColumnView->SetRepresentationFromInputConnection(this->XMLReader->GetOutputPort()); this->ColumnView->SetRepresentationFromInputConnection(this->XMLReader->GetOutputPort());
this->ui->treeView->expandAll(); this->TreeView->ExpandAll();
// Extract a table and give to table view // Extract a table and give to table view
VTK_CREATE(vtkDataObjectToTable, toTable); VTK_CREATE(vtkDataObjectToTable, toTable);
......
...@@ -69,37 +69,28 @@ ...@@ -69,37 +69,28 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<widget class="QTreeView" name="treeView" > <widget class="QFrame" name="treeFrame" >
<property name="sizePolicy" > <property name="frameShape" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" > <enum>QFrame::StyledPanel</enum>
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="alternatingRowColors" > <property name="frameShadow" >
<bool>true</bool> <enum>QFrame::Raised</enum>
</property> </property>
</widget> </widget>
<widget class="QTableView" name="tableView" > <widget class="QFrame" name="tableFrame" >
<property name="sizePolicy" > <property name="frameShape" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" > <enum>QFrame::StyledPanel</enum>
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="alternatingRowColors" > <property name="frameShadow" >
<bool>true</bool> <enum>QFrame::Raised</enum>
</property> </property>
</widget> </widget>
<widget class="QColumnView" name="columnView" > <widget class="QFrame" name="columnFrame" >
<property name="sizePolicy" > <property name="frameShape" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" > <enum>QFrame::StyledPanel</enum>
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="alternatingRowColors" > <property name="frameShadow" >
<bool>true</bool> <enum>QFrame::Raised</enum>
</property> </property>
</widget> </widget>
</widget> </widget>
...@@ -142,7 +133,7 @@ ...@@ -142,7 +133,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1002</width> <width>1002</width>
<height>25</height> <height>21</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile" > <widget class="QMenu" name="menuFile" >
......
...@@ -55,11 +55,23 @@ StatsView::StatsView() ...@@ -55,11 +55,23 @@ StatsView::StatsView()
this->TableView4 = vtkSmartPointer<vtkQtTableView>::New(); this->TableView4 = vtkSmartPointer<vtkQtTableView>::New();
// Set widgets for the tree and table views // Set widgets for the tree and table views
this->TableView1->SetItemView(this->ui->tableView1);
this->TableView2->SetItemView(this->ui->tableView2);
this->TableView3->SetItemView(this->ui->tableView3);
this->TableView4->SetItemView(this->ui->tableView4);
QVBoxLayout *layout1 = new QVBoxLayout;
layout1->addWidget(this->TableView1->GetWidget());
this->ui->tableFrame1->setLayout(layout1);
QVBoxLayout *layout2 = new QVBoxLayout;
layout2->addWidget(this->TableView2->GetWidget());
this->ui->tableFrame2->setLayout(layout2);
QVBoxLayout *layout3 = new QVBoxLayout;
layout3->addWidget(this->TableView3->GetWidget());
this->ui->tableFrame3->setLayout(layout3);
QVBoxLayout *layout4 = new QVBoxLayout;
layout4->addWidget(this->TableView4->GetWidget());
this->ui->tableFrame4->setLayout(layout4);
// Set up action signals and slots // Set up action signals and slots
connect(this->ui->actionOpenSQLiteDB, SIGNAL(triggered()), this, SLOT(slotOpenSQLiteDB())); connect(this->ui->actionOpenSQLiteDB, SIGNAL(triggered()), this, SLOT(slotOpenSQLiteDB()));
}; };
......
...@@ -66,52 +66,37 @@ ...@@ -66,52 +66,37 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<widget class="QTableView" name="tableView1" > <widget class="QFrame" name="tableFrame1" >
<property name="sizePolicy" > <property name="frameShape" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" > <enum>QFrame::StyledPanel</enum>
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="alternatingRowColors" > <property name="frameShadow" >
<bool>true</bool> <enum>QFrame::Raised</enum>
</property> </property>
</widget> </widget>
<widget class="QTableView" name="tableView2" > <widget class="QFrame" name="tableFrame2" >
<property name="sizePolicy" > <property name="frameShape" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" > <enum>QFrame::StyledPanel</enum>
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="alternatingRowColors" > <property name="frameShadow" >
<bool>true</bool> <enum>QFrame::Raised</enum>
</property> </property>
</widget> </widget>
<widget class="QTableView" name="tableView3" > <widget class="QFrame" name="tableFrame3" >
<property name="sizePolicy" > <property name="frameShape" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" > <enum>QFrame::StyledPanel</enum>
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="alternatingRowColors" > <property name="frameShadow" >
<bool>true</bool> <enum>QFrame::Raised</enum>
</property> </property>
</widget> </widget>
</widget> </widget>
<widget class="QTableView" native="1" name="tableView4" > <widget class="QFrame" name="tableFrame4" >
<property name="sizePolicy" > <property name="frameShape" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" > <enum>QFrame::StyledPanel</enum>
<horstretch>1</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property> </property>
<property name="minimumSize" > <property name="frameShadow" >
<size> <enum>QFrame::Raised</enum>
<width>300</width>
<height>300</height>
</size>
</property> </property>
</widget> </widget>
</widget> </widget>
...@@ -139,7 +124,7 @@ ...@@ -139,7 +124,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1002</width> <width>1002</width>
<height>25</height> <height>21</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile" > <widget class="QMenu" name="menuFile" >
...@@ -181,13 +166,6 @@ ...@@ -181,13 +166,6 @@
</property> </property>
</action> </action>
</widget> </widget>
<customwidgets>
<customwidget>
<class>QVTKWidget</class>
<extends>QWidget</extends>
<header>QVTKWidget.h</header>
</customwidget>
</customwidgets>
<resources> <resources>
<include location="Icons/icons.qrc" /> <include location="Icons/icons.qrc" />
</resources> </resources>
......
...@@ -59,14 +59,16 @@ IF(DESIRED_QT_VERSION MATCHES 4) ...@@ -59,14 +59,16 @@ IF(DESIRED_QT_VERSION MATCHES 4)
# add additional files depending on infovis and/or views # add additional files depending on infovis and/or views
IF(VTK_USE_VIEWS) IF(VTK_USE_VIEWS)
SET( QVTKLibSrcs ${QVTKLibSrcs} SET( QVTKLibSrcs ${QVTKLibSrcs}
vtkQtBarChartView.cxx
vtkQtChartRepresentation.cxx vtkQtChartRepresentation.cxx
vtkQtChartTableRepresentation.cxx vtkQtChartTableRepresentation.cxx
vtkQtChartView.cxx vtkQtChartView.cxx
vtkQtChartViewBase.cxx vtkQtChartViewBase.cxx
vtkQtBarChartView.cxx vtkQtColumnView.cxx
vtkQtLineChartView.cxx
vtkQtItemView.cxx vtkQtItemView.cxx
vtkQtLineChartView.cxx
vtkQtListView.cxx vtkQtListView.cxx
vtkQtRecordView.cxx
vtkQtStackedChartView.cxx vtkQtStackedChartView.cxx
vtkQtStatisticalBoxChartView.cxx vtkQtStatisticalBoxChartView.cxx
vtkQtTableDataRepresentation.cxx vtkQtTableDataRepresentation.cxx
...@@ -78,9 +80,17 @@ IF(DESIRED_QT_VERSION MATCHES 4) ...@@ -78,9 +80,17 @@ IF(DESIRED_QT_VERSION MATCHES 4)
) )
SET_SOURCE_FILES_PROPERTIES(vtkQtView.cxx ABSTRACT ) SET_SOURCE_FILES_PROPERTIES(vtkQtView.cxx ABSTRACT )
SET ( QVTKMocHeaders ${QVTKMocHeaders} SET ( QVTKMocHeaders ${QVTKMocHeaders}
vtkQtView.h vtkQtBarChartView.h
vtkQtItemView.h
vtkQtChartRepresentation.h vtkQtChartRepresentation.h
vtkQtChartViewBase.h
vtkQtColumnView.h
vtkQtItemView.h
vtkQtLineChartView.h
vtkQtListView.h
vtkQtRecordView.h
vtkQtTableView.h
vtkQtTreeView.h
vtkQtView.h
) )
ENDIF(VTK_USE_VIEWS) ENDIF(VTK_USE_VIEWS)
......
...@@ -30,14 +30,14 @@ ...@@ -30,14 +30,14 @@
#include "vtkQtChartWidget.h" #include "vtkQtChartWidget.h"
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
vtkCxxRevisionMacro(vtkQtBarChartView, "1.4"); vtkCxxRevisionMacro(vtkQtBarChartView, "1.5");
vtkStandardNewMacro(vtkQtBarChartView); vtkStandardNewMacro(vtkQtBarChartView);
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
vtkQtBarChartView::vtkQtBarChartView() vtkQtBarChartView::vtkQtBarChartView()
{ {
// Get the chart widget from the base class. // Get the chart widget from the base class.
vtkQtChartWidget* chart = this->GetChartWidget(); vtkQtChartWidget* chart = qobject_cast<vtkQtChartWidget*>(this->GetWidget());
vtkQtChartArea* area = chart->getChartArea(); vtkQtChartArea* area = chart->getChartArea();
// Create the bar chart and model. Add them to the chart between the // Create the bar chart and model. Add them to the chart between the
...@@ -104,6 +104,12 @@ vtkQtChartSeriesModelCollection* vtkQtBarChartView::GetChartSeriesModel() ...@@ -104,6 +104,12 @@ vtkQtChartSeriesModelCollection* vtkQtBarChartView::GetChartSeriesModel()
return this->BarModel; return this->BarModel;
} }
//----------------------------------------------------------------------------
vtkQtChartSeriesOptions* vtkQtBarChartView::GetChartSeriesOptions(int idx)
{
return this->BarChart->getSeriesOptions(idx);
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void vtkQtBarChartView::PrintSelf(ostream& os, vtkIndent indent) void vtkQtBarChartView::PrintSelf(ostream& os, vtkIndent indent)
{ {
......
...@@ -27,13 +27,17 @@ ...@@ -27,13 +27,17 @@
#ifndef __vtkQtBarChartView_h #ifndef __vtkQtBarChartView_h
#define __vtkQtBarChartView_h #define __vtkQtBarChartView_h
#include "QVTKWin32Header.h"
#include "vtkQtChartViewBase.h" #include "vtkQtChartViewBase.h"
class vtkQtBarChart; class vtkQtBarChart;
class vtkQtChartSeriesModelCollection; class vtkQtChartSeriesModelCollection;
class vtkQtChartSeriesOptions;
class QVTK_EXPORT vtkQtBarChartView : public vtkQtChartViewBase class QVTK_EXPORT vtkQtBarChartView : public vtkQtChartViewBase
{ {
Q_OBJECT
public: public:
static vtkQtBarChartView *New(); static vtkQtBarChartView *New();
vtkTypeRevisionMacro(vtkQtBarChartView, vtkQtChartViewBase); vtkTypeRevisionMacro(vtkQtBarChartView, vtkQtChartViewBase);
...@@ -69,11 +73,14 @@ public: ...@@ -69,11 +73,14 @@ public:
virtual vtkQtChartSeriesModelCollection* GetChartSeriesModel(); virtual vtkQtChartSeriesModelCollection* GetChartSeriesModel();
//ETX //ETX
// Description:
// Gets the series options.
virtual vtkQtChartSeriesOptions* GetChartSeriesOptions(int series);
protected: protected:
vtkQtBarChartView(); vtkQtBarChartView();
~vtkQtBarChartView(); ~vtkQtBarChartView();
protected:
vtkQtBarChart *BarChart; vtkQtBarChart *BarChart;
vtkQtChartSeriesModelCollection *BarModel; vtkQtChartSeriesModelCollection *BarModel;
......
...@@ -103,8 +103,7 @@ private: ...@@ -103,8 +103,7 @@ private:
}; };
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
vtkCxxRevisionMacro(vtkQtChartViewBase, "1.7"); vtkCxxRevisionMacro(vtkQtChartViewBase, "1.8");
vtkStandardNewMacro(vtkQtChartViewBase);
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
vtkQtChartViewBase::vtkQtChartViewBase() vtkQtChartViewBase::vtkQtChartViewBase()
...@@ -141,7 +140,7 @@ vtkQtChartViewBase::~vtkQtChartViewBase() ...@@ -141,7 +140,7 @@ vtkQtChartViewBase::~vtkQtChartViewBase()
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void vtkQtChartViewBase::Show() void vtkQtChartViewBase::Show()
{ {
this->GetChartWidget()->show(); this->Internal->Chart->show();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
...@@ -495,7 +494,7 @@ void vtkQtChartViewBase::AddChartSelectionHandlers(vtkQtChartMouseSelection*) ...@@ -495,7 +494,7 @@ void vtkQtChartViewBase::AddChartSelectionHandlers(vtkQtChartMouseSelection*)
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
vtkQtChartWidget* vtkQtChartViewBase::GetChartWidget() QWidget* vtkQtChartViewBase::GetWidget()
{ {
return this->Internal->Chart; return this->Internal->Chart;
} }
...@@ -503,7 +502,7 @@ vtkQtChartWidget* vtkQtChartViewBase::GetChartWidget() ...@@ -503,7 +502,7 @@ vtkQtChartWidget* vtkQtChartViewBase::GetChartWidget()
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
vtkQtChartArea* vtkQtChartViewBase::GetChartArea() vtkQtChartArea* vtkQtChartViewBase::GetChartArea()
{ {
return this->GetChartWidget()->getChartArea(); return this->Internal->Chart->getChartArea();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
......
...@@ -29,23 +29,32 @@ ...@@ -29,23 +29,32 @@
#define __vtkQtChartViewBase_h #define __vtkQtChartViewBase_h
#include "QVTKWin32Header.h" #include "QVTKWin32Header.h"
#include "vtkView.h" #include "vtkQtView.h"
class vtkQtChartArea; class vtkQtChartArea;
class vtkQtChartAxis; class vtkQtChartAxis;
class vtkQtChartLegend; class vtkQtChartLegend;
class vtkQtChartMouseSelection; class vtkQtChartMouseSelection;
class vtkQtChartSeriesModelCollection; class vtkQtChartSeriesModelCollection;
class vtkQtChartSeriesOptions;
class vtkQtChartWidget; class vtkQtChartWidget;
class vtkTable; class vtkTable;
class QVTK_EXPORT vtkQtChartViewBase : public vtkView class QVTK_EXPORT vtkQtChartViewBase : public vtkQtView
{ {
Q_OBJECT
public: public:
static vtkQtChartViewBase *New(); vtkTypeRevisionMacro(vtkQtChartViewBase, vtkQtView);
vtkTypeRevisionMacro(vtkQtChartViewBase, vtkView);
void PrintSelf(ostream& os, vtkIndent indent); void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Get the main container of this view (a QWidget).
// The application typically places the view with a call
// to GetWidget(): something like this
// this->ui->box->layout()->addWidget(this->View->GetWidget());
virtual QWidget* GetWidget();
// Description: // Description:
// Updates the view. // Updates the view.
virtual void Update(); virtual void Update();
...@@ -170,10 +179,6 @@ public: ...@@ -170,10 +179,6 @@ public:
// Adds chart layer selection handlers to the mouse selection. // Adds chart layer selection handlers to the mouse selection.
virtual void AddChartSelectionHandlers(vtkQtChartMouseSelection* selector); virtual void AddChartSelectionHandlers(vtkQtChartMouseSelection* selector);
// Description:
// Gets the chart widget, this is the main widget to display.
vtkQtChartWidget* GetChartWidget();
// Description: // Description:
// Gets the chart area from the chart widget. This method is equivalent // Gets the chart area from the chart widget. This method is equivalent
// to GetChartWidget()->getChartArea(). // to GetChartWidget()->getChartArea().
...@@ -187,6 +192,10 @@ public: ...@@ -187,6 +192,10 @@ public:
// Gets the chart series model. // Gets the chart series model.
virtual vtkQtChartSeriesModelCollection* GetChartSeriesModel(); virtual vtkQtChartSeriesModelCollection* GetChartSeriesModel();
// Description:
// Gets the series options.
virtual vtkQtChartSeriesOptions* GetChartSeriesOptions(int series) = 0;
// Description: // Description:
// Gets the chart legend widget. // Gets the chart legend widget.
vtkQtChartLegend* GetLegend(); vtkQtChartLegend* GetLegend();
...@@ -206,13 +215,13 @@ public: ...@@ -206,13 +215,13 @@ public:
void SetColorSchemeToCitrus(); void SetColorSchemeToCitrus();
protected: protected:
vtkQtChartViewBase();
~vtkQtChartViewBase();
// Description: // Description:
// Create a vtkQtChartRepresentation for the given input connection. // Create a vtkQtChartRepresentation for the given input connection.
virtual vtkDataRepresentation* CreateDefaultRepresentation(vtkAlgorithmOutput* conn); virtual vtkDataRepresentation* CreateDefaultRepresentation(vtkAlgorithmOutput* conn);
vtkQtChartViewBase();
~vtkQtChartViewBase();
private: private:
//BTX //BTX
class vtkInternal; class vtkInternal;
......
/*=========================================================================
Program: Visualization Toolkit
Module: vtkQtColumnView.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm 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.
=========================================================================*/
/*-------------------------------------------------------------------------
Copyright 2008 Sandia Corporation.
Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
the U.S. Government retains certain rights in this software.
-------------------------------------------------------------------------*/
#include "vtkQtColumnView.h"
#include <QItemSelection>
#include <QColumnView>
#include "vtkAlgorithm.h"
#include "vtkAlgorithmOutput.h"
#include "vtkConvertSelection.h"
#include "vtkDataRepresentation.h"
#include "vtkIdTypeArray.h"
#include "vtkInformation.h"
#include "vtkObjectFactory.h"
#include "vtkQtTreeModelAdapter.h"
#include "vtkSelection.h"
#include "vtkSelectionLink.h"
#include "vtkSelectionNode.h"
#include "vtkSmartPointer.h"
#include "vtkTree.h"
vtkCxxRevisionMacro(vtkQtColumnView, "1.2");
vtkStandardNewMacro(vtkQtColumnView);
//----------------------------------------------------------------------------
vtkQtColumnView::vtkQtColumnView()
{
this->ColumnView = new QColumnView();
this->TreeAdapter = new vtkQtTreeModelAdapter();
this->ColumnView->setModel(this->TreeAdapter);
this->ColumnView->setSelectionMode(QAbstractItemView::SingleSelection);
this->Selecting = false;
QObject::connect(this->ColumnView->selectionModel(),
SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)),
this,
SLOT(slotSelectionChanged(const QItemSelection&,const QItemSelection&)));
}
//----------------------------------------------------------------------------
vtkQtColumnView::~vtkQtColumnView()
{
if(this->ColumnView)
{
delete this->ColumnView;
}
delete this->TreeAdapter;
}
//----------------------------------------------------------------------------
QWidget* vtkQtColumnView::GetWidget()
{
return this->ColumnView;
}
//----------------------------------------------------------------------------
vtkQtAbstractModelAdapter* vtkQtColumnView::GetItemModelAdapter()
{
return this->TreeAdapter;
}
//----------------------------------------------------------------------------
void vtkQtColumnView::AddInputConnection( int vtkNotUsed(port), int vtkNotUsed(index),
vtkAlgorithmOutput* conn, vtkAlgorithmOutput* vtkNotUsed(selectionConn))
{
// Get a handle to the input data object. Note: For now
// we are enforcing that the input data is a tree.
conn->GetProducer()->Update();
vtkDataObject *d = conn->GetProducer()->GetOutputDataObject(0);
vtkTree *tree = vtkTree::SafeDownCast(d);
// Enforce input
if (!tree)
{
vtkErrorMacro("vtkQtERMView requires a vtkTree as input (for now)");
return;
}
// Give the data object to the Qt Tree Adapters
this->TreeAdapter->SetVTKDataObject(tree);
// Now set the Qt Adapters (qt models) on the views
this->ColumnView->update();
}
//----------------------------------------------------------------------------
void vtkQtColumnView::RemoveInputConnection(int vtkNotUsed(port), int vtkNotUsed(index),
vtkAlgorithmOutput* conn, vtkAlgorithmOutput* vtkNotUsed(selectionConn))
{
// Remove VTK data from the adapter
conn->GetProducer()->Update();
vtkDataObject *d = conn->GetProducer()->GetOutputDataObject(0);
if (this->TreeAdapter->GetVTKDataObject() == d)
{
this->TreeAdapter->SetVTKDataObject(0);
this->ColumnView->update();
}
}
//----------------------------------------------------------------------------
void vtkQtColumnView::slotSelectionChanged(const QItemSelection& vtkNotUsed(s1), const QItemSelection& vtkNotUsed(s2))
{
this->Selecting = true;
// Create index selection
vtkSmartPointer<vtkSelection> selection =
vtkSmartPointer<vtkSelection>::New();
vtkSmartPointer<vtkSelectionNode> node =
vtkSmartPointer<vtkSelectionNode>::New();
node->SetContentType(vtkSelectionNode::INDICES);
node->SetFieldType(vtkSelectionNode::VERTEX);
vtkSmartPointer<vtkIdTypeArray> idarr =
vtkSmartPointer<vtkIdTypeArray>::New();
node->SetSelectionList(idarr);
selection->AddNode(node);
const QModelIndexList list = this->ColumnView->selectionModel()->selectedRows();
// For index selection do this odd little dance with two maps :)
for (int i = 0; i < list.size(); i++)
{
vtkIdType pid = this->TreeAdapter->QModelIndexToPedigree(list.at(i));
idarr->InsertNextValue(this->TreeAdapter->PedigreeToId(pid));
}
// Convert to the correct type of selection
vtkDataObject* data = this->TreeAdapter->GetVTKDataObject();
vtkSmartPointer<vtkSelection> converted;
converted.TakeReference(vtkConvertSelection::ToSelectionType(
selection, data, this->SelectionType, this->SelectionArrayNames));
// Call select on the representation
this->GetRepresentation()->Select(this, converted);
this->Selecting = false;
}
//----------------------------------------------------------------------------
void vtkQtColumnView::Update()
{
vtkDataRepresentation* rep = this->GetRepresentation();
if (!