9 |
jakw |
1 |
#include "SMPreferenceDialog.h"
|
|
|
2 |
#include "ui_SMPreferenceDialog.h"
|
|
|
3 |
|
|
|
4 |
#include "OpenGLContext.h"
|
|
|
5 |
#include "Camera.h"
|
41 |
jakw |
6 |
#include "Algorithm.h"
|
9 |
jakw |
7 |
|
|
|
8 |
using namespace std;
|
|
|
9 |
|
|
|
10 |
SMPreferenceDialog::SMPreferenceDialog(QWidget *parent) : QDialog(parent), ui(new Ui::SMPreferenceDialog) {
|
|
|
11 |
ui->setupUi(this);
|
|
|
12 |
|
|
|
13 |
// Query projectors
|
|
|
14 |
vector<ScreenInfo> screenList = OpenGLContext::GetScreenInfo();
|
|
|
15 |
for(unsigned int i=0; i<screenList.size(); i++){
|
|
|
16 |
QString screenString = QString("Screen %1: %2x%3").arg(i).arg(screenList[i].resX).arg(screenList[i].resY);
|
|
|
17 |
ui->projectorComboBox->addItem(screenString, i);
|
|
|
18 |
}
|
|
|
19 |
|
|
|
20 |
// Add LC3000 option
|
|
|
21 |
#ifdef WITH_LC3000API
|
|
|
22 |
ui->projectorComboBox->addItem("LC3000 API", -2);
|
|
|
23 |
#endif
|
|
|
24 |
// Add LC4500 option
|
|
|
25 |
#ifdef WITH_LC4500API
|
|
|
26 |
ui->projectorComboBox->addItem("LC4500 API", -3);
|
|
|
27 |
#endif
|
|
|
28 |
|
|
|
29 |
// Query cameras
|
159 |
jakw |
30 |
vector< vector<CameraInfo> > interfaceCameraList = CameraFactory::GetInterfaceCameraList();
|
9 |
jakw |
31 |
for(unsigned int i=0; i<interfaceCameraList.size(); i++){
|
|
|
32 |
vector<CameraInfo> cameraList = interfaceCameraList[i];
|
|
|
33 |
for(unsigned int j=0; j<cameraList.size(); j++){
|
53 |
jakw |
34 |
QString cameraString = QString("%1: %2 # %3").arg(cameraList[j].vendor.c_str()).arg(cameraList[j].model.c_str()).arg(cameraList[j].serialNumber);
|
9 |
jakw |
35 |
ui->camera0ComboBox->addItem(cameraString, QPoint(i, j));
|
|
|
36 |
ui->camera1ComboBox->addItem(cameraString, QPoint(i, j));
|
|
|
37 |
}
|
|
|
38 |
}
|
|
|
39 |
|
|
|
40 |
// List pattern modes
|
75 |
jakw |
41 |
ui->algorithmComboBox->addItem("Gray Coding", "GrayCode");
|
166 |
jakw |
42 |
ui->algorithmComboBox->addItem("Gray Coding Horizontal+Vertical (experimental)", "GrayCodeHorzVert");
|
131 |
jakw |
43 |
ui->algorithmComboBox->addItem("Phase Shifting 2 frequency heterodyne", "PhaseShiftTwoFreq");
|
166 |
jakw |
44 |
ui->algorithmComboBox->addItem("Phase Shifting 3 frequency (experimental)", "PhaseShiftThreeFreq");
|
200 |
jakw |
45 |
ui->algorithmComboBox->addItem("Phase Shifting 2 frequency horz.+vert. (experimental)", "PhaseShiftTwoFreqHorzVert");
|
192 |
jakw |
46 |
ui->algorithmComboBox->addItem("Embedded Phase Shifting (experimental)", "PhaseShiftEmbedded");
|
182 |
jakw |
47 |
ui->algorithmComboBox->addItem("Line Shifting", "LineShift");
|
9 |
jakw |
48 |
|
|
|
49 |
// Set all elements to current application settings
|
75 |
jakw |
50 |
unsigned int patternModeIndex = ui->algorithmComboBox->findData(settings.value("algorithm"));
|
|
|
51 |
ui->algorithmComboBox->setCurrentIndex(patternModeIndex);
|
9 |
jakw |
52 |
|
166 |
jakw |
53 |
// Projector
|
9 |
jakw |
54 |
int projectorIndex = ui->projectorComboBox->findData(settings.value("projector/screenNumber"));
|
|
|
55 |
ui->projectorComboBox->setCurrentIndex(projectorIndex);
|
|
|
56 |
ui->diamondPatternCheckBox->setChecked(settings.value("projector/diamondPattern").toBool());
|
|
|
57 |
|
166 |
jakw |
58 |
// Cameras
|
169 |
jakw |
59 |
QPoint camera0InterfaceSetting = QPoint(settings.value("camera0/interfaceNumber",-1).toInt(), settings.value("camera0/cameraNumber",-1).toInt());
|
9 |
jakw |
60 |
unsigned int camera0Index = ui->camera0ComboBox->findData(camera0InterfaceSetting);
|
|
|
61 |
ui->camera0ComboBox->setCurrentIndex(camera0Index);
|
|
|
62 |
|
169 |
jakw |
63 |
QPoint camera1InterfaceSetting = QPoint(settings.value("camera1/interfaceNumber",-1).toInt(), settings.value("camera1/cameraNumber",-1).toInt());
|
9 |
jakw |
64 |
unsigned int camera1Index = ui->camera1ComboBox->findData(camera1InterfaceSetting);
|
|
|
65 |
ui->camera1ComboBox->setCurrentIndex(camera1Index);
|
|
|
66 |
|
255 |
- |
67 |
// Shutter
|
244 |
jakw |
68 |
double shutter = settings.value("camera/shutter", 50.0/3.0).toDouble();
|
|
|
69 |
ui->shutterTimeLabel->setText(QString::number(shutter));
|
|
|
70 |
ui->shutterSpinBox->setValue(shutter/(50.0/3.0));
|
9 |
jakw |
71 |
|
255 |
- |
72 |
QString shuttersString = settings.value("camera/shuttersHDR").toString();
|
|
|
73 |
QStringList list = shuttersString.split("/", QString::SkipEmptyParts);
|
|
|
74 |
std::vector<float> shutters(list.size());
|
|
|
75 |
for(int i=0; i<list.size(); i++)
|
|
|
76 |
shutters[i] = list[i].toFloat();
|
|
|
77 |
bool HDR = !shutters.empty();
|
|
|
78 |
int HDRcount = shutters.size();
|
|
|
79 |
ui->HDRCheckBox->setChecked(HDR);
|
|
|
80 |
ui->HDRCountSpinBox->setValue(HDRcount);
|
|
|
81 |
ui->HDRLabel->setEnabled(HDR);
|
|
|
82 |
ui->HDRCountSpinBox->setEnabled(HDR);
|
|
|
83 |
|
166 |
jakw |
84 |
// Trigger mode
|
53 |
jakw |
85 |
QString triggerMode = settings.value("trigger/mode","software").toString();
|
9 |
jakw |
86 |
if(triggerMode == "hardware"){
|
|
|
87 |
ui->triggerHardwareRadioButton->setChecked(true);
|
|
|
88 |
on_triggerHardwareRadioButton_clicked();
|
|
|
89 |
} else {
|
|
|
90 |
ui->triggerSoftwareRadioButton->setChecked(true);
|
|
|
91 |
on_triggerSoftwareRadioButton_clicked();
|
|
|
92 |
}
|
|
|
93 |
unsigned int shift = settings.value("trigger/shift",0).toInt();
|
|
|
94 |
ui->shiftSpinBox->setValue(shift);
|
54 |
jakw |
95 |
unsigned int delay = settings.value("trigger/delay",120).toInt();
|
9 |
jakw |
96 |
ui->delaySpinBox->setValue(delay);
|
|
|
97 |
|
166 |
jakw |
98 |
// Calibration pattern
|
169 |
jakw |
99 |
unsigned int patternSizeX = settings.value("calibration/patternSizeX", 22).toInt();
|
167 |
jakw |
100 |
ui->patternSizeXSpinBox->setValue(patternSizeX);
|
169 |
jakw |
101 |
unsigned int patternSizeY = settings.value("calibration/patternSizeY", 13).toInt();
|
167 |
jakw |
102 |
ui->patternSizeYSpinBox->setValue(patternSizeY);
|
169 |
jakw |
103 |
float squareSize = settings.value("calibration/squareSize", 15.0).toFloat();
|
167 |
jakw |
104 |
ui->squareSizeSpinBox->setValue(squareSize);
|
9 |
jakw |
105 |
}
|
|
|
106 |
|
|
|
107 |
SMPreferenceDialog::~SMPreferenceDialog(){
|
|
|
108 |
delete ui;
|
|
|
109 |
}
|
|
|
110 |
|
|
|
111 |
void SMPreferenceDialog::on_buttonBox_accepted(){
|
|
|
112 |
|
|
|
113 |
// Save settings
|
|
|
114 |
|
|
|
115 |
// Pattern mode
|
75 |
jakw |
116 |
QString patternMode = ui->algorithmComboBox->itemData(ui->algorithmComboBox->currentIndex()).toString();
|
71 |
jakw |
117 |
settings.setValue("algorithm", patternMode);
|
9 |
jakw |
118 |
|
|
|
119 |
// Projector
|
225 |
jakw |
120 |
if(ui->projectorComboBox->currentIndex() >= 0){
|
|
|
121 |
int proj = ui->projectorComboBox->itemData(ui->projectorComboBox->currentIndex()).toInt();
|
|
|
122 |
settings.setValue("projector/screenNumber", proj);
|
|
|
123 |
vector<ScreenInfo> screenList = OpenGLContext::GetScreenInfo();
|
|
|
124 |
settings.setValue("projector/resX", screenList[proj].resX);
|
|
|
125 |
settings.setValue("projector/resY", screenList[proj].resY);
|
|
|
126 |
}
|
9 |
jakw |
127 |
bool diamondPattern = ui->diamondPatternCheckBox->isChecked();
|
|
|
128 |
settings.setValue("projector/diamondPattern", diamondPattern);
|
|
|
129 |
//bool verticalBaseline = ui->verticalBaselineCheckbox->isChecked();
|
|
|
130 |
//settings.setValue("projector/verticalBaseline", verticalBaseline);
|
|
|
131 |
|
|
|
132 |
// Cameras
|
225 |
jakw |
133 |
if(ui->camera0ComboBox->currentIndex() >=0){
|
|
|
134 |
QPoint cam0 = ui->camera0ComboBox->itemData(ui->camera0ComboBox->currentIndex()).toPoint();
|
|
|
135 |
settings.setValue("camera0/interfaceNumber", cam0.x());
|
|
|
136 |
settings.setValue("camera0/cameraNumber", cam0.y());
|
|
|
137 |
}
|
|
|
138 |
if(ui->camera1ComboBox->currentIndex() >=0){
|
|
|
139 |
QPoint cam1 = ui->camera1ComboBox->itemData(ui->camera1ComboBox->currentIndex()).toPoint();
|
|
|
140 |
settings.setValue("camera1/interfaceNumber", cam1.x());
|
|
|
141 |
settings.setValue("camera1/cameraNumber", cam1.y());
|
|
|
142 |
}
|
9 |
jakw |
143 |
|
255 |
- |
144 |
// Shutter
|
244 |
jakw |
145 |
double shutter = ui->shutterSpinBox->value() * 50.0/3.0;
|
9 |
jakw |
146 |
settings.setValue("camera/shutter", shutter);
|
|
|
147 |
|
255 |
- |
148 |
QString shuttersHDR = "";
|
|
|
149 |
if (ui->HDRCheckBox->isChecked()) {
|
|
|
150 |
for(int i = 0; i < ui->HDRCountSpinBox->value() - 1; ++i) {
|
|
|
151 |
shuttersHDR += QString::number(shutter) + QString("/");
|
|
|
152 |
shutter *= 2;
|
|
|
153 |
}
|
|
|
154 |
shuttersHDR += QString::number(shutter);
|
|
|
155 |
}
|
|
|
156 |
settings.setValue("camera/shuttersHDR", shuttersHDR);
|
|
|
157 |
|
9 |
jakw |
158 |
// Trigger mode
|
|
|
159 |
if(ui->triggerHardwareRadioButton->isChecked())
|
|
|
160 |
settings.setValue("trigger/mode", "hardware");
|
|
|
161 |
else
|
|
|
162 |
settings.setValue("trigger/mode", "software");
|
250 |
jakw |
163 |
auto shift = ui->shiftSpinBox->value();
|
9 |
jakw |
164 |
settings.setValue("trigger/shift", shift);
|
250 |
jakw |
165 |
auto delay = ui->delaySpinBox->value();
|
9 |
jakw |
166 |
settings.setValue("trigger/delay", delay);
|
|
|
167 |
|
164 |
raly |
168 |
// Calibration pattern
|
250 |
jakw |
169 |
auto patternSizeX = ui->patternSizeXSpinBox->value();
|
166 |
jakw |
170 |
settings.setValue("calibration/patternSizeX", patternSizeX);
|
250 |
jakw |
171 |
auto patternSizeY = ui->patternSizeYSpinBox->value();
|
166 |
jakw |
172 |
settings.setValue("calibration/patternSizeY", patternSizeY);
|
250 |
jakw |
173 |
auto squareSize = ui->squareSizeSpinBox->value();
|
166 |
jakw |
174 |
settings.setValue("calibration/squareSize", squareSize);
|
164 |
raly |
175 |
|
9 |
jakw |
176 |
}
|
|
|
177 |
|
|
|
178 |
|
|
|
179 |
|
|
|
180 |
void SMPreferenceDialog::on_triggerHardwareRadioButton_clicked(){
|
|
|
181 |
|
|
|
182 |
ui->shiftLabel->setEnabled(true);
|
|
|
183 |
ui->shiftSpinBox->setEnabled(true);
|
|
|
184 |
ui->delayLabel->setEnabled(false);
|
|
|
185 |
ui->delaySpinBox->setEnabled(false);
|
|
|
186 |
ui->delayMsLabel->setEnabled(false);
|
|
|
187 |
}
|
|
|
188 |
|
|
|
189 |
void SMPreferenceDialog::on_triggerSoftwareRadioButton_clicked(){
|
|
|
190 |
|
|
|
191 |
ui->shiftLabel->setEnabled(false);
|
|
|
192 |
ui->shiftSpinBox->setEnabled(false);
|
|
|
193 |
ui->delayLabel->setEnabled(true);
|
|
|
194 |
ui->delaySpinBox->setEnabled(true);
|
|
|
195 |
ui->delayMsLabel->setEnabled(true);
|
|
|
196 |
}
|
244 |
jakw |
197 |
|
|
|
198 |
void SMPreferenceDialog::on_shutterSpinBox_valueChanged(int arg1)
|
|
|
199 |
{
|
|
|
200 |
ui->shutterTimeLabel->setText(QString::number(50.0/3.0 * arg1));
|
|
|
201 |
}
|
255 |
- |
202 |
|
|
|
203 |
void SMPreferenceDialog::on_HDRCheckBox_toggled(bool checked)
|
|
|
204 |
{
|
|
|
205 |
ui->HDRLabel->setEnabled(checked);
|
|
|
206 |
ui->HDRCountSpinBox->setEnabled(checked);
|
|
|
207 |
}
|