VTK  9.0.1
vtkQtTreeView.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkQtTreeView.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /*-------------------------------------------------------------------------
16  Copyright 2008 Sandia Corporation.
17  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
18  the U.S. Government retains certain rights in this software.
19 -------------------------------------------------------------------------*/
32 #ifndef vtkQtTreeView_h
33 #define vtkQtTreeView_h
34 
35 #include "vtkQtView.h"
36 #include "vtkViewsQtModule.h" // For export macro
37 
38 #include "vtkSmartPointer.h" // Needed for member variables
39 #include <QList> // Needed for member variables
40 #include <QPointer> // Needed for member variables
41 
42 class QAbstractItemDelegate;
43 class QAbstractItemView;
45 class QColumnView;
46 class QItemSelection;
47 class QModelIndex;
48 class QTreeView;
49 class vtkApplyColors;
50 class QVBoxLayout;
52 class QItemSelectionModel;
53 
54 class VTKVIEWSQT_EXPORT vtkQtTreeView : public vtkQtView
55 {
56  Q_OBJECT
57 
58 signals:
59  void expanded(const QModelIndex&);
60  void collapsed(const QModelIndex&);
61  void updatePreviewWidget(const QModelIndex&);
62 
63 public:
64  static vtkQtTreeView* New();
65  vtkTypeMacro(vtkQtTreeView, vtkQtView);
66  void PrintSelf(ostream& os, vtkIndent indent) override;
67 
74  QWidget* GetWidget() override;
75 
79  void SetShowHeaders(bool);
80 
84  void SetAlternatingRowColors(bool);
85 
89  void SetEnableDragDrop(bool);
90 
94  void SetShowRootNode(bool);
95 
99  void HideColumn(int i);
100 
104  void ShowColumn(int i);
105 
109  void HideAllButFirstColumn();
110 
114  void SetFilterColumn(int i);
115 
119  void SetFilterRegExp(const QRegExp& pattern);
120 
124  void SetFilterTreeLevel(int level);
125 
129  void Collapse(const QModelIndex& index);
130 
134  void CollapseAll();
135 
139  void Expand(const QModelIndex& index);
140 
146  void ExpandAll();
147 
151  void ExpandToDepth(int depth);
152 
156  void ResizeColumnToContents(int column);
157 
161  void SetUseColumnView(int state);
162 
166  void Update() override;
167 
171  void SetItemDelegate(QAbstractItemDelegate* delegate);
172 
174 
177  void SetColorArrayName(const char* name);
178  const char* GetColorArrayName();
180 
182 
185  void SetColorByArray(bool vis);
186  bool GetColorByArray();
187  vtkBooleanMacro(ColorByArray, bool);
189 
190  void ApplyViewTheme(vtkViewTheme* theme) override;
191 
192 protected:
193  vtkQtTreeView();
194  ~vtkQtTreeView() override;
195 
198 
199 private slots:
200  void slotQtSelectionChanged(const QItemSelection&, const QItemSelection&);
201 
202 private:
203  void SetVTKSelection();
204  vtkMTimeType CurrentSelectionMTime;
205  vtkMTimeType LastInputMTime;
206 
207  vtkSetStringMacro(ColorArrayNameInternal);
208  vtkGetStringMacro(ColorArrayNameInternal);
209 
210  QPointer<QTreeView> TreeView;
211  QPointer<QColumnView> ColumnView;
212  QPointer<QWidget> Widget;
213  QPointer<QVBoxLayout> Layout;
214  QPointer<QItemSelectionModel> SelectionModel;
215  QList<int> HiddenColumns;
216  vtkQtTreeModelAdapter* TreeAdapter;
217  QAbstractItemView* View;
218  char* ColorArrayNameInternal;
219  QFilterTreeProxyModel* TreeFilter;
220 
222 
223  vtkQtTreeView(const vtkQtTreeView&) = delete;
224  void operator=(const vtkQtTreeView&) = delete;
225 };
226 
227 #endif
vtkQtTreeView
A VTK view based on a Qt tree view.
Definition: vtkQtTreeView.h:54
vtkSmartPointer< vtkApplyColors >
vtkView::AddRepresentationInternal
virtual void AddRepresentationInternal(vtkDataRepresentation *vtkNotUsed(rep))
Subclass "hooks" for notifying subclasses of vtkView when representations are added or removed.
Definition: vtkView.h:234
vtkApplyColors
apply colors to a data set.
Definition: vtkApplyColors.h:86
vtkViewTheme
Sets theme colors for a graphical view.
Definition: vtkViewTheme.h:42
vtkX3D::level
@ level
Definition: vtkX3D.h:401
vtkDataRepresentation
The superclass for all representations.
Definition: vtkDataRepresentation.h:72
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkView::ApplyViewTheme
virtual void ApplyViewTheme(vtkViewTheme *vtkNotUsed(theme))
Apply a theme to the view.
Definition: vtkView.h:156
vtkSmartPointer.h
vtkView::New
static vtkView * New()
vtkX3D::name
@ name
Definition: vtkX3D.h:225
vtkQtView.h
vtkView::Update
virtual void Update()
Update the view.
vtkView::RemoveRepresentationInternal
virtual void RemoveRepresentationInternal(vtkDataRepresentation *vtkNotUsed(rep))
Definition: vtkView.h:235
vtkQtView
Superclass for Qt widget-based views.
Definition: vtkQtView.h:31
vtkQtView::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkX3D::index
@ index
Definition: vtkX3D.h:252
vtkQtView::GetWidget
virtual QWidget * GetWidget()=0
Get the main container of this view (a QWidget).
vtkQtTreeModelAdapter
Adapts a tree to a Qt item model.
Definition: vtkQtTreeModelAdapter.h:48
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:293
QFilterTreeProxyModel
Definition: QFilterTreeProxyModel.h:41