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

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 MATRIXDIALOG_H
0014 #define MATRIXDIALOG_H
0015 
0016 #include "datadialog.h"
0017 #include "datatab.h"
0018 
0019 #include "ui_matrixtab.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 MatrixTab : public DataTab, Ui::MatrixTab {
0032   Q_OBJECT
0033   public:
0034     friend class DialogSI;
0035     enum MatrixMode { DataMatrix, GeneratedMatrix };
0036 
0037     explicit MatrixTab(ObjectStore *store, QWidget *parent = 0);
0038     virtual ~MatrixTab();
0039 
0040     MatrixMode matrixMode() const { return _mode; }
0041     void setMatrixMode(MatrixMode mode);
0042 
0043     //DataMatrix mode methods...
0044     DataSourcePtr dataSource() const;
0045     void setDataSource(DataSourcePtr dataSource);
0046 
0047     QString file() const;
0048     void setFile(const QString &file);
0049 
0050     QString field() const;
0051     void setField(const QString &field);
0052 
0053     void setFieldList(const QStringList &fieldList);
0054 
0055     uint nX() const;
0056     bool nXDirty() const;
0057     void setNX(uint nX);
0058 
0059     uint nY() const;
0060     bool nYDirty() const;
0061     void setNY(uint nY);
0062 
0063     double minX() const;
0064     bool minXDirty() const;
0065     void setMinX(double minX);
0066 
0067     double minY() const;
0068     bool minYDirty() const;
0069     void setMinY(double minY);
0070 
0071     double stepX() const;
0072     bool stepXDirty() const;
0073     void setStepX(double stepX);
0074 
0075     double stepY() const;
0076     bool stepYDirty() const;
0077     void setStepY(double stepY);
0078 
0079     int xStart() const;
0080     bool xStartDirty() const;
0081     void setXStart(int xStart);
0082 
0083     int yStart() const;
0084     bool yStartDirty() const;
0085     void setYStart(int yStart);
0086 
0087     int xNumSteps() const;
0088     bool xNumStepsDirty() const;
0089     void setXNumSteps(int xNumSteps);
0090 
0091     int yNumSteps() const;
0092     bool yNumStepsDirty() const;
0093     void setYNumSteps(int yNumSteps);
0094 
0095     double gradientZAtMin() const;
0096     bool gradientZAtMinDirty() const;
0097     void setGradientZAtMin(double gradientZAtMin);
0098 
0099     double gradientZAtMax() const;
0100     bool gradientZAtMaxDirty() const;
0101     void setGradientZAtMax(double gradientZAtMax);
0102 
0103     bool xDirection() const;
0104     void setXDirection(bool xDirection);
0105 
0106     bool doAverage() const;
0107     bool doAverageDirty() const;
0108     void setDoAverage(bool doAve);
0109 
0110     bool doSkip() const;
0111     bool doSkipDirty() const;
0112     void setDoSkip(bool doSkip);
0113 
0114     int skip() const;
0115     bool skipDirty() const;
0116     void setSkip(int skip);
0117 
0118     int frame() const;
0119     bool frameDirty() const;
0120     void setFrame(int frame);
0121 
0122     bool xStartCountFromEnd() const;
0123     bool xStartCountFromEndDirty() const;
0124     void setXStartCountFromEnd(bool xStartCountFromEnd);
0125 
0126     bool yStartCountFromEnd() const;
0127     bool yStartCountFromEndDirty() const;
0128     void setYStartCountFromEnd(bool yStartCountFromEnd);
0129 
0130     bool xReadToEnd() const;
0131     bool xReadToEndDirty() const;
0132     void setXReadToEnd(bool xReadToEnd);
0133 
0134     bool yReadToEnd() const;
0135     bool yReadToEndDirty() const;
0136     void setYReadToEnd(bool yReadToEnd);
0137 
0138     void hideGeneratedOptions();
0139     void hideDataOptions();    
0140     void hideUnused();
0141 
0142     void enableSingleEditOptions(bool enabled);
0143     void clearTabValues();
0144 
0145     bool validating;
0146 
0147   Q_SIGNALS:
0148     void sourceChanged();
0149 
0150   private Q_SLOTS:
0151     void readFromSourceChanged();
0152     void fileNameChanged(const QString &file);
0153     void showConfigWidget();
0154     void sourceValid(QString filename, int requestID);
0155 
0156     void updateEnables();
0157     void xStartCountFromEndClicked();
0158     void xNumStepsReadToEndClicked();
0159     void yStartCountFromEndClicked();
0160     void yNumStepsReadToEndClicked();
0161 
0162   private:
0163     MatrixMode _mode;
0164     DataSourcePtr _dataSource;
0165     ObjectStore *_store;
0166     QString _initField;
0167     int _requestID;
0168 };
0169 
0170 class MatrixDialog : public DataDialog {
0171   Q_OBJECT
0172   public:
0173     explicit MatrixDialog(ObjectPtr dataObject, QWidget *parent = 0);
0174     virtual ~MatrixDialog();
0175     friend class DialogSI;
0176     virtual void waitForValidation();
0177 
0178   protected:
0179 //     virtual QString tagString() const;
0180     virtual ObjectPtr createNewDataObject();
0181     virtual ObjectPtr editExistingDataObject() const;
0182 
0183   private:
0184     ObjectPtr createNewGeneratedMatrix();
0185     ObjectPtr createNewDataMatrix();
0186     void configureTab(ObjectPtr vector);
0187 
0188   private Q_SLOTS:
0189     void updateButtons();
0190     void editMultipleMode();
0191     void editSingleMode();
0192 
0193   private:
0194     MatrixTab *_matrixTab;
0195 };
0196 
0197 }
0198 
0199 #endif
0200 
0201 // vim: ts=2 sw=2 et