VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkQtTreeView.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00015 /*------------------------------------------------------------------------- 00016 Copyright 2008 Sandia Corporation. 00017 Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 00018 the U.S. Government retains certain rights in this software. 00019 -------------------------------------------------------------------------*/ 00034 #ifndef __vtkQtTreeView_h 00035 #define __vtkQtTreeView_h 00036 00037 #include "vtkViewsQtModule.h" // For export macro 00038 #include "QVTKWin32Header.h" 00039 #include "vtkQtView.h" 00040 00041 #include <QList> 00042 #include <QPointer> 00043 #include "vtkQtAbstractModelAdapter.h" 00044 #include "vtkSmartPointer.h" 00045 #include "QFilterTreeProxyModel.h" 00046 00047 class QAbstractItemDelegate; 00048 class QAbstractItemView; 00049 class QColumnView; 00050 class QItemSelection; 00051 class QTreeView; 00052 class vtkApplyColors; 00053 class QVBoxLayout; 00054 class vtkQtTreeModelAdapter; 00055 class QItemSelectionModel; 00056 00057 class VTKVIEWSQT_EXPORT vtkQtTreeView : public vtkQtView 00058 { 00059 Q_OBJECT 00060 00061 signals: 00062 void expanded(const QModelIndex&); 00063 void collapsed(const QModelIndex&); 00064 void updatePreviewWidget(const QModelIndex&); 00065 00066 public: 00067 static vtkQtTreeView *New(); 00068 vtkTypeMacro(vtkQtTreeView, vtkQtView); 00069 void PrintSelf(ostream& os, vtkIndent indent); 00070 00074 virtual QWidget* GetWidget(); 00075 00077 void SetShowHeaders(bool); 00078 00080 void SetAlternatingRowColors(bool); 00081 00083 void SetEnableDragDrop(bool); 00084 00086 void SetShowRootNode(bool); 00087 00089 void HideColumn(int i); 00090 00092 void ShowColumn(int i); 00093 00095 void HideAllButFirstColumn(); 00096 00098 void SetFilterColumn(int i); 00099 00101 void SetFilterRegExp(const QRegExp& pattern); 00102 00104 void SetFilterTreeLevel(int level); 00105 00107 void Collapse( const QModelIndex & index ); 00108 00110 void CollapseAll(); 00111 00113 void Expand ( const QModelIndex & index ); 00114 00117 void ExpandAll (); 00118 00120 void ExpandToDepth ( int depth ); 00121 00123 void ResizeColumnToContents ( int column ); 00124 00126 void SetUseColumnView(int state); 00127 00129 virtual void Update(); 00130 00132 void SetItemDelegate(QAbstractItemDelegate* delegate); 00133 00135 00136 void SetColorArrayName(const char* name); 00137 const char* GetColorArrayName(); 00139 00141 00142 void SetColorByArray(bool vis); 00143 bool GetColorByArray(); 00144 vtkBooleanMacro(ColorByArray, bool); 00146 00147 virtual void ApplyViewTheme(vtkViewTheme* theme); 00148 00149 protected: 00150 vtkQtTreeView(); 00151 ~vtkQtTreeView(); 00152 00153 virtual void AddRepresentationInternal(vtkDataRepresentation* rep); 00154 virtual void RemoveRepresentationInternal(vtkDataRepresentation* rep); 00155 00156 private slots: 00157 void slotQtSelectionChanged(const QItemSelection&,const QItemSelection&); 00158 00159 private: 00160 void SetVTKSelection(); 00161 unsigned long CurrentSelectionMTime; 00162 unsigned long LastInputMTime; 00163 00164 vtkSetStringMacro(ColorArrayNameInternal); 00165 vtkGetStringMacro(ColorArrayNameInternal); 00166 00167 QPointer<QTreeView> TreeView; 00168 QPointer<QColumnView> ColumnView; 00169 QPointer<QWidget> Widget; 00170 QPointer<QVBoxLayout> Layout; 00171 QPointer<QItemSelectionModel> SelectionModel; 00172 QList<int> HiddenColumns; 00173 vtkQtTreeModelAdapter* TreeAdapter; 00174 QAbstractItemView* View; 00175 char* ColorArrayNameInternal; 00176 QFilterTreeProxyModel* TreeFilter; 00177 00178 vtkSmartPointer<vtkApplyColors> ApplyColors; 00179 00180 vtkQtTreeView(const vtkQtTreeView&); // Not implemented. 00181 void operator=(const vtkQtTreeView&); // Not implemented. 00182 00183 }; 00184 00185 #endif