• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

Analitza

  • sources
  • kde-4.14
  • kdeedu
  • analitza
  • analitzagui
plotsview2d.h
Go to the documentation of this file.
1 /*************************************************************************************
2  * Copyright (C) 2007-2008 by Aleix Pol <aleixpol@kde.org> *
3  * Copyright (C) 2012-2013 by Percy Camilo T. Aucahuasi <percy.camilo.ta@gmail.com> *
4  * *
5  * This program is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU General Public License *
7  * as published by the Free Software Foundation; either version 2 *
8  * of the License, or (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the Free Software *
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
18  *************************************************************************************/
19 
20 #ifndef GRAPH2D_H
21 #define GRAPH2D_H
22 
23 #include <QResizeEvent>
24 #include <QWheelEvent>
25 #include <QMouseEvent>
26 #include <QPaintEvent>
27 #include <QKeyEvent>
28 #include <QWidget>
29 #include <QPainter>
30 #include <QLabel>
31 #include <QPixmap>
32 #include <QModelIndex>
33 
34 #include "analitzaguiexport.h"
35 #include <analitzaplot/plotter2d.h>
36 
37 class QItemSelectionModel;
38 
39 namespace Analitza
40 {
41 class PlotsModel;
42 
54 class ANALITZAGUI_EXPORT PlotsView2D : public QWidget, public Plotter2D
55 {
56 Q_OBJECT
57 
58 Q_PROPERTY(bool showGrid READ showGrid WRITE setShowGrid)
59 
60 
61 Q_PROPERTY(QColor gridColor READ gridColor WRITE setGridColor)
62 
64 Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
65 
66 Q_PROPERTY(bool autoGridStyle READ autoGridStyle WRITE setAutoGridStyle)
67 
68 public:
69  enum Format { PNG, SVG };
70 
72  PlotsView2D(QWidget* parent = 0);
73 
74  ~PlotsView2D();
75 
76  QSize sizeHint() const { return QSize(100, 100); }
77 
79  bool toImage(const QString& path, Format f);
80 
82  QRectF definedViewport() const;
83 
84  void setSelectionModel(QItemSelectionModel* selection);
85 
86 public slots:
88  void forceRepaint() { valid=false; repaint(); }
89 
91  void resetViewport() { setViewport(defViewport); }
92 
94  bool isFramed() const { return m_framed; }
95 
97  void setFramed(bool fr) { m_framed=fr; }
98 
100  bool isReadOnly() const { return m_readonly; }
101 
103  void setReadOnly(bool ro);
104 
105  void snapshotToClipboard();
106 
107  //exposed from plotter2d as slots...
108  void setXAxisLabel(const QString &label) { Plotter2D::setXAxisLabel(label); }
109  void setYAxisLabel(const QString &label) { Plotter2D::setYAxisLabel(label); }
110  void setGridColor(const QColor &color) { Plotter2D::setGridColor(color); }
111  void setTicksShown(QFlags<Qt::Orientation> o) { Plotter2D::setShowTickLabels(o); }
112  void setAxesShown(QFlags<Qt::Orientation> o) { Plotter2D::setShowAxes(o); }
113  //TODO set bgcolor, setbgcolormode auto means that colo is chosses based in lumninosisty onf current bgprofiles
114 
116  virtual void zoomIn() { Plotter2D::zoomIn(true); }
117 
119  virtual void zoomOut() { Plotter2D::zoomOut(true); }
120 
121 private slots:
122  void updateFuncs(const QModelIndex & parent, int start, int end); //update al insertar itesm
123  void updateFuncs(const QModelIndex& start, const QModelIndex& end); //update al setdata
124  void addFuncs(const QModelIndex & parent, int start, int end);
125  void removeFuncs(const QModelIndex & parent, int start, int end);
126  void changeViewport(const QRectF& vp) { setViewport(vp); }
127 
128 signals:
130  void status(const QString &msg);
131 
132  void viewportChanged(const QRectF&);
133 
134 private:
135  //TODO setviewmodemosusemovemode, pan
137  enum GraphMode {
138  None=0,
139  Pan,
140  Selection
141  };
142 
143 private:
144  virtual void viewportChanged();
145  virtual int currentFunction() const;
146  virtual void modelChanged();
147 
148  //painting
149  QPixmap buffer;
150  bool valid;
151  QPointF mark;
152  QPoint cursorPos;
153 
154  //events
155  void paintEvent( QPaintEvent * );
156  void mousePressEvent(QMouseEvent *e);
157  void mouseReleaseEvent(QMouseEvent *e);
158  void mouseMoveEvent(QMouseEvent *e);
159  void keyPressEvent(QKeyEvent * e );
160  void wheelEvent(QWheelEvent *e);
161  void resizeEvent(QResizeEvent *);
162 
163  GraphMode mode;
164  QPoint press; QPoint last;
165 
166  //presentation
167  QPointF ant;
168  QRectF defViewport;
169  void drawAll(QPaintDevice*); // render grid+plots into paintdevice
170 
171  void sendStatus(const QString& msg) { emit status(msg); }
172  bool m_framed;
173  bool m_readonly;
174  QString m_posText;
175  QItemSelectionModel* m_selection;
176  QAbstractItemModel *m_currentModel; // use this pointer to disconnect signals when change the model
177 };
178 
179 }
180 
181 #endif
Analitza::PlotsView2D::setYAxisLabel
void setYAxisLabel(const QString &label)
Definition: plotsview2d.h:109
QModelIndex
QResizeEvent
QWidget
plotter2d.h
Analitza::PlotsView2D::setGridColor
void setGridColor(const QColor &color)
Definition: plotsview2d.h:110
QPaintDevice
analitzaguiexport.h
Analitza::Plotter2D::setGridColor
void setGridColor(const QColor &color)
Definition: plotter2d.h:72
QWheelEvent
Analitza::PlotsView2D::zoomIn
virtual void zoomIn()
Zooms in to the Viewport center.
Definition: plotsview2d.h:116
QPoint
QMouseEvent
ANALITZAGUI_EXPORT
#define ANALITZAGUI_EXPORT
Definition: analitzaguiexport.h:28
Analitza::PlotsView2D::isFramed
bool isFramed() const
Returns whether it has a little border frame.
Definition: plotsview2d.h:94
Analitza::PlotsView2D::Format
Format
Definition: plotsview2d.h:69
Analitza::Plotter2D::setXAxisLabel
void setXAxisLabel(const QString &label)
QPointF
Analitza::PlotsView2D::setXAxisLabel
void setXAxisLabel(const QString &label)
Definition: plotsview2d.h:108
Analitza::Plotter2D::zoomOut
void zoomOut(bool repaint=true)
Zooms out taken ref center too.
QFlags
Analitza::PlotsView2D::isReadOnly
bool isReadOnly() const
Returns whether it is a read-only widget.
Definition: plotsview2d.h:100
Analitza::PlotsView2D::forceRepaint
void forceRepaint()
Marks the image as dirty and repaints everything.
Definition: plotsview2d.h:88
Analitza::Plotter2D::setShowTickLabels
void setShowTickLabels(Qt::Orientations o)
Definition: plotter2d.h:128
Analitza::Plotter2D::zoomIn
void zoomIn(bool repaint=true)
Zooms in to the Viewport center.
Analitza::PlotsView2D::setFramed
void setFramed(bool fr)
Sets whether it has a little border frame.
Definition: plotsview2d.h:97
QString
QColor
Analitza::Plotter2D
Render 2D plots.
Definition: plotter2d.h:55
QPixmap
QSize
QKeyEvent
Analitza::PlotsView2D::setTicksShown
void setTicksShown(QFlags< Qt::Orientation > o)
Definition: plotsview2d.h:111
Analitza::PlotsView2D::zoomOut
virtual void zoomOut()
Zooms out.
Definition: plotsview2d.h:119
Analitza::PlotsView2D::sizeHint
QSize sizeHint() const
Definition: plotsview2d.h:76
QRectF
Analitza::Plotter2D::setShowAxes
void setShowAxes(Qt::Orientations o)
Definition: plotter2d.h:136
QAbstractItemModel
Analitza::Plotter2D::setYAxisLabel
void setYAxisLabel(const QString &label)
QPaintEvent
QItemSelectionModel
Analitza::PlotsView2D::setAxesShown
void setAxesShown(QFlags< Qt::Orientation > o)
Definition: plotsview2d.h:112
Analitza::PlotsView2D::resetViewport
void resetViewport()
Sets the viewport to a default viewport.
Definition: plotsview2d.h:91
Analitza::PlotsView2D
Widget that allows visualization of 2D plots.
Definition: plotsview2d.h:54
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:11:37 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Analitza

Skip menu "Analitza"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal