forked from abcvincent/OpencvDevelop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
variatedialog.cpp
349 lines (260 loc) · 10.8 KB
/
variatedialog.cpp
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
#include "variatedialog.h"
//#include "ui_variatedialog.h"
#include "mainwindow.h"
#include <QString>
#include <QMessageBox>
VariateDialog::VariateDialog(QString title,
QList<QString> ListVariateDlg,
QString text,
int VariaeCount,
QList<QString> ListCV_CodeDlg1,
QList<QString> ListCV_CodeDlg2,
QList<QString> ListCV_CodeDlg3)//:QDialog(parent)
{
m_title=title;
m_text=text;
m_listVatiate=ListVariateDlg;
m_listCV_Code1=ListCV_CodeDlg1;
m_listCV_Code2=ListCV_CodeDlg2;
m_listCV_Code3=ListCV_CodeDlg3;
cancelDlg=0;
if(m_title.isEmpty()) {m_title="无";}
if(m_text.isEmpty()) {m_text="无";}
setWindowTitle(m_title);
setModal(true);
setFixedSize(380,220+VariaeCount*30);
combox=new QComboBox(this);
QLabel *labName1=new QLabel(this);//算子标题
QLabel *labName12=new QLabel(this);//算子解释
QLabel *labName2=new QLabel(this);//输入变量
QLabel *labName3=new QLabel(this);//输出变量
QFrame *line=new QFrame(this);
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
QFrame *line2=new QFrame(this);
line2->setFrameShape(QFrame::HLine);
line2->setFrameShadow(QFrame::Sunken);
QFont lb_font;
lb_font.setPointSize(12);
QPushButton *btOK=new QPushButton(this);
QPushButton *btCancel=new QPushButton(this);
QLineEdit *lineEdit1=new QLineEdit;//输出变量填写框
QGridLayout *layouts=new QGridLayout;//创建对齐对象
// 只能输入英文和数字
// QRegExp regx("[a-zA-Z0-9]+$");
QRegExp regx("^[a-zA-Z][a-zA-Z0-9_]*$");//开头必须英文
QValidator *validator = new QRegExpValidator(regx,this);
lineEdit1->setValidator(validator);
//不能重复变量
// lineEdit2->setText("1");
lineEdit1->setToolTip("只能输入英文及数字");
btOK->setText("确定");
btCancel->setText("取消");
labName1->setText(m_title);
labName12->setText(m_text);
labName2->setText("输入对象 (Input src):");
labName3->setText("输出变量(Output dst):");
labName1->setFont(lb_font);//标题字体
layouts->addWidget(labName1,0,1,1,2);
layouts->addWidget(labName12,1,1,1,2);
layouts->addWidget(line,2,1,1,2);
layouts->addWidget(labName2,3,1,1,1);
layouts->addWidget(combox,3,2,1,1);
layouts->addWidget(labName3,4,1,1,1);
layouts->addWidget(lineEdit1,4,2,1,1);
for(int i=0;i<m_listVatiate.size();++i)
{
QString stri=m_listVatiate.at(i);//QString::number(i,10,0);
combox->addItem(stri);
}
if(m_listCV_Code1.at(0)=="Yes_combox")//列表
{
// QMessageBox mesg;
// mesg.about(NULL,"提示",m_listCV_Code1.at(0));
comboxVar1=new QComboBox(this);//变量box
for(int i=1;i<m_listCV_Code1.size();++i)
{
QString stri=m_listCV_Code1.at(i);//QString::number(i,10,0);
comboxVar1->addItem(stri);
}
QLabel *labNameVar1=new QLabel(this);
labNameVar1->setText("变量值1(int flipCode1):");
layouts->addWidget(labNameVar1,5,1,1,1);
layouts->addWidget(comboxVar1,5,2,1,1);
}
if(m_listCV_Code1.at(0)=="Yes_Number_int")//只呢输入数字整数
{
// QMessageBox mesg;
// mesg.about(NULL,"提示",m_listCV_Code1.at(0));
lineEditVar1=new QLineEdit(this);
QLabel *labNameVar1=new QLabel(this);
labNameVar1->setText("变量值1(int flipCode1):");
layouts->addWidget(labNameVar1,5,1,1,1);
layouts->addWidget(lineEditVar1,5,2,1,1);
//只能输入整数
QRegExp rx("^-?\\d+$");
QRegExpValidator *pReg = new QRegExpValidator(rx, this);
lineEditVar1->setValidator(pReg);
connect(lineEditVar1,SIGNAL(textChanged(QString)),this,SLOT(getLineEdit1(QString)));
}
if(m_listCV_Code1.at(0)=="Yes_Number_double")//输入浮点数
{
lineEditVar1=new QLineEdit(this);
QLabel *labNameVar1=new QLabel(this);
labNameVar1->setText("变量值1(int flipCode1):");
layouts->addWidget(labNameVar1,5,1,1,1);
layouts->addWidget(lineEditVar1,5,2,1,1);
//限制浮点数输入范围为[-999999.9999,999999.9999]
QRegExp rx("^(-?[0]|-?[1-9][0-9]{0,5})(?:\\.\\d{1,4})?$|(^\\t?$)");
QRegExpValidator *pReg = new QRegExpValidator(rx, this);
lineEditVar1->setValidator(pReg);
connect(lineEditVar1,SIGNAL(textChanged(QString)),this,SLOT(getLineEdit1(QString)));
}
if(m_listCV_Code2.at(0)=="Yes_combox")
{
comboxVar2=new QComboBox(this);//变量box
for(int i=1;i<m_listCV_Code2.size();++i)
{
QString stri=m_listCV_Code2.at(i);//QString::number(i,10,0);
comboxVar2->addItem(stri);
}
QLabel *labNameVar2=new QLabel(this);
labNameVar2->setText("变量值2(int flipCode2):");
layouts->addWidget(labNameVar2,6,1,1,1);
layouts->addWidget(comboxVar2,6,2,1,1);
}
if(m_listCV_Code2.at(0)=="Yes_Number_int")
{
lineEditVar2=new QLineEdit(this);
QLabel *labNameVar2=new QLabel(this);
labNameVar2->setText("变量值2(int flipCode2):");
layouts->addWidget(labNameVar2,6,1,1,1);
layouts->addWidget(lineEditVar2,6,2,1,1);
//只能输入整数
QRegExp rx("^-?\\d+$");
QRegExpValidator *pReg = new QRegExpValidator(rx, this);
lineEditVar2->setValidator(pReg);
connect(lineEditVar2,SIGNAL(textChanged(QString)),this,SLOT(getLineEdit2(QString)));
}
if(m_listCV_Code2.at(0)=="Yes_Number_double")//输入浮点数
{
lineEditVar2=new QLineEdit(this);
QLabel *labNameVar2=new QLabel(this);
labNameVar2->setText("变量值2(int flipCode2):");
layouts->addWidget(labNameVar2,6,1,1,1);
layouts->addWidget(lineEditVar2,6,2,1,1);
//限制浮点数输入范围为[-999999.9999,999999.9999]
QRegExp rx("^(-?[0]|-?[1-9][0-9]{0,5})(?:\\.\\d{1,4})?$|(^\\t?$)");
QRegExpValidator *pReg = new QRegExpValidator(rx, this);
lineEditVar2->setValidator(pReg);
connect(lineEditVar2,SIGNAL(textChanged(QString)),this,SLOT(getLineEdit2(QString)));
}
if(m_listCV_Code3.at(0)=="Yes_combox")
{
comboxVar3=new QComboBox(this);//变量box
for(int i=1;i<m_listCV_Code3.size();++i)
{
QString stri=m_listCV_Code3.at(i);//QString::number(i,10,0);
comboxVar3->addItem(stri);
}
QLabel *labNameVar3=new QLabel(this);
labNameVar3->setText("变量值3(int flipCode3):");
layouts->addWidget(labNameVar3,7,1,1,1);
layouts->addWidget(comboxVar3,7,2,1,1);
}
if(m_listCV_Code3.at(0)=="Yes_Number_int")
{
lineEditVar3=new QLineEdit(this);
QLabel *labNameVar3=new QLabel(this);
labNameVar3->setText("变量值2(int flipCode2):");
layouts->addWidget(labNameVar3,7,1,1,1);
layouts->addWidget(lineEditVar3,7,2,1,1);
//只能输入整数
QRegExp rx("^-?\\d+$");
QRegExpValidator *pReg = new QRegExpValidator(rx, this);
lineEditVar3->setValidator(pReg);
connect(lineEditVar3,SIGNAL(textChanged(QString)),this,SLOT(getLineEdit3(QString)));
}
if(m_listCV_Code3.at(0)=="Yes_Number_double")//输入浮点数
{
lineEditVar3=new QLineEdit(this);
QLabel *labNameVar3=new QLabel(this);
labNameVar3->setText("变量值1(int flipCode1):");
layouts->addWidget(labNameVar3,7,1,1,1);
layouts->addWidget(lineEditVar3,7,2,1,1);
//限制浮点数输入范围为[-999999.9999,999999.9999]
QRegExp rx("^(-?[0]|-?[1-9][0-9]{0,5})(?:\\.\\d{1,4})?$|(^\\t?$)");
QRegExpValidator *pReg = new QRegExpValidator(rx, this);
lineEditVar3->setValidator(pReg);
connect(lineEditVar3,SIGNAL(textChanged(QString)),this,SLOT(getLineEdit3(QString)));
}
// comboxVar1=new QComboBox(this);//变量box
// comboxVar2=new QComboBox(this);//变量box
// comboxVar3=new QComboBox(this);//变量box
// QLabel *labName4=new QLabel(this);
// QLabel *labName5=new QLabel(this);
// QLineEdit *lineEdit2=new QLineEdit;
// QLineEdit *lineEdit3=new QLineEdit;
// lineEdit2->setEnabled(false);
// lineEdit3->setEnabled(false);
// labName4->setText("变量值1(int flipCode1):");
// labName5->setText("变量值2(int flipCode2):");
// //限制浮点数输入范围为[-999999.9999,999999.9999]
// QRegExp rx("^(-?[0]|-?[1-9][0-9]{0,5})(?:\\.\\d{1,4})?$|(^\\t?$)");
// QRegExpValidator *pReg = new QRegExpValidator(rx, this);
// lineEdit2->setValidator(pReg);
// lineEdit3->setValidator(pReg);
// layouts->addWidget(labName4,5,1,1,1);
// layouts->addWidget(lineEdit2,5,2,1,1);
// layouts->addWidget(labName5,6,1,1,1);
// layouts->addWidget(lineEdit3,6,2,1,1);
layouts->addWidget(line2,6+VariaeCount,1,1,2);
layouts->addWidget(btCancel,7+VariaeCount,1,1,1);
layouts->addWidget(btOK,7+VariaeCount,2,1,1);
layouts->setVerticalSpacing(10);
setLayout(layouts);
// lineEditStr1=combox->currentText();
// lineEditStr=lineEdit1->text();
// QString var1,var2;
// var1=lineEdit2->text();//输入变量1
// var2=lineEdit3->text();//输入变量2
// double val=str.toDouble();
// lineInt1=QString::number(var1,10,0);
// lineInt2=QString::number(var2,10,0);
connect(btCancel,SIGNAL(clicked(bool)),this,SLOT(close()));
connect(btOK,SIGNAL(clicked(bool)),this,SLOT(sendDlg(bool)));
connect(lineEdit1,SIGNAL(textChanged(QString)),this,SLOT(getLineEdit(QString)));
}
void VariateDialog::sendDlg(bool)
{
comboxStr=combox->currentText();
if(m_listCV_Code1.at(0)=="Yes_combox") {lineEditStr1=comboxVar1->currentText();}
if(m_listCV_Code2.at(0)=="Yes_combox") {lineEditStr2=comboxVar2->currentText();}
if(m_listCV_Code3.at(0)=="Yes_combox") {lineEditStr3=comboxVar3->currentText();}
cancelDlg=1;
this->close();
}
void VariateDialog::getLineEdit(QString linestr)
{
for(int i=0;i<m_listVatiate.size();++i)
{
if(linestr==m_listVatiate.at(i)){
//QString str=QString::number(ui->mdiArea->subWindowList().size(),10,0);
QMessageBox mesg;
mesg.about(NULL,"提示","输出变量不能等于输入变量");
}
else{lineEditStr=linestr;}
}
}
void VariateDialog::getLineEdit1(QString linestr)
{
lineEditStr1=linestr;
}
void VariateDialog::getLineEdit2(QString linestr)
{
lineEditStr2=linestr;
}
void VariateDialog::getLineEdit3(QString linestr)
{
lineEditStr3=linestr;
}