VTK
dox/GUISupport/Qt/vtkQtTableView.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkQtTableView.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 -------------------------------------------------------------------------*/
00037 #ifndef __vtkQtTableView_h
00038 #define __vtkQtTableView_h
00039 
00040 #include "QVTKWin32Header.h"
00041 #include "vtkQtView.h"
00042 
00043 #include <QPointer>
00044 #include <QSortFilterProxyModel>
00045 #include "vtkQtAbstractModelAdapter.h"
00046 #include "vtkSmartPointer.h"
00047 
00048 class vtkAddMembershipArray;
00049 class vtkApplyColors;
00050 class vtkDataObjectToTable;
00051 class vtkIdTypeArray;
00052 class QItemSelection;
00053 class QTableView;
00054 class vtkQtTableModelAdapter;
00055 
00056 class QVTK_EXPORT vtkQtTableView : public vtkQtView
00057 {
00058 Q_OBJECT
00059 
00060 public:
00061   static vtkQtTableView *New();
00062   vtkTypeMacro(vtkQtTableView, vtkQtView);
00063   void PrintSelf(ostream& os, vtkIndent indent);
00064   
00068   virtual QWidget* GetWidget();
00069   
00071   void SetShowVerticalHeaders(bool);
00072   
00074   void SetShowHorizontalHeaders(bool);
00075 
00076   enum
00077     {
00078     FIELD_DATA = 0,
00079     POINT_DATA = 1,
00080     CELL_DATA = 2,
00081     VERTEX_DATA = 3,
00082     EDGE_DATA = 4,
00083     ROW_DATA = 5,
00084     };
00085   
00087 
00089   vtkGetMacro(FieldType, int);
00090   void SetFieldType(int);
00092 
00094   void SetEnableDragDrop(bool);
00095 
00098   void SetSortingEnabled(bool);
00099 
00101 
00104   void SetShowAll(bool);
00105   vtkGetMacro(ShowAll, bool);
00107 
00109 
00111   vtkSetStringMacro(ColumnName);
00112   vtkGetStringMacro(ColumnName);
00114 
00115   void SetColumnVisibility(const QString &name, bool status);
00116 
00119   void SetSplitMultiComponentColumns(bool value);
00120 
00123   bool GetSplitMultiComponentColumns();
00124 
00126 
00127   void SetSortSelectionToTop(bool value);
00128   vtkGetMacro(SortSelectionToTop, bool);
00130 
00132 
00134   void SetApplyRowColors(bool value);
00135   vtkGetMacro(ApplyRowColors, bool);
00137 
00139   virtual void Update();
00140 
00142 
00143   void SetColorArrayName(const char* name);
00144   const char* GetColorArrayName();
00146   
00148 
00149   void SetColorByArray(bool vis);
00150   bool GetColorByArray();
00151   vtkBooleanMacro(ColorByArray, bool);
00153 
00155   virtual void ApplyViewTheme(vtkViewTheme* theme);
00156 
00157   enum
00158     {
00159     SELECT_ITEMS = 0,
00160     SELECT_ROWS,
00161     SELECT_COLUMNS
00162     };
00163 
00165 
00170   virtual void SetSelectionBehavior(int type);
00171   virtual int GetSelectionBehavior();
00173 
00179   virtual void GetSelectedItems(vtkIdTypeArray* arr);
00180 
00181 protected:
00182   vtkQtTableView();
00183   ~vtkQtTableView();
00184 
00185   virtual void AddRepresentationInternal(vtkDataRepresentation* rep);
00186   virtual void RemoveRepresentationInternal(vtkDataRepresentation* rep);
00187 
00188 private slots:
00189   void slotQtSelectionChanged(const QItemSelection&,const QItemSelection&);
00190 
00191 private:
00192   void SetVTKSelection();
00193   unsigned long LastSelectionMTime;
00194   unsigned long LastInputMTime;
00195   unsigned long LastMTime;
00196   
00197   vtkSetStringMacro(ColorArrayNameInternal);
00198   vtkGetStringMacro(ColorArrayNameInternal);
00199 
00200   QPointer<QTableView> TableView;
00201   vtkQtTableModelAdapter* TableAdapter;
00202   QSortFilterProxyModel* TableSorter;
00203   int FieldType;    
00204   bool ShowAll;
00205   char* ColumnName;
00206   bool InSelectionChanged;
00207   bool SortSelectionToTop;
00208   bool ApplyRowColors;
00209   char* ColorArrayNameInternal;
00210 
00211   vtkSmartPointer<vtkAddMembershipArray> AddSelectedColumn;
00212   vtkSmartPointer<vtkDataObjectToTable> DataObjectToTable;
00213   vtkSmartPointer<vtkApplyColors> ApplyColors;
00214   
00215   vtkQtTableView(const vtkQtTableView&);  // Not implemented.
00216   void operator=(const vtkQtTableView&);  // Not implemented.
00217   
00218 };
00219 
00220 #endif