-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathset.cpp
More file actions
129 lines (120 loc) · 4.48 KB
/
set.cpp
File metadata and controls
129 lines (120 loc) · 4.48 KB
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
#include "set.h"
#include <QMessageBox>
#include <QApplication>
#include <QPushButton>//对于connect函数是必要的,否则出现C2664类型转换错误
#include <QChar>
#include "ui_Set.h"
Set::Set(QMainWindow *parent) : QDialog(parent),
set(new Ui::SetDialog)
{
set->setupUi(this);
createConfigurationFile();
connect(set->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(createConfigurationFile()));
connect(set->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), SIGNAL(outputSet()));
connect(set->buttonBox->button(QDialogButtonBox::Ok),SIGNAL(clicked()), this, SLOT(hide()));
connect(set->buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(createConfigurationFile()));
connect(set->buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), SIGNAL(outputSet()));
connect(set->buttonBox->button(QDialogButtonBox::Cancel),SIGNAL(clicked()),this,SLOT(hide()));
}
void Set::test(bool flag)
{
if(flag == true)
QMessageBox::information(NULL, tr("Test"), tr("Successed!"));
else
QMessageBox::warning(NULL, tr("Test"), tr("Failed!"));
}
void Set::createConfigurationFile()//如果是槽函数,那么void声明不可少
{
board_w = set->boardWidth->value();
board_h = set->boardHeight->value();
proj_w = set->projResH->value();
proj_h = set->projResV->value();
scan_w = set->scanResH->value();
scan_h = set->scanResV->value();
if (set->resMode0->isChecked()){
cam_w = 1280;
cam_h = 1024;
}
cell_w = set->cellWidth->value();
cell_h = set->cellHeight->value();
black_threshold = set->blackThresholdEdit->value();
white_threshold = set->whiteThresholdEdit->value();
if(set->autoContrastCheck->isChecked())
autoContrast = true;
else
autoContrast = false;
if(set->raySamplingCheck->isChecked())
raySampling = true;
else
raySampling = false;
if(set->exportObjCheck->isChecked())
exportObj = 1;
else
exportObj = 0;
if(set->exportPlyCheck->isChecked())
exportPly = 1;
else
exportPly = 0;
if (set->GrayOnly->isChecked())
usedPattern = 0;
else if (set->grayEpi->isChecked())
usedPattern = 1;
else
usedPattern = 2;
haveColor = (set->haveColorCheck->isChecked())?(true):(false);
//createSetFile();
}
void Set::createSetFile()
{
int autoc, autocs, ray;
autoc = boolToInt(autoContrast);
ray = boolToInt(raySampling);
const QString &fileName = saveSetPath +"/set.xml";
QFile file(fileName);
file.open(QIODevice::WriteOnly);
QXmlStreamWriter xmlWriter(&file);
xmlWriter.setAutoFormatting(true);
xmlWriter.writeStartDocument();//写入<?xml version="1.0" encoding="UTF-8"?>
xmlWriter.writeStartElement("Settings");
xmlWriter.writeStartElement("ProjectorResolution");
xmlWriter.writeTextElement("Width",QString::number(proj_w, 10));
xmlWriter.writeTextElement("Height",QString::number(proj_h, 10));
xmlWriter.writeEndElement();
xmlWriter.writeStartElement("CalibrationBoard");
xmlWriter.writeTextElement("BoardWidth",QString::number(board_w, 10));
xmlWriter.writeTextElement("BoardHeight",QString::number(board_h, 10));
xmlWriter.writeEndElement();
xmlWriter.writeStartElement("ProjectorWindow");
xmlWriter.writeStartElement("ScanResolution");
xmlWriter.writeTextElement("Width",QString::number(scan_w, 10));
xmlWriter.writeTextElement("Height",QString::number(scan_h, 10));
xmlWriter.writeEndElement();//由于start两次所以end两次
xmlWriter.writeEndElement();
xmlWriter.writeStartElement("Reconstruction");
xmlWriter.writeTextElement("AutoContrast",0);
xmlWriter.writeTextElement("SaveAutoContrastImages",0);
xmlWriter.writeTextElement("RaySampling",0);
xmlWriter.writeTextElement("BlackThreshold",QString::number(black_threshold, 10));
xmlWriter.writeTextElement("WhiteThreshold",QString::number(white_threshold, 10));
xmlWriter.writeEndElement();
xmlWriter.writeStartElement("Export");
xmlWriter.writeTextElement("Obj",QString::number(exportObj, 10));
xmlWriter.writeTextElement("Ply",QString::number(exportPly, 10));
xmlWriter.writeEndElement();
xmlWriter.writeEndDocument();//写入</Settings>
file.close();
if(file.error()){
test(false);
}
}
int Set::boolToInt(bool input)
{
if(input)
return 1;
else
return 0;
}
void Set::switchLang()
{
set->retranslateUi(this);
}