17 #include <QPushButton>
20 #include "graphwidget.h"
21 #include "xwavengraph.h"
22 #include "ui_caltableform.h"
23 #include "ui_graphnurlform.h"
27 XConCalTable::XConCalTable
28 (
const shared_ptr<XThermometerList> &list,
FrmCalTable *form)
36 m_wave(
XNode::createOrphan<
XWaveNGraph>(
"Waveform", true, m_waveform.get())) {
39 m_thermometer = XNode::createOrphan<XItemNode<XThermometerList, XThermometer> >(
40 "thermometer",
false, ref(tr), list,
true);
43 m_conThermo = xqcon_create<XQComboBoxConnector> (m_thermometer,
44 (QComboBox *) form->cmbThermometer,
Snapshot( *list));
45 m_conTemp = xqcon_create<XQLineEditConnector> (m_temp, form->edTemp,
false);
46 m_conValue = xqcon_create<XQLineEditConnector> (m_value, form->edValue,
false);
47 m_conDisplay = xqcon_create<XQButtonConnector> (m_display, form->btnDisplay);
50 m_lsnTemp = tr[ *temp()].onValueChanged().connectWeakly(
52 &XConCalTable::onTempChanged);
55 m_lsnValue = tr[ *value()].onValueChanged().connectWeakly(
57 &XConCalTable::onValueChanged);
60 m_lsnDisplay = tr[ *display()].onTouch().connectWeakly(
62 &XConCalTable::onDisplayTouched, XListener::FLAG_MAIN_THREAD_CALL);
65 m_waveform->setWindowTitle(i18n(
"Thermometer Calibration"));
67 const char *labels[] = {
"Temp. [K]",
"Value",
"T(v(T))-T [K]"};
68 tr[ *m_wave].setColCount(3, labels);
69 tr[ *m_wave].insertPlot(labels[1], 0, 1);
70 tr[ *m_wave].insertPlot(labels[2], 0, -1, 2);
71 tr[ *tr[ *m_wave].plot(0)->label()] = i18n(
"Curve");
72 tr[ *tr[ *m_wave].plot(0)->drawPoints()] =
false;
73 tr[ *tr[ *m_wave].plot(1)->label()] = i18n(
"Error");
74 tr[ *tr[ *m_wave].plot(1)->drawPoints()] =
false;
75 shared_ptr<XAxis> axisx = tr[ *m_wave].axisx();
76 tr[ *axisx->logScale()] =
true;
77 shared_ptr<XAxis> axisy = tr[ *m_wave].axisy();
78 tr[ *axisy->logScale()] =
true;
79 m_wave->drawGraph(tr);
80 tr[ *m_wave].clearPoints();
86 shared_ptr<XThermometer> thermo = ***thermometer();
88 double ret = thermo->getRawValue(shot[ *temp()]);
91 tr.unmark(m_lsnValue);
96 shared_ptr<XThermometer> thermo = ***thermometer();
98 double ret = thermo->getTemp(shot[ *value()]);
101 tr.unmark(m_lsnTemp);
106 shared_ptr<XThermometer> thermo = ***thermometer();
109 tr[ *m_wave].clearPoints();
113 const int length = 1000;
115 double step = (log(shot_th[ *thermo->tempMax()]) - log(shot_th[ *thermo->tempMin()])) / length;
117 tr[ *m_wave].setRowCount(length);
118 double lt = log(shot_th[ *thermo->tempMin()]);
119 for(
int i = 0; i < length; ++i) {
121 double r = thermo->getRawValue(t);
122 tr[ *m_wave].cols(0)[i] = t;
123 tr[ *m_wave].cols(1)[i] = r;
124 tr[ *m_wave].cols(2)[i] = thermo->getTemp(r) - t;
127 m_wave->drawGraph(tr);
129 m_waveform->showNormal();