GOFIGURE2  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
QGoTableWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2  Authors: The GoFigure Dev. Team.
3  at Megason Lab, Systems biology, Harvard Medical school, 2009-11
4 
5  Copyright (c) 2009-11, President and Fellows of Harvard College.
6  All rights reserved.
7 
8  Redistribution and use in source and binary forms, with or without
9  modification, are permitted provided that the following conditions are met:
10 
11  Redistributions of source code must retain the above copyright notice,
12  this list of conditions and the following disclaimer.
13  Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16  Neither the name of the President and Fellows of Harvard College
17  nor the names of its contributors may be used to endorse or promote
18  products derived from this software without specific prior written
19  permission.
20 
21  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
25  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26  OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
27  OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
30  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 
33 =========================================================================*/
34 
35 #ifndef __QGoTableWidget_h
36 #define __QGoTableWidget_h
37 
38 #include <QTableWidget>
39 #include <QStringList>
40 #include <QList>
41 #include "MegaVTK2Configure.h"
42 #include "GoDBTraceInfoForVisu.h"
45 #include "QGoGUILibConfigure.h"
46 #include "GoDBCoordinateRow.h"
47 
54 class QGOGUILIB_EXPORT QGoTableWidget:public QTableWidget
55 {
56  Q_OBJECT
57 public:
58  explicit QGoTableWidget(QWidget *parent = 0);
59  explicit QGoTableWidget(int rows, int columns, QWidget *parent = 0);
60 
61  virtual ~QGoTableWidget();
62 
64 
84  void DisplayInitialContent(const TWContainerType & iTWRowContainer,
85  const std::vector< int > & iIndexColorTraceRowContainer,
86  const std::vector< int > & iIndexColorCollectionRowContainer,
87  const std::string & iTraceName,
88  const std::string & iCollectionName,
89  const std::list< std::pair< std::string, std::string > > & iColumnNames,
90  Qt::CheckState iState,
91  int iIndexShowColumn = 0);
92 
93  void InsertNewRows(const TWContainerType & iTWRowContainer,
94  const std::vector< int > & iIndexColorTraceRowContainer,
95  const std::vector< int > & iIndexColorCollectionRowContainer,
96  const std::string & iTraceName,
97  const std::string & iCollectionName,
98  Qt::CheckState iVisible = Qt::Checked);
111  void InsertOnlyOneNewRow(const TWContainerType & iTWRowContainer,
112  const std::vector< int > & iIndexColorTraceRowContainer,
113  const std::vector< int > & iIndexColorCollectionRowContainer,
114  const std::string & iTraceName,
115  const std::string & iCollectionName,
116  Qt::CheckState iVisible = Qt::Checked);
117 
131  void UpdateRow(const TWContainerType & iTWRowContainer,
132  const std::vector< int > & iIndexColorTraceRowContainer,
133  const std::vector< int > & iIndexColorCollectionRowContainer,
134  const std::string & iTraceName,
135  const std::string & iCollectionName,
136  int iTraceID);
137 
138 
139  void DeleteRowsWithSpecificTimePoints(const QStringList & iListTPs);
140 
147  void DeleteCheckedRows(const std::string & iTraceNameID,
148  const std::list< unsigned int > & iTraceIDs);
149 
157  void AddValuesForID(const std::vector< std::string > & iColumnsNames,
158  const std::vector< std::string > & iValues,
159  unsigned int iID,
160  const std::string & iColumnNameForTraceID);
161 
171  GoDBCoordinateRow GetCoordinateCenterBoundingBox(unsigned int iTraceID,
172  const std::string & iTraceName);
173 
183  void SetCheckStateForTraceID(unsigned int iTraceID,
184  const std::string & iTraceName,
185  Qt::CheckState iState,
186  bool EmitSignal = true);
187 
197  void SetVisibleStateForTraceID(unsigned int iTraceID,
198  const std::string & iTraceName,
199  Qt::CheckState iState,
200  bool EmitSignal = true);
201 
209  std::map<unsigned int, std::string> GetTraceIDAndColumnsValues(
210  const std::string & iTraceIDName, std::string &ioColumnName);
211 
218  void SetVisibleStateForListTraceIDs( const std::list<unsigned int> & iListTraceIDs,
219  Qt::CheckState iState,
220  const std::string & iTraceName);
221 
226  void ShowOnlyRowsForTimePoint(unsigned int iTimePoint);
227 
228  void ShowAllRows();
229 
236  void DisplayColumnNames(
237  const std::list< std::pair<std::string, std::string > >& iColumnNamesAndToolTip);
238 
239  QString GetValue(unsigned int iTraceID,
240  const std::string & iTraceName,
241  const std::string & iColumn);
242 
243  void DeleteRowsAndColumns();
244 
245 
246 public slots:
247 
255  void ChangeCheckStateSelectedRows(std::string iTraceName,
256  std::string iTraceNameID,
257  Qt::CheckState iState);
258 
266  void ChangeVisibilityStateSelectedRows(std::string iTraceName,
267  std::string iTraceNameID,
268  Qt::CheckState iState);
269 
274  void CopySelection();
275 
281  void CopyTable();
282 
283 signals:
284  void CheckedRowsChanged(int iTraceID);
285 
286  void VisibleRowsChanged(int iTraceID);
287 
288  void ModifyHighlightListTraces(QStringList,Qt::CheckState);
289 
290  void ModifyVisibilityListTraces(QStringList,Qt::CheckState);
291 
292 protected:
293  int PrevCol;
295 
303  int GetValueForItem(const std::string & iColumnName, int iRowIndex);
304 
312  std::string GetMeanValue(const std::string & iColumnNameOne,
313  const std::string & iColumnNameTwo,
314  unsigned int iRowIndex);
315 
323  int findValueGivenColumn(int iValue, const QString & iColumn);
324 
331  int findColumnName(const QString & iColumnName);
332 
339  void PrepareRangeToCopy(const QTableWidgetSelectionRange & iRange,
340  QString & istr);
341 
348  int GetRowForTraceID(unsigned int iTraceID,
349  const std::string & iTraceName);
350 
359  void setCheckedUncheckedStateCheckBox(QTableWidgetItem *iItem,
360  Qt::CheckState iState,
361  bool EmitSignal);
362 
371  void setVisibleStateCheckBox(QTableWidgetItem *iItem,
372  Qt::CheckState iState,
373  bool EmitSignal = true);
374 
381  bool setCheckStateCheckBox(QTableWidgetItem *iItem, Qt::CheckState iState);
382 
390  QStringList ValuesForSelectedRows(const QString & iColumnName);
391 
397  void SetSelectedColumn(unsigned int iIndexRow);
398 
405  void SetVisibleColumn( unsigned int iIndexRow,
406  Qt::CheckState iState = Qt::Checked);
407 
418  void SetColorForTable(const TWContainerType & iTWRowContainer,
419  unsigned int iIndexTWRowContainer,
420  const std::vector< int > & iIndexColorRowContainer,
421  const std::string & iNameGroupColor,
422  unsigned int iIndexRowTW);
423 
424  QStringList recordHeaderNamesOrder();
425 
433  bool CheckValueToDisplayData(const std::string & iValue,
434  const std::string & iHeaderCol);
435 
436  void InsertNewRow(const TWContainerType & iTWRowContainer,
437  unsigned int iIndexTWRowContainer,
438  const std::vector< int > & iIndexColorTraceRowContainer,
439  const std::vector< int > & iIndexColorCollectionRowContainer,
440  const std::string & iTraceName,
441  const std::string & iCollectionName,
442  Qt::CheckState iVisible = Qt::Checked);
443 
444  void DisplayDataForOneRow(const TWContainerType & iTWRowContainer,
445  unsigned int iIndexTWRowContainer,
446  int iIndexTWRow,
447  const std::vector< int > & iIndexColorTraceRowContainer,
448  const std::vector< int > & iIndexColorCollectionRowContainer,
449  const std::string & iTraceName,
450  const std::string & iCollectionName);
451 
452 protected slots:
458  void sortItems(int iColumn, Qt::SortOrder iOrder);
459 
467  void UpdateColumnsWithCheckBoxes(int iRow, int iColumn);
468 };
469 
470 #endif
GoDBTableWidgetContainer::TWContainerType TWContainerType
manages a map with keys matching fields of the gofiguredatabase Coordinate table and values of the ma...
void sortItems(int column, Qt::SortOrder order)
std::vector< std::pair< GoDBTraceInfoForTableWidget, std::vector< std::string > > > TWContainerType
inherits from the Qt class QTableWidget, manages all the interactions between the user and the data r...