Subversion Repositories seema-scanner

Rev

Rev 200 | Rev 225 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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