VTK
vtkQtTableView.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkQtTableView.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 -------------------------------------------------------------------------*/
37 #ifndef __vtkQtTableView_h
38 #define __vtkQtTableView_h
39 
40 #include "QVTKWin32Header.h"
41 #include "vtkQtView.h"
42 
43 #include <QPointer>
44 #include <QSortFilterProxyModel>
46 #include "vtkSmartPointer.h"
47 
49 class vtkApplyColors;
51 class vtkIdTypeArray;
52 class QItemSelection;
53 class QTableView;
55 
56 class QVTK_EXPORT vtkQtTableView : public vtkQtView
57 {
58 Q_OBJECT
59 
60 public:
61  static vtkQtTableView *New();
62  vtkTypeMacro(vtkQtTableView, vtkQtView);
63  void PrintSelf(ostream& os, vtkIndent indent);
64 
68  virtual QWidget* GetWidget();
69 
71  void SetShowVerticalHeaders(bool);
72 
74  void SetShowHorizontalHeaders(bool);
75 
76  enum
77  {
78  FIELD_DATA = 0,
79  POINT_DATA = 1,
80  CELL_DATA = 2,
81  VERTEX_DATA = 3,
82  EDGE_DATA = 4,
83  ROW_DATA = 5,
84  };
85 
87 
89  vtkGetMacro(FieldType, int);
90  void SetFieldType(int);
92 
94  void SetEnableDragDrop(bool);
95 
98  void SetSortingEnabled(bool);
99 
101 
104  void SetShowAll(bool);
105  vtkGetMacro(ShowAll, bool);
107 
109 
111  vtkSetStringMacro(ColumnName);
112  vtkGetStringMacro(ColumnName);
114 
115  void SetColumnVisibility(const QString &name, bool status);
116 
119  void SetSplitMultiComponentColumns(bool value);
120 
123  bool GetSplitMultiComponentColumns();
124 
126 
127  void SetSortSelectionToTop(bool value);
128  vtkGetMacro(SortSelectionToTop, bool);
130 
132 
134  void SetApplyRowColors(bool value);
135  vtkGetMacro(ApplyRowColors, bool);
137 
139  virtual void Update();
140 
142 
143  void SetColorArrayName(const char* name);
144  const char* GetColorArrayName();
146 
148 
149  void SetColorByArray(bool vis);
150  bool GetColorByArray();
151  vtkBooleanMacro(ColorByArray, bool);
153 
155  virtual void ApplyViewTheme(vtkViewTheme* theme);
156 
157  enum
158  {
159  SELECT_ITEMS = 0,
161  SELECT_COLUMNS
162  };
163 
165 
170  virtual void SetSelectionBehavior(int type);
171  virtual int GetSelectionBehavior();
173 
179  virtual void GetSelectedItems(vtkIdTypeArray* arr);
180 
181 protected:
182  vtkQtTableView();
183  ~vtkQtTableView();
184 
187 
188 private slots:
189  void slotQtSelectionChanged(const QItemSelection&,const QItemSelection&);
190 
191 private:
192  void SetVTKSelection();
193  unsigned long LastSelectionMTime;
194  unsigned long LastInputMTime;
195  unsigned long LastMTime;
196 
197  vtkSetStringMacro(ColorArrayNameInternal);
198  vtkGetStringMacro(ColorArrayNameInternal);
199 
200  QPointer<QTableView> TableView;
201  vtkQtTableModelAdapter* TableAdapter;
202  QSortFilterProxyModel* TableSorter;
203  int FieldType;
204  bool ShowAll;
205  char* ColumnName;
206  bool InSelectionChanged;
207  bool SortSelectionToTop;
208  bool ApplyRowColors;
209  char* ColorArrayNameInternal;
210 
211  vtkSmartPointer<vtkAddMembershipArray> AddSelectedColumn;
212  vtkSmartPointer<vtkDataObjectToTable> DataObjectToTable;
214 
215  vtkQtTableView(const vtkQtTableView&); // Not implemented.
216  void operator=(const vtkQtTableView&); // Not implemented.
217 
218 };
219 
220 #endif