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

Analitza

  • sources
  • kde-4.12
  • 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 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 
38 class QItemSelectionModel;
39 
40 namespace Analitza
41 {
42 class PlotsModel;
43 
55 class ANALITZAGUI_EXPORT PlotsView2D : public QWidget, public Plotter2D
56 {
57 Q_OBJECT
58 Q_PROPERTY(bool squares READ squares WRITE setSquares)
59 public:
61  enum GraphMode {
62  None=0,
63  Pan,
64  Selection
65  };
66 
67  enum Format { PNG, SVG };
68 
70  PlotsView2D(QWidget* parent = 0);
71 
72  ~PlotsView2D();
73 
74  QSize sizeHint() const { return QSize(100, 100); }
75 
77  bool toImage(const QString& path, Format f);
78 
80  QRectF definedViewport() const;
81 
82  void setSelectionModel(QItemSelectionModel* selection);
83 
84  virtual void showEvent(QShowEvent* ev);
85 
86 public slots:
88  void forceRepaint() { valid=false; repaint(); }
89 
91  void resetViewport() { setViewport(defViewport); }
92 
94  void zoomIn();
95 
97  void zoomOut();
98 
100  bool isFramed() const { return m_framed; }
101 
103  void setFramed(bool fr) { m_framed=fr; }
104 
106  bool isReadOnly() const { return m_readonly; }
107 
109  void setReadOnly(bool ro);
110 
111  void snapshotToClipboard();
112 
113  //exposed from plotter2d as slots...
114  void setXAxisLabel(const QString &label) { Plotter2D::setXAxisLabel(label); }
115  void setYAxisLabel(const QString &label) { Plotter2D::setYAxisLabel(label); }
116  void updateGridColor(const QColor &color) { Plotter2D::updateGridColor(color); }
117  void updateTickScale(QString s, qreal v, int n, int d) { Plotter2D::updateTickScale(s,v,n,d); }
118  void setTicksShown(QFlags<Qt::Orientation> o) { Plotter2D::setTicksShown(o); }
119  void setAxesShown(QFlags<Qt::Orientation> o) { Plotter2D::setAxesShown(o); }
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  virtual void viewportChanged();
136  virtual int currentFunction() const;
137  virtual void modelChanged();
138 
139  //painting
140  QPixmap buffer;
141  bool valid;
142  QPointF mark;
143  QPoint cursorPos;
144 
145  //events
146  void paintEvent( QPaintEvent * );
147  void mousePressEvent(QMouseEvent *e);
148  void mouseReleaseEvent(QMouseEvent *e);
149  void mouseMoveEvent(QMouseEvent *e);
150  void keyPressEvent(QKeyEvent * e );
151  void wheelEvent(QWheelEvent *e);
152  void resizeEvent(QResizeEvent *);
153 
154  GraphMode mode;
155  QPoint press; QPoint last;
156 
157  //presentation
158  QPointF ant;
159  QRectF defViewport;
160  void drawFunctions(QPaintDevice*);
161 
162  void sendStatus(const QString& msg) { emit status(msg); }
163  bool m_framed;
164  bool m_readonly;
165  QString m_posText;
166  QItemSelectionModel* m_selection;
167  QAbstractItemModel *m_currentModel; // use this pointer to disconnect signals when change the model
168 };
169 
170 }
171 
172 #endif
Analitza::PlotsView2D::Pan
Panning, translates the viewport.
Definition: plotsview2d.h:63
Analitza::PlotsView2D::setYAxisLabel
void setYAxisLabel(const QString &label)
Definition: plotsview2d.h:115
plotter2d.h
analitzaguiexport.h
QWidget
Analitza::Plotter2D::updateTickScale
void updateTickScale(const QString &m_tickScaleSymbol, qreal m_tickScaleSymbolValue, int m_tickScaleNumerator, int m_tickScaleDenominator)
Analitza::Plotter2D::setAxesShown
void setAxesShown(Qt::Orientations o)
Definition: plotter2d.h:95
Analitza::PlotsView2D::updateGridColor
void updateGridColor(const QColor &color)
Definition: plotsview2d.h:116
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:100
Analitza::PlotsView2D::Format
Format
Definition: plotsview2d.h:67
Analitza::Plotter2D::setXAxisLabel
void setXAxisLabel(const QString &label)
Analitza::PlotsView2D::setXAxisLabel
void setXAxisLabel(const QString &label)
Definition: plotsview2d.h:114
Analitza::PlotsView2D::isReadOnly
bool isReadOnly() const
Returns whether it is a read-only widget.
Definition: plotsview2d.h:106
Analitza::PlotsView2D::forceRepaint
void forceRepaint()
Marks the image as dirty and repaints everything.
Definition: plotsview2d.h:88
Analitza::Plotter2D::updateGridColor
void updateGridColor(const QColor &color)
Definition: plotter2d.h:92
Analitza::PlotsView2D::setFramed
void setFramed(bool fr)
Sets whether it has a little border frame.
Definition: plotsview2d.h:103
Analitza::Plotter2D
Render 2D plots.
Definition: plotter2d.h:52
Analitza::PlotsView2D::GraphMode
GraphMode
The graph mode will especify the selection mode we are using at the moment.
Definition: plotsview2d.h:61
Analitza::PlotsView2D::setTicksShown
void setTicksShown(QFlags< Qt::Orientation > o)
Definition: plotsview2d.h:118
Analitza::PlotsView2D::sizeHint
QSize sizeHint() const
Definition: plotsview2d.h:74
Analitza::PlotsView2D::updateTickScale
void updateTickScale(QString s, qreal v, int n, int d)
Definition: plotsview2d.h:117
Analitza::Plotter2D::setYAxisLabel
void setYAxisLabel(const QString &label)
Analitza::Plotter2D::setTicksShown
void setTicksShown(Qt::Orientations o)
Definition: plotter2d.h:94
Analitza::PlotsView2D::setAxesShown
void setAxesShown(QFlags< Qt::Orientation > o)
Definition: plotsview2d.h:119
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:55
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:35:21 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
  • kstars
  • libkdeedu
  •   keduvocdocument
  • 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