Changeset View
Changeset View
Standalone View
Standalone View
kstars/ekos/observatory/observatory.cpp
Show First 20 Lines • Show All 396 Lines • ▼ Show 20 Line(s) | 393 | { | |||
---|---|---|---|---|---|
397 | { | 397 | { | ||
398 | QVector<QCPGraphData>* graphDataVector = it->second; | 398 | QVector<QCPGraphData>* graphDataVector = it->second; | ||
399 | if (graphDataVector->size() > 0) | 399 | if (graphDataVector->size() > 0) | ||
400 | { | 400 | { | ||
401 | // we keep only the last one | 401 | // we keep only the last one | ||
402 | QCPGraphData last = graphDataVector->last(); | 402 | QCPGraphData last = graphDataVector->last(); | ||
403 | graphDataVector->clear(); | 403 | graphDataVector->clear(); | ||
404 | QDateTime when = QDateTime(); | 404 | QDateTime when = QDateTime(); | ||
405 | when.setSecsSinceEpoch(static_cast<int>(last.key)); | 405 | when.setTime_t(static_cast<uint>(last.key)); | ||
406 | updateSensorGraph(it->first, when, last.value); | 406 | updateSensorGraph(it->first, when, last.value); | ||
407 | } | 407 | } | ||
408 | } | 408 | } | ||
409 | 409 | | |||
410 | // force an update to the current graph | 410 | // force an update to the current graph | ||
411 | if (selectedSensorID != "") | 411 | if (selectedSensorID != "") | ||
412 | selectedSensorChanged(selectedSensorID); | 412 | selectedSensorChanged(selectedSensorID); | ||
413 | } | 413 | } | ||
▲ Show 20 Lines • Show All 126 Lines • ▼ Show 20 Line(s) | 536 | { | |||
540 | // lazy instantiation of the sensor data storage | 540 | // lazy instantiation of the sensor data storage | ||
541 | if (sensorGraphData[id] == nullptr) | 541 | if (sensorGraphData[id] == nullptr) | ||
542 | { | 542 | { | ||
543 | sensorGraphData[id] = new QVector<QCPGraphData>(); | 543 | sensorGraphData[id] = new QVector<QCPGraphData>(); | ||
544 | sensorRanges[id] = value > 0 ? 1 : (value < 0 ? -1 : 0); | 544 | sensorRanges[id] = value > 0 ? 1 : (value < 0 ? -1 : 0); | ||
545 | } | 545 | } | ||
546 | 546 | | |||
547 | // store the data | 547 | // store the data | ||
548 | sensorGraphData[id]->append(QCPGraphData(static_cast<double>(now.toSecsSinceEpoch()), value)); | 548 | sensorGraphData[id]->append(QCPGraphData(static_cast<double>(now.toTime_t()), value)); | ||
549 | 549 | | |||
550 | // add data for the graphs we display | 550 | // add data for the graphs we display | ||
551 | if (selectedSensorID == id) | 551 | if (selectedSensorID == id) | ||
552 | { | 552 | { | ||
553 | // display data point | 553 | // display data point | ||
554 | sensorGraphs->graph()->addData(sensorGraphData[id]->last().key, sensorGraphData[id]->last().value); | 554 | sensorGraphs->graph()->addData(sensorGraphData[id]->last().key, sensorGraphData[id]->last().value); | ||
555 | sensorGraphs->rescaleAxes(); | 555 | sensorGraphs->rescaleAxes(); | ||
556 | // ensure that the 0-line is visible | 556 | // ensure that the 0-line is visible | ||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | |||||
619 | void Observatory::mouseOverLine(QMouseEvent *event) | 619 | void Observatory::mouseOverLine(QMouseEvent *event) | ||
620 | { | 620 | { | ||
621 | double key = sensorGraphs->xAxis->pixelToCoord(event->localPos().x()); | 621 | double key = sensorGraphs->xAxis->pixelToCoord(event->localPos().x()); | ||
622 | QCPGraph *graph = qobject_cast<QCPGraph *>(sensorGraphs->plottableAt(event->pos(), false)); | 622 | QCPGraph *graph = qobject_cast<QCPGraph *>(sensorGraphs->plottableAt(event->pos(), false)); | ||
623 | 623 | | |||
624 | if (graph) | 624 | if (graph) | ||
625 | { | 625 | { | ||
626 | int index = sensorGraphs->graph(0)->findBegin(key); | 626 | int index = sensorGraphs->graph(0)->findBegin(key); | ||
627 | double value = sensorGraphs->graph(0)->dataMainValue(index); | 627 | double value = sensorGraphs->graph(0)->dataMainValue(index); | ||
628 | QDateTime when = QDateTime::fromTime_t(sensorGraphs->graph(0)->dataMainKey(index)); | ||||
628 | 629 | | |||
629 | QToolTip::showText( | 630 | QToolTip::showText( | ||
630 | event->globalPos(), | 631 | event->globalPos(), | ||
631 | i18n("%1 = %2", selectedSensorID, value)); | 632 | i18n("%1 = %2 @ %3", selectedSensorID, value, when.toString("hh:mm"))); | ||
632 | } | 633 | } | ||
633 | else { | 634 | else { | ||
634 | QToolTip::hideText(); | 635 | QToolTip::hideText(); | ||
635 | } | 636 | } | ||
636 | } | 637 | } | ||
637 | 638 | | |||
638 | 639 | | |||
639 | void Observatory::selectedSensorChanged(QString id) | 640 | void Observatory::selectedSensorChanged(QString id) | ||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Line(s) | 692 | { | |||
727 | sensorGraphs->xAxis->setTicker(dateTicker); | 728 | sensorGraphs->xAxis->setTicker(dateTicker); | ||
728 | 729 | | |||
729 | // allow dragging in all directions | 730 | // allow dragging in all directions | ||
730 | sensorGraphs->setInteraction(QCP::iRangeDrag, true); | 731 | sensorGraphs->setInteraction(QCP::iRangeDrag, true); | ||
731 | sensorGraphs->setInteraction(QCP::iRangeZoom); | 732 | sensorGraphs->setInteraction(QCP::iRangeZoom); | ||
732 | 733 | | |||
733 | // create the universal graph | 734 | // create the universal graph | ||
734 | QCPGraph *graph = sensorGraphs->addGraph(); | 735 | QCPGraph *graph = sensorGraphs->addGraph(); | ||
735 | graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, QPen(Qt::black, 0), QBrush(Qt::green), 5)); | 736 | graph->setPen(QPen(Qt::darkGreen, 2)); | ||
736 | graph->setPen(QPen(Qt::darkGreen)); | | |||
737 | graph->setBrush(QColor(10, 100, 50, 70)); | 737 | graph->setBrush(QColor(10, 100, 50, 70)); | ||
738 | 738 | | |||
739 | // ensure that the 0-line is visible | 739 | // ensure that the 0-line is visible | ||
740 | sensorGraphs->yAxis->setRangeLower(0); | 740 | sensorGraphs->yAxis->setRangeLower(0); | ||
741 | 741 | | |||
742 | sensorDataNamesGroup = new QButtonGroup(); | 742 | sensorDataNamesGroup = new QButtonGroup(); | ||
743 | // enable changing the displayed sensor | 743 | // enable changing the displayed sensor | ||
744 | connect(sensorDataNamesGroup, static_cast<void (QButtonGroup::*)(QAbstractButton*)>(&QButtonGroup::buttonClicked), [this](QAbstractButton *button) | 744 | connect(sensorDataNamesGroup, static_cast<void (QButtonGroup::*)(QAbstractButton*)>(&QButtonGroup::buttonClicked), [this](QAbstractButton *button) | ||
Show All 37 Lines | |||||
782 | void Observatory::domeAzimuthChanged(double position) | 782 | void Observatory::domeAzimuthChanged(double position) | ||
783 | { | 783 | { | ||
784 | domeAzimuthPosition->setText(QString::number(position, 'f', 2)); | 784 | domeAzimuthPosition->setText(QString::number(position, 'f', 2)); | ||
785 | } | 785 | } | ||
786 | 786 | | |||
787 | 787 | | |||
788 | void Observatory::setWarningActions(WeatherActions actions) | 788 | void Observatory::setWarningActions(WeatherActions actions) | ||
789 | { | 789 | { | ||
790 | if (getDomeModel() != nullptr) | ||||
791 | weatherWarningDomeCB->setChecked(actions.parkDome); | ||||
792 | else | ||||
790 | weatherWarningDomeCB->setChecked(actions.parkDome); | 793 | weatherWarningDomeCB->setChecked(actions.parkDome); | ||
794 | | ||||
795 | if (getDomeModel() != nullptr && getDomeModel()->hasShutter()) | ||||
796 | weatherWarningShutterCB->setChecked(actions.closeShutter); | ||||
797 | else | ||||
791 | weatherWarningShutterCB->setChecked(actions.closeShutter); | 798 | weatherWarningShutterCB->setChecked(actions.closeShutter); | ||
799 | | ||||
792 | weatherWarningDelaySB->setValue(static_cast<int>(actions.delay)); | 800 | weatherWarningDelaySB->setValue(static_cast<int>(actions.delay)); | ||
793 | } | 801 | } | ||
794 | 802 | | |||
795 | 803 | | |||
796 | void Observatory::setAlertActions(WeatherActions actions) | 804 | void Observatory::setAlertActions(WeatherActions actions) | ||
797 | { | 805 | { | ||
806 | if (getDomeModel() != nullptr) | ||||
798 | weatherAlertDomeCB->setChecked(actions.parkDome); | 807 | weatherAlertDomeCB->setChecked(actions.parkDome); | ||
808 | else | ||||
809 | weatherAlertDomeCB->setChecked(false); | ||||
810 | | ||||
811 | if (getDomeModel() != nullptr && getDomeModel()->hasShutter()) | ||||
799 | weatherAlertShutterCB->setChecked(actions.closeShutter); | 812 | weatherAlertShutterCB->setChecked(actions.closeShutter); | ||
813 | else | ||||
814 | weatherAlertShutterCB->setChecked(false); | ||||
815 | | ||||
800 | weatherAlertDelaySB->setValue(static_cast<int>(actions.delay)); | 816 | weatherAlertDelaySB->setValue(static_cast<int>(actions.delay)); | ||
801 | } | 817 | } | ||
802 | 818 | | |||
803 | void Observatory::toggleButtons(QPushButton *buttonPressed, QString titlePressed, QPushButton *buttonCounterpart, QString titleCounterpart) | 819 | void Observatory::toggleButtons(QPushButton *buttonPressed, QString titlePressed, QPushButton *buttonCounterpart, QString titleCounterpart) | ||
804 | { | 820 | { | ||
805 | buttonPressed->setEnabled(false); | 821 | buttonPressed->setEnabled(false); | ||
806 | buttonPressed->setText(titlePressed); | 822 | buttonPressed->setText(titlePressed); | ||
807 | 823 | | |||
▲ Show 20 Lines • Show All 50 Lines • Show Last 20 Lines |