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)  

AbstractFilter.cpp
Go to the documentation of this file.
1 
11 
29 #include "AbstractFilter.h"
30 
31 bool AbstractFilter::input(int port, const AbstractColumn* source)
32 {
33  if (port<0 || (inputCount()>=0 && port>=inputCount())) return false;
34  if (source && !inputAcceptable(port, source)) return false;
35  if (port >= d_inputs.size()) d_inputs.resize(port+1);
36  const AbstractColumn* old_input = d_inputs.value(port);
37  if (source == old_input) return true;
38  if (old_input)
39  {
40  disconnect(old_input, 0, this, 0);
41  // replace input, notifying the filter implementation of the changes
44  inputMaskingAboutToChange(old_input);
45  inputDataAboutToChange(old_input);
46  if(source && source->columnMode() != old_input->columnMode())
47  inputModeAboutToChange(old_input);
48  }
49  if (!source)
50  inputAboutToBeDisconnected(old_input);
51  d_inputs[port] = source;
52  if (source) { // we have a new source
53  if(old_input && source->columnMode() != old_input->columnMode())
54  inputModeAboutToChange(source);
55  inputDataChanged(source);
56  inputMaskingChanged(source);
59  // connect the source's signals
60  QObject::connect(source, SIGNAL(aspectDescriptionAboutToChange(const AbstractAspect *)),
61  this, SLOT(inputDescriptionAboutToChange(const AbstractAspect *)));
62  QObject::connect(source, SIGNAL(aspectDescriptionChanged(const AbstractAspect *)),
63  this, SLOT(inputDescriptionChanged(const AbstractAspect *)));
64  QObject::connect(source, SIGNAL(plotDesignationAboutToChange(const AbstractColumn *)),
66  QObject::connect(source, SIGNAL(plotDesignationChanged(const AbstractColumn *)),
67  this, SLOT(inputPlotDesignationChanged(const AbstractColumn *)));
68  QObject::connect(source, SIGNAL(modeAboutToChange(const AbstractColumn *)),
69  this, SLOT(inputModeAboutToChange(const AbstractColumn *)));
70  QObject::connect(source, SIGNAL(modeChanged(const AbstractColumn *)),
71  this, SLOT(inputModeChanged(const AbstractColumn *)));
72  QObject::connect(source, SIGNAL(dataAboutToChange(const AbstractColumn *)),
73  this, SLOT(inputDataAboutToChange(const AbstractColumn *)));
74  QObject::connect(source, SIGNAL(dataChanged(const AbstractColumn *)),
75  this, SLOT(inputDataChanged(const AbstractColumn *)));
76  QObject::connect(source, SIGNAL(aboutToBeReplaced(const AbstractColumn *,const AbstractColumn*)),
77  this, SLOT(inputAboutToBeReplaced(const AbstractColumn *,const AbstractColumn*)));
78  QObject::connect(source,
79  SIGNAL(rowsAboutToBeInserted(const AbstractColumn *,int,int)),
80  this, SLOT(inputRowsAboutToBeInserted(const AbstractColumn *,int,int)));
81  QObject::connect(source,
82  SIGNAL(rowsInserted(const AbstractColumn *,int,int)),
83  this, SLOT(inputRowsInserted(const AbstractColumn *,int,int)));
84  QObject::connect(source,
85  SIGNAL(rowsAboutToBeRemoved(const AbstractColumn *,int,int)),
86  this, SLOT(inputRowsAboutToBeRemoved(const AbstractColumn *,int,int)));
87  QObject::connect(source,
88  SIGNAL(rowsRemoved(const AbstractColumn *, int, int)),
89  this, SLOT(inputRowsRemoved(const AbstractColumn *,int,int)));
90  QObject::connect(source, SIGNAL(maskingAboutToChange(const AbstractColumn *)),
91  this, SLOT(inputMaskingAboutToChange(const AbstractColumn *)));
92  QObject::connect(source, SIGNAL(maskingChanged(const AbstractColumn *)),
93  this, SLOT(inputMaskingChanged(const AbstractColumn *)));
94  QObject::connect(source, SIGNAL(aboutToBeDestroyed(const AbstractColumn *)),
95  this, SLOT(inputAboutToBeDestroyed(const AbstractColumn *)));
96  } else { // source==0, that is, the input port has been disconnected
97  // try to shrink d_inputs
98  int num_connected_inputs = d_inputs.size();
99  while ( d_inputs.at(num_connected_inputs-1) == 0 )
100  {
101  num_connected_inputs--;
102  if(!num_connected_inputs) break;
103  }
104  d_inputs.resize(num_connected_inputs);
105  }
106  return true;
107 }
108 
110 {
111  if (!sources) return false;
112  bool result = true;
113  for (int i=0; i<sources->outputCount(); i++)
114  if (!input(i, sources->output(i)))
115  result = false;
116  return result;
117 }
118 
119 QString AbstractFilter::inputLabel(int port) const
120 {
121  return QObject::tr("In%1").arg(port + 1);
122 }
123 
125 {
126  input(portIndexOf(source), replacement);
127 }
128 
AbstractFilter::input
bool input(int port, const AbstractColumn *source)
Connect the provided data source to the specified input port.
Definition: AbstractFilter.cpp:31
AbstractFilter.h
AbstractFilter::inputPlotDesignationAboutToChange
virtual void inputPlotDesignationAboutToChange(const AbstractColumn *source)
The plot designation of an input is about to change.
Definition: AbstractFilter.h:204
AbstractFilter::inputRowsRemoved
virtual void inputRowsRemoved(const AbstractColumn *source, int first, int count)
Definition: AbstractFilter.h:259
AbstractFilter
Base class for all analysis operations.
Definition: AbstractFilter.h:77
AbstractFilter::inputMaskingAboutToChange
virtual void inputMaskingAboutToChange(const AbstractColumn *source)
Definition: AbstractFilter.h:262
AbstractFilter::inputDataChanged
virtual void inputDataChanged(const AbstractColumn *source)
The data of an input has changed.
Definition: AbstractFilter.h:235
AbstractFilter::inputDescriptionAboutToChange
virtual void inputDescriptionAboutToChange(const AbstractColumn *source)
Name and/or comment of an input will be changed.
Definition: AbstractFilter.h:183
AbstractFilter::inputRowsAboutToBeRemoved
virtual void inputRowsAboutToBeRemoved(const AbstractColumn *source, int first, int count)
Definition: AbstractFilter.h:256
AbstractFilter::inputMaskingChanged
virtual void inputMaskingChanged(const AbstractColumn *source)
Definition: AbstractFilter.h:265
AbstractFilter::inputAcceptable
virtual bool inputAcceptable(int port, const AbstractColumn *source)
Give implementations a chance to reject connections to their input ports.
Definition: AbstractFilter.h:163
AbstractFilter::inputDataAboutToChange
virtual void inputDataAboutToChange(const AbstractColumn *source)
The data of an input is about to change.
Definition: AbstractFilter.h:229
AbstractColumn::columnMode
virtual SciDAVis::ColumnMode columnMode() const =0
Return the column mode.
AbstractFilter::inputModeAboutToChange
virtual void inputModeAboutToChange(const AbstractColumn *source)
The display mode and possibly the data type of an input is about to change.
Definition: AbstractFilter.h:217
AbstractFilter::inputRowsAboutToBeInserted
virtual void inputRowsAboutToBeInserted(const AbstractColumn *source, int before, int count)
Definition: AbstractFilter.h:250
AbstractFilter::inputRowsInserted
virtual void inputRowsInserted(const AbstractColumn *source, int before, int count)
Definition: AbstractFilter.h:253
AbstractFilter::inputLabel
virtual QString inputLabel(int port) const
Return the label associated to the given input port.
Definition: AbstractFilter.cpp:119
AbstractFilter::inputAboutToBeDestroyed
void inputAboutToBeDestroyed(const AbstractColumn *source)
Definition: AbstractFilter.h:268
AbstractFilter::inputDescriptionChanged
virtual void inputDescriptionChanged(const AbstractColumn *source)
Name and/or comment of an input changed.
Definition: AbstractFilter.h:194
AbstractAspect::aspectDescriptionAboutToChange
void aspectDescriptionAboutToChange(const AbstractAspect *aspect)
Emit this before the name, comment or caption spec is changed.
AbstractAspect::aspectDescriptionChanged
void aspectDescriptionChanged(const AbstractAspect *aspect)
Emit this when the name, comment or caption spec changed.
AbstractFilter::inputCount
virtual int inputCount() const =0
Return the number of input ports supported by the filter or -1 if any number of inputs is acceptable.
AbstractFilter::portIndexOf
int portIndexOf(const AbstractColumn *column)
Return the input port to which the column is connected or -1 if it's not connected.
Definition: AbstractFilter.h:150
AbstractFilter::inputPlotDesignationChanged
virtual void inputPlotDesignationChanged(const AbstractColumn *source)
The plot designation of an input changed.
Definition: AbstractFilter.h:211
AbstractFilter::outputCount
virtual int outputCount() const =0
Return the number of output ports provided by the filter.
AbstractFilter::output
virtual AbstractColumn * output(int port=0)=0
Get the data source associated with the specified output port.
AbstractFilter::inputModeChanged
virtual void inputModeChanged(const AbstractColumn *source)
The display mode and possibly the data type has changed.
Definition: AbstractFilter.h:223
AbstractFilter::inputAboutToBeReplaced
virtual void inputAboutToBeReplaced(const AbstractColumn *source, const AbstractColumn *replacement)
An input is about to be replaced.
Definition: AbstractFilter.cpp:124
AbstractFilter::d_inputs
QVector< const AbstractColumn * > d_inputs
The data sources connected to my input ports.
Definition: AbstractFilter.h:275
AbstractFilter::inputAboutToBeDisconnected
virtual void inputAboutToBeDisconnected(const AbstractColumn *source)
Called whenever an input is disconnected or deleted.
Definition: AbstractFilter.h:172
AbstractAspect
Base class of all persistent objects in a Project.
Definition: AbstractAspect.h:86
AbstractColumn
Interface definition for data with column logic.
Definition: AbstractColumn.h:82