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");
|
182 |
jakw |
45 |
ui->algorithmComboBox->addItem("Line Shifting", "LineShift");
|
9 |
jakw |
46 |
|
|
|
47 |
// Set all elements to current application settings
|
75 |
jakw |
48 |
unsigned int patternModeIndex = ui->algorithmComboBox->findData(settings.value("algorithm"));
|
|
|
49 |
ui->algorithmComboBox->setCurrentIndex(patternModeIndex);
|
9 |
jakw |
50 |
|
166 |
jakw |
51 |
// Projector
|
9 |
jakw |
52 |
int projectorIndex = ui->projectorComboBox->findData(settings.value("projector/screenNumber"));
|
|
|
53 |
ui->projectorComboBox->setCurrentIndex(projectorIndex);
|
|
|
54 |
ui->diamondPatternCheckBox->setChecked(settings.value("projector/diamondPattern").toBool());
|
|
|
55 |
|
166 |
jakw |
56 |
// Cameras
|
169 |
jakw |
57 |
QPoint camera0InterfaceSetting = QPoint(settings.value("camera0/interfaceNumber",-1).toInt(), settings.value("camera0/cameraNumber",-1).toInt());
|
9 |
jakw |
58 |
unsigned int camera0Index = ui->camera0ComboBox->findData(camera0InterfaceSetting);
|
|
|
59 |
ui->camera0ComboBox->setCurrentIndex(camera0Index);
|
|
|
60 |
|
169 |
jakw |
61 |
QPoint camera1InterfaceSetting = QPoint(settings.value("camera1/interfaceNumber",-1).toInt(), settings.value("camera1/cameraNumber",-1).toInt());
|
9 |
jakw |
62 |
unsigned int camera1Index = ui->camera1ComboBox->findData(camera1InterfaceSetting);
|
|
|
63 |
ui->camera1ComboBox->setCurrentIndex(camera1Index);
|
|
|
64 |
|
|
|
65 |
float shutter = settings.value("camera/shutter", 16.666).toFloat();
|
|
|
66 |
ui->shutterDoubleSpinBox->setValue(shutter);
|
|
|
67 |
|
166 |
jakw |
68 |
// Trigger mode
|
53 |
jakw |
69 |
QString triggerMode = settings.value("trigger/mode","software").toString();
|
9 |
jakw |
70 |
if(triggerMode == "hardware"){
|
|
|
71 |
ui->triggerHardwareRadioButton->setChecked(true);
|
|
|
72 |
on_triggerHardwareRadioButton_clicked();
|
|
|
73 |
} else {
|
|
|
74 |
ui->triggerSoftwareRadioButton->setChecked(true);
|
|
|
75 |
on_triggerSoftwareRadioButton_clicked();
|
|
|
76 |
}
|
|
|
77 |
unsigned int shift = settings.value("trigger/shift",0).toInt();
|
|
|
78 |
ui->shiftSpinBox->setValue(shift);
|
54 |
jakw |
79 |
unsigned int delay = settings.value("trigger/delay",120).toInt();
|
9 |
jakw |
80 |
ui->delaySpinBox->setValue(delay);
|
|
|
81 |
|
166 |
jakw |
82 |
// Calibration pattern
|
169 |
jakw |
83 |
unsigned int patternSizeX = settings.value("calibration/patternSizeX", 22).toInt();
|
167 |
jakw |
84 |
ui->patternSizeXSpinBox->setValue(patternSizeX);
|
169 |
jakw |
85 |
unsigned int patternSizeY = settings.value("calibration/patternSizeY", 13).toInt();
|
167 |
jakw |
86 |
ui->patternSizeYSpinBox->setValue(patternSizeY);
|
169 |
jakw |
87 |
float squareSize = settings.value("calibration/squareSize", 15.0).toFloat();
|
167 |
jakw |
88 |
ui->squareSizeSpinBox->setValue(squareSize);
|
9 |
jakw |
89 |
}
|
|
|
90 |
|
|
|
91 |
SMPreferenceDialog::~SMPreferenceDialog(){
|
|
|
92 |
delete ui;
|
|
|
93 |
}
|
|
|
94 |
|
|
|
95 |
void SMPreferenceDialog::on_buttonBox_accepted(){
|
|
|
96 |
|
|
|
97 |
// Save settings
|
|
|
98 |
|
|
|
99 |
// Pattern mode
|
75 |
jakw |
100 |
QString patternMode = ui->algorithmComboBox->itemData(ui->algorithmComboBox->currentIndex()).toString();
|
71 |
jakw |
101 |
settings.setValue("algorithm", patternMode);
|
9 |
jakw |
102 |
|
|
|
103 |
// Projector
|
|
|
104 |
int proj = ui->projectorComboBox->itemData(ui->projectorComboBox->currentIndex()).toInt();
|
|
|
105 |
settings.setValue("projector/screenNumber", proj);
|
|
|
106 |
bool diamondPattern = ui->diamondPatternCheckBox->isChecked();
|
|
|
107 |
settings.setValue("projector/diamondPattern", diamondPattern);
|
36 |
jakw |
108 |
vector<ScreenInfo> screenList = OpenGLContext::GetScreenInfo();
|
|
|
109 |
settings.setValue("projector/resX", screenList[proj].resX);
|
|
|
110 |
settings.setValue("projector/resY", screenList[proj].resY);
|
9 |
jakw |
111 |
//bool verticalBaseline = ui->verticalBaselineCheckbox->isChecked();
|
|
|
112 |
//settings.setValue("projector/verticalBaseline", verticalBaseline);
|
|
|
113 |
|
|
|
114 |
// Cameras
|
|
|
115 |
QPoint cam0 = ui->camera0ComboBox->itemData(ui->camera0ComboBox->currentIndex()).toPoint();
|
|
|
116 |
settings.setValue("camera0/interfaceNumber", cam0.x());
|
|
|
117 |
settings.setValue("camera0/cameraNumber", cam0.y());
|
|
|
118 |
|
|
|
119 |
QPoint cam1 = ui->camera1ComboBox->itemData(ui->camera1ComboBox->currentIndex()).toPoint();
|
|
|
120 |
settings.setValue("camera1/interfaceNumber", cam1.x());
|
|
|
121 |
settings.setValue("camera1/cameraNumber", cam1.y());
|
|
|
122 |
|
|
|
123 |
float shutter = ui->shutterDoubleSpinBox->value();
|
|
|
124 |
settings.setValue("camera/shutter", shutter);
|
|
|
125 |
|
|
|
126 |
// Trigger mode
|
|
|
127 |
if(ui->triggerHardwareRadioButton->isChecked())
|
|
|
128 |
settings.setValue("trigger/mode", "hardware");
|
|
|
129 |
else
|
|
|
130 |
settings.setValue("trigger/mode", "software");
|
|
|
131 |
unsigned int shift = ui->shiftSpinBox->value();
|
|
|
132 |
settings.setValue("trigger/shift", shift);
|
|
|
133 |
unsigned int delay = ui->delaySpinBox->value();
|
|
|
134 |
settings.setValue("trigger/delay", delay);
|
|
|
135 |
|
164 |
raly |
136 |
// Calibration pattern
|
166 |
jakw |
137 |
unsigned int patternSizeX = ui->patternSizeXSpinBox->value();
|
|
|
138 |
settings.setValue("calibration/patternSizeX", patternSizeX);
|
|
|
139 |
unsigned int patternSizeY = ui->patternSizeYSpinBox->value();
|
|
|
140 |
settings.setValue("calibration/patternSizeY", patternSizeY);
|
|
|
141 |
float squareSize = ui->squareSizeSpinBox->value();
|
|
|
142 |
settings.setValue("calibration/squareSize", squareSize);
|
164 |
raly |
143 |
|
9 |
jakw |
144 |
}
|
|
|
145 |
|
|
|
146 |
|
|
|
147 |
|
|
|
148 |
void SMPreferenceDialog::on_triggerHardwareRadioButton_clicked(){
|
|
|
149 |
|
|
|
150 |
ui->shiftLabel->setEnabled(true);
|
|
|
151 |
ui->shiftSpinBox->setEnabled(true);
|
|
|
152 |
ui->delayLabel->setEnabled(false);
|
|
|
153 |
ui->delaySpinBox->setEnabled(false);
|
|
|
154 |
ui->delayMsLabel->setEnabled(false);
|
|
|
155 |
}
|
|
|
156 |
|
|
|
157 |
void SMPreferenceDialog::on_triggerSoftwareRadioButton_clicked(){
|
|
|
158 |
|
|
|
159 |
ui->shiftLabel->setEnabled(false);
|
|
|
160 |
ui->shiftSpinBox->setEnabled(false);
|
|
|
161 |
ui->delayLabel->setEnabled(true);
|
|
|
162 |
ui->delaySpinBox->setEnabled(true);
|
|
|
163 |
ui->delayMsLabel->setEnabled(true);
|
|
|
164 |
}
|