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)  

Double2StringFilter.h
Go to the documentation of this file.
1 
11 
29 #ifndef DOUBLE2STRING_FILTER_H
30 #define DOUBLE2STRING_FILTER_H
31 
32 #include "../AbstractSimpleFilter.h"
33 #include <QLocale>
34 #include <QChar>
35 #include <QtDebug>
36 
39 {
40  Q_OBJECT
41 
42  public:
44  explicit Double2StringFilter(char format='e', int digits=6) : d_format(format), d_digits(digits) {}
46  void setNumericFormat(char format);
48  void setNumDigits(int digits);
50  char numericFormat() const { return d_format; }
52  int numDigits() const { return d_digits; }
53 
56 
57  signals:
58  void formatChanged();
59 
60  private:
64  char d_format;
66  int d_digits;
67 
68 
70 
71  virtual void writeExtraAttributes(QXmlStreamWriter * writer) const;
72  virtual bool load(XmlStreamReader * reader);
74 
75  public:
76  virtual QString textAt(int row) const {
77  if (!d_inputs.value(0)) return QString();
78  if (d_inputs.value(0)->rowCount() <= row) return QString();
79  if (d_inputs.value(0)->isInvalid(row)) return QString();
80  return QLocale().toString(d_inputs.value(0)->valueAt(row), d_format, d_digits);
81  }
82 
83  protected:
85  virtual bool inputAcceptable(int, const AbstractColumn *source) {
86  return source->dataType() == SciDAVis::TypeDouble;
87  }
88 };
89 
90 class Double2StringFilterSetFormatCmd : public QUndoCommand
91 {
92  public:
93  Double2StringFilterSetFormatCmd(Double2StringFilter* target, char new_format);
94 
95  virtual void redo();
96  virtual void undo();
97 
98  private:
101 };
102 
103 class Double2StringFilterSetDigitsCmd : public QUndoCommand
104 {
105  public:
106  Double2StringFilterSetDigitsCmd(Double2StringFilter* target, int new_digits);
107 
108  virtual void redo();
109  virtual void undo();
110 
111  private:
114 };
115 
116 
117 #endif // ifndef DOUBLE2STRING_FILTER_H
118 
Double2StringFilter::dataType
virtual SciDAVis::ColumnDataType dataType() const
Return the data type of the column.
Definition: Double2StringFilter.h:55
Double2StringFilterSetDigitsCmd
Definition: Double2StringFilter.h:104
Double2StringFilter::Double2StringFilter
Double2StringFilter(char format='e', int digits=6)
Standard constructor.
Definition: Double2StringFilter.h:44
Double2StringFilter::load
virtual bool load(XmlStreamReader *reader)
Load from XML.
Definition: Double2StringFilter.cpp:40
Double2StringFilter::d_format
char d_format
Format character as in QString::number.
Definition: Double2StringFilter.h:64
Double2StringFilterSetDigitsCmd::Double2StringFilterSetDigitsCmd
Double2StringFilterSetDigitsCmd(Double2StringFilter *target, int new_digits)
Definition: Double2StringFilter.cpp:96
Double2StringFilterSetFormatCmd::Double2StringFilterSetFormatCmd
Double2StringFilterSetFormatCmd(Double2StringFilter *target, char new_format)
Definition: Double2StringFilter.cpp:74
SciDAVis::TypeQString
@ TypeQString
Definition: globals.h:79
XmlStreamReader
XML stream parser that supports errors as well as warnings.
Definition: XmlStreamReader.h:42
SciDAVis::ColumnDataType
ColumnDataType
Column data type.
Definition: globals.h:77
Double2StringFilter::numericFormat
char numericFormat() const
Get format character as in QString::number.
Definition: Double2StringFilter.h:50
Double2StringFilterSetDigitsCmd::undo
virtual void undo()
Definition: Double2StringFilter.cpp:113
Double2StringFilterSetFormatCmd
Definition: Double2StringFilter.h:91
AbstractColumn::dataType
virtual SciDAVis::ColumnDataType dataType() const =0
Return the data type of the column.
Double2StringFilterSetFormatCmd::d_other_format
char d_other_format
Definition: Double2StringFilter.h:100
Double2StringFilter::setNumDigits
void setNumDigits(int digits)
Set number of displayed digits.
Definition: Double2StringFilter.cpp:69
Double2StringFilterSetFormatCmd::d_target
Double2StringFilter * d_target
Definition: Double2StringFilter.h:99
Double2StringFilterSetFormatCmd::undo
virtual void undo()
Definition: Double2StringFilter.cpp:91
Double2StringFilterSetDigitsCmd::d_target
Double2StringFilter * d_target
Definition: Double2StringFilter.h:112
Double2StringFilter::writeExtraAttributes
virtual void writeExtraAttributes(QXmlStreamWriter *writer) const
Definition: Double2StringFilter.cpp:34
Double2StringFilter::formatChanged
void formatChanged()
Double2StringFilter::setNumericFormat
void setNumericFormat(char format)
Set format character as in QString::number.
Definition: Double2StringFilter.cpp:64
Double2StringFilterSetDigitsCmd::redo
virtual void redo()
Definition: Double2StringFilter.cpp:105
Double2StringFilterSetFormatCmd::redo
virtual void redo()
Definition: Double2StringFilter.cpp:83
Double2StringFilter::inputAcceptable
virtual bool inputAcceptable(int, const AbstractColumn *source)
Using typed ports: only double inputs are accepted.
Definition: Double2StringFilter.h:85
Double2StringFilter::textAt
virtual QString textAt(int row) const
Return the content of row 'row'.
Definition: Double2StringFilter.h:76
SciDAVis::TypeDouble
@ TypeDouble
Definition: globals.h:78
Double2StringFilter::numDigits
int numDigits() const
Get number of displayed digits.
Definition: Double2StringFilter.h:52
AbstractSimpleFilter
Simplified filter interface for filters with only one output port.
Definition: AbstractSimpleFilter.h:129
Double2StringFilterSetDigitsCmd::d_other_digits
int d_other_digits
Definition: Double2StringFilter.h:113
Double2StringFilter::d_digits
int d_digits
Display digits or precision as in QString::number
Definition: Double2StringFilter.h:66
Double2StringFilter
Locale-aware conversion filter double -> QString.
Definition: Double2StringFilter.h:39
AbstractFilter::d_inputs
QVector< const AbstractColumn * > d_inputs
The data sources connected to my input ports.
Definition: AbstractFilter.h:275
AbstractColumn
Interface definition for data with column logic.
Definition: AbstractColumn.h:82