• 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
  • analitzaplot
plotter2d.h
Go to the documentation of this file.
1 /*************************************************************************************
2  * Copyright (C) 2011 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 PLOTTER2D_H
21 #define PLOTTER2D_H
22 
23 #include <QRectF>
24 #include <QLineF>
25 #include <QString>
26 #include <QPair>
27 #include <QColor>
28 
29 #include "analitzaplotexport.h"
30 #include <analitzaplot/plottingenums.h>
31 
32 class QAbstractItemModel;
33 class QPainter;
34 class QPaintDevice;
35 class QModelIndex;
36 
37 namespace Analitza
38 {
39 struct GridInfo;
40 class PlotItem;
41 
52 class ANALITZAPLOT_EXPORT Plotter2D
53 {
54  public:
55  Plotter2D(const QSizeF& size);
56  virtual ~Plotter2D();
57 
58  virtual void drawFunctions(QPaintDevice *qpd);
59  virtual void forceRepaint() = 0;
60  virtual void viewportChanged() = 0;
61  virtual int currentFunction() const = 0;
62  virtual void modelChanged() = 0;
63 
65  void setSquares(bool newSquare) { m_squares=newSquare; forceRepaint(); }
66 
68  bool squares() const {return m_squares; }
69 
71  void setKeepAspectRatio(bool ar);
72 
74  bool keepAspectRatio() const { return m_keepRatio; }
75 
77  void updateFunctions(const QModelIndex & parent, int start, int end);
78 
79  void setModel(QAbstractItemModel* f);
80  QAbstractItemModel* model() const { return m_model; }
81 
83  void setViewport(const QRectF& vp, bool repaint=true);
84 
86  void moveViewport(const QPoint& delta);
87 
88  //ticks & axis
89  void setXAxisLabel(const QString &label);
90  void setYAxisLabel(const QString &label);
91  // tick symbols
92  void updateGridColor(const QColor &color) { m_gridColor = color; forceRepaint(); }
93  void updateTickScale(const QString& m_tickScaleSymbol, qreal m_tickScaleSymbolValue, int m_tickScaleNumerator, int m_tickScaleDenominator);
94  void setTicksShown(Qt::Orientations o) { m_ticksShown = o; forceRepaint(); }
95  void setAxesShown(Qt::Orientations o) { m_axesShown = o; forceRepaint(); }
96 
97  Qt::Orientations ticksShown() const { return m_ticksShown; }
98 
99  protected:
100  QRectF lastViewport() const { return viewport; }
101  QRectF lastUserViewport() const { return userViewport; }
102  void updateScale(bool repaint);
103 
104  QPointF toWidget(const QPointF &) const;
105  QPointF fromWidget(const QPoint& p) const;
106  QPointF toViewport(const QPoint& mv) const;
107  QPair<QPointF, QString> calcImage(const QPointF& ndp) const;
108  QLineF slope(const QPointF& dp) const;
109 
110  QLineF toWidget(const QLineF &) const;
111  void setPaintedSize(const QSize& size);
112  void scaleViewport(qreal s, const QPoint& center);
113 
114  private:
115  void drawAxes(QPainter* painter, CoordinateSystem a) const;
116  void drawPolarGrid(QPainter* painter, const GridInfo& inc) const;
117  void drawCartesianGrid(QPainter *f, const GridInfo& inc) const;
118  void drawMainAxes(QPainter* painter) const;
119  GridInfo drawTicks(QPainter* painter) const;
120  PlotItem *itemAt(int row) const;
121  int width() const { return m_size.width(); }
122  int height() const { return m_size.height(); }
123 
124  double rang_x, rang_y;
125  bool m_squares;
126  bool m_keepRatio;
127  bool m_dirty; // or m_updated; como ahora contamos con setmodel, es necesario que se actualicen los datos antes de pintar, es necesario que no sea dirty
128  QRectF viewport;
129  QRectF userViewport;
130  QSizeF m_size;
131  QAbstractItemModel* m_model;
132 
133  static const QColor m_axeColor;
134  static const QColor m_derivativeColor;
135 
136  QString m_tickScaleSymbol;
137  qreal m_tickScaleSymbolValue;
138  int m_tickScaleNumerator;
139  int m_tickScaleDenominator;
140  Qt::Orientations m_ticksShown;
141  Qt::Orientations m_axesShown;
142  QString m_axisXLabel;
143  QString m_axisYLabel;
144 
145  QColor m_gridColor;
146 };
147 
148 }
149 
150 #endif // PLOTTER2D_H
plottingenums.h
Analitza::Plotter2D::setSquares
void setSquares(bool newSquare)
Sets whether we will see a grid or only the axes.
Definition: plotter2d.h:65
analitzaplotexport.h
Analitza::PlotItem
Represents a visual item.
Definition: plotitem.h:45
Analitza::Plotter2D::keepAspectRatio
bool keepAspectRatio() const
Sets whether it is keeping the aspect ratio (1:1 grid).
Definition: plotter2d.h:74
Analitza::Plotter2D::ticksShown
Qt::Orientations ticksShown() const
Definition: plotter2d.h:97
Analitza::Plotter2D::setAxesShown
void setAxesShown(Qt::Orientations o)
Definition: plotter2d.h:95
Analitza::Plotter2D::model
QAbstractItemModel * model() const
Definition: plotter2d.h:80
Analitza::Plotter2D::updateGridColor
void updateGridColor(const QColor &color)
Definition: plotter2d.h:92
Analitza::Plotter2D
Render 2D plots.
Definition: plotter2d.h:52
Analitza::CoordinateSystem
CoordinateSystem
Definition: plottingenums.h:35
Analitza::Plotter2D::lastUserViewport
QRectF lastUserViewport() const
Definition: plotter2d.h:101
Analitza::Plotter2D::lastViewport
QRectF lastViewport() const
Definition: plotter2d.h:100
ANALITZAPLOT_EXPORT
#define ANALITZAPLOT_EXPORT
Definition: analitzaplotexport.h:28
Analitza::Plotter2D::squares
bool squares() const
Returns whether we have chosen to see the grid.
Definition: plotter2d.h:68
Analitza::Plotter2D::setTicksShown
void setTicksShown(Qt::Orientations o)
Definition: plotter2d.h:94
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