Subversion Repositories seema-scanner

Rev

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