qt_editdata_impl.cc
Go to the documentation of this file.
1 
18 /* system includes */
19 #include <qdialog.h>
20 #include <qtable.h>
21 #include <qmessagebox.h>
22 #include <qheader.h>
23 
24 /* my includes */
25 #include "qt_editdata_impl.h"
26 
28 {
29 
30 }
31 
33  const char* name,
34  bool modal,
35  WFlags fl )
36  : qt_editdata(parent, name, modal, fl)
37 {
38  updateCal();
39 }
40 
41 
43 {
44 }
45 
46 
47 bool
49 
50  tcal = t;
51  updateCal();
52  return true;
53 }
54 
55 
58 
59  return tcal;
60 }
61 
62 bool
64 
65  // determine number of lines (sensors)
66  unsigned int numrows = tcal.size();
67  unsigned int numcols = 0;
68  // number of cols is MAX(all line lenghts)
69  for (unsigned int i=0; i<numrows; i++)
70  numcols = tcal[i].size() > numcols ? tcal[i].size() : numcols;
71 
72  datatable->setNumRows(numrows);
73  datatable->setNumCols(2*numcols);
74 
75  // loop through all cols
76  for (unsigned int j=0; j<numcols; j+=1){
77  char outp[12], inp[12];
78  sprintf(outp, "Output %d", j+1);
79  sprintf(inp, "Input %d", j+1);
80  datatable->horizontalHeader()->setLabel( j*2, outp);
81  datatable->horizontalHeader()->setLabel( j*2+1, inp);
82  }
83 
84  // loop through all lines
85  for (unsigned int i=0; i<numrows; i++){
86  // loop through all cols
87  for (unsigned int j=0; j<tcal[i].size(); j++){
88  // enter numbers
89  datatable->setItem( i, 2*j,
90  new QTableItem( datatable,
91  QTableItem::WhenCurrent,
92  QString::number( tcal[i][j].first ) ) );
93  datatable->setItem( i, 2*j+1,
94  new QTableItem( datatable,
95  QTableItem::WhenCurrent,
96  QString::number( tcal[i][j].second ) ) );
97  }
98  }
99  return true;
100 }
101 
102 void
104 
106  bool ok = true;
107  unsigned int numrows = datatable->numRows();
108  unsigned int numcols = datatable->numCols();
109 
110  // loop through all lines
111  for (unsigned int i=0; i<numrows; i++){
112  cData::sensorCal scal;
113  // loop through all cols
114  for (unsigned int j=0; j<numcols; j+=2){
115  bool oktmp;
117  f.first = datatable->text(i,j).toDouble(&oktmp);
118  ok = ok && oktmp;
119  f.second = datatable->text(i,j+1).toDouble(&oktmp);
120  ok = ok && oktmp;
121  scal.push_back(f);
122  }
123  t.push_back(scal);
124  }
125  if(ok){
126  tcal = t;
127  QDialog::accept();
128  }
129  else{
130  QMessageBox::critical(this,
131  "Calibration data",
132  "Data is corrupt. Cannot store it.\nOnly numbers are allowed.",
133  "Ok");
134  }
135 }
136 
137 
138 
139 #if qt_editdata_test
140 #include <stdio.h>
141 int main(int argc, char **argv)
142 {
143  // This is a module-test block. You can put code here that tests
144  // just the contents of this C file, and build it by saying
145  // make qt_editdata_test
146  // Then, run the resulting executable (qt_editdata_test).
147  // If it works as expected, the module is probably correct. ;-)
148 
149  fprintf(stderr, "Testing qt_editdata\n");
150 
151  return 0;
152 }
153 #endif /* qt_editdata_test */
f
int main(int argc, char **argv)
std::pair< double, double > fulcrum
Definition: cData.h:44
cData::trackerCal getTrackerCal()
std::vector< sensorCal > trackerCal
Definition: cData.h:46
cData::trackerCal tcal
std::vector< fulcrum > sensorCal
Definition: cData.h:45
bool setTrackerCal(cData::trackerCal t)


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 Mon Jun 10 2019 12:44:40