File indexing completed on 2024-12-22 04:17:29

0001 /***************************************************************************
0002  *                                                                         *
0003  *   copyright : (C) 2007 The University of Toronto                        *
0004  *                   netterfield@astro.utoronto.ca                         *
0005  *                                                                         *
0006  *   This program is free software; you can redistribute it and/or modify  *
0007  *   it under the terms of the GNU General Public License as published by  *
0008  *   the Free Software Foundation; either version 2 of the License, or     *
0009  *   (at your option) any later version.                                   *
0010  *                                                                         *
0011  ***************************************************************************/
0012 
0013 #ifndef DATAWIZARD_H
0014 #define DATAWIZARD_H
0015 
0016 #include <QWizard>
0017 #include <QThread>
0018 
0019 #include "kst_export.h"
0020 
0021 #include "ui_datawizardpagedatasource.h"
0022 #include "ui_datawizardpagevectors.h"
0023 #include "ui_datawizardpagefilters.h"
0024 #include "ui_datawizardpageplot.h"
0025 #include "ui_datawizardpagedatapresentation.h"
0026 
0027 #include "datasource.h"
0028 #include "curveplacement.h"
0029 
0030 namespace Kst {
0031 
0032 class Document;
0033 class ObjectStore;
0034 class PlotItemInterface;
0035 class ValidateDataSourceThread;
0036 class DataWizard;
0037 
0038 class DataWizardPageDataSource : public QWizardPage, Ui::DataWizardPageDataSource
0039 {
0040   Q_OBJECT
0041   public:
0042     DataWizardPageDataSource(ObjectStore *store, QWidget *parent, const QString& filename);
0043     virtual ~DataWizardPageDataSource();
0044 
0045     bool isComplete() const;
0046     QStringList dataSourceFieldList() const;
0047 
0048     DataSourcePtr dataSource() const;
0049 
0050     void setTypeActivated();
0051     int updateType();
0052 
0053   public Q_SLOTS:
0054     void sourceChanged(const QString&);
0055     void configureSource();
0056     void sourceValid(QString filename, int requestID);
0057     void updateTypeActivated(int);
0058     void recentFileClicked(QListWidgetItem*);
0059     void cleanupRecentDataFilesClicked();
0060 
0061   Q_SIGNALS:
0062     void dataSourceChanged();
0063     void progress(int, const QString&);
0064 
0065   private:
0066     bool _pageValid;
0067     ObjectStore *_store;
0068     DataSourcePtr _dataSource;
0069     int _requestID;
0070     void updateUpdateBox();
0071 };
0072 
0073 class DataWizardPageVectors : public QWizardPage, Ui::DataWizardPageVectors
0074 {
0075   Q_OBJECT
0076   public:
0077     explicit DataWizardPageVectors(QWidget *parent);
0078     virtual ~DataWizardPageVectors();
0079 
0080     bool isComplete() const;
0081     QListWidget* plotVectors() const;
0082 
0083   public Q_SLOTS:
0084     void add();
0085     void remove();
0086     void up();
0087     void down();
0088     void filterVectors(const QString&);
0089     void searchVectors();
0090     void updateVectors();
0091 
0092   private:
0093     bool vectorsSelected() const;
0094 
0095 };
0096 
0097 class DataWizardPageFilters : public QWizardPage, Ui::DataWizardPageFilters
0098 {
0099   Q_OBJECT
0100   public:
0101     explicit DataWizardPageFilters(QWidget *parent);
0102     virtual ~DataWizardPageFilters();
0103 
0104 };
0105 
0106 class DataWizardPagePlot : public QWizardPage, Ui::DataWizardPagePlot
0107 {
0108   Q_OBJECT
0109   public:
0110     enum CurvePlotPlacement { OnePlot, MultiplePlots, CyclePlotCount, CycleExisting, ExistingPlot };
0111 
0112     enum PlotTabPlacement { CurrentTab, NewTab, SeparateTabs };
0113 
0114     explicit DataWizardPagePlot(QWidget *parent);
0115     virtual ~DataWizardPagePlot();
0116 
0117     CurvePlacement::Layout layout() const;
0118     int gridColumns() const;
0119 
0120     bool drawLines() const;
0121     bool drawPoints() const;
0122     bool drawLinesAndPoints() const;
0123 
0124     bool PSDLogX() const;
0125     bool PSDLogY() const;
0126 
0127     bool legendsOn() const;
0128     bool legendsAuto() const;
0129     bool legendsVertical() const;
0130 
0131     bool rescaleFonts() const;
0132     bool shareAxis() const;
0133 
0134     CurvePlotPlacement curvePlacement() const;
0135     PlotItemInterface *existingPlot() const;
0136 
0137     PlotTabPlacement plotTabPlacement() const;
0138 
0139     int plotCount() const;
0140 
0141   public Q_SLOTS:
0142     void updatePlotBox();
0143     void updateButtons();
0144 };
0145 
0146 class DataWizardPageDataPresentation : public QWizardPage, Ui::DataWizardPageDataPresentation
0147 {
0148   Q_OBJECT
0149   public:
0150     DataWizardPageDataPresentation(ObjectStore *store, DataWizard *parent);
0151     virtual ~DataWizardPageDataPresentation();
0152 
0153     int nextId() const;
0154     bool isComplete() const;
0155 
0156     bool createXAxisFromField() const;
0157     QString vectorField() const;
0158 
0159     bool plotPSD() const;
0160     bool plotData() const;
0161     bool plotDataPSD() const;
0162 
0163     VectorPtr selectedVector() const;
0164 
0165     FFTOptions* getFFTOptions() const;
0166     DataRange* dataRange() const;
0167 
0168   public Q_SLOTS:
0169     void applyFilter(bool);
0170     void updateVectors();
0171     void optionsUpdated();
0172     void checkWarningLabel();
0173 
0174   Q_SIGNALS:
0175     void filterApplied(bool);
0176 
0177   private:
0178     bool _pageValid;
0179     bool validOptions();
0180     DataWizard *_dw;
0181 };
0182 
0183 class DataWizard : public QWizard
0184 {
0185   Q_OBJECT
0186   public:
0187     enum DataWizardPages {PageDataSource, PageVectors, PageDataPresentation, PageFilters, PagePlot};
0188 
0189     explicit DataWizard(QWidget *parent, const QString& fn = QString());
0190     virtual ~DataWizard();
0191 
0192     QStringList dataSourceFieldList() const;
0193     QStringList dataSourceIndexList() const;
0194 
0195     DataWizardPageDataSource *_pageDataSource;
0196   private:
0197     DataWizardPageVectors *_pageVectors;
0198     DataWizardPageFilters *_pageFilters;
0199     DataWizardPagePlot *_pagePlot;
0200     DataWizardPageDataPresentation *_pageDataPresentation;
0201 
0202   Q_SIGNALS:
0203     void dataSourceLoaded(const QString&);
0204 
0205   private Q_SLOTS:
0206     void finished();
0207 
0208   private:
0209     Document *_document;
0210 };
0211 
0212 }
0213 #endif
0214 
0215 // vim: ts=2 sw=2 et