1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
/*************************************************************************************
* Copyright (C) 2010 by Aleix Pol <aleixpol@kde.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
*************************************************************************************/
#ifndef GRAPH2DMOBILE_H
#define GRAPH2DMOBILE_H
#include <QtQuick/QQuickPaintedItem>
#include <analitzaplot/plotter2d.h>
#include <QPixmap>
namespace Analitza {
class Variables;
}
class Graph2DMobile : public QQuickItem, public Analitza::Plotter2D
{
Q_OBJECT
Q_PROPERTY(QAbstractItemModel* model READ model WRITE setModel)
Q_PROPERTY(QRectF viewport READ lastViewport WRITE setViewport RESET resetViewport)
Q_PROPERTY(bool showGrid READ showGrid WRITE setShowGrid NOTIFY showGridChanged)
Q_PROPERTY(bool showMinorGrid READ showMinorGrid WRITE setShowMinorGrid)
Q_PROPERTY(bool keepAspectRatio READ keepAspectRatio WRITE setKeepAspectRatio)
Q_PROPERTY(bool currentFunction READ currentFunction WRITE setCurrentFunction)
Q_PROPERTY(bool ticksShown READ ticksShownAtAll WRITE setTicksShownAtAll)
Q_PROPERTY(bool minorTicksShown READ minorTicksShown WRITE setShowMinorTicks)
Q_PROPERTY(QStringList filters READ filters CONSTANT)
public:
Graph2DMobile(QQuickItem* parent = 0);
virtual void forceRepaint() override;
virtual void viewportChanged() override {}
virtual void modelChanged() override;
virtual int currentFunction() const override { return m_currentFunction; }
void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry) override;
QSGNode* updatePaintNode(QSGNode*, UpdatePaintNodeData*) override;
void setCurrentFunction(int f) { m_currentFunction = f; }
bool ticksShownAtAll() const { return ticksShown()!=0; }
void setTicksShownAtAll(bool shown);
QStringList filters() const;
public Q_SLOTS:
void translate(qreal x, qreal y);
void scale(qreal s, int x, int y);
void resetViewport();
QStringList addFunction(const QString& expression, const QSharedPointer<Analitza::Variables>& vars = {});
bool save(const QUrl &url) const;
private Q_SLOTS:
void updateFuncs(const QModelIndex& start, const QModelIndex& end);
void addFuncs(const QModelIndex& parent, int start, int end);
void removeFuncs(const QModelIndex& parent, int start, int end);
Q_SIGNALS:
void showGridChanged() override;
private:
void paint();
bool m_dirty;
int m_currentFunction;
QImage m_buffer;
QRectF defViewport;
};
#endif // GRAPH2DMOBILE_H
|