File indexing completed on 2024-04-14 14:08:48

0001 /*************************************************************************************
0002  *  Copyright (C) 2012 by Percy Camilo T. Aucahuasi <percy.camilo.ta@gmail.com>      *
0003  *                                                                                   *
0004  *  This program is free software; you can redistribute it and/or                    *
0005  *  modify it under the terms of the GNU General Public License                      *
0006  *  as published by the Free Software Foundation; either version 2                   *
0007  *  of the License, or (at your option) any later version.                           *
0008  *                                                                                   *
0009  *  This program is distributed in the hope that it will be useful,                  *
0010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of                   *
0011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                    *
0012  *  GNU General Public License for more details.                                     *
0013  *                                                                                   *
0014  *  You should have received a copy of the GNU General Public License                *
0015  *  along with this program; if not, write to the Free Software                      *
0016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA   *
0017  *************************************************************************************/
0018 
0019 #ifndef KHIPU_DOCUMENT_H_ds
0020 #define KHIPU_DOCUMENT_H_ds
0021 
0022 //Qt includes
0023 #include <QObject>
0024 #include <QMap>
0025 #include <QModelIndex>
0026 
0027 class QItemSelectionModel;
0028 class SpaceItem;
0029 
0030 namespace Analitza {
0031 class PlotsDictionaryModel;
0032 class Variables;
0033 class PlotsModel;
0034 class PlotItem;
0035 }
0036 
0037 class SpacesModel;
0038 class SpacePlotsFilterProxyModel;
0039 
0040 class DataStore : public QObject
0041 {
0042     Q_OBJECT
0043 
0044 public:
0045     explicit DataStore(QObject *parent = nullptr);
0046     ~DataStore() override;
0047 
0048     int currentSpace() const { return m_currentSpace; }
0049 
0050     Analitza::PlotsDictionaryModel *plotsDictionaryModel() const { return m_plotsDictionaryModel; }
0051     SpacesModel *spacesModel() const { return m_spacesModel; }
0052     Analitza::PlotsModel *plotsModel() const { return m_plotsModel; }
0053 
0054     SpacePlotsFilterProxyModel * currentPlots() const { return m_spacePlotsFilterProxyModel; }
0055     QItemSelectionModel *currentSelectionModel() const { return m_currentSelectionModel; }
0056     QItemSelectionModel *currentSpaceSelectionModel() const { return m_currentSpaceSelectionModel; }
0057     QMap<SpaceItem*, Analitza::PlotItem*> currentDataMap() const { return m_maps; }
0058 
0059     bool isMapped(SpaceItem *space, Analitza::PlotItem *plot) const;
0060     void removeSpace(int row);
0061 
0062 private slots:
0063     void mapPlot(const QModelIndex& parent, int start);
0064     void selectCurrentPlot(const QModelIndex & curr);
0065     void plotDataChanged ( const QModelIndex& topLeft );
0066 
0067 public slots: 
0068     void setCurrentSpace(int spaceidx);
0069     void removeCurrentSpace();
0070     void unmapPlot(const QModelIndex & proxyindex);
0071     void saveSpaceAsDictionary(QModelIndex ind);
0072     void clearAllData();
0073 
0074 signals:
0075     void spaceActivated(int spaceidx);
0076     void gridStyleChanged(int i); // 1 cartesian 2 polar
0077     void mapDataChanged();
0078 
0079 private:
0080     Analitza::PlotsDictionaryModel *m_plotsDictionaryModel;
0081     SpacesModel *m_spacesModel;
0082     Analitza::PlotsModel *m_plotsModel;
0083     
0084     SpacePlotsFilterProxyModel * m_spacePlotsFilterProxyModel;
0085     QItemSelectionModel *m_currentSelectionModel;
0086     QItemSelectionModel *m_currentSpaceSelectionModel;
0087     
0088     Analitza::Variables *m_variables;
0089 
0090     //one to many -- space index -> many plots index
0091     int m_currentSpace; // curr space index 
0092     QMap<SpaceItem*, Analitza::PlotItem *> m_maps;
0093 };
0094 
0095 
0096 #endif