File indexing completed on 2024-05-12 15:26:40

0001 /***************************************************************************
0002     File                 : Datapicker.h
0003     Project              : LabPlot
0004     Description          : Datapicker
0005     --------------------------------------------------------------------
0006     Copyright            : (C) 2015 by Ankit Wagadre (wagadre.ankit@gmail.com)
0007     Copyright            : (C) 2015-2017 by Alexander Semke (alexander.semke@web.de)
0008 
0009  ***************************************************************************/
0010 /***************************************************************************
0011  *                                                                         *
0012  *  This program is free software; you can redistribute it and/or modify   *
0013  *  it under the terms of the GNU General Public License as published by   *
0014  *  the Free Software Foundation; either version 2 of the License, or      *
0015  *  (at your option) any later version.                                    *
0016  *                                                                         *
0017  *  This program is distributed in the hope that it will be useful,        *
0018  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
0019  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
0020  *  GNU General Public License for more details.                           *
0021  *                                                                         *
0022  *   You should have received a copy of the GNU General Public License     *
0023  *   along with this program; if not, write to the Free Software           *
0024  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
0025  *   Boston, MA  02110-1301  USA                                           *
0026  *                                                                         *
0027  ***************************************************************************/
0028 
0029 #ifndef DATAPICKER_H
0030 #define DATAPICKER_H
0031 
0032 #include "backend/core/AbstractPart.h"
0033 
0034 class Spreadsheet;
0035 class DatapickerCurve;
0036 class DatapickerImage;
0037 class DatapickerView;
0038 
0039 class QXmlStreamWriter;
0040 class XmlStreamReader;
0041 class Transform;
0042 class QPointF;
0043 class QVector3D;
0044 
0045 class Datapicker : public AbstractPart {
0046     Q_OBJECT
0047 
0048 public:
0049     explicit Datapicker(const QString& name, const bool loading = false);
0050     ~Datapicker() override;
0051 
0052     QIcon icon() const override;
0053     QMenu* createContextMenu() override;
0054     QWidget* view() const override;
0055 
0056     bool exportView() const override;
0057     bool printView() override;
0058     bool printPreview() const override;
0059 
0060     DatapickerCurve* activeCurve();
0061     Spreadsheet* currentSpreadsheet() const;
0062     DatapickerImage* image() const;
0063 
0064     void setChildSelectedInView(int index, bool selected);
0065     void setSelectedInView(const bool);
0066     void addNewPoint(QPointF, AbstractAspect*);
0067 
0068     QVector3D mapSceneToLogical(QPointF) const;
0069     QVector3D mapSceneLengthToLogical(QPointF) const;
0070 
0071     void save(QXmlStreamWriter*) const override;
0072     bool load(XmlStreamReader*, bool preview) override;
0073 
0074 public slots:
0075     void childSelected(const AbstractAspect*) override;
0076 
0077 private:
0078     mutable DatapickerView* m_view{nullptr};
0079     DatapickerCurve* m_activeCurve{nullptr};
0080     Transform* m_transform;
0081     DatapickerImage* m_image{nullptr};
0082     void init();
0083     void handleChildAspectAboutToBeRemoved(const AbstractAspect*);
0084     void handleChildAspectAdded(const AbstractAspect*);
0085 
0086 private slots:
0087     void childDeselected(const AbstractAspect*) override;
0088     void handleAspectAdded(const AbstractAspect*);
0089     void handleAspectAboutToBeRemoved(const AbstractAspect*);
0090 
0091 signals:
0092     void datapickerItemSelected(int);
0093     void requestUpdateActions();
0094 };
0095 
0096 #endif