1
/*************************************************************************************
2
* Copyright (C) 2007 by Aleix Pol <aleixpol@kde.org> *
4
* This program is free software; you can redistribute it and/or *
5
* modify it under the terms of the GNU General Public License *
6
* as published by the Free Software Foundation; either version 2 *
7
* of the License, or (at your option) any later version. *
9
* This program is distributed in the hope that it will be useful, *
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12
* GNU General Public License for more details. *
14
* You should have received a copy of the GNU General Public License *
15
* along with this program; if not, write to the Free Software *
16
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
17
*************************************************************************************/
23
#include <QtCore/QThread>
25
#include "analitza/analyzer.h"
28
* Used to calculate 3D Graphs in parallel.
29
* @author Aleix Pol i Gonzalez <aleixpol@kde.org>
32
class Calculate3D : public QThread
35
/** Constructor. Creates a Calculate3D thread.
36
@param p parent object.
37
@param na Analitza module used fot the calculations.
38
@param poi memory space where the results will be located.
39
@param fr Beginning of the calculated values.
40
@param to End of the calculated values.
41
@param m Distance of each dimension from the (0, 0) to be calculated.
42
@param s Step between each 2 values.
44
Calculate3D(QObject *p, const Analitza::Analyzer &na, double** poi, int fr, int to, double m, double s) :
45
QThread(p), a(na), points(poi), from(fr), to(to), size(m), step(s) {}
47
/** Runs the thread. */
50
/** Sets the end of the segment to calculate. */
51
void setTo(int nto) { to = nto; }
63
* The Graph3D provides a 3D OpenGL graph representation.
64
* @author Aleix Pol i Gonzalez
67
class Graph3D : public QGLWidget
71
/** Defines how will be the graph representated. */
73
Dots=0, ///< Dots will be drawn.
74
Lines=1, ///< Lines will be drawn.
75
Solid=2 ///< A solid graph will be drawn with a line texture.
78
/** Constructor. Creates a new Graph3D widget. */
79
Graph3D(QWidget *parent = 0);
84
/** Sets @p exp as the function's expression. */
85
void setFunc(const Analitza::Expression& exp);
87
/** Toggles the transparency for Solid graphs. */
88
void setTransparency(bool tr) { trans = tr; glDraw(); }
90
/** Returns whether there is transparency. */
91
bool transparency() const { return trans; }
93
/** Returns the pixmap painting. */
96
/** Sets the @p max maximum size. */
97
void setSize(double max);
99
/** Sets the interval between two points. */
100
void setStep(double res);
102
/** Sets the Z coordinate. */
103
void setZoom(float alpha);
105
/** Sets the showed method. */
106
void setMethod(Type m);
108
void wheelEvent(QWheelEvent *e);
110
static bool checkExpression(const QStringList& bvars, const Analitza::ExpressionType& actual);
113
/** Resets the view coordinates. */
117
/** Emits a status message. */
118
void status(const QString &msg);
123
virtual void initializeGL() ;
124
virtual void resizeGL( int width, int height ) ;
125
virtual void paintGL() ;
127
void keyPressEvent(QKeyEvent *e);
128
void keyReleaseEvent(QKeyEvent *e);
130
void mousePressEvent(QMouseEvent *e); QPoint press;
131
void mouseReleaseEvent(QMouseEvent *e);
132
void mouseMoveEvent(QMouseEvent *e);
134
bool create(const Analitza::Expression& func3d);
135
void sendStatus(const QString& msg) { emit status(msg); }
137
Analitza::Analyzer a;
146
unsigned short keyspressed;