Commit 11857279 authored by Jasem Mutlaq's avatar Jasem Mutlaq
Browse files

REVIEW:112994

parent 38a50149
...@@ -211,86 +211,128 @@ void SkyCalendar::addPlanetEvents( int nPlanet ) { ...@@ -211,86 +211,128 @@ void SkyCalendar::addPlanetEvents( int nPlanet ) {
KPlotObject *oRise = new KPlotObject( pColor, KPlotObject::Lines, 2.0 ); KPlotObject *oRise = new KPlotObject( pColor, KPlotObject::Lines, 2.0 );
KPlotObject *oSet = new KPlotObject( pColor, KPlotObject::Lines, 2.0 ); KPlotObject *oSet = new KPlotObject( pColor, KPlotObject::Lines, 2.0 );
KPlotObject *oTransit = new KPlotObject( pColor, KPlotObject::Lines, 2.0 ); KPlotObject *oTransit = new KPlotObject( pColor, KPlotObject::Lines, 2.0 );
bool needRiseLabel = true;
bool needSetLabel = true; float defaultSetTime = -10.0;
bool needTransertLabel = true; float defaultRiseTime = 8.0;
QString label; QString label;
bool initialRise = true;
bool initialSet = true;
bool initialTransit = true;
bool extraCheckRise = true;
bool extraCheckSet = true;
bool extraCheckTransit = true;
bool needRiseLabel = false;
bool needSetLabel = false;
bool needTransertLabel = false;
float maxRiseTime = 0.0;
for( int i=0; i<vRise.size(); ++i ){
if (vRise.at(i).x()>=maxRiseTime)
maxRiseTime = vRise.at(i).x();
}
maxRiseTime = qFloor(maxRiseTime) - 1.0;
for ( int i=0; i<vRise.size(); ++i ) {
/* if rise time is set under -23.0 or above 23.0, it means the planet never rise or set, for (int i=0; i<vRise.size(); ++i){
* we add the current KPlotObject to CalendarView and create a new one. */ if(initialRise && (vRise.at(i).x() > defaultSetTime && vRise.at(i).x() < defaultRiseTime )){
if ( vRise.at( i ).x() > -23.0 && vRise.at( i ).x() < 23.0 ) { needRiseLabel = true;
/* If the difference between to points is greater than 6 hours, initialRise = false;
* we consider the line continues on the other side of the view. }else if (vRise.at(i).x() < defaultSetTime || vRise.at(i).x() > defaultRiseTime){
* Add the current KPlotObject to CalendarView and create a new one. */ initialRise = true;
if ( i > 0 && fabs( vRise.at( i ).x() - vRise.at( i-1 ).x() ) > 6.0 ) { needRiseLabel = false;
scUI->CalendarView->addPlotObject( oRise ); }else
oRise = new KPlotObject( pColor, KPlotObject::Lines, 2.0 ); needRiseLabel = false;
needRiseLabel = true;
}
// Set label if the line is on the night area, and if it needs one. if(extraCheckRise && vRise.at(i).x() > defaultRiseTime && vRise.at(i).x() < maxRiseTime){
if ( needRiseLabel needRiseLabel = true;
&& vRise.at(i).x() > scUI->CalendarView->getSetTime( i ) extraCheckRise = false;
&& vRise.at(i).x() < scUI->CalendarView->getRiseTime( i ) ) { }
if(initialSet && (vSet.at(i).x() > defaultSetTime && vSet.at(i).x() < defaultRiseTime)){
needSetLabel = true;
initialSet = false;
}else if (vSet.at(i).x() < defaultSetTime || vSet.at(i).x() > defaultRiseTime){
initialSet = true;
needSetLabel = false;
}else
needSetLabel = false;
if(extraCheckSet && vSet.at(i).x() > defaultRiseTime && vSet.at(i).x() < maxRiseTime){
needSetLabel = true;
extraCheckSet = false;
}
if(initialTransit && (vTransit.at(i).x() > defaultSetTime && vTransit.at(i).x() < defaultRiseTime)){
needTransertLabel = true;
initialTransit = false;
}else if (vTransit.at(i).x() < defaultSetTime || vTransit.at(i).x() > defaultRiseTime){
initialTransit = true;
needTransertLabel = false;;
}else
needTransertLabel = false;
if(extraCheckTransit && vTransit.at(i).x() > defaultRiseTime && vTransit.at(i).x() < maxRiseTime ){
needTransertLabel = true;
extraCheckTransit = false;
}
if ( vRise.at( i ).x() > -23.0 && vRise.at( i ).x() < 23.0 ) {
if ( i > 0 && fabs( vRise.at( i ).x() - vRise.at( i-1 ).x() ) > 6.0 ) {
scUI->CalendarView->addPlotObject( oRise );
oRise = new KPlotObject( pColor, KPlotObject::Lines, 2.0 );
extraCheckRise = true;
}
if(needRiseLabel)
label = i18nc( "A planet rises from the horizon", "%1 rises", ksp->name() ); label = i18nc( "A planet rises from the horizon", "%1 rises", ksp->name() );
needRiseLabel = false; else
} else
label = QString(); label = QString();
/* When the line is over day area, we set needRiseLabel to true, so, the next // Add the current point to KPlotObject
* time the line pass over the night area, a label will be draw. */ oRise->addPoint( vRise.at(i), label );
if ( vRise.at(i).x() >= scUI->CalendarView->getRiseTime( i ) ) }else {
needRiseLabel = true;
// Add the current point to KPlotObject
oRise->addPoint( vRise.at(i), label );
} else {
scUI->CalendarView->addPlotObject( oRise ); scUI->CalendarView->addPlotObject( oRise );
oRise = new KPlotObject( pColor, KPlotObject::Lines, 2.0 ); oRise = new KPlotObject( pColor, KPlotObject::Lines, 2.0 );
needRiseLabel = true;
} }
// Same process for set time if ( vSet.at( i ).x() > -23.0 && vSet.at( i ).x() < 23.0) {
if ( vSet.at( i ).x() > -23.0 && vSet.at( i ).x() < 23.0) { if ( i > 0 && fabs( vSet.at( i ).x() - vSet.at( i-1 ).x() ) > 6.0 ) {
if ( i > 0 && fabs( vSet.at( i ).x() - vSet.at( i-1 ).x() ) > 6.0 ) { scUI->CalendarView->addPlotObject( oSet );
scUI->CalendarView->addPlotObject( oSet ); oSet = new KPlotObject( pColor, KPlotObject::Lines, 2.0 );
oSet = new KPlotObject( pColor, KPlotObject::Lines, 2.0 ); extraCheckSet = true;
needSetLabel = true; }
}
if ( needSetLabel && vSet.at(i).x() > scUI->CalendarView->getSetTime( i ) && vSet.at(i).x() < scUI->CalendarView->getRiseTime( i ) ){ if(needSetLabel)
label = i18nc( "A planet sets from the horizon", "%1 sets", ksp->name() ); label = i18nc( "A planet sets from the horizon", "%1 sets", ksp->name() );
needSetLabel = false; else
} else label = QString();
label = QString();
if ( vSet.at(i).x() <= scUI->CalendarView->getSetTime( i ) ) oSet->addPoint( vSet.at(i), label );
needSetLabel = true; }else {
oSet->addPoint( vSet.at(i), label );
} else {
scUI->CalendarView->addPlotObject( oSet ); scUI->CalendarView->addPlotObject( oSet );
oSet = new KPlotObject( pColor, KPlotObject::Lines, 2.0 ); oSet = new KPlotObject( pColor, KPlotObject::Lines, 2.0 );
needSetLabel = true;
} }
// Same process for transit time if ( vTransit.at( i ).x() > -23.0 && vTransit.at( i ).x() < 23.0) {
if ( vTransit.at( i ).x() > -23.0 && vTransit.at( i ).x() < 23.0) { if ( i > 0 && fabs( vTransit.at( i ).x() - vTransit.at( i-1 ).x() ) > 6.0 ) {
if ( i > 0 && fabs( vTransit.at( i ).x() - vTransit.at( i-1 ).x() ) > 6.0 ) { scUI->CalendarView->addPlotObject( oTransit );
scUI->CalendarView->addPlotObject( oTransit ); oTransit = new KPlotObject( pColor, KPlotObject::Lines, 2.0 );
oTransit = new KPlotObject( pColor, KPlotObject::Lines, 2.0 ); extraCheckTransit = true;
needTransertLabel = true; }
}
if ( needTransertLabel && vTransit.at(i).x() > scUI->CalendarView->getSetTime( i ) && vTransit.at(i).x() < scUI->CalendarView->getRiseTime( i ) ) { if(needTransertLabel)
label = i18nc( "A planet transits across the meridian", "%1 transits", ksp->name() ); label = i18nc( "A planet transits across the meridian", "%1 transits", ksp->name() );
needTransertLabel = false; else
} else
label = QString(); label = QString();
if ( vTransit.at(i).x() <= scUI->CalendarView->getSetTime( i ) || vTransit.at(i).x() >= scUI->CalendarView->getRiseTime( i ) )
needTransertLabel = true; oTransit->addPoint( vTransit.at(i), label );
oTransit->addPoint( vTransit.at(i), label ); }else {
} else {
scUI->CalendarView->addPlotObject( oTransit ); scUI->CalendarView->addPlotObject( oTransit );
oTransit = new KPlotObject( pColor, KPlotObject::Lines, 2.0 ); oTransit = new KPlotObject( pColor, KPlotObject::Lines, 2.0 );
needTransertLabel = true;
} }
} }
// Add the last points // Add the last points
scUI->CalendarView->addPlotObject( oRise ); scUI->CalendarView->addPlotObject( oRise );
scUI->CalendarView->addPlotObject( oSet ); scUI->CalendarView->addPlotObject( oSet );
......
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