Commit 9cb97bf0 authored by Raphael Cojocaru's avatar Raphael Cojocaru

Rise/Set/Transit markers are ready

Now, the user can mark the Rise/Set/Transit points on the curve with just a  click on specific button.
I have chosen to mark the points with solid colored circles: Red for Rise, Blue for Set and Green for Transit.

CCMAIL: kstars-devel@kde.org
parent 52554db7
......@@ -123,6 +123,10 @@ AltVsTime::AltVsTime( QWidget* parent) :
// set up the initial minimum and maximum altitude
minAlt = 0;
maxAlt = 0;
// set up the markers booleans for Rise/Set/Transit
markedRiseTime = false;
markedSetTime = false;
markedTransitTime = false;
showCurrentDate();
if ( getDate().time().hour() > 12 )
DayOffset = 1;
......@@ -151,6 +155,9 @@ AltVsTime::AltVsTime( QWidget* parent) :
connect( avtUI->latBox, SIGNAL( returnPressed() ), this, SLOT( slotAdvanceFocus() ) );
connect( avtUI->PlotList, SIGNAL( currentRowChanged(int) ), this, SLOT( slotHighlight(int) ) );
connect( avtUI->computeButton, SIGNAL( clicked() ), this, SLOT( slotComputeAltitudeByTime() ) );
connect( avtUI->riseButton, SIGNAL( clicked() ), this, SLOT( slotMarkRiseTime() ) );
connect( avtUI->setButton, SIGNAL( clicked() ), this, SLOT( slotMarkSetTime() ) );
connect( avtUI->transitButton, SIGNAL( clicked() ), this, SLOT( slotMarkTransitTime() ) );
setMouseTracking( true );
}
......@@ -246,6 +253,7 @@ void AltVsTime::slotBrowseObject() {
delete fd;
avtUI->View->update();
avtUI->View->replot();
}
void AltVsTime::processObject( SkyObject *o, bool forceAdd ) {
......@@ -344,13 +352,13 @@ double AltVsTime::findAltitude( SkyPoint *p, double hour ) {
void AltVsTime::slotHighlight( int row ) {
//highlight the curve of the selected object
for ( int i=0; i<avtUI->View->graphCount(); i++ ) {
if ( i == row ){
if ( i == row )
avtUI->View->graph(i)->setPen(QPen( Qt::black, 2 ));
} else{
else
avtUI->View->graph(i)->setPen(QPen( Qt::red, 1 ));
}
}
avtUI->View->update();
avtUI->View->replot();
if( row >= 0 && row < pList.size() ) {
SkyObject *p = pList.at(row);
......@@ -488,6 +496,7 @@ void AltVsTime::slotClear() {
avtUI->epochName->clear();
// remove all graphs from the plot:
avtUI->View->clearGraphs();
avtUI->View->clearItems();
avtUI->View->update();
avtUI->View->replot();
}
......@@ -544,6 +553,150 @@ void AltVsTime::slotComputeAltitudeByTime(){
}
}
void AltVsTime::slotMarkRiseTime(){
const KStarsDateTime &ut = KStarsData::Instance()->ut();
SkyObject *selectedObject = KStarsData::Instance()->objectNamed(avtUI->nameBox->text());
QCPItemTracer *riseTimeTracer;
// check if at least one graph exists in the plot
if( avtUI->View->graphCount() > 0 ){
double time = 0;
double hours, minutes;
QCPGraph *selectedGraph;
// get the graph's name from the name box
QString graphName = avtUI->nameBox->text();
// find the graph index
int graphIndex = 0;
for( int i=0;i<avtUI->View->graphCount();i++ )
if( avtUI->View->graph(i)->name().compare(graphName) == 0 ){
graphIndex = i;
break;
}
selectedGraph = avtUI->View->graph(graphIndex);
QTime rt = selectedObject->riseSetTime( ut, geo, true ); //true = use rise time
// mark the Rise time with a red circle
if ( rt.isValid() && selectedGraph ) {
hours = rt.hour();
minutes = rt.minute();
if( hours < 14 )
hours += 24;
hours -= 2;
time = hours * 3600 + minutes * 60;
riseTimeTracer = new QCPItemTracer(avtUI->View);
avtUI->View->addItem(riseTimeTracer);
riseTimeTracer->setGraph(selectedGraph);
riseTimeTracer->setInterpolating(true);
riseTimeTracer->setStyle(QCPItemTracer::tsCircle);
riseTimeTracer->setPen(QPen(Qt::red));
riseTimeTracer->setBrush(Qt::red);
riseTimeTracer->setSize(10);
riseTimeTracer->setGraphKey(time);
riseTimeTracer->setVisible(true);
avtUI->View->update();
avtUI->View->replot();
}
}
}
void AltVsTime::slotMarkSetTime(){
const KStarsDateTime &ut = KStarsData::Instance()->ut();
SkyObject *selectedObject = KStarsData::Instance()->objectNamed(avtUI->nameBox->text());
QCPItemTracer *setTimeTracer;
// check if at least one graph exists in the plot
if( avtUI->View->graphCount() > 0 ){
double time = 0;
double hours, minutes;
QCPGraph *selectedGraph;
// get the graph's name from the name box
QString graphName = avtUI->nameBox->text();
// find the graph index
int graphIndex = 0;
for( int i=0;i<avtUI->View->graphCount();i++ )
if( avtUI->View->graph(i)->name().compare(graphName) == 0 ){
graphIndex = i;
break;
}
selectedGraph = avtUI->View->graph(graphIndex);
QTime rt = selectedObject->riseSetTime( ut, geo, true ); //true = use rise time
//If set time is before rise time, use set time for tomorrow
QTime st = selectedObject->riseSetTime( ut, geo, false ); //false = use set time
if ( st < rt )
st = selectedObject->riseSetTime( ut.addDays( 1 ), geo, false ); //false = use set time
// mark the Set time with a blue circle
if ( rt.isValid() ) {
hours = st.hour();
minutes = st.minute();
if( hours < 14 )
hours += 24;
hours -= 2;
time = hours * 3600 + minutes * 60;
setTimeTracer = new QCPItemTracer(avtUI->View);
avtUI->View->addItem(setTimeTracer);
setTimeTracer->setGraph(selectedGraph);
setTimeTracer->setInterpolating(true);
setTimeTracer->setStyle(QCPItemTracer::tsCircle);
setTimeTracer->setPen(QPen(Qt::blue));
setTimeTracer->setBrush(Qt::blue);
setTimeTracer->setSize(10);
setTimeTracer->setGraphKey(time);
setTimeTracer->setVisible(true);
avtUI->View->update();
avtUI->View->replot();
}
}
}
void AltVsTime::slotMarkTransitTime(){
const KStarsDateTime &ut = KStarsData::Instance()->ut();
SkyObject *selectedObject = KStarsData::Instance()->objectNamed(avtUI->nameBox->text());
QCPItemTracer *transitTimeTracer;
// check if at least one graph exists in the plot
if( avtUI->View->graphCount() > 0 ){
double time = 0;
double hours, minutes;
QCPGraph *selectedGraph;
// get the graph's name from the name box
QString graphName = avtUI->nameBox->text();
// find the graph index
int graphIndex = 0;
for( int i=0;i<avtUI->View->graphCount();i++ )
if( avtUI->View->graph(i)->name().compare(graphName) == 0 ){
graphIndex = i;
break;
}
selectedGraph = avtUI->View->graph(graphIndex);
QTime rt = selectedObject->riseSetTime( ut, geo, true ); //true = use rise time
//If transit time is before rise time, use transit time for tomorrow
QTime tt = selectedObject->transitTime( ut, geo );
if ( tt < rt )
tt = selectedObject->transitTime( ut.addDays( 1 ), geo );
// mark the Transit time with a green circle
hours = tt.hour();
minutes = tt.minute();
if( hours < 14 )
hours += 24;
hours -= 2;
time = hours * 3600 + minutes * 60;
transitTimeTracer = new QCPItemTracer(avtUI->View);
avtUI->View->addItem(transitTimeTracer);
transitTimeTracer->setGraph(selectedGraph);
transitTimeTracer->setInterpolating(true);
transitTimeTracer->setStyle(QCPItemTracer::tsCircle);
transitTimeTracer->setPen(QPen(Qt::green));
transitTimeTracer->setBrush(Qt::green);
transitTimeTracer->setSize(10);
transitTimeTracer->setGraphKey(time);
transitTimeTracer->setVisible(true);
avtUI->View->update();
avtUI->View->replot();
}
}
void AltVsTime::computeSunRiseSetTimes() {
//Determine the time of sunset and sunrise for the desired date and location
//expressed as doubles, the fraction of a full day.
......@@ -553,9 +706,12 @@ void AltVsTime::computeSunRiseSetTimes() {
ksal.setLocation(geo);
double sunRise = ksal.getSunRise();
double sunSet = ksal.getSunSet();
// TODO
// QCustomPlot can not support "setSunRiseSetTimes" method
// avtUI->View->setSunRiseSetTimes( sunRise, sunSet );
this->setSunRiseSetTimes( sunRise, sunSet );
}
void AltVsTime::setSunRiseSetTimes(double sunRise, double sunSet){
this->sunRise = sunRise;
this->sunSet = sunSet;
}
void AltVsTime::slotUpdateDateLoc() {
......
......@@ -110,6 +110,7 @@ public:
*/
QString getObjectName(const SkyObject *o, bool translated=true);
void setSunRiseSetTimes( double sunRise, double sunSet );
public slots:
/** @short Update the plot to reflec new Date and Location settings. */
void slotUpdateDateLoc();
......@@ -129,6 +130,15 @@ public slots:
/** @short Compute the altitude for a certain time. */
void slotComputeAltitudeByTime();
/** @short Mark the rise time on the curve. */
void slotMarkRiseTime();
/** @short Mark the set time on the curve. */
void slotMarkSetTime();
/** @short Mark the transit time on the curve. */
void slotMarkTransitTime();
/** @short Clear the edit boxes for specifying a new object. */
void slotClearBoxes();
......@@ -174,6 +184,8 @@ private:
int DayOffset;
int minAlt;
int maxAlt;
bool markedRiseTime, markedSetTime, markedTransitTime;
double sunRise, sunSet;
};
#endif // ALTVSTIME_H_
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>452</width>
<height>529</height>
<width>508</width>
<height>564</height>
</rect>
</property>
<property name="windowTitle">
......@@ -28,11 +28,6 @@
<height>325</height>
</size>
</property>
<zorder>tabWidget2</zorder>
<zorder>tabWidget2</zorder>
<zorder>tabWidget2</zorder>
<zorder>tabWidget2</zorder>
<zorder>tabWidget2</zorder>
</widget>
</item>
<item alignment="Qt::AlignTop">
......@@ -330,7 +325,64 @@
</size>
</property>
<property name="text">
<string> </string>
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="riseButton">
<property name="text">
<string>Rise</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="setButton">
<property name="text">
<string>Set</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="transitButton">
<property name="text">
<string>Transit</string>
</property>
</widget>
</item>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment