File indexing completed on 2025-07-06 04:09:49

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 VECTORDIALOG_H
0014 #define VECTORDIALOG_H
0015 
0016 #include "datadialog.h"
0017 #include "datatab.h"
0018 
0019 #include "ui_vectortab.h"
0020 
0021 #include <QPointer>
0022 
0023 #include "kst_export.h"
0024 
0025 #include "datasource.h"
0026 
0027 namespace Kst {
0028 
0029 class ObjectStore;
0030 
0031 class VectorTab : public DataTab, Ui::VectorTab {
0032   Q_OBJECT
0033 
0034   public:
0035     friend class DialogSI;
0036     enum VectorMode { DataVector, GeneratedVector };
0037 
0038     explicit VectorTab(ObjectStore *store, QWidget *parent = 0);
0039     virtual ~VectorTab();
0040 
0041     VectorMode vectorMode() const { return _mode; }
0042     void setVectorMode(VectorMode mode);
0043 
0044     //DataVector mode methods...
0045     DataSourcePtr dataSource() const;
0046     void setDataSource(DataSourcePtr dataSource);
0047 
0048     QString file() const;
0049     void setFile(const QString &file);
0050 
0051     QString field() const;
0052     void setField(const QString &field);
0053 
0054     void setFieldList(const QStringList &fieldList);
0055 
0056     DataRange *dataRange() const;
0057 
0058     //GeneratedVector methods...
0059     qreal from() const;
0060     void setFrom(qreal from);
0061     bool fromDirty() const;
0062 
0063     qreal to() const;
0064     void setTo(qreal to);
0065     bool toDirty() const;
0066 
0067     int numberOfSamples() const;
0068     void setNumberOfSamples(int numberOfSamples);
0069     bool numberOfSamplesDirty() const;
0070 
0071     void hideGeneratedOptions();
0072     void hideDataOptions();
0073     void enableSingleEditOptions(bool enabled);
0074     void clearTabValues();
0075 
0076     bool validating;
0077 
0078     void updateIndexList(DataSourcePtr dataSource);
0079 
0080   Q_SIGNALS:
0081     void sourceChanged();
0082     void fieldChanged();
0083 
0084   private Q_SLOTS:
0085     void readFromSourceClicked();
0086     void generateClicked();
0087     void fileNameChanged(const QString &file);
0088     void showConfigWidget();
0089     void sourceValid(QString filename, int requestID);
0090     void updateTypeActivated(int);
0091     void clearIndexList();
0092 
0093   private:
0094     VectorMode _mode;
0095     ObjectStore *_store;
0096     DataSourcePtr _dataSource;
0097     QString _initField;
0098     int _requestID;
0099     void updateUpdateBox();
0100     bool _valid;
0101 };
0102 
0103 class VectorDialog : public DataDialog {
0104   Q_OBJECT
0105   public:
0106     friend class DialogSI;
0107     explicit VectorDialog(ObjectPtr dataObject, QWidget *parent = 0);
0108     virtual ~VectorDialog();
0109 
0110     void setField(QString field) {_vectorTab->setField(field);}
0111     virtual void waitForValidation();
0112 
0113   protected:
0114 //     virtual QString tagString() const;
0115     virtual ObjectPtr createNewDataObject();
0116     virtual ObjectPtr editExistingDataObject() const;
0117 
0118   private:
0119     ObjectPtr createNewDataVector();
0120     ObjectPtr createNewGeneratedVector();
0121     void configureTab(ObjectPtr vector=0);
0122 
0123   private Q_SLOTS:
0124     void updateButtons();
0125     void editMultipleMode();
0126     void editSingleMode();
0127 
0128   private:
0129     VectorTab *_vectorTab;
0130 
0131 };
0132 
0133 }
0134 
0135 #endif
0136 
0137 // vim: ts=2 sw=2 et