"Fossies" - the Fresh Open Source Software Archive

Member "scidavis-2.3.0/libscidavis/src/future/core/AbstractSimpleFilter.cpp" (12 Jun 2020, 6332 Bytes) of package /linux/misc/scidavis-2.3.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "AbstractSimpleFilter.cpp" see the Fossies "Dox" file reference documentation.

    1 /***************************************************************************
    2     File                 : AbstractSimpleFilter.cpp
    3     Project              : SciDAVis
    4     --------------------------------------------------------------------
    5     Copyright            : (C) 2007-2009 by Knut Franke, Tilman Benkert
    6     Email (use @ for *)  : knut.franke*gmx.de, thzs*gmx.net
    7     Description          : Simplified filter interface for filters with
    8                            only one output port.
    9 
   10  ***************************************************************************/
   11 
   12 /***************************************************************************
   13  *                                                                         *
   14  *  This program is free software; you can redistribute it and/or modify   *
   15  *  it under the terms of the GNU General Public License as published by   *
   16  *  the Free Software Foundation; either version 2 of the License, or      *
   17  *  (at your option) any later version.                                    *
   18  *                                                                         *
   19  *  This program is distributed in the hope that it will be useful,        *
   20  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
   21  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
   22  *  GNU General Public License for more details.                           *
   23  *                                                                         *
   24  *   You should have received a copy of the GNU General Public License     *
   25  *   along with this program; if not, write to the Free Software           *
   26  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
   27  *   Boston, MA  02110-1301  USA                                           *
   28  *                                                                         *
   29  ***************************************************************************/
   30 
   31 #include "AbstractSimpleFilter.h"
   32 #include <QtDebug>
   33 
   34 // TODO: should simple filters have a name argument?
   35 AbstractSimpleFilter::AbstractSimpleFilter()
   36     : AbstractFilter("SimpleFilter"), d_output_column(new SimpleFilterColumn(this))
   37 {
   38     addChild(d_output_column);
   39 }
   40 
   41 void AbstractSimpleFilter::clearMasks()
   42 {
   43     emit d_output_column->maskingAboutToChange(d_output_column);
   44     d_masking.clear();
   45     emit d_output_column->maskingChanged(d_output_column);
   46 }
   47 
   48 void AbstractSimpleFilter::setMasked(Interval<int> i, bool mask)
   49 {
   50     emit d_output_column->maskingAboutToChange(d_output_column);
   51     d_masking.setValue(i, mask);
   52     emit d_output_column->maskingChanged(d_output_column);
   53 }
   54 
   55 void AbstractSimpleFilter::inputPlotDesignationAboutToChange(const AbstractColumn*)
   56 {
   57     emit d_output_column->plotDesignationAboutToChange(d_output_column);
   58 }
   59 
   60 void AbstractSimpleFilter::inputPlotDesignationChanged(const AbstractColumn*)
   61 {
   62     emit d_output_column->plotDesignationChanged(d_output_column);
   63 }
   64 
   65 void AbstractSimpleFilter::inputModeAboutToChange(const AbstractColumn*)
   66 {
   67     emit d_output_column->dataAboutToChange(d_output_column);
   68 }
   69 
   70 void AbstractSimpleFilter::inputModeChanged(const AbstractColumn*)
   71 {
   72     emit d_output_column->dataChanged(d_output_column);
   73 }
   74 
   75 void AbstractSimpleFilter::inputDataAboutToChange(const AbstractColumn*)
   76 {
   77     emit d_output_column->dataAboutToChange(d_output_column);
   78 }
   79 
   80 void AbstractSimpleFilter::inputDataChanged(const AbstractColumn*)
   81 {
   82     emit d_output_column->dataChanged(d_output_column);
   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 
  115 AbstractColumn *AbstractSimpleFilter::output(int port)
  116 {
  117     return port == 0 ? static_cast<AbstractColumn*>(d_output_column) : 0;
  118 }
  119 
  120 const AbstractColumn *AbstractSimpleFilter::output(int port) const
  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 
  135 bool AbstractSimpleFilter::load(XmlStreamReader * reader)
  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