VTK  9.1.0
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 Q_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 
85 
89  void SetEnableDragDrop(bool);
90 
94  void SetShowRootNode(bool);
95 
99  void HideColumn(int i);
100 
104  void ShowColumn(int i);
105 
110 
114  void SetFilterColumn(int i);
115 
119 #if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
120  void SetFilterRegExp(const QRegularExpression& pattern);
121 #else
122  void SetFilterRegExp(const QRegExp& pattern);
123 #endif
124 
129 
133  void Collapse(const QModelIndex& index);
134 
138  void CollapseAll();
139 
143  void Expand(const QModelIndex& index);
144 
150  void ExpandAll();
151 
155  void ExpandToDepth(int depth);
156 
160  void ResizeColumnToContents(int column);
161 
165  void SetUseColumnView(int state);
166 
170  void Update() override;
171 
175  void SetItemDelegate(QAbstractItemDelegate* delegate);
176 
178 
181  void SetColorArrayName(const char* name);
182  const char* GetColorArrayName();
184 
186 
189  void SetColorByArray(bool vis);
191  vtkBooleanMacro(ColorByArray, bool);
193 
194  void ApplyViewTheme(vtkViewTheme* theme) override;
195 
196 protected:
198  ~vtkQtTreeView() override;
199 
202 
203 private Q_SLOTS:
204  void slotQtSelectionChanged(const QItemSelection&, const QItemSelection&);
205 
206 private:
207  void SetVTKSelection();
208  vtkMTimeType CurrentSelectionMTime;
209  vtkMTimeType LastInputMTime;
210 
211  vtkSetStringMacro(ColorArrayNameInternal);
212  vtkGetStringMacro(ColorArrayNameInternal);
213 
214  QPointer<QTreeView> TreeView;
215  QPointer<QColumnView> ColumnView;
216  QPointer<QWidget> Widget;
217  QPointer<QVBoxLayout> Layout;
218  QPointer<QItemSelectionModel> SelectionModel;
219  QList<int> HiddenColumns;
220  vtkQtTreeModelAdapter* TreeAdapter;
221  QAbstractItemView* View;
222  char* ColorArrayNameInternal;
223  QFilterTreeProxyModel* TreeFilter;
224 
226 
227  vtkQtTreeView(const vtkQtTreeView&) = delete;
228  void operator=(const vtkQtTreeView&) = delete;
229 };
230 
231 #endif
vtkQtTreeView::GetColorArrayName
const char * GetColorArrayName()
The array to use for coloring items in view.
vtkQtTreeView::Update
void Update() override
Updates the view.
vtkQtTreeView::vtkQtTreeView
vtkQtTreeView()
vtkQtTreeView::collapsed
void collapsed(const QModelIndex &)
vtkQtTreeView::SetColorByArray
void SetColorByArray(bool vis)
Whether to color vertices.
vtkQtTreeView
A VTK view based on a Qt tree view.
Definition: vtkQtTreeView.h:55
vtkQtTreeView::RemoveRepresentationInternal
void RemoveRepresentationInternal(vtkDataRepresentation *rep) override
vtkQtTreeView::SetEnableDragDrop
void SetEnableDragDrop(bool)
Have the view alternate its row colors (default is OFF)
vtkQtTreeView::SetUseColumnView
void SetUseColumnView(int state)
Set whether to use a QColumnView (QTreeView is the default)
vtkSmartPointer< vtkApplyColors >
vtkQtTreeView::ExpandToDepth
void ExpandToDepth(int depth)
Expands all expandable items to the given depth.
vtkApplyColors
apply colors to a data set.
Definition: vtkApplyColors.h:87
vtkQtTreeView::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkQtTreeView::HideColumn
void HideColumn(int i)
Hide the column of the given index from being shown in the view.
vtkQtTreeView::SetShowHeaders
void SetShowHeaders(bool)
Have the view show/hide its column headers (default is ON)
vtkViewTheme
Sets theme colors for a graphical view.
Definition: vtkViewTheme.h:132
vtkX3D::level
@ level
Definition: vtkX3D.h:401
vtkDataRepresentation
The superclass for all representations.
Definition: vtkDataRepresentation.h:92
vtkQtTreeView::ResizeColumnToContents
void ResizeColumnToContents(int column)
Resizes the column given to the size of its contents.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkSmartPointer.h
vtkQtTreeView::SetShowRootNode
void SetShowRootNode(bool)
Show the root node of the tree (default is OFF)
vtkQtTreeView::SetFilterRegExp
void SetFilterRegExp(const QRegularExpression &pattern)
The column used to filter on.
vtkQtTreeView::~vtkQtTreeView
~vtkQtTreeView() override
vtkQtTreeView::ExpandAll
void ExpandAll()
Expands all expandable items.
vtkX3D::name
@ name
Definition: vtkX3D.h:225
vtkQtTreeView::SetItemDelegate
void SetItemDelegate(QAbstractItemDelegate *delegate)
Set item delegate to something custom.
vtkQtTreeView::SetFilterColumn
void SetFilterColumn(int i)
The column used to filter on.
vtkQtTreeView::SetAlternatingRowColors
void SetAlternatingRowColors(bool)
Have the view alternate its row colors (default is OFF)
vtkQtTreeView::GetWidget
QWidget * GetWidget() override
Get the main container of this view (a QWidget).
vtkQtView.h
vtkQtTreeView::ApplyViewTheme
void ApplyViewTheme(vtkViewTheme *theme) override
vtkQtTreeView::ShowColumn
void ShowColumn(int i)
Show the column of the given index in the view.
vtkQtTreeView::GetColorByArray
bool GetColorByArray()
Whether to color vertices.
vtkQtTreeView::CollapseAll
void CollapseAll()
Collapses all expanded items.
vtkQtTreeView::SetColorArrayName
void SetColorArrayName(const char *name)
The array to use for coloring items in view.
vtkQtTreeView::HideAllButFirstColumn
void HideAllButFirstColumn()
Hide all but the first column in the view.
vtkQtView
Superclass for Qt widget-based views.
Definition: vtkQtView.h:34
vtkQtTreeView::Collapse
void Collapse(const QModelIndex &index)
Collapses the model item specified by the index.
vtkQtTreeView::New
static vtkQtTreeView * New()
vtkQtTreeView::expanded
void expanded(const QModelIndex &)
vtkQtTreeView::AddRepresentationInternal
void AddRepresentationInternal(vtkDataRepresentation *rep) override
vtkX3D::index
@ index
Definition: vtkX3D.h:252
vtkQtTreeView::Expand
void Expand(const QModelIndex &index)
Expands the model item specified by the index.
vtkQtTreeView::updatePreviewWidget
void updatePreviewWidget(const QModelIndex &)
vtkQtTreeView::SetFilterTreeLevel
void SetFilterTreeLevel(int level)
The column used to filter on.
vtkQtTreeModelAdapter
Adapts a tree to a Qt item model.
Definition: vtkQtTreeModelAdapter.h:49
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
QFilterTreeProxyModel
Definition: QFilterTreeProxyModel.h:42