VTK
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 "vtkViewsQtModule.h" // For export macro
39 #include "vtkQtView.h"
40 
41 #include <QList> // Needed for member variables
42 #include <QPointer> // Needed for member variables
43 #include "vtkSmartPointer.h" // 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 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 
87  void SetAlternatingRowColors(bool);
88 
92  void SetEnableDragDrop(bool);
93 
97  void SetShowRootNode(bool);
98 
102  void HideColumn(int i);
103 
107  void ShowColumn(int i);
108 
112  void HideAllButFirstColumn();
113 
117  void SetFilterColumn(int i);
118 
122  void SetFilterRegExp(const QRegExp& pattern);
123 
127  void SetFilterTreeLevel(int level);
128 
132  void Collapse( const QModelIndex & index );
133 
137  void CollapseAll();
138 
142  void Expand ( const QModelIndex & index );
143 
149  void ExpandAll ();
150 
154  void ExpandToDepth ( int depth );
155 
159  void ResizeColumnToContents ( int column );
160 
164  void SetUseColumnView(int state);
165 
169  void Update() override;
170 
174  void SetItemDelegate(QAbstractItemDelegate* delegate);
175 
177 
180  void SetColorArrayName(const char* name);
181  const char* GetColorArrayName();
183 
185 
188  void SetColorByArray(bool vis);
189  bool GetColorByArray();
190  vtkBooleanMacro(ColorByArray, bool);
192 
193  void ApplyViewTheme(vtkViewTheme* theme) override;
194 
195 protected:
196  vtkQtTreeView();
197  ~vtkQtTreeView() override;
198 
201 
202 private slots:
203  void slotQtSelectionChanged(const QItemSelection&,const QItemSelection&);
204 
205 private:
206  void SetVTKSelection();
207  vtkMTimeType CurrentSelectionMTime;
208  vtkMTimeType LastInputMTime;
209 
210  vtkSetStringMacro(ColorArrayNameInternal);
211  vtkGetStringMacro(ColorArrayNameInternal);
212 
213  QPointer<QTreeView> TreeView;
214  QPointer<QColumnView> ColumnView;
215  QPointer<QWidget> Widget;
216  QPointer<QVBoxLayout> Layout;
217  QPointer<QItemSelectionModel> SelectionModel;
218  QList<int> HiddenColumns;
219  vtkQtTreeModelAdapter* TreeAdapter;
220  QAbstractItemView* View;
221  char* ColorArrayNameInternal;
222  QFilterTreeProxyModel* TreeFilter;
223 
225 
226  vtkQtTreeView(const vtkQtTreeView&) = delete;
227  void operator=(const vtkQtTreeView&) = delete;
228 
229 };
230 
231 #endif
virtual void ApplyViewTheme(vtkViewTheme *vtkNotUsed(theme))
Apply a theme to the view.
Definition: vtkView.h:153
static vtkView * New()
Adapts a tree to a Qt item model.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:302
virtual void Update()
Update the view.
virtual QWidget * GetWidget()=0
Get the main container of this view (a QWidget).
virtual void AddRepresentationInternal(vtkDataRepresentation *vtkNotUsed(rep))
Subclass "hooks" for notifying subclasses of vtkView when representations are added or removed...
Definition: vtkView.h:237
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Sets theme colors for a graphical view.
Definition: vtkViewTheme.h:48
a simple class to control print indentation
Definition: vtkIndent.h:39
The superclass for all representations.
apply colors to a data set.
Superclass for Qt widget-based views.
Definition: vtkQtView.h:31
virtual void RemoveRepresentationInternal(vtkDataRepresentation *vtkNotUsed(rep))
Meant for use by subclasses and vtkRepresentation subclasses.
Definition: vtkView.h:238
A VTK view based on a Qt tree view.
Definition: vtkQtTreeView.h:57