Marine systems simulation
setlabel.h
1#ifndef SETLABEL_H
2#define SETLABEL_H
3
4#include <QLabel>
5#include <QtGui/QDialog>
6#include "qwt_plot.h"
7#include <qwt_plot_curve.h>
8#include <QTimer>
9#include <qwt_plot_grid.h>
10#include <qwt_plot_panner.h>
11#include "server.h"
12#include <sstream>
13#include <math.h>
14#include <string.h>
15#include <stdlib.h>
16
17
21
22
23
24class setlabel : public QLabel
25
26{
27Q_OBJECT
28
29public:
30 setlabel(QWidget *parent = 0){}
31
32public slots:
33 void setlabelfuncSOG(struct myOutputStruct FHSimData)
34 {
35
36 std::ostringstream strs;
37
38 double displaytmp1 = FHSimData.display[0]*100;
39 int displaytmp2 = displaytmp1;
40 double display = displaytmp2/100.0;
41 strs.precision(2);
42
43 strs.setf(std::ios::fixed,std::ios::floatfield);
44 strs << display;
45
46 std::string str = strs.str();
47
48 int des = str.size() - str.find(".");
49 QString qstr ;
50 if( des < 2 )
51 qstr = QString::fromStdString(str+"0");
52 else
53 qstr = QString::fromStdString(str);
54
55 this->setText(qstr);
56
57
58 };
59
60 void setlabelfuncCOG(struct myOutputStruct FHSimData)
61 {
62 std::ostringstream strs;
63
64 double displaytmp1 = FHSimData.display[2]*100;
65 int displaytmp2 = displaytmp1;
66 double display = displaytmp2/100.0;
67 strs.precision(2);
68
69 strs.setf(std::ios::fixed,std::ios::floatfield);
70 strs << display;
71
72 std::string str = strs.str();
73
74 int des = str.size() - str.find(".");
75 QString qstr ;
76 if( des < 2 )
77 qstr = QString::fromStdString(str+"0");
78 else
79 qstr = QString::fromStdString(str);
80
81 this->setText(qstr);
82
83 };
84
85 void setlabelfuncROT(struct myOutputStruct FHSimData)
86 {
87 std::ostringstream strs;
88
89 double displaytmp1 = FHSimData.display[1]*100;
90 int displaytmp2 = displaytmp1;
91 double display = displaytmp2/100.0;
92 strs.precision(2);
93
94 strs.setf(std::ios::fixed,std::ios::floatfield);
95 strs << display;
96
97 std::string str = strs.str();
98
99 int des = str.size() - str.find(".");
100 QString qstr ;
101 if( des < 2 )
102 qstr = QString::fromStdString(str+"0");
103 else
104 qstr = QString::fromStdString(str);
105
106 this->setText(qstr);
107 };
108
109};
110
111#endif
Definition: setlabel.h:26
Definition: myOutputStruct.h:5