Skip to content

Commit

Permalink
msec to date
Browse files Browse the repository at this point in the history
  • Loading branch information
lauracosta committed May 20, 2024
1 parent 4308adb commit 839976f
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 6 deletions.
4 changes: 2 additions & 2 deletions project/project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4622,8 +4622,8 @@ bool Project::computeSingleWell(QString idWell, int indexWell)
WaterTable waterTable(meteoPoints, nrMeteoPoints, meteoGridDbHandler->meteoGrid(), isMeteoGridLoaded, *meteoSettings, gisSettings);
waterTable.computeWaterTable(wellPoints[indexWell], maxNrDays);
waterTableList.push_back(waterTable);
DialogSummary dialogResult(waterTable); // show results
DialogSummary* dialogResult = new DialogSummary(waterTable); // show results
waterTable.viewWaterTableSeries(); // prepare series to show
//WaterTableWidget chartResult(idWell, waterTable.getMyDates(), waterTable.getMyHindcastSeries(), waterTable.getMyInterpolateSeries(), waterTable.getDepths());
WaterTableWidget* chartResult = new WaterTableWidget(idWell, waterTable.getMyDates(), waterTable.getMyHindcastSeries(), waterTable.getMyInterpolateSeries(), waterTable.getDepths());
return true;
}
10 changes: 10 additions & 0 deletions waterTable/dialogSummary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,13 @@ DialogSummary::DialogSummary(WaterTable myWaterTable)
setLayout(mainLayout);
show();
}

DialogSummary::~DialogSummary()
{

}

void DialogSummary::closeEvent(QCloseEvent *event)
{
event->accept();
}
2 changes: 2 additions & 0 deletions waterTable/dialogSummary.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class DialogSummary : public QDialog
{
public:
DialogSummary(WaterTable myWaterTable);
~DialogSummary();
void closeEvent(QCloseEvent *event);
};

#endif // DIALOGSUMMARY_H
26 changes: 22 additions & 4 deletions waterTable/waterTableChartView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,22 @@ void WaterTableChartView::draw(std::vector<QDate> myDates, std::vector<float> my
axisY->setMax(300);
axisY->setMin(0);
axisY->setLabelFormat("%d");

QDateTime firstDateTime;
firstDateTime.setDate(myDates[0]);
firstDateTime.setTime(QTime(0,0));
QDateTime lastDateTime;
lastDateTime.setDate(myDates[myDates.size()-1]);
lastDateTime.setTime(QTime(0,0));

axisX->setTickCount(12);
axisX->setMin(firstDateTime);
axisX->setMax(lastDateTime);

chart()->addSeries(obsDepthSeries);
chart()->addSeries(hindcastSeries);
chart()->addSeries(interpolationSeries);

connect(obsDepthSeries, &QScatterSeries::hovered, this, &WaterTableChartView::tooltipObsDepthSeries);
connect(hindcastSeries, &QLineSeries::hovered, this, &WaterTableChartView::tooltipLineSeries);
connect(interpolationSeries, &QLineSeries::hovered, this, &WaterTableChartView::tooltipLineSeries);
Expand All @@ -72,10 +88,11 @@ void WaterTableChartView::tooltipObsDepthSeries(QPointF point, bool state)
auto serie = qobject_cast<QScatterSeries *>(sender());
if (state)
{
double xValue = point.x();
QDateTime firstDate(QDate(1970,1,1), QTime(0,0,0));
QDateTime xValue = firstDate.addMSecs(point.x());
double yValue = point.y();

m_tooltip->setText(QString("%1: %2").arg(xValue).arg(yValue, 0, 'd'));
m_tooltip->setText(QString("%1: %2").arg(xValue.date().toString("yyyy/MM/dd")).arg(yValue, 0, 'd'));
m_tooltip->setSeries(serie);
m_tooltip->setAnchor(point);
m_tooltip->setZValue(11);
Expand All @@ -94,10 +111,11 @@ void WaterTableChartView::tooltipLineSeries(QPointF point, bool state)
auto serie = qobject_cast<QLineSeries *>(sender());
if (state)
{
int xValue = point.x();
QDateTime firstDate(QDate(1970,1,1), QTime(0,0,0));
QDateTime xValue = firstDate.addMSecs(point.x());
double yValue = point.y();

m_tooltip->setText(QString("%1: %2").arg(xValue).arg(yValue, 0, 'd'));
m_tooltip->setText(QString("%1: %2").arg(xValue.date().toString("yyyy/MM/dd")).arg(yValue, 0, 'd'));
m_tooltip->setSeries(serie);
m_tooltip->setAnchor(point);
m_tooltip->setZValue(11);
Expand Down
10 changes: 10 additions & 0 deletions waterTable/waterTableWidge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,13 @@ WaterTableWidget::WaterTableWidget(QString id, std::vector<QDate> myDates, std::
waterTableChartView->draw(myDates, myHindcastSeries, myInterpolateSeries, obsDepths);
show();
}

WaterTableWidget::~WaterTableWidget()
{

}

void WaterTableWidget::closeEvent(QCloseEvent *event)
{
event->accept();
}
2 changes: 2 additions & 0 deletions waterTable/waterTableWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class WaterTableWidget : public QWidget
Q_OBJECT
public:
WaterTableWidget(QString id, std::vector<QDate> myDates, std::vector<float> myHindcastSeries, std::vector<float> myInterpolateSeries, QMap<QDate, int> obsDepths);
~WaterTableWidget();
void closeEvent(QCloseEvent *event);

private:
WaterTableChartView *waterTableChartView;
Expand Down

0 comments on commit 839976f

Please sign in to comment.