-
Notifications
You must be signed in to change notification settings - Fork 4
/
SLPreferenceDialog.cpp
216 lines (179 loc) · 8.74 KB
/
SLPreferenceDialog.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
#include "SLPreferenceDialog.h"
#include "ui_SLPreferenceDialog.h"
#include "OpenGLContext.h"
#include "Camera.h"
#include "Codec.h"
#include <QSettings>
using namespace std;
SLPreferenceDialog::SLPreferenceDialog(QWidget *parent) : QDialog(parent),
ui(new Ui::SLPreferenceDialog)
{
ui->setupUi(this);
// Query projectors
vector<ScreenInfo> screenList = OpenGLContext::GetScreenInfo();
for(unsigned int i=0; i<screenList.size(); i++){
QString screenString = QString("Screen %1: %2x%3").arg(i).arg(screenList[i].resX).arg(screenList[i].resY);
ui->projectorComboBox->addItem(screenString, i);
}
// Add virtual projector option
ui->projectorComboBox->addItem("SLStudio Virtual Screen", -1);
// Add LC3000 option
#ifdef WITH_LC3000API
ui->projectorComboBox->addItem("LC3000 API", -2);
#endif
// Add LC4500 option
#ifdef WITH_LC4500API
ui->projectorComboBox->addItem("LC4500 API", -3);
#endif
// Query cameras
vector< vector<CameraInfo> > interfaceCameraList = Camera::GetInterfaceCameraList();
for(unsigned int i=0; i<interfaceCameraList.size(); i++){
vector<CameraInfo> cameraList = interfaceCameraList[i];
for(unsigned int j=0; j<cameraList.size(); j++){
QString cameraString = QString("%1: %2").arg(cameraList[j].vendor.c_str()).arg(cameraList[j].model.c_str());
ui->cameraComboBox->addItem(cameraString, QPoint(i, j));
}
}
// Add virtual camera option
ui->cameraComboBox->addItem("SLStudio Virtual Camera", QPoint(-1, -1));
// List pattern modes
ui->patternModeComboBox->addItem("3 Pattern Phase Shift", "CodecPhaseShift3");
ui->patternModeComboBox->addItem("4 Pattern Phase Shift", "CodecPhaseShift4");
ui->patternModeComboBox->addItem("2x3 Pattern Phase Shift", "CodecPhaseShift2x3");
ui->patternModeComboBox->addItem("3 Pattern Phase Shift Unwrap", "CodecPhaseShift3Unwrap");
ui->patternModeComboBox->addItem("N Step Pattern Phase Shift", "CodecPhaseShiftNStep");
ui->patternModeComboBox->addItem("3 Pattern Phase Shift Fast Wrap", "CodecPhaseShift3FastWrap");
ui->patternModeComboBox->addItem("2+1 Pattern Phase Shift", "CodecPhaseShift2p1");
ui->patternModeComboBox->addItem("Descattering Phase Shift", "CodecPhaseShiftDescatter");
ui->patternModeComboBox->addItem("Modulated Phase Shift", "CodecPhaseShiftModulated");
ui->patternModeComboBox->addItem("Micro Phase Shift", "CodecPhaseShiftMicro");
ui->patternModeComboBox->addItem("Fast Ratio", "CodecFastRatio");
ui->patternModeComboBox->addItem("Gray Coding", "CodecGrayCode");
// Set all elements to current application settings
QSettings settings("SLStudio");
QString aquistion = settings.value("aquisition","continuous").toString();
if(aquistion == "continuous")
ui->aquisitioncontinuousRadioButton->setChecked(true);
else
ui->aquisitionSingleRadioButton->setChecked(true);
unsigned int patternModeIndex = ui->patternModeComboBox->findData(settings.value("pattern/mode"));
ui->patternModeComboBox->setCurrentIndex(patternModeIndex);
CodecDir codecDir = (CodecDir)settings.value("pattern/direction", CodecDirHorizontal).toInt();
ui->patternHorizontalCheckBox->setChecked(codecDir & CodecDirHorizontal);
ui->patternVerticalCheckBox->setChecked(codecDir & CodecDirVertical);
int projectorIndex = ui->projectorComboBox->findData(settings.value("projector/screenNumber"));
ui->projectorComboBox->setCurrentIndex(projectorIndex);
ui->diamondPatternCheckBox->setChecked(settings.value("projector/diamondPattern").toBool());
//ui->verticalBaselineCheckbox->setChecked(settings.value("projector/verticalBaseline").toBool());
QPoint cameraInterfaceSetting = QPoint(settings.value("camera/interfaceNumber").toInt(), settings.value("camera/cameraNumber").toInt());
unsigned int cameraIndex = ui->cameraComboBox->findData(cameraInterfaceSetting);
ui->cameraComboBox->setCurrentIndex(cameraIndex);
float shutter = settings.value("camera/shutter", 16.666).toFloat();
ui->shutterDoubleSpinBox->setValue(shutter);
QString triggerMode = settings.value("trigger/mode","hardware").toString();
if(triggerMode == "hardware"){
ui->triggerHardwareRadioButton->setChecked(true);
on_triggerHardwareRadioButton_clicked();
} else {
ui->triggerSoftwareRadioButton->setChecked(true);
on_triggerSoftwareRadioButton_clicked();
}
unsigned int shift = settings.value("trigger/shift",0).toInt();
ui->shiftSpinBox->setValue(shift);
unsigned int delay = settings.value("trigger/delay",50).toInt();
ui->delaySpinBox->setValue(delay);
bool frames = settings.value("writeToDisk/frames",false).toBool();
ui->framesCheckBox->setChecked(frames);
bool pointclouds = settings.value("writeToDisk/pointclouds",false).toBool();
ui->pointCloudsCheckBox->setChecked(pointclouds);
bool tracking = settings.value("writeToDisk/tracking",false).toBool();
ui->trackingCheckBox->setChecked(tracking);
}
SLPreferenceDialog::~SLPreferenceDialog(){
delete ui;
}
void SLPreferenceDialog::on_buttonBox_accepted(){
// Save settings
QSettings settings("SLStudio");
// Aquisition
if(ui->aquisitioncontinuousRadioButton->isChecked())
settings.setValue("aquisition", "continuous");
else
settings.setValue("aquisition", "single");
// Pattern mode
QString patternMode = ui->patternModeComboBox->itemData(ui->patternModeComboBox->currentIndex()).toString();
settings.setValue("pattern/mode", patternMode);
// Pattern direction
bool patternHorizontal = ui->patternHorizontalCheckBox->isChecked();
bool patternVertical = ui->patternVerticalCheckBox->isChecked();
CodecDir dir = CodecDirNone;
if(patternHorizontal && patternVertical)
dir = CodecDirBoth;
else if(patternHorizontal)
dir = CodecDirHorizontal;
else if(patternVertical)
dir = CodecDirVertical;
settings.setValue("pattern/direction", dir);
// Projector
int proj = ui->projectorComboBox->itemData(ui->projectorComboBox->currentIndex()).toInt();
settings.setValue("projector/screenNumber", proj);
bool diamondPattern = ui->diamondPatternCheckBox->isChecked();
settings.setValue("projector/diamondPattern", diamondPattern);
//bool verticalBaseline = ui->verticalBaselineCheckbox->isChecked();
//settings.setValue("projector/verticalBaseline", verticalBaseline);
// Camera
QPoint cam = ui->cameraComboBox->itemData(ui->cameraComboBox->currentIndex()).toPoint();
settings.setValue("camera/interfaceNumber", cam.x());
settings.setValue("camera/cameraNumber", cam.y());
float shutter = ui->shutterDoubleSpinBox->value();
settings.setValue("camera/shutter", shutter);
// Trigger mode
if(ui->triggerHardwareRadioButton->isChecked())
settings.setValue("trigger/mode", "hardware");
else
settings.setValue("trigger/mode", "software");
unsigned int shift = ui->shiftSpinBox->value();
settings.setValue("trigger/shift", shift);
unsigned int delay = ui->delaySpinBox->value();
settings.setValue("trigger/delay", delay);
// Write to disk
bool frames = ui->framesCheckBox->isChecked();
settings.setValue("writeToDisk/frames", frames);
bool pointclouds = ui->pointCloudsCheckBox->isChecked();
settings.setValue("writeToDisk/pointclouds", pointclouds);
bool tracking = ui->trackingCheckBox->isChecked();
settings.setValue("writeToDisk/tracking", tracking);
}
void SLPreferenceDialog::on_triggerHardwareRadioButton_clicked(){
// ui->shiftLayout->setEnabled(true);
// ui->delayLayout->setEnabled(false);
ui->shiftLabel->setEnabled(true);
ui->shiftSpinBox->setEnabled(true);
ui->delayLabel->setEnabled(false);
ui->delaySpinBox->setEnabled(false);
ui->delayMsLabel->setEnabled(false);
}
void SLPreferenceDialog::on_triggerSoftwareRadioButton_clicked(){
// ui->delayLayout->setEnabled(true);
// ui->shiftLayout->setEnabled(false);
ui->shiftLabel->setEnabled(false);
ui->shiftSpinBox->setEnabled(false);
ui->delayLabel->setEnabled(true);
ui->delaySpinBox->setEnabled(true);
ui->delayMsLabel->setEnabled(true);
}
void SLPreferenceDialog::on_cameraComboBox_currentIndexChanged(const QString &arg1){
if(arg1 == "SLStudio Virtual Camera"){
ui->shutterDoubleSpinBox->setEnabled(false);
} else {
ui->shutterDoubleSpinBox->setEnabled(true);
}
}
void SLPreferenceDialog::on_patternHorizontalCheckBox_clicked(){
if(!ui->patternHorizontalCheckBox->isChecked())
ui->patternVerticalCheckBox->setChecked(true);
}
void SLPreferenceDialog::on_patternVerticalCheckBox_clicked(){
if(!ui->patternVerticalCheckBox->isChecked())
ui->patternHorizontalCheckBox->setChecked(true);
}