~ubuntu-branches/ubuntu/utopic/scidavis/utopic-proposed

« back to all changes in this revision

Viewing changes to .pc/graph_const.diff/scidavis/src/scidavis.sip

  • Committer: Package Import Robot
  • Author(s): Scott Howard
  • Date: 2012-02-07 12:14:34 UTC
  • Revision ID: package-import@ubuntu.com-20120207121434-ugz4k7a791vygnu1
Tags: 0.2.4-3.1
* Non-maintainer upload. (Closes: #658644)
* Move plugins to /usr/lib (Closes: #646190)
  debian/patches/lib64.diff
* Fixed declaring Graph as const when it is not (Closes: #655776)
  debian/patches/graph_const.diff
* Recommends on qt-assistant-compat (Closes: #624752)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* vim: set filetype=cpp : */
 
2
/* due to a limitation of sip, this file has to use Unix style line endings */
 
3
/***************************************************************************
 
4
        File                 : scidavis.sip
 
5
        Project              : SciDAVis
 
6
        Description          : Specifications for Python bindings
 
7
    --------------------------------------------------------------------
 
8
    Copyright            : (C) 2006-2009 Knut Franke (knut.franke*gmx.de)
 
9
    Copyright            : (C) 2008-2009 Tilman Benkert (thzs*gmx.net)
 
10
    Copyright            : (C) 2006-2007 Ion Vasilief (ion_vasilief*yahoo.fr)
 
11
                           (replace * with @ in the email addresses) 
 
12
 
 
13
 ***************************************************************************/
 
14
 
 
15
/***************************************************************************
 
16
 *                                                                         *
 
17
 *  This program is free software; you can redistribute it and/or modify   *
 
18
 *  it under the terms of the GNU General Public License as published by   *
 
19
 *  the Free Software Foundation; either version 2 of the License, or      *
 
20
 *  (at your option) any later version.                                    *
 
21
 *                                                                         *
 
22
 *  This program is distributed in the hope that it will be useful,        *
 
23
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
 
24
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
 
25
 *  GNU General Public License for more details.                           *
 
26
 *                                                                         *
 
27
 *   You should have received a copy of the GNU General Public License     *
 
28
 *   along with this program; if not, write to the Free Software           *
 
29
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
 
30
 *   Boston, MA  02110-1301  USA                                           *
 
31
 *                                                                         *
 
32
 ***************************************************************************/
 
33
 
 
34
%Module scidavis 0
 
35
%Import QtCore/QtCoremod.sip
 
36
%Import QtGui/QtGuimod.sip
 
37
 
 
38
class AbstractAspect : QObject
 
39
{
 
40
%TypeHeaderCode
 
41
#include "core/AbstractAspect.h"
 
42
%End
 
43
        public:
 
44
/*
 
45
                AbstractAspect(const QString &name);
 
46
                AbstractAspect * parentAspect() const;
 
47
//              future::Folder * folder();
 
48
                bool isDescendantOf(AbstractAspect *other);
 
49
                void addChild(AbstractAspect* child /Transfer/);
 
50
                void insertChild(AbstractAspect *child /Transfer/, int index);
 
51
                void removeChild(AbstractAspect* child, bool detach=false);
 
52
                void removeChild(int index);
 
53
                AbstractAspect* child(int index) const;
 
54
                int childCount() const;
 
55
                int indexOfChild(const AbstractAspect * child) const;
 
56
                */
 
57
                int index() const;
 
58
                /*
 
59
                void moveChild(int from, int to);
 
60
                void reparentChild(AbstractAspect *new_parent, AbstractAspect *child, int d_new_index);
 
61
                void reparentChild(AbstractAspect *new_parent, AbstractAspect *child);
 
62
                QList<AbstractAspect *> descendantsThatInherit(const char *class_name);
 
63
                void removeAllChildAspects();
 
64
//              const Project *project() const;
 
65
//              Project *project();
 
66
                QString path() const;
 
67
                */
 
68
                QIcon icon() const;
 
69
                /*
 
70
                QMenu *createContextMenu() const;
 
71
                */
 
72
                QString name() const;
 
73
                QString comment() const;
 
74
                QString captionSpec() const;
 
75
                QDateTime creationTime() const;
 
76
                QString caption() const;
 
77
                /*
 
78
                QUndoStack *undoStack() const;
 
79
                void exec(QUndoCommand *command);
 
80
                void beginMacro(const QString& text);
 
81
                void endMacro();
 
82
                static QVariant global(const QString &key);
 
83
                static void setGlobal(const QString &key, const QVariant &value);
 
84
                static void setGlobalDefault(const QString &key, const QVariant &value);
 
85
//              void save(QXmlStreamWriter *) const;
 
86
//              bool load(XmlStreamReader *);
 
87
                */
 
88
        public slots:
 
89
                void setName(const QString &value);
 
90
                void setComment(const QString &value);
 
91
                void setCaptionSpec(const QString &value);
 
92
                void remove();
 
93
                /*
 
94
                QString uniqueNameFor(const QString &current_name) const;
 
95
                */
 
96
        signals:
 
97
                void aspectDescriptionAboutToChange(const AbstractAspect *aspect);
 
98
                void aspectDescriptionChanged(const AbstractAspect *aspect);
 
99
                void aspectAboutToBeAdded(const AbstractAspect *parent, int index);
 
100
                void aspectAdded(const AbstractAspect *aspect);
 
101
                void aspectAdded(const AbstractAspect *parent, int index);
 
102
                void aspectAboutToBeRemoved(const AbstractAspect *aspect);
 
103
                void aspectAboutToBeRemoved(const AbstractAspect *parent, int index);
 
104
                void aspectRemoved(const AbstractAspect *parent, int index);
 
105
                void statusInfo(const QString &text);
 
106
        private:
 
107
                AbstractAspect(const AbstractAspect&);
 
108
};
 
109
 
 
110
class Column: AbstractAspect
 
111
{
 
112
%TypeHeaderCode
 
113
#include "globals.h"
 
114
#include "core/column/Column.h"
 
115
#include "table/future_Table.h"
 
116
%End
 
117
        public:
 
118
/* will be removed in favour of columMode() - don't encourage anyone to start using it
 
119
                SIP_PYOBJECT dataType() const;
 
120
%MethodCode
 
121
                int mode = sipCpp->dataType();
 
122
                sipRes = PyString_FromString(SciDAVis::enumValueToString(mode, "ColumnDataType"));
 
123
%End
 
124
*/
 
125
                SIP_PYOBJECT columnMode() const;
 
126
%MethodCode
 
127
                int mode = sipCpp->columnMode();
 
128
                sipRes = PyString_FromString(SciDAVis::enumValueToString(mode, "ColumnMode"));
 
129
%End
 
130
                void setColumnMode(QString mode);
 
131
%MethodCode
 
132
                int mode_code = SciDAVis::enumStringToValue(*a0, "ColumnMode");
 
133
                if(mode_code != -1)
 
134
                        sipCpp->setColumnMode((SciDAVis::ColumnMode)mode_code);
 
135
%End
 
136
                bool copy(const Column * other);
 
137
                bool copy(const Column * source, int source_start, int dest_start, int num_rows);
 
138
                int rowCount() const;
 
139
                void insertRows(int before, int count);
 
140
                void removeRows(int first, int count);
 
141
                SIP_PYOBJECT plotDesignation() const;
 
142
%MethodCode
 
143
                int pd = sipCpp->plotDesignation();
 
144
                sipRes = PyString_FromString(SciDAVis::enumValueToString(pd, "PlotDesignation"));
 
145
%End
 
146
                void setPlotDesignation(QString pd);
 
147
%MethodCode
 
148
                int mode_code = SciDAVis::enumStringToValue(*a0, "PlotDesignation");
 
149
                if(mode_code != -1)
 
150
                        sipCpp->setPlotDesignation((SciDAVis::PlotDesignation)mode_code);
 
151
%End
 
152
                void clear();
 
153
                bool isInvalid(int row) const;
 
154
//              bool isMasked(int row) const;
 
155
                void clearValidity();
 
156
//              void clearMasks();
 
157
                void setInvalid(int row, bool invalid = true);
 
158
//              void setMasked(int row, bool mask = true);
 
159
                QString formula(int row) const;
 
160
                void setFormula(int row, QString formula);
 
161
                void clearFormulas();
 
162
                QString textAt(int row) const;
 
163
                void setTextAt(int row, const QString& new_value);
 
164
                void replaceTexts(int first, const QStringList& new_values);
 
165
                QDate dateAt(int row) const;
 
166
                void setDateAt(int row, const QDate& new_value);
 
167
                QTime timeAt(int row) const;
 
168
                void setTimeAt(int row, const QTime& new_value);
 
169
                QDateTime dateTimeAt(int row) const;
 
170
                void setDateTimeAt(int row, const QDateTime& new_value);
 
171
                void replaceDateTimes(int first, const QList<QDateTime>& new_values);
 
172
                double valueAt(int row) const;
 
173
                void setValueAt(int row, double new_value);
 
174
                void replaceValues(int first, const QVector<double>& new_values);
 
175
 
 
176
  Column * x() const /NoDerived/;
 
177
%MethodCode
 
178
    future::Table *t = qobject_cast<future::Table *>(sipCpp->parentAspect());
 
179
    if (t)
 
180
        sipRes = t->column(t->colX(t->indexOfChild(sipCpp)));
 
181
%End
 
182
 
 
183
  Column * y() const /NoDerived/;
 
184
%MethodCode
 
185
    future::Table *t = qobject_cast<future::Table *>(sipCpp->parentAspect());
 
186
    if (t)
 
187
        sipRes = t->column(t->colY(t->indexOfChild(sipCpp)));
 
188
%End
 
189
 
 
190
 
 
191
private:
 
192
  Column(const Column&);
 
193
};
 
194
 
 
195
class ScriptEdit: QTextEdit
 
196
{
 
197
%TypeHeaderCode
 
198
#include "src/ScriptEdit.h"
 
199
%End
 
200
public slots:
 
201
  void execute();
 
202
  void executeAll();
 
203
  void evaluate();
 
204
  void print();
 
205
  void insertFunction(const QString &);
 
206
private:
 
207
  ScriptEdit(ScriptEdit&);
 
208
};
 
209
 
 
210
class MyWidget: QWidget /PyName=MDIWindow/
 
211
{
 
212
%TypeHeaderCode
 
213
#include "src/MyWidget.h"
 
214
#include "src/ApplicationWindow.h"
 
215
%End
 
216
public:
 
217
  enum CaptionPolicy{Name = 0, Label = 1, Both = 2};
 
218
 
 
219
  SIP_PYOBJECT windowLabel();
 
220
%MethodCode
 
221
  sipRes = PyString_FromString(sipCpp->windowLabel());
 
222
%End
 
223
  void setWindowLabel(const QString&);
 
224
 
 
225
  QString name();
 
226
  void setName(const QString& s);
 
227
%MethodCode
 
228
        ApplicationWindow *app = sipscidavis_app();
 
229
        if (app) app->renameWindow(sipCpp, *a0);
 
230
%End
 
231
 
 
232
        MyWidget *clone() /NoDerived/;
 
233
%MethodCode
 
234
        ApplicationWindow *app = sipscidavis_app();
 
235
        if (app) sipRes = app->clone(sipCpp);
 
236
%End
 
237
 
 
238
  CaptionPolicy captionPolicy();
 
239
  void setCaptionPolicy(CaptionPolicy);
 
240
 
 
241
  // not usable as is - doesn't yield a valid template file,
 
242
  // geometry info has to be supplied by user, doesn't work on graphs (where it's most
 
243
  // interesting)...
 
244
  /*
 
245
  virtual SIP_PYOBJECT saveAsTemplate(const QString& );
 
246
%MethodCode
 
247
  sipRes = PyString_FromString(sipCpp->saveAsTemplate(*a0));
 
248
%End
 
249
*/
 
250
  // same issues as with saveAsTemplate
 
251
  /*
 
252
  virtual void restore(const QStringList& );
 
253
  */
 
254
  Folder* folder();
 
255
 
 
256
  void askOnCloseEvent(bool)/PyName=confirmClose/;
 
257
 
 
258
private:
 
259
  MyWidget(const MyWidget&);
 
260
};
 
261
 
 
262
 
 
263
 
 
264
class Table: MyWidget
 
265
{
 
266
%TypeHeaderCode
 
267
#include "src/Table.h"
 
268
 
 
269
#define CHECK_TABLE_COL(arg)\
 
270
    int col;\
 
271
    if (PyInt_Check(arg)) {\
 
272
      col = (int)PyInt_AsLong(arg) - 1;\
 
273
                if (col < 0 || col >= sipCpp->numCols()) {\
 
274
                        sipIsErr = 1;\
 
275
                        PyErr_Format(PyExc_ValueError, "There's no column %d in table %s!", col+1, sipCpp->name().toAscii().constData());\
 
276
                }\
 
277
         } else {\
 
278
      PyObject *tmp = PyObject_Str(arg);\
 
279
                if (!tmp) {\
 
280
                        sipIsErr = 1;\
 
281
                        PyErr_Format(PyExc_TypeError, "Column argument must be either int or string.");\
 
282
                } else {\
 
283
                        col = sipCpp->colNames().indexOf(PyString_AsString(tmp));\
 
284
                        if (col < 0) {\
 
285
                                sipIsErr = 1;\
 
286
                                PyErr_Format(PyExc_ValueError, "There's no column named %s in table %s!", PyString_AsString(tmp),\
 
287
                                                sipCpp->name().toAscii().constData());\
 
288
                                Py_DECREF(tmp);\
 
289
                        }\
 
290
                }\
 
291
         }
 
292
#define CHECK_TABLE_ROW(arg)\
 
293
   int row = arg-1;\
 
294
        if (row < 0 || row >= sipCpp->numRows()) {\
 
295
                sipIsErr = 1;\
 
296
                PyErr_Format(PyExc_ValueError, "There's no row %d in table %s!", row+1, sipCpp->name().toAscii().constData());\
 
297
        }
 
298
 
 
299
%End
 
300
 
 
301
public:
 
302
  int numRows();
 
303
  int numCols();
 
304
  int rowCount();
 
305
  int columnCount();
 
306
  void setNumRows(int);
 
307
  void setNumCols(int);
 
308
  Column * column(int index) const;
 
309
  Column * column(const QString & name) const;
 
310
 
 
311
  Column * __getitem__(int index) const /NoDerived/;
 
312
%MethodCode
 
313
  sipRes = sipCpp->column(a0);
 
314
%End
 
315
 
 
316
  Column * __getitem__(const QString &name) const /NoDerived/;
 
317
%MethodCode
 
318
  sipRes = sipCpp->column(*a0);
 
319
%End
 
320
 
 
321
  SIP_PYOBJECT text(SIP_PYOBJECT, int) /Deprecated/;
 
322
%MethodCode
 
323
  sipIsErr = 0;
 
324
  CHECK_TABLE_COL(a0);
 
325
  CHECK_TABLE_ROW(a1);
 
326
  if (sipIsErr == 0) {
 
327
                PyObject *encstr = PyString_FromString(sipCpp->text(row, col).utf8());
 
328
                if (encstr) {
 
329
                        sipRes = PyUnicode_FromEncodedObject(encstr, "utf8", 0);
 
330
                        Py_DECREF(encstr);
 
331
                } else {
 
332
                        sipRes = NULL;
 
333
                        sipIsErr = 1;
 
334
                }
 
335
        }
 
336
%End
 
337
  double cell(SIP_PYOBJECT, int) /Deprecated/;
 
338
%MethodCode
 
339
  sipIsErr = 0;
 
340
  CHECK_TABLE_COL(a0);
 
341
  CHECK_TABLE_ROW(a1);
 
342
        if (sipIsErr == 0)
 
343
                sipRes = sipCpp->cell(row, col);
 
344
%End
 
345
  void setText(SIP_PYOBJECT, int, const QString&) /Deprecated/;
 
346
%MethodCode
 
347
  sipIsErr = 0;
 
348
  CHECK_TABLE_COL(a0);
 
349
  CHECK_TABLE_ROW(a1);
 
350
        if (sipIsErr == 0)
 
351
                sipCpp->setText(row, col, *a2);
 
352
%End
 
353
  void setCell(SIP_PYOBJECT, int, double) /Deprecated/;
 
354
%MethodCode
 
355
  sipIsErr = 0;
 
356
  CHECK_TABLE_COL(a0);
 
357
  CHECK_TABLE_ROW(a1);
 
358
        if (sipIsErr == 0)
 
359
                sipCpp->setCell(row, col, a2);
 
360
%End
 
361
  SIP_PYOBJECT colName(int) /Deprecated/;
 
362
%MethodCode
 
363
   if (a0 < 1 || a0 > sipCpp->numCols()) {\
 
364
                sipIsErr = 1;\
 
365
                PyErr_SetString(PyExc_ValueError, "Invalid column argument");\
 
366
        } else
 
367
                sipRes = PyString_FromString(sipCpp->colLabel(a0-1));
 
368
%End
 
369
  void setColName(SIP_PYOBJECT, const QString&) /Deprecated/;
 
370
%MethodCode
 
371
        sipIsErr = 0;
 
372
   CHECK_TABLE_COL(a0);
 
373
        if (sipIsErr == 0)
 
374
                sipCpp->setColName(col, *a1);
 
375
%End
 
376
  void notifyChanges() /Deprecated/;
 
377
 
 
378
  void importASCII(const QString&, const QString&="\t", int=0, bool=false, bool=true, bool=false, bool=false);
 
379
  bool exportASCII(const QString&, const QString&="\t", bool=false, bool=false);
 
380
  void normalize(SIP_PYOBJECT) /NoDerived/;
 
381
%MethodCode
 
382
        sipIsErr = 0;
 
383
        CHECK_TABLE_COL(a0);
 
384
        if (sipIsErr == 0)
 
385
                sipCpp->d_future_table->normalizeColumns(QList< Column* >() << sipCpp->column(col));
 
386
%End
 
387
  void normalize() /NoDerived/;
 
388
%MethodCode
 
389
        QList< Column* > cols;
 
390
        for (int i=0; i<sipCpp->numCols(); i++)
 
391
                cols << sipCpp->column(i);
 
392
        sipCpp->d_future_table->normalizeColumns(cols);
 
393
%End
 
394
 
 
395
  void sortColumn(SIP_PYOBJECT, int order = 0) /NoDerived/;
 
396
%MethodCode
 
397
        sipIsErr = 0;
 
398
        CHECK_TABLE_COL(a0);
 
399
        if (sipIsErr == 0)
 
400
                sipCpp->d_future_table->sortColumns(0, QList<Column*>() << sipCpp->column(col), a1==0);
 
401
%End
 
402
  void sort(int type = 0, int order = 0, const QString& leadCol = QString()) /NoDerived/;
 
403
%MethodCode
 
404
        Column * lead;
 
405
        if (a0 == 0)
 
406
                lead = 0; // sort separately
 
407
        else
 
408
                lead = sipCpp->column(*a2);
 
409
        QList< Column* > cols;
 
410
        for (int i=0; i<sipCpp->numCols(); i++)
 
411
                cols << sipCpp->column(i);
 
412
        sipCpp->d_future_table->sortColumns(lead, cols, a1==0);
 
413
%End
 
414
  void sortColumns(SIP_PYTUPLE, int=0, int=0, const QString&=QString());
 
415
%MethodCode
 
416
        Column * lead;
 
417
        if (a1 == 0)
 
418
                lead = 0; // sort separately
 
419
        else
 
420
                lead = sipCpp->column(*a3);
 
421
        QList< Column* > cols;
 
422
  int n = PyTuple_Size(a0);
 
423
  for (int i=0; i<n; i++) {
 
424
          PyObject *str = PyObject_Str(PyTuple_GET_ITEM(a0,i));
 
425
          if (str) {
 
426
                  cols << sipCpp->column(PyString_AsString(str));
 
427
                  Py_DECREF(str);
 
428
          } else {
 
429
                  sipIsErr = 1;
 
430
                  break;
 
431
          }
 
432
  }
 
433
  sipCpp->d_future_table->sortColumns(lead, cols, a2==0);
 
434
%End
 
435
        void setCommand(SIP_PYOBJECT, const QString&) /Deprecated/;
 
436
%MethodCode
 
437
        sipIsErr = 0;
 
438
        CHECK_TABLE_COL(a0);
 
439
        if (sipIsErr == 0)
 
440
                sipCpp->setCommand(col, *a1);
 
441
%End
 
442
 
 
443
        void setComment(SIP_PYOBJECT, const QString&) /Deprecated/;
 
444
%MethodCode
 
445
        sipIsErr = 0;
 
446
        CHECK_TABLE_COL(a0);
 
447
        if (sipIsErr == 0)
 
448
                sipCpp->setColComment(col, *a1);
 
449
%End
 
450
 
 
451
private:
 
452
  Table(const Table&);
 
453
};
 
454
 
 
455
class Matrix: MyWidget
 
456
{
 
457
%TypeHeaderCode
 
458
#include "src/Matrix.h"
 
459
#define CHECK_MATRIX_COL(arg)\
 
460
        int col = arg-1;\
 
461
   if (col < 0 || col >= sipCpp->numCols()) {\
 
462
                sipIsErr = 1;\
 
463
                PyErr_Format(PyExc_ValueError, "There's no column %d in matrix %s!", col+1, sipCpp->name().toAscii().constData());\
 
464
        }
 
465
#define CHECK_MATRIX_ROW(arg)\
 
466
   int row = arg-1;\
 
467
        if (row < 0 || row >= sipCpp->numRows()) {\
 
468
                sipIsErr = 1;\
 
469
                PyErr_Format(PyExc_ValueError, "There's no row %d in matrix %s!", row+1, sipCpp->name().toAscii().constData());\
 
470
        }
 
471
%End
 
472
public:
 
473
  int numRows();
 
474
  void setNumRows(int);
 
475
  int numCols();
 
476
  void setNumCols(int);
 
477
  void setDimensions(int rows, int cols);
 
478
 
 
479
  SIP_PYOBJECT text(int, int);
 
480
%MethodCode
 
481
        sipIsErr = 0;
 
482
        CHECK_MATRIX_ROW(a0);
 
483
        CHECK_MATRIX_COL(a1);
 
484
        if (sipIsErr == 0)
 
485
                sipRes = PyString_FromString(sipCpp->text(row, col));
 
486
%End
 
487
  double cell(int, int);
 
488
%MethodCode
 
489
        sipIsErr = 0;
 
490
        CHECK_MATRIX_ROW(a0);
 
491
        CHECK_MATRIX_COL(a1);
 
492
        if (sipIsErr == 0)
 
493
                sipRes = sipCpp->cell(row, col);
 
494
%End
 
495
  void setText(int, int, const QString&);
 
496
%MethodCode
 
497
        sipIsErr = 0;
 
498
        CHECK_MATRIX_ROW(a0);
 
499
        CHECK_MATRIX_COL(a1);
 
500
        if (sipIsErr == 0)
 
501
                sipCpp->setText(row, col, *a2);
 
502
%End
 
503
  void setCell(int, int, double);
 
504
%MethodCode
 
505
        sipIsErr = 0;
 
506
        CHECK_MATRIX_ROW(a0);
 
507
        CHECK_MATRIX_COL(a1);
 
508
        if (sipIsErr == 0)
 
509
                sipCpp->setCell(row, col, a2);
 
510
%End
 
511
 
 
512
    double xStart();
 
513
        double xEnd();
 
514
        double yStart();
 
515
        double yEnd();
 
516
    void setCoordinates(double xs, double xe, double ys, double ye);
 
517
 
 
518
    void setFormula(const QString &s);
 
519
         bool recalculate();
 
520
 
 
521
    void setNumericPrecision(int prec);
 
522
 
 
523
    void transpose();
 
524
        void invert();
 
525
        double determinant();
 
526
 
 
527
private:
 
528
  Matrix(const Matrix&);
 
529
};
 
530
 
 
531
class ArrowMarker // : QwtPlotMarker
 
532
{
 
533
%TypeHeaderCode
 
534
#include "src/ArrowMarker.h"
 
535
%End
 
536
public:
 
537
 
 
538
  ArrowMarker();
 
539
 
 
540
  void setStartPoint(double, double) /PyName=setStart/;
 
541
  void setEndPoint(double, double) /PyName=setEnd/;
 
542
 
 
543
  void setStyle(Qt::PenStyle);
 
544
  void setColor(const QColor&);
 
545
  void setWidth(int);
 
546
  void drawStartArrow(bool = true);
 
547
  void drawEndArrow(bool = true);
 
548
  void setHeadLength(int);
 
549
  void setHeadAngle(int);
 
550
  void fillArrowHead(bool = true);
 
551
 
 
552
private:
 
553
  ArrowMarker(const ArrowMarker&);
 
554
};
 
555
 
 
556
class ImageMarker // : QwtPlotMarker
 
557
{
 
558
%TypeHeaderCode
 
559
#include "src/ImageMarker.h"
 
560
%End
 
561
public:
 
562
 
 
563
  ImageMarker(const QString&);
 
564
  QString fileName();
 
565
  
 
566
  QSize size();
 
567
  void setSize(int, int);
 
568
  
 
569
  void setBoundingRect(double, double, double, double) /PyName=setCoordinates/;
 
570
  
 
571
private:
 
572
  ImageMarker(const ImageMarker&);
 
573
};
 
574
 
 
575
class Legend // : QwtPlotMarker
 
576
{
 
577
%TypeHeaderCode
 
578
#include "src/Legend.h"
 
579
%End
 
580
public:
 
581
 
 
582
  void setText(const QString&);
 
583
  void setTextColor(const QColor&);
 
584
  void setFrameStyle(int);
 
585
  void setBackgroundColor(const QColor&);
 
586
  void setFont(const QFont&);
 
587
  void setOriginCoord(double, double);
 
588
 
 
589
private:
 
590
  Legend(const Legend&);
 
591
};
 
592
 
 
593
class QwtSymbol
 
594
{
 
595
%TypeHeaderCode
 
596
#include <qwt_symbol.h>
 
597
#include "ColorBox.h"
 
598
%End
 
599
        public:
 
600
    enum Style 
 
601
    { 
 
602
        NoSymbol = -1, 
 
603
 
 
604
        Ellipse, 
 
605
        Rect, 
 
606
        Diamond, 
 
607
        Triangle, 
 
608
        DTriangle,
 
609
        UTriangle, 
 
610
        LTriangle, 
 
611
        RTriangle, 
 
612
        Cross, 
 
613
        XCross, 
 
614
        HLine, 
 
615
        VLine, 
 
616
        Star1, 
 
617
        Star2, 
 
618
        Hexagon, 
 
619
 
 
620
        StyleCnt 
 
621
    };
 
622
 
 
623
    QwtSymbol();
 
624
    QwtSymbol(Style st, const QBrush &bd, const QPen &pn, const QSize &s);
 
625
 
 
626
    virtual QwtSymbol *clone() const;
 
627
 
 
628
    void setSize(const QSize &s);
 
629
    void setSize(int a, int b = -1);
 
630
    void setBrush(const QBrush& b);
 
631
    void setPen(const QPen &p);
 
632
    void setStyle (Style s);
 
633
 
 
634
    const QBrush& brush() const;
 
635
    const QPen& pen() const;
 
636
    const QSize& size() const;
 
637
    Style style() const;
 
638
 
 
639
         // convenience methods for scripting
 
640
 
 
641
         void setColor(const QColor& color) /NoDerived/;
 
642
%MethodCode
 
643
        QPen pen = sipCpp->pen();
 
644
        pen.setColor(*a0);
 
645
        sipCpp->setPen(pen);
 
646
        QBrush brush = sipCpp->brush();
 
647
        brush.setColor(*a0);
 
648
        sipCpp->setBrush(brush);
 
649
%End
 
650
         void setColor(int color) /NoDerived/;
 
651
%MethodCode
 
652
        QPen pen = sipCpp->pen();
 
653
        pen.setColor(ColorBox::color(a0));
 
654
        sipCpp->setPen(pen);
 
655
        QBrush brush = sipCpp->brush();
 
656
        brush.setColor(ColorBox::color(a0));
 
657
        sipCpp->setBrush(brush);
 
658
%End
 
659
         void setOutlineColor(const QColor& color) /NoDerived/;
 
660
%MethodCode
 
661
        QPen pen = sipCpp->pen();
 
662
        pen.setColor(*a0);
 
663
        sipCpp->setPen(pen);
 
664
%End
 
665
         void setOutlineColor(int color) /NoDerived/;
 
666
%MethodCode
 
667
        QPen pen = sipCpp->pen();
 
668
        pen.setColor(ColorBox::color(a0));
 
669
        sipCpp->setPen(pen);
 
670
%End
 
671
         void setFillColor(const QColor& color) /NoDerived/;
 
672
%MethodCode
 
673
        QBrush brush = sipCpp->brush();
 
674
        brush.setColor(*a0);
 
675
        sipCpp->setBrush(brush);
 
676
%End
 
677
         void setFillColor(int color) /NoDerived/;
 
678
%MethodCode
 
679
        QBrush brush = sipCpp->brush();
 
680
        brush.setColor(ColorBox::color(a0));
 
681
        sipCpp->setBrush(brush);
 
682
%End
 
683
 
 
684
        private:
 
685
QwtSymbol(const QwtSymbol&);
 
686
};
 
687
 
 
688
class QwtPlotCurve
 
689
{
 
690
%TypeHeaderCode
 
691
#include <qwt_plot_curve.h>
 
692
#include "Graph.h"
 
693
%End
 
694
        public:
 
695
                int dataSize() const;
 
696
                double x(int i) const;
 
697
                double y(int i) const;
 
698
                double minXValue() const;
 
699
                double maxXValue() const;
 
700
                double minYValue() const;
 
701
                double maxYValue() const;
 
702
 
 
703
                void setPen(const QPen &);
 
704
                const QPen &pen() const;
 
705
 
 
706
                void setBrush(const QBrush &);
 
707
                const QBrush &brush() const;
 
708
 
 
709
                void setSymbol(const QwtSymbol &s);
 
710
                const QwtSymbol& symbol() const;
 
711
 
 
712
         // convenience methods for scripting
 
713
         
 
714
         void setColor(const QColor& color) /NoDerived/;
 
715
%MethodCode
 
716
        QPen pen = sipCpp->pen();
 
717
        pen.setColor(*a0);
 
718
        sipCpp->setPen(pen);
 
719
        QBrush brush = sipCpp->brush();
 
720
        brush.setColor(*a0);
 
721
        sipCpp->setBrush(brush);
 
722
%End
 
723
         void setColor(int color) /NoDerived/;
 
724
%MethodCode
 
725
        QPen pen = sipCpp->pen();
 
726
        pen.setColor(ColorBox::color(a0));
 
727
        sipCpp->setPen(pen);
 
728
        QBrush brush = sipCpp->brush();
 
729
        brush.setColor(ColorBox::color(a0));
 
730
        sipCpp->setBrush(brush);
 
731
%End
 
732
         void setOutlineColor(const QColor& color) /NoDerived/;
 
733
%MethodCode
 
734
        QPen pen = sipCpp->pen();
 
735
        pen.setColor(*a0);
 
736
        sipCpp->setPen(pen);
 
737
%End
 
738
         void setOutlineColor(int color) /NoDerived/;
 
739
%MethodCode
 
740
        QPen pen = sipCpp->pen();
 
741
        pen.setColor(ColorBox::color(a0));
 
742
        sipCpp->setPen(pen);
 
743
%End
 
744
         void setFillColor(const QColor& color) /NoDerived/;
 
745
%MethodCode
 
746
        QBrush brush = sipCpp->brush();
 
747
        brush.setColor(*a0);
 
748
        sipCpp->setBrush(brush);
 
749
%End
 
750
         void setFillColor(int color) /NoDerived/;
 
751
%MethodCode
 
752
        QBrush brush = sipCpp->brush();
 
753
        brush.setColor(ColorBox::color(a0));
 
754
        sipCpp->setBrush(brush);
 
755
%End
 
756
         void setFillStyle(Qt::BrushStyle style) /NoDerived/;
 
757
%MethodCode
 
758
        QBrush brush = sipCpp->brush();
 
759
        brush.setStyle(a0);
 
760
        sipCpp->setBrush(brush);
 
761
%End
 
762
 
 
763
        private:
 
764
                QwtPlotCurve(const QwtPlotCurve&);
 
765
};
 
766
 
 
767
class QwtPlot {
 
768
%TypeHeaderCode
 
769
#include <qwt_plot.h>
 
770
%End
 
771
        public:
 
772
  enum Axis 
 
773
  { 
 
774
        yLeft,
 
775
        yRight,
 
776
        xBottom,
 
777
        xTop,
 
778
  
 
779
        axisCnt
 
780
  };
 
781
        private:
 
782
  QwtPlot(const QwtPlot&);
 
783
};
 
784
 
 
785
class Grid
 
786
{
 
787
%TypeHeaderCode
 
788
#include "src/Grid.h"
 
789
%End
 
790
        public:
 
791
                void enableX(bool) /PyName=setXMajor/;
 
792
                bool xEnabled() /PyName=xMajor/;
 
793
 
 
794
                void enableY(bool) /PyName=setYMajor/;
 
795
                bool yEnabled() /PyName=yMajor/;
 
796
 
 
797
                void enableXMin(bool) /PyName=setXMinor/;
 
798
                bool xMinEnabled() /PyName=xMinor/;
 
799
 
 
800
                void enableYMin(bool) /PyName=setYMinor/;
 
801
                bool yMinEnabled() /PyName=yMinor/;
 
802
 
 
803
                void enableZeroLineX(bool enable = true) /PyName=setXZeroLine/;
 
804
                bool xZeroLineEnabled() /PyName=xZeroLine/;
 
805
 
 
806
                void enableZeroLineY(bool enable = true) /PyName=setYZeroLine/;
 
807
                bool yZeroLineEnabled() /PyName=yZeroLine/;
 
808
 
 
809
                void setMajPenX(const QPen &p) /PyName=setXMajorPen/;
 
810
                const QPen& majPenX() const /PyName=xMajorPen/;
 
811
 
 
812
                void setMinPenX(const QPen &p) /PyName=setXMinorPen/;
 
813
                const QPen& minPenX() const /PyName=xMinorPen/;
 
814
 
 
815
                void setMajPenY(const QPen &p) /PyName=setYMajorPen/;
 
816
                const QPen& majPenY() const /PyName=yMajorPen/;
 
817
 
 
818
                void setMinPenY(const QPen &p) /PyName=setYMinorPen/;
 
819
                const QPen& minPenY() const /PyName=yMinorPen/;
 
820
 
 
821
                void setMajor(bool) /NoDerived/;
 
822
%MethodCode
 
823
        sipCpp->enableX(a0);
 
824
        sipCpp->enableY(a0);
 
825
%End
 
826
 
 
827
                void setMinor(bool) /NoDerived/;
 
828
%MethodCode
 
829
        sipCpp->enableXMin(a0);
 
830
        sipCpp->enableYMin(a0);
 
831
%End
 
832
 
 
833
                void setMajorPen(const QPen &p) /NoDerived/;
 
834
%MethodCode
 
835
        sipCpp->setMajPenX(*a0);
 
836
        sipCpp->setMajPenY(*a0);
 
837
%End
 
838
                void setMinorPen(const QPen &p) /NoDerived/;
 
839
%MethodCode
 
840
        sipCpp->setMinPenX(*a0);
 
841
        sipCpp->setMinPenY(*a0);
 
842
%End
 
843
        private:
 
844
                Grid(const Grid&);
 
845
};
 
846
 
 
847
class Graph : QWidget /PyName=Layer/
 
848
{
 
849
%TypeHeaderCode
 
850
#include "src/Graph.h"
 
851
#include "src/Legend.h"
 
852
#include "src/ColorBox.h"
 
853
#include "src/FunctionCurve.h"
 
854
#include "src/DataPointPicker.h"
 
855
#include <qwt_plot_canvas.h>
 
856
%End
 
857
public:
 
858
  bool isPiePlot();
 
859
  SIP_PYOBJECT pieLegendText() /PyName=pieLegend/;
 
860
%MethodCode
 
861
  sipRes = PyString_FromString(sipCpp->pieLegendText());
 
862
%End
 
863
 
 
864
  bool insertCurve(Table*, const QString&, int=1, int color=-1) /NoDerived/;
 
865
%MethodCode
 
866
        if (sipCpp->insertCurve(a0, *a1, a2)) {
 
867
                CurveLayout cl = sipCpp->initCurveLayout(a2, 1);
 
868
                if (a3 >= 0) {
 
869
                        cl.lCol = a3;
 
870
                        cl.symCol = a3;
 
871
                        cl.fillCol = a3;
 
872
                }
 
873
                sipCpp->updateCurveLayout(sipCpp->curves()-1, &cl);
 
874
                sipRes = true;
 
875
        } else
 
876
                sipRes = false;
 
877
%End
 
878
  bool insertCurve(Table*, const QString&, const QString&, int=1, int color=-1);
 
879
%MethodCode
 
880
        if (sipCpp->insertCurve(a0, *a1, *a2, a3)) {
 
881
                CurveLayout cl = sipCpp->initCurveLayout(a3, 1);
 
882
                if (a4 >= 0) {
 
883
                        cl.lCol = a4;
 
884
                        cl.symCol = a4;
 
885
                        cl.fillCol = a4;
 
886
                }
 
887
                sipCpp->updateCurveLayout(sipCpp->curves()-1, &cl);
 
888
                sipRes = true;
 
889
        } else
 
890
                sipRes = false;
 
891
%End
 
892
        bool insertFunctionCurve(const QString &formula, double from=0, double to=1, int points=100,
 
893
                        const QString &title = QString::null) /NoDerived/;
 
894
%MethodCode
 
895
        ApplicationWindow *app = sipscidavis_app();
 
896
        if (app)
 
897
                sipRes = sipCpp->addFunctionCurve(app, FunctionCurve::Normal, QStringList() << *a0, "x",
 
898
                                QList<double>() << a1 << a2, a3, *a4);
 
899
        else
 
900
                sipRes = false;
 
901
%End
 
902
        bool insertPolarCurve(const QString &radial, const QString &angular,
 
903
                        double from=0, double to=2*M_PI, const QString &parameter="t", int points=100,
 
904
                        const QString &title = QString::null) /NoDerived/;
 
905
%MethodCode
 
906
        ApplicationWindow *app = sipscidavis_app();
 
907
        if (app)
 
908
                sipRes = sipCpp->addFunctionCurve(app, FunctionCurve::Polar, QStringList() << *a0 << *a1,
 
909
                                *a4, QList<double>() << a2 << a3, a5, *a6);
 
910
        else
 
911
                sipRes = false;
 
912
%End
 
913
        bool insertParametricCurve(const QString &x, const QString &y,
 
914
                        double from=0, double to=1, const QString &parameter="t", int points=100,
 
915
                        const QString &title =QString::null) /NoDerived/;
 
916
%MethodCode
 
917
        ApplicationWindow *app = sipscidavis_app();
 
918
        if (app)
 
919
                sipRes = sipCpp->addFunctionCurve(app, FunctionCurve::Parametric, QStringList() << *a0 << *a1,
 
920
                                *a4, QList<double>() << a2 << a3, a5, *a6);
 
921
        else
 
922
                sipRes = false;
 
923
%End
 
924
 
 
925
  void removeCurve(int);
 
926
  void removeCurve(const QString&);
 
927
  void deleteFitCurves();
 
928
  int curves() /PyName=numCurves/;
 
929
  QList<QwtPlotCurve*> curves() const /NoDerived/;
 
930
%MethodCode
 
931
        sipRes = new QList<QwtPlotCurve*>();
 
932
        for (int i = 0; i<sipCpp->curves(); i++)
 
933
                sipRes->append(sipCpp->curve(i));
 
934
%End
 
935
  void showCurve(int index, bool visible=true);
 
936
 
 
937
  QwtPlotCurve* curve(int index);
 
938
  QwtPlotCurve* curve(const QString &title);
 
939
 
 
940
  void addErrorBars(const QString&, Table *, const QString&,
 
941
                  int type = 1, int width = 1, int cap = 8, const QColor& color = QColor(Qt::black),
 
942
                  bool through = true, bool minus = true, bool plus = true);
 
943
 
 
944
  void addArrow(ArrowMarker*);
 
945
 
 
946
  ImageMarker* addImage(ImageMarker*);
 
947
  ImageMarker* addImage(const QString& fileName);
 
948
  
 
949
  void setTitle(const QString& t);
 
950
  Legend* newLegend();
 
951
  Legend* newLegend(const QString&);
 
952
  void setLegend(const QString&) /NoDerived/;
 
953
%MethodCode
 
954
  sipCpp->legend()->setText(*a0);
 
955
%End
 
956
 
 
957
  Legend* legend();
 
958
 
 
959
  void removeLegend();
 
960
  void addTimeStamp();
 
961
 
 
962
  void enableAxis(int axis, bool on = true);
 
963
  void setXAxisTitle(const QString& text) /PyName=setXTitle/;
 
964
  void setYAxisTitle(const QString& text) /PyName=setYTitle/;
 
965
  void setRightAxisTitle(const QString &text) /PyName=setRightTitle/;
 
966
  void setTopAxisTitle(const QString &text) /PyName=setTopTitle/;
 
967
 
 
968
  void setLabelsNumericFormat(int axis, int format, int = 6, const QString& = QString()) /PyName=setAxisNumericFormat/;
 
969
  void setScale(int axis, double start, double end, double step = 0.0,
 
970
                int majorTicks = 5, int minorTicks = 5, int type = 0, bool inverted = false);
 
971
 
 
972
  void setMargin(int);
 
973
  void setFrame(int width = 1, const QColor& color = QColor(Qt::black));
 
974
  void setBackgroundColor(const QColor& color);
 
975
  void setCanvasBackground(const QColor& color) /PyName=setCanvasColor/;
 
976
 
 
977
  void showGrid(int);
 
978
  void showGrid();
 
979
  Grid *grid();
 
980
 
 
981
  void replot();
 
982
  void print() /PyName=printDialog/;
 
983
  void exportImage(const QString& fileName, int quality = 100, bool transparent = false);
 
984
  void exportVector(const QString& fileName, int res = 0, bool color = true,
 
985
                    bool keepAspect = true, QPrinter::PageSize pageSize = QPrinter::Custom);
 
986
  void exportToFile(const QString& fileName) /PyName=export/;
 
987
 
 
988
  void enableAutoscaling(bool = true);
 
989
  void setIgnoreResizeEvents(bool = true)/PyName=setIgnoreResize/;
 
990
  void setAutoscaleFonts(bool = true);
 
991
  void setAntialiasing(bool on = true, bool update = true);
 
992
 
 
993
  QWidget * canvas() const /NoDerived/;
 
994
%MethodCode
 
995
        sipRes = sipCpp->d_plot->canvas();
 
996
%End
 
997
 
 
998
        QPointF pickPoint() const /NoDerived/;
 
999
%MethodCode
 
1000
        ApplicationWindow *app = sipscidavis_app();
 
1001
        sipRes = new QPointF();
 
1002
        if (app)
 
1003
                *sipRes = DataPointPicker(sipCpp, app).pick();
 
1004
%End
 
1005
 
 
1006
private:
 
1007
  Graph(const Graph&);
 
1008
};
 
1009
 
 
1010
class MultiLayer : MyWidget /PyName=Graph/
 
1011
{
 
1012
%TypeHeaderCode
 
1013
#include "src/MultiLayer.h"
 
1014
%End
 
1015
public:
 
1016
  Graph *activeGraph() /PyName=activeLayer/;
 
1017
  void setActiveGraph(Graph*) /PyName=setActiveLayer/;
 
1018
  int layers() /PyName=numLayers/;
 
1019
  QWidgetList layerWidgets() const /PyName=layers/;
 
1020
  Graph* layer(int num);
 
1021
  Graph* addLayer(int = 0, int = 0, int = 0, int = 0);
 
1022
%MethodCode
 
1023
        sipRes = sipCpp->addLayer(a0, a1, a2, a3);
 
1024
        ApplicationWindow *app = sipscidavis_app();
 
1025
        if (app) app->setPreferences(sipRes);
 
1026
%End
 
1027
 
 
1028
  void setCols(int);
 
1029
  void setRows(int);
 
1030
  void setSpacing (int, int);
 
1031
  void setMargins (int, int, int, int);
 
1032
  void setLayerCanvasSize (int, int);
 
1033
%MethodCode
 
1034
        sipCpp->setLayerCanvasSize(a0, a1);
 
1035
        sipCpp->arrangeLayers(true, true);
 
1036
%End
 
1037
        // for backwards-compatibility
 
1038
  void setAlignement (int, int);
 
1039
  void setAlignement (int, int) /PyName=setAlignment/;
 
1040
  void arrangeLayers(bool fit = true) /NoDerived/;
 
1041
%MethodCode
 
1042
        sipCpp->arrangeLayers(a0, false);
 
1043
%End
 
1044
        // for backwards-compatibility
 
1045
  void arrangeLayers(bool fit, bool user_size);
 
1046
 
 
1047
  void exportToFile(const QString& fileName) /PyName=export/;
 
1048
  void exportImage(const QString& fileName, int quality = 100, bool transparent = false);
 
1049
  void exportVector(const QString& fileName, int res = 0, bool color = true,
 
1050
                    bool keepAspect = true, QPrinter::PageSize pageSize = QPrinter::Custom);
 
1051
 
 
1052
  void print() /PyName=printDialog/;
 
1053
private:
 
1054
  MultiLayer(const MultiLayer&);
 
1055
};
 
1056
 
 
1057
class Note: MyWidget
 
1058
{
 
1059
%TypeHeaderCode
 
1060
#include "src/Note.h"
 
1061
%End
 
1062
public:
 
1063
// TODO: Calling execute()/executeAll() from Python currently doesn't work reliably!
 
1064
  void execute();
 
1065
  void executeAll();
 
1066
  bool autoexec() const;
 
1067
  void setAutoexec(bool);
 
1068
  QString text();
 
1069
  void setText(const QString &s);
 
1070
  QString exportASCII(const QString &file);
 
1071
  QString importASCII(const QString &file);
 
1072
private:
 
1073
  Note(const Note&);
 
1074
};
 
1075
 
 
1076
class ApplicationWindow: QMainWindow
 
1077
{
 
1078
%TypeHeaderCode
 
1079
#include "src/ApplicationWindow.h"
 
1080
#include "src/ColorBox.h"
 
1081
#include <qwt_symbol.h>
 
1082
%End
 
1083
%ConvertToSubClassCode
 
1084
// we have to do this to override casting in qt/qobject.sip
 
1085
// without this, app.windows() returns Tables as QWidgets (strangely, Notes
 
1086
// are returned correctly in any case)
 
1087
sipClass = sipFindClass(sipCpp->className());
 
1088
%End
 
1089
 
 
1090
public:
 
1091
  Table* table(const QString&);
 
1092
%MethodCode
 
1093
  sipRes = sipCpp->current_folder->table(*a0, false);
 
1094
  if(!sipRes)
 
1095
    sipRes = sipCpp->projectFolder()->table(*a0, true);
 
1096
%End
 
1097
  Table* newTable();
 
1098
  Table* newTable(const QString&, int=2, int=30);
 
1099
%MethodCode
 
1100
  sipRes = sipCpp->newTable(a2, a1, *a0);
 
1101
%End
 
1102
  Matrix* matrix(const QString&);
 
1103
%MethodCode
 
1104
  sipRes = sipCpp->current_folder->matrix(*a0, false);
 
1105
  if(!sipRes)
 
1106
    sipRes = sipCpp->projectFolder()->matrix(*a0, true);
 
1107
%End
 
1108
  Matrix* newMatrix();
 
1109
  Matrix* newMatrix(const QString&, int=32, int=32);
 
1110
  MultiLayer *plot(const QString&) /PyName=graph/;
 
1111
%MethodCode
 
1112
  sipRes = sipCpp->current_folder->graph(*a0, false);
 
1113
  if(!sipRes)
 
1114
    sipRes = sipCpp->projectFolder()->graph(*a0, true);
 
1115
%End
 
1116
  MultiLayer* newGraph();
 
1117
  MultiLayer* newGraph(const QString &name);
 
1118
%MethodCode
 
1119
        // Code copied from ApplicationWindow::newGraph() and modified to actually use the requested
 
1120
        // name if it is already unique.
 
1121
        if (sipCpp->alreadyUsedName(*a0))
 
1122
                sipRes = sipCpp->multilayerPlot(sipCpp->generateUniqueName(*a0));
 
1123
        else
 
1124
                sipRes = sipCpp->multilayerPlot(*a0);
 
1125
        if (sipRes) {
 
1126
                Graph *g = sipRes->addLayer();
 
1127
                sipCpp->setPreferences(g);
 
1128
                g->newLegend();
 
1129
                g->setAutoscaleFonts(false);
 
1130
                g->setIgnoreResizeEvents(false);
 
1131
                sipRes->arrangeLayers(false, false);
 
1132
                sipRes->adjustSize();
 
1133
                g->setAutoscaleFonts(sipCpp->autoScaleFonts);//restore user defined fonts behaviour
 
1134
                g->setIgnoreResizeEvents(!sipCpp->autoResizeLayers);
 
1135
                sipCpp->customMenu(sipRes);
 
1136
        }
 
1137
%End
 
1138
  Note *note(const QString&);
 
1139
%MethodCode
 
1140
  sipRes = sipCpp->current_folder->note(*a0, false);
 
1141
  if(!sipRes)
 
1142
    sipRes = sipCpp->projectFolder()->note(*a0, true);
 
1143
%End
 
1144
        // TODO: If name is already taken, this chooses a default name like "Notes1",
 
1145
        // which is inconsistent with newTable, newMatrix and newGraph. Not changing in
 
1146
        // a bugfix release though, since an unexpected change in behaviour may be even
 
1147
        // more confusing than the inconsistency.
 
1148
  Note* newNote(const QString& = QString::null);
 
1149
  MultiLayer *plot(Table*, SIP_PYTUPLE, int style=1, int color=-1) /NoDerived/;
 
1150
%MethodCode
 
1151
  QStringList l;
 
1152
  int n = PyTuple_Size(a1);
 
1153
  for (int i=0; i<n; i++) {
 
1154
    PyObject *str = PyObject_Str(PyTuple_GET_ITEM(a1,i));
 
1155
    if (str) {
 
1156
      l << PyString_AsString(str);
 
1157
                Py_DECREF(str);
 
1158
         } else {
 
1159
      sipIsErr = 1;
 
1160
      break;
 
1161
    }
 
1162
  }
 
1163
  if (a0==0) {
 
1164
          sipIsErr = 1;
 
1165
          PyErr_Format(PyExc_ValueError, "Invalid table in argument to plot().");
 
1166
  } else {
 
1167
    sipRes = sipCpp->multilayerPlot(a0, l, a2);
 
1168
    if (sipRes && sipRes->activeGraph() && a3 >= 0) {
 
1169
                 for (int c =0; c < sipRes->activeGraph()->curves(); c++) {
 
1170
                         QwtPlotCurve *curve = sipRes->activeGraph()->curve(c);
 
1171
                         QPen pen = curve->pen();
 
1172
                         pen.setColor(ColorBox::color(a3));
 
1173
                         curve->setPen(pen);
 
1174
                         QwtSymbol symbol = curve->symbol();
 
1175
                         pen = symbol.pen();
 
1176
                         pen.setColor(ColorBox::color(a3));
 
1177
                         symbol.setPen(pen);
 
1178
                         QBrush brush = symbol.brush();
 
1179
                         brush.setColor(ColorBox::color(a3));
 
1180
                         symbol.setBrush(brush);
 
1181
                         curve->setSymbol(symbol);
 
1182
                 }
 
1183
    }
 
1184
  }
 
1185
%End
 
1186
  MultiLayer *plot(Table*, const QString&, int style=1, int color=-1) /NoDerived/;
 
1187
%MethodCode
 
1188
  if (a0==0) {
 
1189
          sipIsErr = 1;
 
1190
          PyErr_Format(PyExc_ValueError, "Invalid table in argument to plot().");
 
1191
  } else {
 
1192
    QStringList l;
 
1193
    l << *a1;
 
1194
    sipRes = sipCpp->multilayerPlot(a0, l, a2);
 
1195
    if (a3 >= 0) {
 
1196
       QwtPlotCurve * c = sipRes->activeGraph()->curve(0);
 
1197
       QPen pen = c->pen();
 
1198
       pen.setColor(ColorBox::color(a3));
 
1199
       c->setPen(pen);
 
1200
                 QwtSymbol symbol = c->symbol();
 
1201
                 pen = symbol.pen();
 
1202
                 pen.setColor(ColorBox::color(a3));
 
1203
                 symbol.setPen(pen);
 
1204
                 QBrush brush = symbol.brush();
 
1205
                 brush.setColor(ColorBox::color(a3));
 
1206
                 symbol.setBrush(brush);
 
1207
                 c->setSymbol(symbol);
 
1208
    }
 
1209
  }
 
1210
%End
 
1211
 
 
1212
        Matrix* importImage();
 
1213
        Matrix* importImage(const QString&);
 
1214
        MultiLayer* plotContour(Matrix*);
 
1215
        MultiLayer* plotColorMap(Matrix*);
 
1216
        MultiLayer* plotGrayScale(Matrix*);
 
1217
 
 
1218
  QWidgetList *windowsList() /PyName=windows/;
 
1219
 
 
1220
  QTextEdit *results;
 
1221
//  QTextEdit *console;
 
1222
 
 
1223
  // folders
 
1224
  Folder *activeFolder() /NoDerived/;
 
1225
%MethodCode
 
1226
  sipRes = sipCpp->current_folder;
 
1227
%End
 
1228
  void saveFolder(Folder *folder, const QString& fn) /Deprecated/;
 
1229
  Folder* projectFolder() /PyName=rootFolder/;
 
1230
 
 
1231
  void renameWindow(MyWidget *, const QString &) /Deprecated/;
 
1232
 
 
1233
  // Prior to SciDAVis 0.2.4, it was necessary to call this on a layer created using
 
1234
  // Graph.addLayer() if you wanted the layer to be intialized correctly. This is now
 
1235
  // done automatically as part of addLayer(); doing so again doesn't hurt, but is not necessary
 
1236
  // any more.
 
1237
  void setPreferences(Graph*) /Deprecated/;
 
1238
 
 
1239
  MyWidget* clone(MyWidget*) /Deprecated/;
 
1240
 
 
1241
private:
 
1242
  ApplicationWindow(const ApplicationWindow&);
 
1243
};
 
1244
 
 
1245
class Fit : QObject
 
1246
{
 
1247
%TypeHeaderCode
 
1248
#include "src/Fit.h"
 
1249
%End
 
1250
public:
 
1251
  enum Algorithm{ScaledLevenbergMarquardt, UnscaledLevenbergMarquardt, NelderMeadSimplex};
 
1252
  enum ErrorSource {UnknownErrors, AssociatedErrors, PoissonErrors, CustomErrors};
 
1253
 
 
1254
  Fit(ApplicationWindow* /TransferThis/, Graph*=0, const char*=0);
 
1255
  ~Fit();
 
1256
 
 
1257
  virtual void fit();
 
1258
 
 
1259
  bool setYErrorSource(ErrorSource err, const QString& colName = QString::null);
 
1260
 
 
1261
  bool setDataFromCurve(const QString&, Graph*=0);
 
1262
 
 
1263
  bool setDataFromCurve(const QString&, double, double, Graph*=0) /Deprecated/;
 
1264
 
 
1265
  void setInterval(double from, double to);
 
1266
 
 
1267
  QString formula();
 
1268
  int numParameters();
 
1269
 
 
1270
  void setInitialGuess(int, double) /PyName=setInitialValue/;
 
1271
  void setInitialGuesses(...) /PyName=setInitialValues/;
 
1272
%MethodCode
 
1273
int n = PyTuple_GET_SIZE(a0);
 
1274
double *values = new double[n];
 
1275
for (int i=0; i<n; i++) {
 
1276
  PyObject *item = PyTuple_GET_ITEM(a0, i);
 
1277
  if (PyNumber_Check(item)) {
 
1278
    item=PyNumber_Float(item);
 
1279
    if (!item) {
 
1280
      sipIsErr=1;
 
1281
      break;
 
1282
    }
 
1283
    values[i] = PyFloat_AS_DOUBLE(item);
 
1284
    Py_DECREF(item);
 
1285
  } else
 
1286
    values[i] = 0;
 
1287
}
 
1288
sipCpp->setInitialGuesses(values);
 
1289
delete values;
 
1290
%End
 
1291
 
 
1292
  virtual void guessInitialValues();
 
1293
 
 
1294
  void setAlgorithm(Algorithm);
 
1295
 
 
1296
  void setTolerance(double);
 
1297
 
 
1298
  void setColor(int);
 
1299
 
 
1300
  // inconsistent with other setColor() methods and accepts only colors from the palette,
 
1301
  // in contrast to what one would expect
 
1302
  void setColor(const QString&) /Deprecated/;
 
1303
 
 
1304
  void setOutputPrecision(int);
 
1305
 
 
1306
  void generateFunction(bool, int=100);
 
1307
 
 
1308
  void setMaximumIterations(int);
 
1309
 
 
1310
  void showLegend();
 
1311
 
 
1312
  virtual QString legendInfo();
 
1313
 
 
1314
  void scaleErrors(bool yes = true);
 
1315
 
 
1316
  SIP_PYTUPLE results();
 
1317
%MethodCode
 
1318
double *results = sipCpp->results();
 
1319
int size=sipCpp->numParameters();
 
1320
sipRes = PyTuple_New(size);
 
1321
if(sipRes)
 
1322
{
 
1323
  for(int i=0; i<size; i++)
 
1324
    PyTuple_SET_ITEM(sipRes, i, PyFloat_FromDouble(results[i]));
 
1325
} else
 
1326
  sipIsErr = 1;
 
1327
%End
 
1328
 
 
1329
  SIP_PYTUPLE errors();
 
1330
%MethodCode
 
1331
double *errors = sipCpp->errors();
 
1332
int size=sipCpp->numParameters();
 
1333
sipRes = PyTuple_New(size);
 
1334
if(sipRes)
 
1335
{
 
1336
  for(int i=0; i<size; i++)
 
1337
    PyTuple_SET_ITEM(sipRes, i, PyFloat_FromDouble(errors[i]));
 
1338
} else
 
1339
  sipIsErr = 1;
 
1340
%End
 
1341
 
 
1342
  //! Returns the sum of squares of the residuals from the best-fit line
 
1343
  double chiSquare();
 
1344
 
 
1345
  Table* parametersTable(const QString&);
 
1346
  Matrix* covarianceMatrix(const QString&);
 
1347
};
 
1348
 
 
1349
%ModuleCode
 
1350
ApplicationWindow *sipscidavis_app()
 
1351
{
 
1352
  int iserr = 0;
 
1353
  PyObject *me = PyImport_ImportModule("scidavis");
 
1354
  PyObject *mydict = PyModule_GetDict(me);
 
1355
  PyObject *pyapp = PyDict_GetItemString(mydict,"app");
 
1356
  Py_DECREF(me);
 
1357
  if (sipCanConvertToInstance(pyapp, sipClass_ApplicationWindow, SIP_NOT_NONE))
 
1358
    return (ApplicationWindow*) sipConvertToInstance(pyapp, sipClass_ApplicationWindow, NULL, SIP_NOT_NONE, NULL, &iserr);
 
1359
  else
 
1360
    return NULL;
 
1361
}
 
1362
%End
 
1363
%ModuleHeaderCode
 
1364
class ApplicationWindow;
 
1365
ApplicationWindow *sipscidavis_app();
 
1366
#define SIPSCIDAVIS_APP(sipcppexpr)\
 
1367
ApplicationWindow *app = sipscidavis_app();\
 
1368
if (app) sipCpp = sipcppexpr;\
 
1369
else { sipCpp = NULL; }
 
1370
%End
 
1371
 
 
1372
class ExponentialFit : Fit
 
1373
{
 
1374
%TypeHeaderCode
 
1375
#include "src/ExponentialFit.h"
 
1376
%End
 
1377
public:
 
1378
  ExponentialFit(ApplicationWindow * /TransferThis/, Graph *, const QString&, bool=false);
 
1379
  ExponentialFit(ApplicationWindow * /TransferThis/, Graph *, const QString&, double, double, bool=false);
 
1380
  ExponentialFit(Graph *, const QString&, bool=false) /NoDerived/;
 
1381
%MethodCode
 
1382
  SIPSCIDAVIS_APP(new sipExponentialFit(app, a0, *a1, a2))
 
1383
%End
 
1384
  ExponentialFit(Graph *, const QString&, double, double, bool=false) /NoDerived/;
 
1385
%MethodCode
 
1386
  SIPSCIDAVIS_APP(new sipExponentialFit(app, a0, *a1, a2, a3, a4))
 
1387
%End
 
1388
};
 
1389
 
 
1390
class TwoExpFit : Fit
 
1391
{
 
1392
%TypeHeaderCode
 
1393
#include "src/ExponentialFit.h"
 
1394
%End
 
1395
public:
 
1396
  TwoExpFit(ApplicationWindow * /TransferThis/, Graph *, const QString&);
 
1397
  TwoExpFit(ApplicationWindow * /TransferThis/, Graph *, const QString&, double, double);
 
1398
  TwoExpFit(Graph *, const QString&) /NoDerived/;
 
1399
%MethodCode
 
1400
  SIPSCIDAVIS_APP(new sipTwoExpFit(app, a0, *a1))
 
1401
%End
 
1402
  TwoExpFit(Graph *, const QString&, double, double) /NoDerived/;
 
1403
%MethodCode
 
1404
  SIPSCIDAVIS_APP(new sipTwoExpFit(app, a0, *a1, a2, a3))
 
1405
%End
 
1406
};
 
1407
 
 
1408
class ThreeExpFit : Fit
 
1409
{
 
1410
%TypeHeaderCode
 
1411
#include "src/ExponentialFit.h"
 
1412
%End
 
1413
public:
 
1414
  ThreeExpFit(ApplicationWindow * /TransferThis/, Graph *, const QString&);
 
1415
  ThreeExpFit(ApplicationWindow * /TransferThis/, Graph *, const QString&, double, double);
 
1416
  ThreeExpFit(Graph *, const QString&) /NoDerived/;
 
1417
%MethodCode
 
1418
  SIPSCIDAVIS_APP(new sipThreeExpFit(app, a0, *a1))
 
1419
%End
 
1420
  ThreeExpFit(Graph *, const QString&, double, double) /NoDerived/;
 
1421
%MethodCode
 
1422
  SIPSCIDAVIS_APP(new sipThreeExpFit(app, a0, *a1, a2, a3))
 
1423
%End
 
1424
};
 
1425
 
 
1426
class SigmoidalFit : Fit
 
1427
{
 
1428
%TypeHeaderCode
 
1429
#include "src/SigmoidalFit.h"
 
1430
%End
 
1431
public:
 
1432
  SigmoidalFit(ApplicationWindow * /TransferThis/, Graph *, const QString&);
 
1433
  SigmoidalFit(ApplicationWindow * /TransferThis/, Graph *, const QString&, double, double);
 
1434
  SigmoidalFit(Graph *, const QString&) /NoDerived/;
 
1435
%MethodCode
 
1436
  SIPSCIDAVIS_APP(new sipSigmoidalFit(app, a0, *a1))
 
1437
%End
 
1438
  SigmoidalFit(Graph *, const QString&, double, double) /NoDerived/;
 
1439
%MethodCode
 
1440
  SIPSCIDAVIS_APP(new sipSigmoidalFit(app, a0, *a1, a2, a3))
 
1441
%End
 
1442
};
 
1443
 
 
1444
class GaussAmpFit : Fit
 
1445
{
 
1446
%TypeHeaderCode
 
1447
#include "src/MultiPeakFit.h"
 
1448
%End
 
1449
public:
 
1450
  GaussAmpFit(ApplicationWindow * /TransferThis/, Graph *, const QString&);
 
1451
  GaussAmpFit(ApplicationWindow * /TransferThis/, Graph *, const QString&, double, double);
 
1452
  GaussAmpFit(Graph *, const QString&) /NoDerived/;
 
1453
%MethodCode
 
1454
  SIPSCIDAVIS_APP(new sipGaussAmpFit(app, a0, *a1))
 
1455
%End
 
1456
  GaussAmpFit(Graph *, const QString&, double, double) /NoDerived/;
 
1457
%MethodCode
 
1458
  SIPSCIDAVIS_APP(new sipGaussAmpFit(app, a0, *a1, a2, a3))
 
1459
%End
 
1460
};
 
1461
 
 
1462
class NonLinearFit : Fit
 
1463
{
 
1464
%TypeHeaderCode
 
1465
#include "src/NonLinearFit.h"
 
1466
%End
 
1467
public:
 
1468
  NonLinearFit(ApplicationWindow * /TransferThis/, Graph *, const QString&);
 
1469
  NonLinearFit(ApplicationWindow * /TransferThis/, Graph *, const QString&, double, double);
 
1470
  NonLinearFit(Graph *, const QString&) /NoDerived/;
 
1471
%MethodCode
 
1472
  SIPSCIDAVIS_APP(new sipNonLinearFit(app, a0, *a1))
 
1473
%End
 
1474
  NonLinearFit(Graph *, const QString&, double, double) /NoDerived/;
 
1475
%MethodCode
 
1476
  SIPSCIDAVIS_APP(new sipNonLinearFit(app, a0, *a1, a2, a3))
 
1477
%End
 
1478
  void setParametersList(...) /PyName=setParameters/;
 
1479
%MethodCode
 
1480
  QStringList l;
 
1481
  char *item;
 
1482
  for (int i=0; i<PyTuple_GET_SIZE(a0); i++)
 
1483
    if (item = PyString_AsString(PyTuple_GET_ITEM(a0, i)))
 
1484
      l << item;
 
1485
    else
 
1486
      sipIsErr = 1;
 
1487
  sipCpp->setParametersList(l);
 
1488
%End
 
1489
  // TODO: make it accept Python callables
 
1490
  void setFormula(const QString&);
 
1491
};
 
1492
 
 
1493
class PluginFit : Fit
 
1494
{
 
1495
%TypeHeaderCode
 
1496
#include "src/PluginFit.h"
 
1497
%End
 
1498
public:
 
1499
  PluginFit(ApplicationWindow * /TransferThis/, Graph *, const QString&);
 
1500
  PluginFit(ApplicationWindow * /TransferThis/, Graph *, const QString&, double, double);
 
1501
  PluginFit(Graph *, const QString&) /NoDerived/;
 
1502
%MethodCode
 
1503
  SIPSCIDAVIS_APP(new sipPluginFit(app, a0, *a1))
 
1504
%End
 
1505
  PluginFit(Graph *, const QString&, double, double) /NoDerived/;
 
1506
%MethodCode
 
1507
  SIPSCIDAVIS_APP(new sipPluginFit(app, a0, *a1, a2, a3))
 
1508
%End
 
1509
  bool load(const QString&);
 
1510
};
 
1511
 
 
1512
class MultiPeakFit : Fit
 
1513
{
 
1514
%TypeHeaderCode
 
1515
#include "src/MultiPeakFit.h"
 
1516
%End
 
1517
public:
 
1518
  enum PeakProfile{Gauss, Lorentz};
 
1519
  MultiPeakFit(ApplicationWindow * /TransferThis/, Graph *, PeakProfile=Gauss, int=1);
 
1520
 
 
1521
  int peaks() /PyName=numPeaks/;
 
1522
  void setNumPeaks(int);
 
1523
 
 
1524
  void enablePeakCurves(bool);
 
1525
  void setPeakCurvesColor(int);
 
1526
 
 
1527
  static QString generateFormula(int, PeakProfile);
 
1528
  static QStringList generateParameterList(int);
 
1529
};
 
1530
 
 
1531
class LorentzFit : MultiPeakFit
 
1532
{
 
1533
%TypeHeaderCode
 
1534
#include "src/MultiPeakFit.h"
 
1535
%End
 
1536
public:
 
1537
  LorentzFit(ApplicationWindow * /TransferThis/, Graph *, const QString&);
 
1538
  LorentzFit(ApplicationWindow * /TransferThis/, Graph *, const QString&, double, double);
 
1539
  LorentzFit(Graph *, const QString&) /NoDerived/;
 
1540
%MethodCode
 
1541
  SIPSCIDAVIS_APP(new sipLorentzFit(app, a0, *a1))
 
1542
%End
 
1543
  LorentzFit(Graph *, const QString&, int, int) /NoDerived/;
 
1544
%MethodCode
 
1545
  SIPSCIDAVIS_APP(new sipLorentzFit(app, a0, *a1, a2, a3))
 
1546
%End
 
1547
};
 
1548
 
 
1549
class GaussFit : MultiPeakFit
 
1550
{
 
1551
%TypeHeaderCode
 
1552
#include "src/MultiPeakFit.h"
 
1553
%End
 
1554
public:
 
1555
  GaussFit(ApplicationWindow * /TransferThis/, Graph *, const QString&);
 
1556
  GaussFit(ApplicationWindow * /TransferThis/, Graph *, const QString&, double, double);
 
1557
  GaussFit(Graph *, const QString&) /NoDerived/;
 
1558
%MethodCode
 
1559
  SIPSCIDAVIS_APP(new sipGaussFit(app, a0, *a1))
 
1560
%End
 
1561
  GaussFit(Graph *, const QString&, double, double) /NoDerived/;
 
1562
%MethodCode
 
1563
  SIPSCIDAVIS_APP(new sipGaussFit(app, a0, *a1, a2, a3))
 
1564
%End
 
1565
};
 
1566
 
 
1567
class PolynomialFit : Fit
 
1568
{
 
1569
%TypeHeaderCode
 
1570
#include "src/PolynomialFit.h"
 
1571
%End
 
1572
public:
 
1573
  PolynomialFit(ApplicationWindow * /TransferThis/, Graph *, QString&, int=2, bool=false);
 
1574
  PolynomialFit(ApplicationWindow * /TransferThis/, Graph *, QString&, int, int, int=2, bool=false);
 
1575
  PolynomialFit(Graph *, QString&, int=2, bool=false) /NoDerived/;
 
1576
%MethodCode
 
1577
  SIPSCIDAVIS_APP(new sipPolynomialFit(app, a0, *a1, a2, a3))
 
1578
%End
 
1579
  PolynomialFit(Graph *, QString&, int, int, int=2, bool=false) /NoDerived/;
 
1580
%MethodCode
 
1581
  SIPSCIDAVIS_APP(new sipPolynomialFit(app, a0, *a1, a2, a3, a4, a5))
 
1582
%End
 
1583
 
 
1584
  virtual QString legendInfo();
 
1585
  void fit();
 
1586
 
 
1587
  static QString generateFormula(int);
 
1588
  static QStringList generateParameterList(int);
 
1589
};
 
1590
 
 
1591
class LinearFit : Fit
 
1592
{
 
1593
%TypeHeaderCode
 
1594
#include "src/PolynomialFit.h"
 
1595
%End
 
1596
public:
 
1597
  LinearFit(ApplicationWindow * /TransferThis/, Graph *, const QString&);
 
1598
  LinearFit(ApplicationWindow * /TransferThis/, Graph *, const QString&, double, double);
 
1599
  LinearFit(Graph *, const QString&) /NoDerived/;
 
1600
%MethodCode
 
1601
  SIPSCIDAVIS_APP(new sipLinearFit(app, a0, *a1))
 
1602
%End
 
1603
  LinearFit(Graph *, const QString&, double, double) /NoDerived/;
 
1604
%MethodCode
 
1605
  SIPSCIDAVIS_APP(new sipLinearFit(app, a0, *a1, a2, a3))
 
1606
%End
 
1607
  void fit();
 
1608
};
 
1609
 
 
1610
class Filter : QObject
 
1611
{
 
1612
%TypeHeaderCode
 
1613
#include "src/Filter.h"
 
1614
%End
 
1615
public:
 
1616
  Filter(ApplicationWindow* /TransferThis/, Graph*=0, const char*=0);
 
1617
  ~Filter();
 
1618
 
 
1619
  void setOutputPoints(int);
 
1620
 
 
1621
  void setColor(int);
 
1622
  void setColor(const QString&);
 
1623
 
 
1624
  virtual bool run();
 
1625
};
 
1626
 
 
1627
class Differentiation : Filter
 
1628
{
 
1629
%TypeHeaderCode
 
1630
#include "src/Differentiation.h"
 
1631
%End
 
1632
public:
 
1633
  Differentiation(ApplicationWindow * /TransferThis/, Graph *, const QString&);
 
1634
  Differentiation(ApplicationWindow * /TransferThis/, Graph *, const QString&, double, double);
 
1635
  Differentiation(Graph *, const QString&) /NoDerived/;
 
1636
%MethodCode
 
1637
  SIPSCIDAVIS_APP(new sipDifferentiation(app, a0, *a1))
 
1638
%End
 
1639
  Differentiation(Graph *, const QString&, double, double) /NoDerived/;
 
1640
%MethodCode
 
1641
  SIPSCIDAVIS_APP(new sipDifferentiation(app, a0, *a1, a2, a3))
 
1642
%End
 
1643
  bool run();
 
1644
};
 
1645
 
 
1646
class Integration : Filter
 
1647
{
 
1648
%TypeHeaderCode
 
1649
#include "src/Integration.h"
 
1650
%End
 
1651
public:
 
1652
  Integration(ApplicationWindow * /TransferThis/, Graph *, const QString&);
 
1653
  Integration(ApplicationWindow * /TransferThis/, Graph *, const QString&, double, double);
 
1654
  Integration(Graph *, const QString&) /NoDerived/;
 
1655
%MethodCode
 
1656
  SIPSCIDAVIS_APP(new sipIntegration(app, a0, *a1))
 
1657
%End
 
1658
  Integration(Graph *, const QString&, double, double) /NoDerived/;
 
1659
%MethodCode
 
1660
  SIPSCIDAVIS_APP(new sipIntegration(app, a0, *a1, a2, a3))
 
1661
%End
 
1662
 
 
1663
        enum InterpolationMethod{Linear, Cubic, Akima};
 
1664
        InterpolationMethod method();
 
1665
    void setMethod(InterpolationMethod method);
 
1666
 
 
1667
  bool run();
 
1668
};
 
1669
 
 
1670
class Interpolation : Filter
 
1671
{
 
1672
%TypeHeaderCode
 
1673
#include "src/Interpolation.h"
 
1674
%End
 
1675
public:
 
1676
  enum InterpolationMethod{Linear, Cubic, Akima};
 
1677
 
 
1678
  Interpolation(ApplicationWindow * /TransferThis/, Graph *, const QString&, int=0);
 
1679
  Interpolation(ApplicationWindow * /TransferThis/, Graph *, const QString&, double, double, int=0);
 
1680
  Interpolation(Graph *, const QString&, int=0) /NoDerived/;
 
1681
%MethodCode
 
1682
  SIPSCIDAVIS_APP(new sipInterpolation(app, a0, *a1, a2))
 
1683
%End
 
1684
  Interpolation(Graph *, const QString&, double, double, int=0) /NoDerived/;
 
1685
%MethodCode
 
1686
  SIPSCIDAVIS_APP(new sipInterpolation(app, a0, *a1, a2, a3, a4))
 
1687
%End
 
1688
 
 
1689
  void setMethod(int n);
 
1690
  void setMethod(InterpolationMethod m /Constrained/);
 
1691
  bool run();
 
1692
};
 
1693
 
 
1694
class SmoothFilter : Filter
 
1695
{
 
1696
%TypeHeaderCode
 
1697
#include "src/SmoothFilter.h"
 
1698
%End
 
1699
public:
 
1700
  enum SmoothMethod{SavitzkyGolay = 1, FFT = 2, Average = 3};
 
1701
 
 
1702
  SmoothFilter(ApplicationWindow * /TransferThis/, Graph *, const QString&, int=3);
 
1703
  SmoothFilter(ApplicationWindow * /TransferThis/, Graph *, const QString&, double, double, int=3);
 
1704
  SmoothFilter(Graph *, const QString&, int=3) /NoDerived/;
 
1705
%MethodCode
 
1706
  SIPSCIDAVIS_APP(new sipSmoothFilter(app, a0, *a1, a2))
 
1707
%End
 
1708
  SmoothFilter(Graph *, const QString&, double, double, int=3) /NoDerived/;
 
1709
%MethodCode
 
1710
  SIPSCIDAVIS_APP(new sipSmoothFilter(app, a0, *a1, a2, a3, a4))
 
1711
%End
 
1712
 
 
1713
  void setMethod(int);
 
1714
  void setMethod(SmoothMethod /Constrained/);
 
1715
 
 
1716
  void setSmoothPoints(int, int = 0);
 
1717
  void setPolynomOrder(int);
 
1718
 
 
1719
  bool run();
 
1720
};
 
1721
 
 
1722
class FFTFilter : Filter
 
1723
{
 
1724
%TypeHeaderCode
 
1725
#include "src/FFTFilter.h"
 
1726
%End
 
1727
public:
 
1728
  enum FilterType{LowPass = 1, HighPass = 2, BandPass = 3, BandBlock = 4};
 
1729
 
 
1730
  FFTFilter(ApplicationWindow * /TransferThis/, Graph *, const QString&, int=1);
 
1731
  FFTFilter(ApplicationWindow * /TransferThis/, Graph *, const QString&, double, double, int=1);
 
1732
  FFTFilter(Graph *, const QString&, int=1) /NoDerived/;
 
1733
%MethodCode
 
1734
  SIPSCIDAVIS_APP(new sipFFTFilter(app, a0, *a1, a2))
 
1735
%End
 
1736
  FFTFilter(Graph *, const QString&, double, double, int=1) /NoDerived/;
 
1737
%MethodCode
 
1738
  SIPSCIDAVIS_APP(new sipFFTFilter(app, a0, *a1, a2, a3, a4))
 
1739
%End
 
1740
 
 
1741
  void setFilterType(int);
 
1742
  void setFilterType(FilterType /Constrained/);
 
1743
 
 
1744
  void setCutoff(double);
 
1745
  void setBand(double, double);
 
1746
  void enableOffset(bool=true);
 
1747
 
 
1748
  bool run();
 
1749
};
 
1750
 
 
1751
class FFT : Filter
 
1752
{
 
1753
%TypeHeaderCode
 
1754
#include "src/FFT.h"
 
1755
%End
 
1756
public:
 
1757
 
 
1758
  FFT(ApplicationWindow * /TransferThis/, Table *, const QString&, const QString& = QString());
 
1759
  FFT(ApplicationWindow * /TransferThis/, Graph *, const QString&);
 
1760
  FFT(Table *, const QString&, const QString& = QString()) /NoDerived/;
 
1761
%MethodCode
 
1762
  SIPSCIDAVIS_APP(new sipFFT(app, a0, *a1, *a2))
 
1763
%End
 
1764
  FFT(Graph *, const QString&) /NoDerived/;
 
1765
%MethodCode
 
1766
  SIPSCIDAVIS_APP(new sipFFT(app, a0, *a1))
 
1767
%End
 
1768
 
 
1769
  void setInverseFFT(bool=true);
 
1770
  void setSampling(double);
 
1771
  void normalizeAmplitudes(bool=true);
 
1772
  void shiftFrequencies(bool=true);
 
1773
 
 
1774
  bool run();
 
1775
};
 
1776
 
 
1777
class Correlation : Filter
 
1778
{
 
1779
%TypeHeaderCode
 
1780
#include "src/Correlation.h"
 
1781
%End
 
1782
public:
 
1783
 
 
1784
  Correlation(ApplicationWindow * /TransferThis/, Table *, const QString&, const QString&);
 
1785
  Correlation(Table *, const QString&, const QString&) /NoDerived/;
 
1786
%MethodCode
 
1787
  SIPSCIDAVIS_APP(new sipCorrelation(app, a0, *a1, *a2))
 
1788
%End
 
1789
 
 
1790
  void setDataFromTable(Table *, const QString&, const QString&);
 
1791
  bool run();
 
1792
};
 
1793
 
 
1794
class Convolution : Filter
 
1795
{
 
1796
%TypeHeaderCode
 
1797
#include "src/Convolution.h"
 
1798
%End
 
1799
public:
 
1800
 
 
1801
  Convolution(ApplicationWindow * /TransferThis/, Table *, const QString&, const QString&);
 
1802
  Convolution(Table *, const QString&, const QString&) /NoDerived/;
 
1803
%MethodCode
 
1804
  SIPSCIDAVIS_APP(new sipConvolution(app, a0, *a1, *a2))
 
1805
%End
 
1806
 
 
1807
  void setDataFromTable(Table *, const QString&, const QString&);
 
1808
  bool run();
 
1809
};
 
1810
 
 
1811
class Deconvolution : Filter
 
1812
{
 
1813
%TypeHeaderCode
 
1814
#include "src/Convolution.h"
 
1815
%End
 
1816
public:
 
1817
 
 
1818
  Deconvolution(ApplicationWindow * /TransferThis/, Table *, const QString&, const QString&);
 
1819
  Deconvolution(Table *, const QString&, const QString&) /NoDerived/;
 
1820
%MethodCode
 
1821
  SIPSCIDAVIS_APP(new sipDeconvolution(app, a0, *a1, *a2))
 
1822
%End
 
1823
 
 
1824
  void setDataFromTable(Table *, const QString&, const QString&);
 
1825
  bool run();
 
1826
};
 
1827
 
 
1828
// used for output redirection
 
1829
class PythonScripting
 
1830
{
 
1831
%TypeHeaderCode
 
1832
#include "src/PythonScripting.h"
 
1833
%End
 
1834
public:
 
1835
  void write(const QString&);
 
1836
private:
 
1837
  PythonScripting(const PythonScripting&);
 
1838
};
 
1839
class PythonScript
 
1840
{
 
1841
%TypeHeaderCode
 
1842
#include "src/PythonScript.h"
 
1843
%End
 
1844
public:
 
1845
  void write(const QString&);
 
1846
private:
 
1847
  PythonScript(const PythonScript&);
 
1848
};
 
1849
 
 
1850
class Folder : QObject
 
1851
{
 
1852
%TypeHeaderCode
 
1853
#include "src/Folder.h"
 
1854
%End
 
1855
public:
 
1856
  QList<MyWidget*> windowsList() /PyName=windows/;
 
1857
// TODO: implement signal Folder::nameChanged and make it update the project explorer; adjust renaming from GUI accordingly
 
1858
//  void setFolderName(const QString&) /PyName=setName/;
 
1859
  QString name();
 
1860
  QString path();
 
1861
 
 
1862
  QList<Folder*> folders() const;
 
1863
  Folder *findSubfolder(const QString&, bool=true, bool=false)  /PyName=folder/;
 
1864
  MyWidget* findWindow(const QString&, bool=true, bool=true, bool=false, bool=true);
 
1865
 
 
1866
  MyWidget *window(const QString &name, const char *cls="MyWidget", bool recursive=false);
 
1867
  Table *table(const QString &name, bool recursive=false);
 
1868
  Matrix *matrix(const QString &name, bool recursive=false);
 
1869
  MultiLayer *graph(const QString &name, bool recursive=false);
 
1870
  Note *note(const QString &name, bool recursive=false);
 
1871
 
 
1872
  Folder* rootFolder();
 
1873
 
 
1874
  void save(const QString &filename) /NoDerived/;
 
1875
%MethodCode
 
1876
        ApplicationWindow *app = sipscidavis_app();
 
1877
        if (app)
 
1878
                app->saveFolder(sipCpp, *a0);
 
1879
%End
 
1880
 
 
1881
private:
 
1882
  Folder(const Folder&);
 
1883
};