Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/ElmerGUI/Application/twod/renderarea.h
3203 views
1
/*****************************************************************************
2
* *
3
* Elmer, A Finite Element Software for Multiphysical Problems *
4
* *
5
* Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland *
6
* *
7
* This program is free software; you can redistribute it and/or *
8
* modify it under the terms of the GNU General Public License *
9
* as published by the Free Software Foundation; either version 2 *
10
* of the License, or (at your option) any later version. *
11
* *
12
* This program is distributed in the hope that it will be useful, *
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15
* GNU General Public License for more details. *
16
* *
17
* You should have received a copy of the GNU General Public License *
18
* along with this program (in file fem/GPL-2); if not, write to the *
19
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
20
* Boston, MA 02110-1301, USA. *
21
* *
22
*****************************************************************************/
23
24
/*****************************************************************************
25
* *
26
* ElmerGUI RenderArea *
27
* *
28
*****************************************************************************
29
* *
30
* Authors: Mikko Lyly, Juha Ruokolainen and Peter Råback *
31
* Email: [email protected] *
32
* Web: http://www.csc.fi/elmer *
33
* Address: CSC - IT Center for Science Ltd. *
34
* Keilaranta 14 *
35
* 02101 Espoo, Finland *
36
* *
37
* Original Date: 15 Mar 2008 *
38
* *
39
*****************************************************************************/
40
#ifndef RENDERAREA_H
41
#define RENDERAREA_H
42
43
#include <QWidget>
44
#include <QHash>
45
46
class CurveEditor;
47
class QTableWidget;
48
49
class Spline
50
{
51
public:
52
int out;
53
int in;
54
int np;
55
int p[3];
56
};
57
58
class RenderArea : public QWidget
59
{
60
Q_OBJECT
61
62
public:
63
RenderArea(QWidget *parent = 0);
64
~RenderArea();
65
66
void setCurveEditor(CurveEditor *curveEditor);
67
void modifyPoint(int idx, double x, double y);
68
void modifyCurve(int idx, int in, int out, int np, int p1, int p2, int p3);
69
void updatePoints(QTableWidget *table);
70
void updateCurves(QTableWidget *table);
71
72
public slots:
73
void fitSlot();
74
void readSlot(QString fileName);
75
void saveSlot(QString fileName);
76
void drawPointsSlot(bool state);
77
void drawSplinesSlot(bool state);
78
void drawTangentsSlot(bool state);
79
void drawPointNumbersSlot(bool state);
80
void drawSplineNumbersSlot(bool state);
81
void drawMaterialNumbersSlot(bool state);
82
83
signals:
84
void statusMessage(QString message);
85
86
protected:
87
void paintEvent(QPaintEvent *event);
88
void mousePressEvent(QMouseEvent *event);
89
void mouseReleaseEvent(QMouseEvent *event);
90
void mouseMoveEvent(QMouseEvent *event);
91
void wheelEvent(QWheelEvent *event);
92
93
private:
94
QHash<int, QPointF> points;
95
QHash<int, Spline> splines;
96
QVector<int> bodies;
97
QRectF viewport;
98
QRectF renderport;
99
int selectedPoint;
100
int pointRadius;
101
QPointF mapToViewport(QPointF point) const;
102
QPointF mapToRenderport(QPointF point) const;
103
QPointF quadNurbs(double u, QPointF P0, QPointF P1, QPointF P2) const;
104
QPoint lastPos;
105
bool drawPoints;
106
bool drawSplines;
107
bool drawTangents;
108
bool drawPointNumbers;
109
bool drawSplineNumbers;
110
bool drawMaterialNumbers;
111
CurveEditor *curveEditor;
112
bool reading;
113
};
114
115
#endif // RENDERAREA_H
116
117