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 "QVTKWin32Header.h" 00038 #include "vtkQtView.h" 00039 00040 #include <QList> 00041 #include <QPointer> 00042 #include "vtkQtAbstractModelAdapter.h" 00043 #include "vtkSmartPointer.h" 00044 #include "QFilterTreeProxyModel.h" 00045 00046 class QAbstractItemDelegate; 00047 class QAbstractItemView; 00048 class QColumnView; 00049 class QItemSelection; 00050 class QTreeView; 00051 class vtkApplyColors; 00052 class QVBoxLayout; 00053 class vtkQtTreeModelAdapter; 00054 class QItemSelectionModel; 00055 00056 class QVTK_EXPORT vtkQtTreeView : public vtkQtView 00057 { 00058 Q_OBJECT 00059 00060 signals: 00061 void expanded(const QModelIndex&); 00062 void collapsed(const QModelIndex&); 00063 void updatePreviewWidget(const QModelIndex&); 00064 00065 public: 00066 static vtkQtTreeView *New(); 00067 vtkTypeMacro(vtkQtTreeView, vtkQtView); 00068 void PrintSelf(ostream& os, vtkIndent indent); 00069 00073 virtual QWidget* GetWidget(); 00074 00076 void SetShowHeaders(bool); 00077 00079 void SetAlternatingRowColors(bool); 00080 00082 void SetEnableDragDrop(bool); 00083 00085 void SetShowRootNode(bool); 00086 00088 void HideColumn(int i); 00089 00091 void ShowColumn(int i); 00092 00094 void HideAllButFirstColumn(); 00095 00097 void SetFilterColumn(int i); 00098 00100 void SetFilterRegExp(const QRegExp& pattern); 00101 00103 void SetFilterTreeLevel(int level); 00104 00106 void Collapse( const QModelIndex & index ); 00107 00109 void CollapseAll(); 00110 00112 void Expand ( const QModelIndex & index ); 00113 00116 void ExpandAll (); 00117 00119 void ExpandToDepth ( int depth ); 00120 00122 void ResizeColumnToContents ( int column ); 00123 00125 void SetUseColumnView(int state); 00126 00128 virtual void Update(); 00129 00131 void SetItemDelegate(QAbstractItemDelegate* delegate); 00132 00134 00135 void SetColorArrayName(const char* name); 00136 const char* GetColorArrayName(); 00138 00140 00141 void SetColorByArray(bool vis); 00142 bool GetColorByArray(); 00143 vtkBooleanMacro(ColorByArray, bool); 00145 00146 virtual void ApplyViewTheme(vtkViewTheme* theme); 00147 00148 protected: 00149 vtkQtTreeView(); 00150 ~vtkQtTreeView(); 00151 00152 virtual void AddRepresentationInternal(vtkDataRepresentation* rep); 00153 virtual void RemoveRepresentationInternal(vtkDataRepresentation* rep); 00154 00155 private slots: 00156 void slotQtSelectionChanged(const QItemSelection&,const QItemSelection&); 00157 00158 private: 00159 void SetVTKSelection(); 00160 unsigned long CurrentSelectionMTime; 00161 unsigned long LastInputMTime; 00162 00163 vtkSetStringMacro(ColorArrayNameInternal); 00164 vtkGetStringMacro(ColorArrayNameInternal); 00165 00166 QPointer<QTreeView> TreeView; 00167 QPointer<QColumnView> ColumnView; 00168 QPointer<QWidget> Widget; 00169 QPointer<QVBoxLayout> Layout; 00170 QPointer<QItemSelectionModel> SelectionModel; 00171 QList<int> HiddenColumns; 00172 vtkQtTreeModelAdapter* TreeAdapter; 00173 QAbstractItemView* View; 00174 char* ColorArrayNameInternal; 00175 QFilterTreeProxyModel* TreeFilter; 00176 00177 vtkSmartPointer<vtkApplyColors> ApplyColors; 00178 00179 vtkQtTreeView(const vtkQtTreeView&); // Not implemented. 00180 void operator=(const vtkQtTreeView&); // Not implemented. 00181 00182 }; 00183 00184 #endif