VTK  9.2.5
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 -------------------------------------------------------------------------*/
35 #ifndef vtkQtTreeView_h
36 #define vtkQtTreeView_h
37 
38 #include "vtkQtView.h"
39 #include "vtkViewsQtModule.h" // For export macro
40 
41 #include "vtkSmartPointer.h" // Needed for member variables
42 #include <QList> // Needed for member variables
43 #include <QPointer> // Needed for member variables
44 
45 class QAbstractItemDelegate;
46 class QAbstractItemView;
48 class QColumnView;
49 class QItemSelection;
50 class QModelIndex;
51 class QTreeView;
52 class vtkApplyColors;
53 class QVBoxLayout;
55 class QItemSelectionModel;
56 
57 class VTKVIEWSQT_EXPORT vtkQtTreeView : public vtkQtView
58 {
59  Q_OBJECT
60 
61 Q_SIGNALS:
62  void expanded(const QModelIndex&);
63  void collapsed(const QModelIndex&);
64  void updatePreviewWidget(const QModelIndex&);
65 
66 public:
67  static vtkQtTreeView* New();
68  vtkTypeMacro(vtkQtTreeView, vtkQtView);
69  void PrintSelf(ostream& os, vtkIndent indent) override;
70 
77  QWidget* GetWidget() override;
78 
82  void SetShowHeaders(bool);
83 
88 
92  void SetEnableDragDrop(bool);
93 
97  void SetShowRootNode(bool);
98 
102  void HideColumn(int i);
103 
107  void ShowColumn(int i);
108 
113 
117  void SetFilterColumn(int i);
118 
122 #if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
123  void SetFilterRegExp(const QRegularExpression& pattern);
124 #else
125  void SetFilterRegExp(const QRegExp& pattern);
126 #endif
127 
132 
136  void Collapse(const QModelIndex& index);
137 
141  void CollapseAll();
142 
146  void Expand(const QModelIndex& index);
147 
153  void ExpandAll();
154 
158  void ExpandToDepth(int depth);
159 
163  void ResizeColumnToContents(int column);
164 
168  void SetUseColumnView(int state);
169 
173  void Update() override;
174 
178  void SetItemDelegate(QAbstractItemDelegate* delegate);
179 
181 
184  void SetColorArrayName(const char* name);
185  const char* GetColorArrayName();
187 
189 
192  void SetColorByArray(bool vis);
194  vtkBooleanMacro(ColorByArray, bool);
196 
197  void ApplyViewTheme(vtkViewTheme* theme) override;
198 
199 protected:
201  ~vtkQtTreeView() override;
202 
205 
206 private Q_SLOTS:
207  void slotQtSelectionChanged(const QItemSelection&, const QItemSelection&);
208 
209 private:
210  void SetVTKSelection();
211  vtkMTimeType CurrentSelectionMTime;
212  vtkMTimeType LastInputMTime;
213 
214  vtkSetStringMacro(ColorArrayNameInternal);
215  vtkGetStringMacro(ColorArrayNameInternal);
216 
217  QPointer<QTreeView> TreeView;
218  QPointer<QColumnView> ColumnView;
219  QPointer<QWidget> Widget;
220  QPointer<QVBoxLayout> Layout;
221  QPointer<QItemSelectionModel> SelectionModel;
222  QList<int> HiddenColumns;
223  vtkQtTreeModelAdapter* TreeAdapter;
224  QAbstractItemView* View;
225  char* ColorArrayNameInternal;
226  QFilterTreeProxyModel* TreeFilter;
227 
229 
230  vtkQtTreeView(const vtkQtTreeView&) = delete;
231  void operator=(const vtkQtTreeView&) = delete;
232 };
233 
234 #endif
apply colors to a data set.
The superclass for all representations.
a simple class to control print indentation
Definition: vtkIndent.h:119
Adapts a tree to a Qt item model.
A VTK view based on a Qt tree view.
Definition: vtkQtTreeView.h:58
void SetFilterTreeLevel(int level)
The column used to filter on.
void SetShowRootNode(bool)
Show the root node of the tree (default is OFF)
void SetColorByArray(bool vis)
Whether to color vertices.
void ApplyViewTheme(vtkViewTheme *theme) override
void SetUseColumnView(int state)
Set whether to use a QColumnView (QTreeView is the default)
void SetFilterRegExp(const QRegularExpression &pattern)
The column used to filter on.
void ExpandToDepth(int depth)
Expands all expandable items to the given depth.
void SetColorArrayName(const char *name)
The array to use for coloring items in view.
void RemoveRepresentationInternal(vtkDataRepresentation *rep) override
void Collapse(const QModelIndex &index)
Collapses the model item specified by the index.
void AddRepresentationInternal(vtkDataRepresentation *rep) override
void SetFilterColumn(int i)
The column used to filter on.
bool GetColorByArray()
Whether to color vertices.
void updatePreviewWidget(const QModelIndex &)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void CollapseAll()
Collapses all expanded items.
void HideAllButFirstColumn()
Hide all but the first column in the view.
static vtkQtTreeView * New()
void Expand(const QModelIndex &index)
Expands the model item specified by the index.
~vtkQtTreeView() override
void collapsed(const QModelIndex &)
QWidget * GetWidget() override
Get the main container of this view (a QWidget).
void SetEnableDragDrop(bool)
Have the view alternate its row colors (default is OFF)
void ResizeColumnToContents(int column)
Resizes the column given to the size of its contents.
void ShowColumn(int i)
Show the column of the given index in the view.
void SetShowHeaders(bool)
Have the view show/hide its column headers (default is ON)
void SetItemDelegate(QAbstractItemDelegate *delegate)
Set item delegate to something custom.
void HideColumn(int i)
Hide the column of the given index from being shown in the view.
void SetAlternatingRowColors(bool)
Have the view alternate its row colors (default is OFF)
const char * GetColorArrayName()
The array to use for coloring items in view.
void ExpandAll()
Expands all expandable items.
void expanded(const QModelIndex &)
void Update() override
Updates the view.
Superclass for Qt widget-based views.
Definition: vtkQtView.h:34
Sets theme colors for a graphical view.
Definition: vtkViewTheme.h:138
@ level
Definition: vtkX3D.h:401
@ name
Definition: vtkX3D.h:225
@ index
Definition: vtkX3D.h:252
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287