summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphael Cojocaru <raphael.cojocaru@yahoo.com>2016-11-12 16:42:58 (GMT)
committerRaphael Cojocaru <raphael.cojocaru@yahoo.com>2016-11-12 16:42:58 (GMT)
commit5b4cc61cfce1cdce9ecd863ebda662446ba06afc (patch)
treef77b630adfef65b386b8a6fd3f59ddc14b82719b
parent8bf445ee4b10edcf488f88cd2b69699bb3165648 (diff)
Added functionality for Update button. Now, the AltvsTime widget will recompute all the graphs points when the Update button is pressed.
-rw-r--r--kstars/tools/altvstime.cpp81
1 files changed, 72 insertions, 9 deletions
diff --git a/kstars/tools/altvstime.cpp b/kstars/tools/altvstime.cpp
index ee15095..feb4bdf 100644
--- a/kstars/tools/altvstime.cpp
+++ b/kstars/tools/altvstime.cpp
@@ -973,12 +973,43 @@ void AltVsTime::slotUpdateDateLoc() {
//update pList entry
pList.replace( i, o );
- KPlotObject *po = new KPlotObject( Qt::white, KPlotObject::Lines, 3 );
- for ( double h=-12.0; h<=12.0; h+=0.5 ) {
- po->addPoint( h, findAltitude( o, h ) );
+ // We are creating a new data set (time, altitude) for the new date:
+ QVector<double> time_dataSet, altitude_dataSet;
+ double point_altitudeValue, point_timeValue;
+ // compute the new graph values:
+ // time range: 24h
+ int offset = 3;
+ for ( double h=-12.0, i=0; h<=12.0; h+=0.25, i++ ) {
+ point_altitudeValue = findAltitude(o, h);
+ altitude_dataSet.push_back(point_altitudeValue);
+ if(point_altitudeValue > maxAlt)
+ maxAlt = point_altitudeValue;
+ if(point_altitudeValue < minAlt)
+ minAlt = point_altitudeValue;
+ point_timeValue = i*900 + 43200;
+ time_dataSet.push_back(point_timeValue);
}
- // TODO:
- // avtUI->View->replacePlotObject( i, po );
+
+ // Replace graph data set:
+ avtUI->View->graph(i)->setData(time_dataSet, altitude_dataSet);
+
+ // Go into initial state: without Zoom/Pan
+ avtUI->View->xAxis->setRange(43200, 129600);
+ avtUI->View->xAxis2->setRange(61200, 147600);
+
+ // Center the altitude axis in 0 value:
+ if(abs(minAlt) > maxAlt)
+ maxAlt = abs(minAlt) ;
+ else
+ minAlt = -maxAlt;
+ avtUI->View->yAxis->setRange(minAlt - offset, maxAlt + offset);
+
+ // Update background coordonates:
+ background->topLeft->setCoords(avtUI->View->xAxis->range().lower,avtUI->View->yAxis->range().upper);
+ background->bottomRight->setCoords(avtUI->View->xAxis->range().upper, avtUI->View->yAxis->range().lower);
+
+ // Redraw the plot:
+ avtUI->View->replot();
//restore original position
if ( o->isSolarSystem() ) {
@@ -990,11 +1021,43 @@ void AltVsTime::slotUpdateDateLoc() {
} else { //assume unfound object is a custom object
pList.at(i)->updateCoordsNow( num ); //precess to desired epoch
- KPlotObject *po = new KPlotObject( Qt::white, KPlotObject::Lines, 3 );
- for ( double h=-12.0; h<=12.0; h+=0.5 ) {
- po->addPoint( h, findAltitude( pList.at(i), h ) );
+ // We are creating a new data set (time, altitude) for the new date:
+ QVector<double> time_dataSet, altitude_dataSet;
+ double point_altitudeValue, point_timeValue;
+ // compute the new graph values:
+ // time range: 24h
+ int offset = 3;
+ for ( double h=-12.0, i=0; h<=12.0; h+=0.25, i++ ) {
+ point_altitudeValue = findAltitude(pList.at(i), h);
+ altitude_dataSet.push_back(point_altitudeValue);
+ if(point_altitudeValue > maxAlt)
+ maxAlt = point_altitudeValue;
+ if(point_altitudeValue < minAlt)
+ minAlt = point_altitudeValue;
+ point_timeValue = i*900 + 43200;
+ time_dataSet.push_back(point_timeValue);
}
- // avtUI->View->replacePlotObject( i, po );
+
+ // Replace graph data set:
+ avtUI->View->graph(i)->setData(time_dataSet, altitude_dataSet);
+
+ // Go into initial state: without Zoom/Pan
+ avtUI->View->xAxis->setRange(43200, 129600);
+ avtUI->View->xAxis2->setRange(61200, 147600);
+
+ // Center the altitude axis in 0 value:
+ if(abs(minAlt) > maxAlt)
+ maxAlt = abs(minAlt) ;
+ else
+ minAlt = -maxAlt;
+ avtUI->View->yAxis->setRange(minAlt - offset, maxAlt + offset);
+
+ // Update background coordonates:
+ background->topLeft->setCoords(avtUI->View->xAxis->range().lower,avtUI->View->yAxis->range().upper);
+ background->bottomRight->setCoords(avtUI->View->xAxis->range().upper, avtUI->View->yAxis->range().lower);
+
+ // Redraw the plot:
+ avtUI->View->replot();
}
}