scidavis  2.3.0
About: SciDAVis is a free application for Scientific Data Analysis and Visualization (a fork off of QtiPlot).
  Fossies Dox: scidavis-2.3.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

Table.h
Go to the documentation of this file.
1 
13 
31 #ifndef TABLE_H
32 #define TABLE_H
33 
34 #include <QVarLengthArray>
35 #include <QDateTime>
36 #include <QHash>
37 #include <QMap>
38 #include <QPointer>
39 
40 #include "Graph.h"
41 #include "MyWidget.h"
42 #include "ScriptingEnv.h"
43 #include "Script.h"
45 #include "future/table/TableView.h"
46 #include "globals.h"
47 
50 class Table: public TableView, public scripted
51 {
52  Q_OBJECT
53 
54 public:
55  QPointer<future::Table> d_future_table;
56 
57  enum ColType{Numeric = 0, Text = 1, Date = 2, Time = 3, Month = 4, Day = 5, DateTime = 6}; // TODO: remove this in favor of SciDAVis::columnMode
58 
59  Table(ScriptingEnv *env, const QString &fname,const QString &sep, int ignoredLines, bool renameCols,
60  bool stripSpaces, bool simplifySpaces, bool convertToNumeric, QLocale numericFormat, const QString &label,
61  QWidget* parent=0, const char* name=0, Qt::WindowFlags f=0);
62  Table(ScriptingEnv *env, int r,int c, const QString &label, QWidget* parent=0, const char* name=0, Qt::WindowFlags f=0);
63 
65  void setNumericPrecision(int prec);
66 
68  virtual QString name() { return d_future_table? d_future_table->name(): QString();}
70  virtual void setName(const QString& s) { if (d_future_table) d_future_table->setName(s); }
72  virtual QString windowLabel() { return d_future_table? d_future_table->comment(): QString(); }
74  virtual void setWindowLabel(const QString& s) { if (d_future_table) d_future_table->setComment(s); updateCaption(); }
77  {
78  if (d_future_table)
79  {
80  caption_policy = policy;
81  updateCaption();
82  switch (policy)
83  {
84  case Name:
85  d_future_table->setCaptionSpec("%n");
86  break;
87  case Label:
88  d_future_table->setCaptionSpec("%c");
89  break;
90  case Both:
91  d_future_table->setCaptionSpec("%n%C{ - }%c");
92  break;
93  }
94  }
95  }
97  virtual void setBirthDate(const QString& s)
98  {
99  birthdate = s;
100  if (d_future_table)
101  d_future_table->importV0x0001XXCreationTime(s);
102  }
103 
104  void closeEvent( QCloseEvent *);
105 public slots:
106  void copy(Table *m);
107  int numRows();
108  int numCols();
109  int rowCount();
110  int columnCount();
111  void setNumRows(int rows);
112  void setNumCols(int cols);
113  void handleChange();
114  void handleRowChange();
115  void handleColumnChange(int,int);
116  void handleColumnChange(int,int,int,int);
117  void handleColumnsAboutToBeRemoved(int,int);
118  void handleColumnsRemoved(int,int);
119 
121  Column* column(int index) const { return d_future_table? d_future_table->column(index): nullptr; }
123 
128  Column* column(const QString & name) const { return d_future_table? d_future_table->column(name): nullptr; }
129 
131 
137  double cell(int row, int col);
138  void setCell(int row, int col, double val);
139 
140  QString text(int row, int col);
141  QStringList columnsList();
142  QStringList colNames();
143  QString colName(int col);
144  QString colLabel(int col);
145  int colIndex(const QString& name);
146 
150  QList<int> plotDesignations();
151 
152  void setColName(int col,const QString& text);
153  void setHeader(QStringList header);
154  void importV0x0001XXHeader(QStringList header);
155  void setText(int row,int col,const QString & text);
156 
157  void clearCell(int row, int col);
158 
159  void print();
160  void print(const QString& fileName);
161  void exportPDF(const QString& fileName);
162  void customEvent(QEvent* e);
163 
165 
166  void removeCol();
167  void removeCol(const QStringList& list);
168  void clearCol();
169  void insertCol();
170  void insertCols(int start, int count);
172  void addColumns(int c);
174 
175  int firstXCol();
176  bool noXColumn();
177  bool noYColumn();
178  int colX(int col);
179  int colY(int col);
180 
182  void setCommands(const QStringList& com);
184  void setCommands(const QString& com);
186  void setCommand(int col, const QString& com);
188  bool recalculate(int col, bool only_selected_rows=true);
190  bool recalculate();
191 
193 
194  void deleteSelectedRows();
195  void insertRow();
197 
199 
200  void cutSelection();
201  void copySelection();
202  void clearSelection();
203  void pasteSelection();
204  void selectAllTable();
205  void deselect();
206  void clear();
208 
209  void init();
210  QStringList selectedColumns();
211  QStringList selectedYColumns();
212  QStringList selectedErrColumns();
213  QMap<int, QString> selectedYLabels();
214  QStringList drawableColumnSelection();
215  QStringList YColumns();
216  int selectedColsNumber();
217 
218  int columnWidth(int col);
219  void setColWidths(const QStringList& widths);
220 
221  int numSelectedRows();
222 
223  int columnType(int col);
224 
225  QList<int> columnTypes();
226  void setColumnTypes(QList<int> ctl);
227  void setColumnTypes(const QStringList& ctl);
228  void setColumnType(int col, SciDAVis::ColumnMode mode);
229 
230 
231  QString columnFormat(int col);
232 
233  void importASCII(const QString &fname, const QString &sep, int ignoredLines,
234  bool renameCols, bool stripSpaces, bool simplifySpaces, bool newTable);
235  bool exportASCII(const QString& fname, const QString& separator,
236  bool withLabels = false, bool exportSelection = false);
237 
239 
240  virtual QString saveToString(const QString& geometry);
241  void saveToDevice(QIODevice *device, const QString &geometry);
242  QString saveHeader();
243  QString saveComments();
244  QString saveCommands();
245  QString saveColumnWidths();
246  QString saveColumnTypes();
248 
249  void setBackgroundColor(const QColor& col);
250  void setTextColor(const QColor& col);
251  void setHeaderColor(const QColor& col);
252  void setTextFont(const QFont& fnt);
253  void setHeaderFont(const QFont& fnt);
254 
255  int verticalHeaderWidth();
256 
257  QString colComment(int col);
258  void setColComment(int col, const QString& s);
259  QStringList colComments();
260  void setColComments(const QStringList& lst);
261  bool commentsEnabled();
262 
263  QString saveAsTemplate(const QString& geometryInfo);
264  void restore(const QStringList& lst);
265 
266 signals:
267  void changedColHeader(const QString&, const QString&);
268  void aboutToRemoveCol(const QString&);
269  void removedCol(const QString&);
270  void modifiedData(Table *, const QString&);
271  void resizedTable(QWidget*);
272  void showContextMenu(bool selection);
273 
274 protected slots:
275  void applyFormula();
276  void addFunction();
277  void addReference();
278  void updateFunctionDoc();
281 
282 private:
283  QHash<const AbstractAspect *, QString> d_stored_column_labels;
284 };
285 
286 #endif
Table::cell
double cell(int row, int col)
Return the value of the cell as a double.
Definition: Table.cpp:907
Table::handleChange
void handleChange()
Definition: Table.cpp:153
Table::insertCols
void insertCols(int start, int count)
Definition: Table.cpp:773
Table::Numeric
@ Numeric
Definition: Table.h:57
Table::deleteSelectedRows
void deleteSelectedRows()
Definition: Table.cpp:834
Table::commentsEnabled
bool commentsEnabled()
Definition: Table.cpp:1384
Table::setNumericPrecision
void setNumericPrecision(int prec)
Sets the number of significant digits.
Table::YColumns
QStringList YColumns()
Definition: Table.cpp:675
Table::cutSelection
void cutSelection()
Selection Operations.
Definition: Table.cpp:840
Table::saveCommands
QString saveCommands()
Definition: Table.cpp:516
MyWidget::Label
@ Label
caption detemined by the window label
Definition: MyWidget.h:70
Table::column
Column * column(int index) const
Return column number 'index'.
Definition: Table.h:121
Table::text
QString text(int row, int col)
Definition: Table.cpp:931
Table::Text
@ Text
Definition: Table.h:57
Table::selectAllTable
void selectAllTable()
Definition: Table.cpp:846
Table::Date
@ Date
Definition: Table.h:57
Table::colPlotDesignation
SciDAVis::PlotDesignation colPlotDesignation(int col)
Definition: Table.cpp:1277
Table::exportASCII
bool exportASCII(const QString &fname, const QString &separator, bool withLabels=false, bool exportSelection=false)
Definition: Table.cpp:1032
MyWidget::caption_policy
CaptionPolicy caption_policy
The caption policy.
Definition: MyWidget.h:173
Table::columnCount
int columnCount()
Definition: Table.cpp:902
Table::clearCol
void clearCol()
Definition: Table.cpp:820
ScriptingEnv.h
Table::saveToString
virtual QString saveToString(const QString &geometry)
Definition: Table.cpp:542
Table::DateTime
@ DateTime
Definition: Table.h:57
Table::setColumnTypes
void setColumnTypes(QList< int > ctl)
Definition: Table.cpp:1310
Table::Table
Table(ScriptingEnv *env, const QString &fname, const QString &sep, int ignoredLines, bool renameCols, bool stripSpaces, bool simplifySpaces, bool convertToNumeric, QLocale numericFormat, const QString &label, QWidget *parent=0, const char *name=0, Qt::WindowFlags f=0)
Definition: Table.cpp:61
Table::recalculate
bool recalculate()
Recalculate selected cells.
Definition: Table.cpp:427
Table::colComment
QString colComment(int col)
Definition: Table.cpp:1363
Table::colLabel
QString colLabel(int col)
Definition: Table.cpp:1272
Table::numSelectedRows
int numSelectedRows()
Definition: Table.cpp:755
Table::drawableColumnSelection
QStringList drawableColumnSelection()
Definition: Table.cpp:713
Table::setColName
void setColName(int col, const QString &text)
Definition: Table.cpp:655
SciDAVis::Y
@ Y
y values
Definition: globals.h:58
Table::handleColumnsAboutToBeRemoved
void handleColumnsAboutToBeRemoved(int, int)
Definition: Table.cpp:171
Table::saveAsTemplate
QString saveAsTemplate(const QString &geometryInfo)
Definition: Table.cpp:1197
Table::clearSelection
void clearSelection()
Definition: Table.cpp:856
Table::copy
void copy(Table *m)
Definition: Table.cpp:1189
Table::setBackgroundColor
void setBackgroundColor(const QColor &col)
Definition: Table.cpp:189
Table::noYColumn
bool noYColumn()
Definition: Table.cpp:1027
Table::setWindowLabel
virtual void setWindowLabel(const QString &s)
Set the window label.
Definition: Table.h:74
Table::handleColumnChange
void handleColumnChange(int, int)
Definition: Table.cpp:158
Table::insertCol
void insertCol()
Definition: Table.cpp:787
Table::addFunction
void addFunction()
Definition: Table.cpp:1410
Table::plotDesignations
QList< int > plotDesignations()
Definition: Table.cpp:1287
Table::applyFormula
void applyFormula()
Definition: Table.cpp:1389
Column
Aspect that manages a column.
Definition: Column.h:59
MyWidget::birthdate
QString birthdate
The creation date.
Definition: MyWidget.h:166
Table::setText
void setText(int row, int col, const QString &text)
Definition: Table.cpp:938
Table::verticalHeaderWidth
int verticalHeaderWidth()
Definition: Table.cpp:1358
Table::copySelection
void copySelection()
Definition: Table.cpp:862
Table::d_future_table
QPointer< future::Table > d_future_table
Definition: Table.h:55
Table::clearCell
void clearCell(int row, int col)
Definition: Table.cpp:826
Table::windowLabel
virtual QString windowLabel()
Return the window label.
Definition: Table.h:72
Table::aboutToRemoveCol
void aboutToRemoveCol(const QString &)
Table::setHeaderColor
void setHeaderColor(const QColor &col)
Definition: Table.cpp:208
Table::handleRowChange
void handleRowChange()
Definition: Table.cpp:183
Table::removedCol
void removedCol(const QString &)
Table::setColComment
void setColComment(int col, const QString &s)
Definition: Table.cpp:650
Table
MDI window providing a spreadsheet table with column logic.
Definition: Table.h:51
TableView.h
scripted
Interface for maintaining a reference to the current ScriptingEnv.
Definition: Script.h:149
Table::setName
virtual void setName(const QString &s)
Set the window name.
Definition: Table.h:70
future_Table.h
Table::customEvent
void customEvent(QEvent *e)
Definition: Table.cpp:1137
Table::saveToDevice
void saveToDevice(QIODevice *device, const QString &geometry)
Definition: Table.cpp:558
Table::setCommands
void setCommands(const QStringList &com)
Set all column formulae.
Definition: Table.cpp:409
Table::setTextFont
void setTextFont(const QFont &fnt)
Definition: Table.cpp:203
Table::firstXCol
int firstXCol()
Definition: Table.cpp:640
Table::saveHeader
QString saveHeader()
Definition: Table.cpp:610
Table::columnWidth
int columnWidth(int col)
Definition: Table.cpp:348
Table::addReference
void addReference()
Definition: Table.cpp:1415
Table::setColPlotDesignation
void setColPlotDesignation(int col, SciDAVis::PlotDesignation d)
Definition: Table.cpp:1282
MyWidget::CaptionPolicy
CaptionPolicy
Possible window captions.
Definition: MyWidget.h:68
SciDAVis::ColumnMode
ColumnMode
The column mode (defines output and input filter for table columns)
Definition: globals.h:66
Table::setColumnType
void setColumnType(int col, SciDAVis::ColumnMode mode)
Definition: Table.cpp:1340
Table::pasteSelection
void pasteSelection()
Definition: Table.cpp:868
Table::setTextColor
void setTextColor(const QColor &col)
Definition: Table.cpp:196
TableView
View class for Table.
Definition: TableView.h:89
globals.h
Table::saveComments
QString saveComments()
Definition: Table.cpp:531
Table::setHeaderFont
void setHeaderFont(const QFont &fnt)
Definition: Table.cpp:215
Table::showContextMenu
void showContextMenu(bool selection)
Table::setCommand
void setCommand(int col, const QString &com)
Set formula for column col.
Definition: Table.cpp:415
Table::columnTypes
QList< int > columnTypes()
Definition: Table.cpp:1296
Table::columnsList
QStringList columnsList()
Definition: Table.cpp:745
Table::clear
void clear()
Definition: Table.cpp:1257
Script.h
Table::importASCII
void importASCII(const QString &fname, const QString &sep, int ignoredLines, bool renameCols, bool stripSpaces, bool simplifySpaces, bool newTable)
Definition: Table.cpp:1467
Table::Time
@ Time
Definition: Table.h:57
Table::removeCol
void removeCol()
Definition: Table.cpp:874
Table::name
virtual QString name()
Return the window name.
Definition: Table.h:68
Table::colX
int colX(int col)
Definition: Table.cpp:332
Table::numCols
int numCols()
Definition: Table.cpp:892
Table::rowCount
int rowCount()
Definition: Table.cpp:897
Table::noXColumn
bool noXColumn()
Definition: Table.cpp:1022
Table::importV0x0001XXHeader
void importV0x0001XXHeader(QStringList header)
Definition: Table.cpp:943
Table::resizedTable
void resizedTable(QWidget *)
Table::closeEvent
void closeEvent(QCloseEvent *)
Definition: Table.cpp:1143
ScriptingEnv
An interpreter for evaluating scripting code. Abstract.
Definition: ScriptingEnv.h:53
Table::setColWidths
void setColWidths(const QStringList &widths)
Definition: Table.cpp:353
Table::deselect
void deselect()
Definition: Table.cpp:851
Table::setHeader
void setHeader(QStringList header)
Definition: Table.cpp:1000
Table::setNumCols
void setNumCols(int cols)
Definition: Table.cpp:1183
Table::exportPDF
void exportPDF(const QString &fileName)
Definition: Table.cpp:220
Table::colComments
QStringList colComments()
Definition: Table.cpp:1368
Table::saveColumnTypes
QString saveColumnTypes()
Definition: Table.cpp:400
MyWidget::Name
@ Name
caption determined by the window name
Definition: MyWidget.h:69
Table::selectedYColumns
QStringList selectedYColumns()
Definition: Table.cpp:687
Table::colName
QString colName(int col)
Definition: Table.cpp:765
Table::addCol
void addCol(SciDAVis::PlotDesignation pd=SciDAVis::Y)
Definition: Table.cpp:799
Table::setColComments
void setColComments(const QStringList &lst)
Definition: Table.cpp:1377
Table::selectedErrColumns
QStringList selectedErrColumns()
Definition: Table.cpp:699
Table::d_stored_column_labels
QHash< const AbstractAspect *, QString > d_stored_column_labels
Definition: Table.h:283
Table::selectedColsNumber
int selectedColsNumber()
Definition: Table.cpp:760
Graph.h
Table::init
void init()
Definition: Table.cpp:96
Table::setCaptionPolicy
void setCaptionPolicy(CaptionPolicy policy)
Set the caption policy.
Definition: Table.h:76
Table::Month
@ Month
Definition: Table.h:57
Table::selectedColumns
QStringList selectedColumns()
Definition: Table.cpp:663
MyWidget::Both
@ Both
caption = "name - label"
Definition: MyWidget.h:71
MyWidget.h
Table::Day
@ Day
Definition: Table.h:57
Table::ColType
ColType
Definition: Table.h:57
Table::setPlotDesignation
void setPlotDesignation(SciDAVis::PlotDesignation pd)
Definition: Table.cpp:342
Table::columnFormat
QString columnFormat(int col)
Definition: Table.cpp:1345
Table::setCell
void setCell(int row, int col, double val)
Definition: Table.cpp:926
SciDAVis::PlotDesignation
PlotDesignation
Types of plot designations.
Definition: globals.h:55
Table::colNames
QStringList colNames()
Definition: Table.cpp:1263
Table::addColumns
void addColumns(int c)
Definition: Table.cpp:809
Table::modifiedData
void modifiedData(Table *, const QString &)
Table::handleAspectDescriptionAboutToChange
void handleAspectDescriptionAboutToChange(const AbstractAspect *aspect)
Definition: Table.cpp:1425
Table::restore
void restore(const QStringList &lst)
Definition: Table.cpp:1211
Table::colY
int colY(int col)
Definition: Table.cpp:337
Table::print
void print()
Definition: Table.cpp:225
Table::colIndex
int colIndex(const QString &name)
Definition: Table.cpp:1017
Table::selectedYLabels
QMap< int, QString > selectedYLabels()
Definition: Table.cpp:733
Table::columnType
int columnType(int col)
Definition: Table.cpp:1305
Table::saveColumnWidths
QString saveColumnWidths()
Definition: Table.cpp:390
Table::changedColHeader
void changedColHeader(const QString &, const QString &)
MyWidget::updateCaption
void updateCaption()
Set caption according to current CaptionPolicy, name and label.
Definition: MyWidget.cpp:52
Table::handleColumnsRemoved
void handleColumnsRemoved(int, int)
Definition: Table.cpp:177
Table::setNumRows
void setNumRows(int rows)
Definition: Table.cpp:1177
Table::setBirthDate
virtual void setBirthDate(const QString &s)
Set the creation date.
Definition: Table.h:97
Table::column
Column * column(const QString &name) const
Return the column determined by the given name.
Definition: Table.h:128
MyWidget::aspect
QString aspect()
Return the window status as a string.
Definition: MyWidget.cpp:106
Table::insertRow
void insertRow()
Definition: Table.cpp:793
AbstractAspect
Base class of all persistent objects in a Project.
Definition: AbstractAspect.h:86
Table::handleAspectDescriptionChange
void handleAspectDescriptionChange(const AbstractAspect *aspect)
Definition: Table.cpp:1434
Table::numRows
int numRows()
Definition: Table.cpp:887
Table::updateFunctionDoc
void updateFunctionDoc()
Definition: Table.cpp:1420