/usr/include/Analitza5/analitzagui/plotsview2d.h is in libanalitza-dev 4:16.08.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | /*************************************************************************************
* Copyright (C) 2007-2008 by Aleix Pol <aleixpol@kde.org> *
* Copyright (C) 2012-2013 by Percy Camilo T. Aucahuasi <percy.camilo.ta@gmail.com> *
* *
* 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 GRAPH2D_H
#define GRAPH2D_H
#include <QResizeEvent>
#include <QWheelEvent>
#include <QMouseEvent>
#include <QPaintEvent>
#include <QKeyEvent>
#include <QWidget>
#include <QPainter>
#include <QLabel>
#include <QPixmap>
#include <QModelIndex>
#include "analitzawidgets_export.h"
#include <analitzaplot/plotter2d.h>
class QItemSelectionModel;
namespace Analitza
{
class PlotsModel;
/**
* \class PlotsView2D
*
* \ingroup AnalitzaGUIModule
*
* \brief Widget that allows visualization of 2D plots.
*
* This class lets you create a widget that can draw multiple 2D graphs. This widget
* use Plotter2D as a backend.
*/
class ANALITZAWIDGETS_EXPORT PlotsView2D : public QWidget, public Plotter2D
{
Q_OBJECT
Q_PROPERTY(bool showGrid READ showGrid WRITE setShowGrid)
/** The default grid color is a soft mix between KColorScheme::NormalBackground and KColorScheme::NormalText (foreground) of QPalette::Active. **/
Q_PROPERTY(QColor gridColor READ gridColor WRITE setGridColor)
/** The default background color is KColorScheme::NormalBackground of QPalette::Active. **/
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
Q_PROPERTY(bool autoGridStyle READ autoGridStyle WRITE setAutoGridStyle)
public:
enum Format { PNG, SVG };
/** Constructor. Constructs a new Graph2D. */
PlotsView2D(QWidget* parent = 0);
~PlotsView2D();
QSize sizeHint() const override { return QSize(100, 100); }
/** Saves the graphs to a file located at @p path. */
bool toImage(const QString& path, Format f);
/** Returns the viewing port */
QRectF definedViewport() const;
void setSelectionModel(QItemSelectionModel* selection);
public Q_SLOTS:
/** Marks the image as dirty and repaints everything. */
void forceRepaint() override { valid=false; repaint(); }
/** Sets the viewport to a default viewport. */
void resetViewport() { setViewport(defViewport); }
/** Returns whether it has a little border frame. */
bool isFramed() const { return m_framed; }
/** Sets whether it has a little border frame. */
void setFramed(bool fr) { m_framed=fr; }
/** Returns whether it is a read-only widget. */
bool isReadOnly() const { return m_readonly; }
/** Sets whether it is a read-only widget. */
void setReadOnly(bool ro);
void snapshotToClipboard();
//exposed from plotter2d as slots...
void setXAxisLabel(const QString &label) { Plotter2D::setXAxisLabel(label); }
void setYAxisLabel(const QString &label) { Plotter2D::setYAxisLabel(label); }
void setGridColor(const QColor &color) { Plotter2D::setGridColor(color); }
void setTicksShown(QFlags<Qt::Orientation> o) { Plotter2D::setShowTickLabels(o); }
void setAxesShown(QFlags<Qt::Orientation> o) { Plotter2D::setShowAxes(o); }
//TODO set bgcolor, setbgcolormode auto means that colo is chosses based in lumninosisty onf current bgprofiles
/** Zooms in to the Viewport center */
virtual void zoomIn() { Plotter2D::zoomIn(true); }
/** Zooms out */
virtual void zoomOut() { Plotter2D::zoomOut(true); }
private Q_SLOTS:
void updateFuncs(const QModelIndex & parent, int start, int end); //update al insertar itesm
void updateFuncs(const QModelIndex& start, const QModelIndex& end); //update al setdata
void addFuncs(const QModelIndex & parent, int start, int end);
void removeFuncs(const QModelIndex & parent, int start, int end);
void changeViewport(const QRectF& vp) { setViewport(vp); }
Q_SIGNALS:
/** Emits a status when it changes. */
void status(const QString &msg);
void viewportChanged(const QRectF&);
private:
//TODO setviewmodemosusemovemode, pan
/** The graph mode will especify the selection mode we are using at the moment */
enum GraphMode {
None=0, /**< Normal behaviour */
Pan, /**< Panning, translates the viewport. */
Selection /**< There is a rectangle delimiting a region, for zooming. */
};
private:
virtual void viewportChanged() override;
virtual int currentFunction() const override;
virtual void modelChanged() override;
//painting
QPixmap buffer;
bool valid;
QPointF mark;
QPoint cursorPos;
//events
void paintEvent( QPaintEvent * ) override;
void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override;
void keyPressEvent(QKeyEvent * e ) override;
void wheelEvent(QWheelEvent *e) override;
void resizeEvent(QResizeEvent *) override;
GraphMode mode;
QPoint press; QPoint last;
//presentation
QPointF ant;
QRectF defViewport;
void sendStatus(const QString& msg) { emit status(msg); }
bool m_framed;
bool m_readonly;
QString m_posText;
QItemSelectionModel* m_selection;
QAbstractItemModel *m_currentModel; // use this pointer to disconnect signals when change the model
};
}
#endif
|