Go to the documentation of this file.00001
00018
00019 #include <qdialog.h>
00020 #include <qtable.h>
00021 #include <qmessagebox.h>
00022 #include <qheader.h>
00023
00024
00025 #include "qt_editdata_impl.h"
00026
00027 qt_editdata_impl::qt_editdata_impl()
00028 {
00029
00030 }
00031
00032 qt_editdata_impl::qt_editdata_impl(QWidget* parent,
00033 const char* name,
00034 bool modal,
00035 WFlags fl )
00036 : qt_editdata(parent, name, modal, fl)
00037 {
00038 updateCal();
00039 }
00040
00041
00042 qt_editdata_impl::~qt_editdata_impl()
00043 {
00044 }
00045
00046
00047 bool
00048 qt_editdata_impl::setTrackerCal(cData::trackerCal t){
00049
00050 tcal = t;
00051 updateCal();
00052 return true;
00053 }
00054
00055
00056 cData::trackerCal
00057 qt_editdata_impl::getTrackerCal(){
00058
00059 return tcal;
00060 }
00061
00062 bool
00063 qt_editdata_impl::updateCal(){
00064
00065
00066 unsigned int numrows = tcal.size();
00067 unsigned int numcols = 0;
00068
00069 for (unsigned int i=0; i<numrows; i++)
00070 numcols = tcal[i].size() > numcols ? tcal[i].size() : numcols;
00071
00072 datatable->setNumRows(numrows);
00073 datatable->setNumCols(2*numcols);
00074
00075
00076 for (unsigned int j=0; j<numcols; j+=1){
00077 char outp[12], inp[12];
00078 sprintf(outp, "Output %d", j+1);
00079 sprintf(inp, "Input %d", j+1);
00080 datatable->horizontalHeader()->setLabel( j*2, outp);
00081 datatable->horizontalHeader()->setLabel( j*2+1, inp);
00082 }
00083
00084
00085 for (unsigned int i=0; i<numrows; i++){
00086
00087 for (unsigned int j=0; j<tcal[i].size(); j++){
00088
00089 datatable->setItem( i, 2*j,
00090 new QTableItem( datatable,
00091 QTableItem::WhenCurrent,
00092 QString::number( tcal[i][j].first ) ) );
00093 datatable->setItem( i, 2*j+1,
00094 new QTableItem( datatable,
00095 QTableItem::WhenCurrent,
00096 QString::number( tcal[i][j].second ) ) );
00097 }
00098 }
00099 return true;
00100 }
00101
00102 void
00103 qt_editdata_impl::accept(){
00104
00105 cData::trackerCal t;
00106 bool ok = true;
00107 unsigned int numrows = datatable->numRows();
00108 unsigned int numcols = datatable->numCols();
00109
00110
00111 for (unsigned int i=0; i<numrows; i++){
00112 cData::sensorCal scal;
00113
00114 for (unsigned int j=0; j<numcols; j+=2){
00115 bool oktmp;
00116 cData::fulcrum f;
00117 f.first = datatable->text(i,j).toDouble(&oktmp);
00118 ok = ok && oktmp;
00119 f.second = datatable->text(i,j+1).toDouble(&oktmp);
00120 ok = ok && oktmp;
00121 scal.push_back(f);
00122 }
00123 t.push_back(scal);
00124 }
00125 if(ok){
00126 tcal = t;
00127 QDialog::accept();
00128 }
00129 else{
00130 QMessageBox::critical(this,
00131 "Calibration data",
00132 "Data is corrupt. Cannot store it.\nOnly numbers are allowed.",
00133 "Ok");
00134 }
00135 }
00136
00137
00138
00139 #if qt_editdata_test
00140 #include <stdio.h>
00141 int main(int argc, char **argv)
00142 {
00143
00144
00145
00146
00147
00148
00149 fprintf(stderr, "Testing qt_editdata\n");
00150
00151 return 0;
00152 }
00153 #endif
asr_flock_of_birds
Author(s): Bernhardt Andre, Engelmann Stephan, Giesler Björn, Heller Florian, Jäkel Rainer, Nguyen Trung, Pardowitz Michael, Weckesser Peter, Yi Xie, Zöllner Raoul
autogenerated on Sat Jun 8 2019 19:36:21