diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-07-22 16:10:47 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-07-22 16:10:47 -0500 |
commit | 043cc2c3d96a6270ac4d664911ffaa54f06db925 (patch) | |
tree | 7bb6eaaf10bf038043cd8c90ba39d89a075e31d9 /clients/tde/src/part/sensormonitor/part.cpp | |
parent | 1f5a3c2804333aec7258129e55a2726c56a1245a (diff) | |
download | ulab-043cc2c3d96a6270ac4d664911ffaa54f06db925.tar.gz ulab-043cc2c3d96a6270ac4d664911ffaa54f06db925.zip |
Fix a number of problems and streamline instrument parts
Diffstat (limited to 'clients/tde/src/part/sensormonitor/part.cpp')
-rw-r--r-- | clients/tde/src/part/sensormonitor/part.cpp | 80 |
1 files changed, 71 insertions, 9 deletions
diff --git a/clients/tde/src/part/sensormonitor/part.cpp b/clients/tde/src/part/sensormonitor/part.cpp index 4d39b86..92fd199 100644 --- a/clients/tde/src/part/sensormonitor/part.cpp +++ b/clients/tde/src/part/sensormonitor/part.cpp @@ -114,39 +114,46 @@ TraceControlWidget::TraceControlWidget(TQWidget *parent, const char *name) m_groupBox->setColumnLayout(0, TQt::Vertical); topGrid->addMultiCellWidget(m_groupBox, 0, 0, 0, 0); m_groupBox->setTitle(i18n("Unknown Channel")); - m_primaryLayout = new TQGridLayout(m_groupBox->layout(), KDialog::marginHint(), KDialog::spacingHint()); + m_primaryLayout = new TQGridLayout(m_groupBox->layout(), 1, 1, KDialog::spacingHint()); m_channelEnabledCheckBox = new TQCheckBox(m_groupBox); connect(m_channelEnabledCheckBox, SIGNAL(clicked()), this, SLOT(enableClicked())); m_channelEnabledCheckBox->setText(i18n("Enable")); - m_primaryLayout->addMultiCellWidget(m_channelEnabledCheckBox, 0, 0, 0, 0); + m_primaryLayout->addMultiCellWidget(m_channelEnabledCheckBox, 0, 0, 0, 2); m_valueLabel = new TQLabel(m_groupBox); m_valueLabel->setText(i18n("<qt><nobr>Value: <b>%1</b></qt>").arg(i18n("<unknown>"))); - m_primaryLayout->addMultiCellWidget(m_valueLabel, 1, 1, 0, 1); + m_primaryLayout->addMultiCellWidget(m_valueLabel, 1, 1, 0, 2); m_valueLabel->hide(); m_timestampLabel = new TQLabel(m_groupBox); m_timestampLabel->setText(i18n("<qt><nobr>Sampled: <b>%1</b></qt>").arg(i18n("<unknown>"))); - m_primaryLayout->addMultiCellWidget(m_timestampLabel, 2, 2, 0, 1); + m_primaryLayout->addMultiCellWidget(m_timestampLabel, 2, 2, 0, 2); m_timestampLabel->hide(); m_timestepLabel1 = new TQLabel(m_groupBox); - m_timestepLabel1->setText(i18n("Sample every:")); + m_timestepLabel1->setText(i18n("<qt><nobr>Sample every:</qt>")); m_primaryLayout->addMultiCellWidget(m_timestepLabel1, 3, 3, 0, 0); m_timestepLabel1->hide(); m_timestepSpinBox = new FloatSpinBox(m_groupBox); m_timestepSpinBox->setFloatMax(60*60*24); // 1 day connect(m_timestepSpinBox, SIGNAL(floatValueChanged(double)), this, SLOT(timestepChanged(double))); - m_primaryLayout->addMultiCellWidget(m_timestepSpinBox, 4, 4, 0, 0); + m_primaryLayout->addMultiCellWidget(m_timestepSpinBox, 3, 3, 1, 1); m_timestepSpinBox->hide(); m_timestepLabel2 = new TQLabel(m_groupBox); - m_timestepLabel2->setText(i18n("seconds")); - m_primaryLayout->addMultiCellWidget(m_timestepLabel2, 4, 4, 1, 1); + m_timestepLabel2->setText(i18n("<qt><nobr>seconds<qt>")); + m_primaryLayout->addMultiCellWidget(m_timestepLabel2, 3, 3, 2, 2); m_timestepLabel2->hide(); + m_clearPushButton = new TQPushButton(m_groupBox); + m_clearPushButton->setText(i18n("Erase Existing Data")); + connect(m_clearPushButton, SIGNAL(clicked()), this, SLOT(clearTraceDataClicked())); + m_primaryLayout->addMultiCellWidget(m_clearPushButton, 5, 5, 0, 2); + m_clearPushButton->setSizePolicy(TQSizePolicy(TQSizePolicy::MinimumExpanding, TQSizePolicy::Minimum)); + m_clearPushButton->hide(); + m_sampleTimer = new TQTimer(); connect(m_sampleTimer, SIGNAL(timeout()), this, SIGNAL(newSampleDesired())); } @@ -156,6 +163,10 @@ TraceControlWidget::~TraceControlWidget() { delete m_sampleTimer; } +void TraceControlWidget::clearTraceDataClicked() { + emit(clearTraceRequested()); +} + void TraceControlWidget::startSampleTimer(int msecs) { if (m_channelEnabledCheckBox->isOn()) { m_nominalTimeStep = msecs/1.0e3; @@ -178,6 +189,7 @@ void TraceControlWidget::setTraceEnabled(bool enabled) { m_timestepSpinBox->show(); m_valueLabel->show(); m_timestampLabel->show(); + m_clearPushButton->show(); } else { m_timestepLabel1->hide(); @@ -185,6 +197,7 @@ void TraceControlWidget::setTraceEnabled(bool enabled) { m_timestepSpinBox->hide(); m_valueLabel->hide(); m_timestampLabel->hide(); + m_clearPushButton->hide(); } } @@ -205,6 +218,18 @@ void TraceControlWidget::setTimestep(double seconds) { void TraceControlWidget::setMinTimestep(double seconds) { m_minimumTimeStep = seconds; m_timestepSpinBox->setFloatMin(seconds); + if (seconds < 0.001) { + m_timestepSpinBox->setPrecision(3); + } + else if (seconds < 0.01) { + m_timestepSpinBox->setPrecision(2); + } + else if (seconds < 0.1) { + m_timestepSpinBox->setPrecision(1); + } + else { + m_timestepSpinBox->setPrecision(0); + } } void TraceControlWidget::enableClicked() { @@ -223,7 +248,7 @@ void TraceControlWidget::setCurrentSampleValue(double value, TQString units) { } void TraceControlWidget::setCurrentSampleTimestamp(TQDateTime timestamp) { - m_timestampLabel->setText(i18n("<qt><nobr>Sampled: <b>%1</b></qt>").arg(timestamp.toString())); + m_timestampLabel->setText(i18n("<qt><nobr>Sampled: <b>%1 UTC</b></qt>").arg(timestamp.toString())); } SensorMonitorPart::SensorMonitorPart(TQWidget *parentWidget, const char *widgetName, TQObject *parent, const char *name, const TQStringList&) @@ -701,6 +726,7 @@ void SensorMonitorPart::updateTraceControlWidgets() { m_traceControlWidgetList[i] = new TraceControlWidget(m_base->traceControlLayoutWidget); connect(m_traceControlWidgetList[i], SIGNAL(enableChanged(bool)), this, SLOT(traceControlEnableChanged(bool))); connect(m_traceControlWidgetList[i], SIGNAL(newSampleDesired()), this, SLOT(processNewSampleRequest())); + connect(m_traceControlWidgetList[i], SIGNAL(clearTraceRequested()), this, SLOT(traceControlClearRequested())); m_traceControlWidgetGrid->addMultiCellWidget(m_traceControlWidgetList[i], i, i, 0, 0); m_traceControlWidgetList[i]->setTraceName(i18n("Sensor %1").arg(m_sensorList[i].name)); m_traceControlWidgetList[i]->show(); @@ -739,6 +765,36 @@ void SensorMonitorPart::traceControlEnableChanged(bool enabled) { updateTraceControlWidgets(); } +void SensorMonitorPart::traceControlClearRequested() { + int i; + int channel = -1; + const TraceControlWidget* widget = dynamic_cast<const TraceControlWidget*>(sender()); + if (widget) { + for (i=0; i<MAXTRACES;i++) { + if (m_traceControlWidgetList[i] == widget) { + channel = i; + break; + } + } + if ((channel >= 0) && (channel <=MAXTRACES)) { + m_samplesInTrace[channel] = 0; + TQDoubleArray sampleArray; + TQDoubleArray positionArray; + m_traceWidget->setSamples(m_sampleRequestIndex, sampleArray); + m_traceWidget->setPositions(m_sampleRequestIndex, positionArray); + m_base->traceZoomWidget->setSamples(m_sampleRequestIndex, sampleArray); + m_base->traceZoomWidget->setPositions(m_sampleRequestIndex, positionArray); + m_traceControlWidgetList[m_sampleRequestIndex]->setCurrentSampleValue(0, m_sensorList[channel].units); + m_traceControlWidgetList[m_sampleRequestIndex]->setCurrentSampleTimestamp(TQDateTime()); + } + } + + updateGraticule(); + m_traceWidget->repaint(false); + m_base->traceZoomWidget->repaint(false); + updateTraceControlWidgets(); +} + void SensorMonitorPart::processNewSampleRequest() { int i; int channel = -1; @@ -901,6 +957,12 @@ void SensorMonitorPart::recallWaveforms() { m_traceWidget->setPositions(traceno, positions); m_base->traceZoomWidget->setSamples(traceno, values); m_base->traceZoomWidget->setPositions(traceno, positions); + if (m_samplesInTrace[traceno] > 0) { + m_traceControlWidgetList[traceno]->setCurrentSampleValue(values[m_samplesInTrace[traceno]-1], m_sensorList[traceno].units); + TQDateTime lastSampleTime; + lastSampleTime.setTime_t(positions[m_samplesInTrace[traceno]-1]); + m_traceControlWidgetList[traceno]->setCurrentSampleTimestamp(lastSampleTime); + } } for (int cursorno=0; cursorno<4; cursorno++) { double cursorPos; |