/
beam.h
191 lines (164 loc) · 4.98 KB
/
beam.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#ifndef BEAM_H
#define BEAM_H
#include <QMainWindow>
#include <QHBoxLayout>
#include <QToolBar>
#include <QtCore>
#include <QtGui>
#include <QGraphicsScene>
#include <QGraphicsEllipseItem>
#include <QGraphicsItem>
#include <QGraphicsTextItem>
#include <QGraphicsLineItem>
#include <QGraphicsRectItem>
#include <QGraphicsItemGroup>
#include <QGraphicsPolygonItem>
#include <QGraphicsPathItem>
#include <QTreeWidgetItem>
#include "qtpropertymanager.h"
#include "qtvariantproperty.h"
#include "qttreepropertybrowser.h"
#include "ui_materialproperties.h"
#include "ui_distributedloaddialog.h"
#include <armadillo>
const double beamL = 800;
struct Component
{
QGraphicsItem *item;
};
struct Force : Component{
float posX;
float mag;
double angle;
bool directionUp;
};
struct Support : Component{
double posX;
enum t {FIXED,ROLLER,PINNED};
t type;
};
struct DistLoad : Component{
double x1;
double x2;
std::vector< double > data = {1,2};
enum LoadTypes { UNIFORM, ///< <tt>UNIFORM</tt> uniform full or short load
TRAPEZOIDAL ///< <tt>TRAPEZOIDAL</tt> trapezoidal load
};
LoadTypes type = UNIFORM;
};
struct Moment : Component{
float mag;
bool directionCw; // clockwise direction
};
struct Profile{
std::vector< std::vector<double> > dims; // length, x, y
QPixmap image;
QPixmap image_section;
enum ProfileTypes { T,L,I };
ProfileTypes type;
};
struct Material {
QString name;
Profile profile;
double E = 120; // in GPa
double PR = 0.3; // poisson's ratio
double A;
double Ixx = 1250;
double Iyy;
};
Q_DECLARE_METATYPE(Force)
Q_DECLARE_METATYPE(Support)
Q_DECLARE_METATYPE(Moment)
Q_DECLARE_METATYPE(DistLoad)
Q_DECLARE_METATYPE(Profile)
Q_DECLARE_METATYPE(Material)
Q_DECLARE_METATYPE(QTreeWidgetItem*)
namespace Ui {
class beam;
}
class beam : public QMainWindow
{
Q_OBJECT
public:
explicit beam(QWidget *parent = 0);
~beam();
private slots:
void on_solveBtn_clicked();
void on_treeWidget_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
void on_treeWidget_customContextMenuRequested(const QPoint &pos);
void on_actionForce_triggered();
void on_actionDistributed_Load_triggered();
void on_actionMoment_triggered();
void on_action_Save_triggered();
void componentsActionDelete();
void on_actionSave_as_triggered();
void propertyValueChanged(QtProperty *property, const QVariant &value);
void grsel();
void on_actionExit_triggered();
void testt(QGraphicsSceneHoverEvent *ev);
void on_actionMaterial_Properties_triggered();
void on_actionShowElasticCurve_toggled(bool checked);
void on_actionShow_Reactions_toggled(bool checked);
void on_actionShowMomentDiagram_toggled(bool checked);
void on_actionShowShearDiagram_toggled(bool checked);
void on_actionShowSlopeDiagram_toggled(bool checked);
void scaleChanged(int sf);
private:
Ui::beam *ui;
QGraphicsScene *scene;
QList<Force> forces;
QList<Support> supports;
QList<DistLoad > distributedloads;
QList<Moment> moments;
QList<Profile> profiles;
QList< QPair<double,double> > resForces;
QGraphicsItem *drawSupport(Support s);
QGraphicsItem *drawSingleForce(Force f);
QGraphicsItem *drawMoment(Moment m);
void addSingleForce(Force force);
void addSupport(Support support);
void addMoment(Moment moment);
void reDrawCPanel();
void reDrawScene();
void drawElasticCurve(arma::vec u, arma::vec nodes);
void drawReactions(arma::vec p,arma::vec nodes);
QGraphicsPathItem *elasticCurve = new QGraphicsPathItem;
QGraphicsPathItem *slopeDiagram = new QGraphicsPathItem;
QGraphicsPathItem *momentDiagram = new QGraphicsPathItem;
QGraphicsPathItem *shearDiagram = new QGraphicsPathItem;
QGraphicsItemGroup *reactions = new QGraphicsItemGroup;
double realBeamL;
double LFactor;
QGraphicsItem *drawDistLoad(DistLoad dl);
void addDistLoad(DistLoad dl);
QtVariantPropertyManager *variantManager;
QtProperty *topItem;
QtTreePropertyBrowser *variantEditor;
void printv(std::vector<std::vector<double> > A);
QDialog *materialprops;
Ui::materialproperties matui;
QDialog *distloaddialog;
Ui::distributedloaddialog distui;
QButtonGroup *bg;
Profile activeProfile;
Material activeMaterial;
Material currentMaterial;
Material calculateSectionProperties(Material m);
int currentMaterialTab = 0;
bool first=true;
void redrawProfile();
//void distLoadEquivalent();
Support findPreviousSupport(double posX);
Support findNextSupport(double posX);
int findSupportInterval(double posX);
void redrawComponents();
void drawMomentDiagram(arma::vec p, arma::vec nodes);
void drawShearDiagram(arma::vec p, arma::vec nodes);
void drawSlopeDiagram(arma::vec u, arma::vec nodes);
int scaleFactor=1;
arma::vec disp_nodes;
arma::colvec disp_P;
arma::colvec disp_u;
QList<Material> materials;
};
#endif // BEAM_H