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)  

AbstractSimpleFilter.cpp
Go to the documentation of this file.
1 
12 
31 #include "AbstractSimpleFilter.h"
32 #include <QtDebug>
33 
34 // TODO: should simple filters have a name argument?
36  : AbstractFilter("SimpleFilter"), d_output_column(new SimpleFilterColumn(this))
37 {
39 }
40 
42 {
44  d_masking.clear();
46 }
47 
49 {
51  d_masking.setValue(i, mask);
53 }
54 
56 {
58 }
59 
61 {
63 }
64 
66 {
68 }
69 
71 {
73 }
74 
76 {
78 }
79 
81 {
83 }
84 
85 void AbstractSimpleFilter::inputRowsAboutToBeInserted(const AbstractColumn * source, int before, int count)
86 {
87  Q_UNUSED(source);
88  Q_UNUSED(count);
89  foreach(Interval<int> output_range, dependentRows(Interval<int>(before, before)))
90  emit d_output_column->rowsAboutToBeInserted(d_output_column, output_range.start(), output_range.size());
91 }
92 
93 void AbstractSimpleFilter::inputRowsInserted(const AbstractColumn * source, int before, int count)
94 {
95  Q_UNUSED(source);
96  Q_UNUSED(count);
97  foreach(Interval<int> output_range, dependentRows(Interval<int>(before, before)))
98  emit d_output_column->rowsInserted(d_output_column, output_range.start(), output_range.size());
99 }
100 
101 void AbstractSimpleFilter::inputRowsAboutToBeRemoved(const AbstractColumn * source, int first, int count)
102 {
103  Q_UNUSED(source);
104  foreach(Interval<int> output_range, dependentRows(Interval<int>(first, first+count-1)))
105  emit d_output_column->rowsAboutToBeRemoved(d_output_column, output_range.start(), output_range.size());
106 }
107 
108 void AbstractSimpleFilter::inputRowsRemoved(const AbstractColumn * source, int first, int count)
109 {
110  Q_UNUSED(source);
111  foreach(Interval<int> output_range, dependentRows(Interval<int>(first, first+count-1)))
112  emit d_output_column->rowsRemoved(d_output_column, output_range.start(), output_range.size());
113 }
114 
116 {
117  return port == 0 ? static_cast<AbstractColumn*>(d_output_column) : 0;
118 }
119 
121 {
122  return port == 0 ? static_cast<const AbstractColumn*>(d_output_column) : 0;
123 }
124 
125 void AbstractSimpleFilter::save(QXmlStreamWriter * writer) const
126 {
127  writer->writeStartElement("simple_filter");
128  writeBasicAttributes(writer);
129  writeExtraAttributes(writer);
130  writer->writeAttribute("filter_name", metaObject()->className());
131  writeCommentElement(writer);
132  writer->writeEndElement();
133 }
134 
136 {
137  if(reader->isStartElement() && reader->name() == "simple_filter")
138  {
139  if (!readBasicAttributes(reader)) return false;
140 
141  QXmlStreamAttributes attribs = reader->attributes();
142  QString str = attribs.value(reader->namespaceUri().toString(), "filter_name").toString();
143  if(str != metaObject()->className())
144  {
145  reader->raiseError(tr("incompatible filter type"));
146  return false;
147  }
148 
149  // read child elements
150  while (!reader->atEnd())
151  {
152  reader->readNext();
153 
154  if (reader->isEndElement()) break;
155 
156  if (reader->isStartElement())
157  {
158  if (reader->name() == "comment")
159  {
160  if (!readCommentElement(reader)) return false;
161  }
162  else // unknown element
163  {
164  reader->raiseWarning(tr("unknown element '%1'").arg(reader->name().toString()));
165  if (!reader->skipToEndElement()) return false;
166  }
167  }
168  }
169  }
170  else
171  reader->raiseError(tr("no simple filter element found"));
172 
173  return !reader->hasError();
174 }
175 
AbstractSimpleFilter::AbstractSimpleFilter
AbstractSimpleFilter()
Ctor.
Definition: AbstractSimpleFilter.cpp:35
AbstractSimpleFilter::dependentRows
virtual QList< Interval< int > > dependentRows(Interval< int > input_range) const
Definition: AbstractSimpleFilter.h:215
AbstractColumn::dataAboutToChange
void dataAboutToChange(const AbstractColumn *source)
Data (including validity) of the column will be changed.
AbstractAspect::writeCommentElement
void writeCommentElement(QXmlStreamWriter *writer) const
Save the comment to XML.
Definition: AbstractAspect.cpp:52
AbstractColumn::plotDesignationChanged
void plotDesignationChanged(const AbstractColumn *source)
Column plot designation changed.
AbstractSimpleFilter::inputModeAboutToChange
virtual void inputModeAboutToChange(const AbstractColumn *)
The display mode and possibly the data type of an input is about to change.
Definition: AbstractSimpleFilter.cpp:65
AbstractSimpleFilter::inputPlotDesignationChanged
virtual void inputPlotDesignationChanged(const AbstractColumn *)
The plot designation of an input changed.
Definition: AbstractSimpleFilter.cpp:60
XmlStreamReader::raiseError
void raiseError(const QString &message=QString())
Definition: XmlStreamReader.cpp:80
str
#define str(x)
Definition: PythonScripting.cpp:41
AbstractFilter
Base class for all analysis operations.
Definition: AbstractFilter.h:77
XmlStreamReader
XML stream parser that supports errors as well as warnings.
Definition: XmlStreamReader.h:42
AbstractSimpleFilter::inputModeChanged
virtual void inputModeChanged(const AbstractColumn *)
The display mode and possibly the data type has changed.
Definition: AbstractSimpleFilter.cpp:70
AbstractColumn::maskingChanged
void maskingChanged(const AbstractColumn *source)
IntervalAttribute related signal.
AbstractSimpleFilter::d_masking
IntervalAttribute< bool > d_masking
Definition: AbstractSimpleFilter.h:259
AbstractSimpleFilter.h
Interval::size
T size() const
Definition: Interval.h:216
AbstractColumn::rowsInserted
void rowsInserted(const AbstractColumn *source, int before, int count)
Rows have been inserted.
AbstractColumn::maskingAboutToChange
void maskingAboutToChange(const AbstractColumn *source)
IntervalAttribute related signal.
AbstractSimpleFilter::d_output_column
SimpleFilterColumn * d_output_column
Definition: AbstractSimpleFilter.h:276
XmlStreamReader::skipToEndElement
bool skipToEndElement()
Go to the end element tag of the current element.
Definition: XmlStreamReader.cpp:121
AbstractSimpleFilter::inputRowsRemoved
virtual void inputRowsRemoved(const AbstractColumn *source, int first, int count)
Definition: AbstractSimpleFilter.cpp:108
AbstractSimpleFilter::inputDataAboutToChange
virtual void inputDataAboutToChange(const AbstractColumn *)
The data of an input is about to change.
Definition: AbstractSimpleFilter.cpp:75
AbstractSimpleFilter::save
virtual void save(QXmlStreamWriter *writer) const
Save to XML.
Definition: AbstractSimpleFilter.cpp:125
AbstractSimpleFilter::inputRowsInserted
virtual void inputRowsInserted(const AbstractColumn *source, int before, int count)
Definition: AbstractSimpleFilter.cpp:93
IntervalAttribute< bool >::setValue
void setValue(Interval< int > i, bool value=true)
Definition: IntervalAttribute.h:210
AbstractSimpleFilter::inputPlotDesignationAboutToChange
virtual void inputPlotDesignationAboutToChange(const AbstractColumn *)
The plot designation of an input is about to change.
Definition: AbstractSimpleFilter.cpp:55
AbstractColumn::rowsRemoved
void rowsRemoved(const AbstractColumn *source, int first, int count)
Rows have been deleted.
AbstractSimpleFilter::output
virtual AbstractColumn * output(int port)
Return a pointer to d_output_column on port 0 (don't override unless you really know what you are doi...
Definition: AbstractSimpleFilter.cpp:115
AbstractAspect::readBasicAttributes
bool readBasicAttributes(XmlStreamReader *reader)
Load name, creation time and caption spec from XML.
Definition: AbstractAspect.cpp:77
SimpleFilterColumn
Definition: AbstractSimpleFilter.h:280
AbstractColumn::rowsAboutToBeInserted
void rowsAboutToBeInserted(const AbstractColumn *source, int before, int count)
Rows will be inserted.
AbstractSimpleFilter::clearMasks
virtual void clearMasks()
Clear all masking information.
Definition: AbstractSimpleFilter.cpp:41
AbstractSimpleFilter::writeExtraAttributes
virtual void writeExtraAttributes(QXmlStreamWriter *writer) const
Override this in derived classes if they have other attributes than filter_name.
Definition: AbstractSimpleFilter.h:255
AbstractAspect::writeBasicAttributes
void writeBasicAttributes(QXmlStreamWriter *writer) const
Save name, creation time and caption spec to XML.
Definition: AbstractAspect.cpp:70
AbstractSimpleFilter::inputDataChanged
virtual void inputDataChanged(const AbstractColumn *)
The data of an input has changed.
Definition: AbstractSimpleFilter.cpp:80
AbstractSimpleFilter::inputRowsAboutToBeRemoved
virtual void inputRowsAboutToBeRemoved(const AbstractColumn *source, int first, int count)
Definition: AbstractSimpleFilter.cpp:101
AbstractSimpleFilter::load
virtual bool load(XmlStreamReader *reader)
Load from XML.
Definition: AbstractSimpleFilter.cpp:135
IntervalAttribute< bool >::clear
void clear()
Definition: IntervalAttribute.h:294
AbstractSimpleFilter::inputRowsAboutToBeInserted
virtual void inputRowsAboutToBeInserted(const AbstractColumn *source, int before, int count)
Definition: AbstractSimpleFilter.cpp:85
AbstractSimpleFilter::setMasked
virtual void setMasked(Interval< int > i, bool mask=true)
Set an interval masked.
Definition: AbstractSimpleFilter.cpp:48
AbstractAspect::addChild
void addChild(AbstractAspect *child)
Add the given Aspect to my list of children.
Definition: AbstractAspect.cpp:114
AbstractColumn::rowsAboutToBeRemoved
void rowsAboutToBeRemoved(const AbstractColumn *source, int first, int count)
Rows will be deleted.
XmlStreamReader::raiseWarning
void raiseWarning(const QString &message=QString())
Definition: XmlStreamReader.cpp:86
Interval< int >
AbstractColumn::dataChanged
void dataChanged(const AbstractColumn *source)
Data (including validity) of the column has changed.
AbstractAspect::readCommentElement
bool readCommentElement(XmlStreamReader *reader)
Load comment from an XML element.
Definition: AbstractAspect.cpp:61
AbstractColumn::plotDesignationAboutToChange
void plotDesignationAboutToChange(const AbstractColumn *source)
Column plot designation will be changed.
AbstractColumn
Interface definition for data with column logic.
Definition: AbstractColumn.h:82