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   //BTX
00077   enum
00078     {
00079     FIELD_DATA = 0,
00080     POINT_DATA = 1,
00081     CELL_DATA = 2,
00082     VERTEX_DATA = 3,
00083     EDGE_DATA = 4,
00084     ROW_DATA = 5,
00085     };
00086   //ETX
00087   
00089 
00091   vtkGetMacro(FieldType, int);
00092   void SetFieldType(int);
00094 
00096   void SetEnableDragDrop(bool);
00097 
00100   void SetSortingEnabled(bool);
00101 
00103 
00106   void SetShowAll(bool);
00107   vtkGetMacro(ShowAll, bool);
00109 
00111 
00113   vtkSetStringMacro(ColumnName);
00114   vtkGetStringMacro(ColumnName);
00116 
00117   void SetColumnVisibility(const QString &name, bool status);
00118 
00121   void SetSplitMultiComponentColumns(bool value);
00122 
00125   bool GetSplitMultiComponentColumns();
00126 
00128 
00129   void SetSortSelectionToTop(bool value);
00130   vtkGetMacro(SortSelectionToTop, bool);
00132 
00134 
00136   void SetApplyRowColors(bool value);
00137   vtkGetMacro(ApplyRowColors, bool);
00139 
00141   virtual void Update();
00142 
00144 
00145   void SetColorArrayName(const char* name);
00146   const char* GetColorArrayName();
00148   
00150 
00151   void SetColorByArray(bool vis);
00152   bool GetColorByArray();
00153   vtkBooleanMacro(ColorByArray, bool);
00155 
00157   virtual void ApplyViewTheme(vtkViewTheme* theme);
00158 
00159   //BTX
00160   enum
00161     {
00162     SELECT_ITEMS = 0,
00163     SELECT_ROWS,
00164     SELECT_COLUMNS
00165     };
00166   //ETX
00167 
00169 
00174   virtual void SetSelectionBehavior(int type);
00175   virtual int GetSelectionBehavior();
00177 
00183   virtual void GetSelectedItems(vtkIdTypeArray* arr);
00184 
00185 protected:
00186   vtkQtTableView();
00187   ~vtkQtTableView();
00188 
00189   virtual void AddRepresentationInternal(vtkDataRepresentation* rep);
00190   virtual void RemoveRepresentationInternal(vtkDataRepresentation* rep);
00191 
00192 private slots:
00193   void slotQtSelectionChanged(const QItemSelection&,const QItemSelection&);
00194 
00195 private:
00196   void SetVTKSelection();
00197   unsigned long LastSelectionMTime;
00198   unsigned long LastInputMTime;
00199   unsigned long LastMTime;
00200   
00201   vtkSetStringMacro(ColorArrayNameInternal);
00202   vtkGetStringMacro(ColorArrayNameInternal);
00203 
00204   QPointer<QTableView> TableView;
00205   vtkQtTableModelAdapter* TableAdapter;
00206   QSortFilterProxyModel* TableSorter;
00207   int FieldType;    
00208   bool ShowAll;
00209   char* ColumnName;
00210   bool InSelectionChanged;
00211   bool SortSelectionToTop;
00212   bool ApplyRowColors;
00213   char* ColorArrayNameInternal;
00214 
00215 //BTX
00216   vtkSmartPointer<vtkAddMembershipArray> AddSelectedColumn;
00217   vtkSmartPointer<vtkDataObjectToTable> DataObjectToTable;
00218   vtkSmartPointer<vtkApplyColors> ApplyColors;
00219 //ETX
00220   
00221   vtkQtTableView(const vtkQtTableView&);  // Not implemented.
00222   void operator=(const vtkQtTableView&);  // Not implemented.
00223   
00224 };
00225 
00226 #endif