Esempio n. 1
0
/*****************************************************
**
**   HoraExpert   ---   write
**
******************************************************/
void HoraExpert::write( Sheet *sheet, const bool isLocaltime )
{
	TzUtil tzu;
	wxString s;
	TzFormattedDate fd;
	Lang lang;
	SheetFormatter fmt;

	double corr = ( location->getTimeZone() + location->getDST()) / 24;

	Table *table = new Table( 7, 13 );
	if ( config->view->showTextViewHeaders ) table->setHeader( _( "Hora" ));

	table->setHeader( 0,  _( "Begin" ));
	table->setHeader( 1,  _( "Lord" ));
	table->setHeader( 2,  _( "End" ));
	//table->setHeader( 3,  wxEmptyString );
	table->setHeader( 4,  _( "Begin" ));
	table->setHeader( 5,  _( "Lord" ));
	table->setHeader( 6,  _( "End" ));
	int line = 1;
	int colskip = 0;
	for ( int i = 0; i < 24; i++ )
	{
		if ( i == 12 )
		{
			colskip = 4;
			line = 1;
		}

		table->setEntry( 3, line, wxEmptyString );
		fd = tzu.getDateFormatted( horaStart[i] + corr, isLocaltime );
		table->setEntry( colskip, line, fd.timeFormatted );

		table->setEntry( 1+colskip, line, fmt.getObjectName( horaLord[i], TF_LONG ));

		fd = tzu.getDateFormatted( horaStart[i+1] + corr, isLocaltime );
		table->setEntry( 2+colskip, line, fd.timeFormatted );
		line++;
	}
	sheet->addItem( table );

	sheet->addLine( wxString::Format( wxT( "%s: %s" ), _( "Lord of the day" ),
		lang.getObjectName( getDinaLord(), TF_LONG ).c_str()));
	sheet->addLine( wxString::Format( wxT( "%s: %s" ), _( "Lord of the month" ),
		lang.getObjectName( getMasaLord(), TF_LONG ).c_str()));
	sheet->addLine( wxString::Format( wxT( "%s: %s" ), _( "Lord of the year" ),
		lang.getObjectName( getVarshaLord(), TF_LONG ).c_str() ));
}
Esempio n. 2
0
/*****************************************************
**
**   GraphicalEphemWidgetItem   ---   paintPlanets
**
******************************************************/
void GraphicalEphemWidgetItem::paintPlanets( Painter *painter )
{
	ObjectId p;
	double x1, x2, y1, y2;  // daily positions in y and y dimension
	double xp;              // x position for jumps
	double l1, l2;       // length of planets
	double yp, yp2, ydiff;      // length values for jumps
	const int sshift = 60;
	int lsymbolshift[sshift];
	int rsymbolshift[sshift];
	int ylshift, yrshift;
	const int xshiftunit = 15;

	const int mlen = expert->getNumberOfDays();  // length of month
	const double xstep = rect.width / mlen;  // daily step in x dimension

	wxString s;
	Lang lang;

	for ( int i = 0; i < sshift; i++ )
	{
		lsymbolshift[i] = 0;
		rsymbolshift[i] = 0;
	}

	for ( unsigned i1 = 0; i1 < expert->getPlanetdataSize(); i1++ )
	{
		p = expert->getPlanetId( i1 );

		// loop if daily motion of moon is smaller than max_deg
		if ( max_deg < 14 &&  p == OMOON ) continue;

		setLineStyle( painter, p );
		for ( int day = 0; day < mlen; day++ )
		{
			x1 =  rect.x + day * xstep;
			x2 =  x1 + xstep;
			l1 = a_red( expert->getPlanetLongitude( i1, day ), max_deg );
			y1 = ybottom - l1 * rect.height / max_deg;
			l2 = a_red( expert->getPlanetLongitude( i1, day+1 ), max_deg );
			y2 = ybottom - l2 * rect.height / max_deg;

			if ( expert->getPlanetRetro( i1, day ))
			{
				if (( l1 < l2 ) && expert->getPlanetRetro( i1, day+1 )) // handle jumps
				{
					yp = l1;
					yp2 = max_deg - l2;
					ydiff = yp / ( yp + yp2 );
					xp = (int)( x1 + ydiff * xstep );
					painter->drawLine( x1, y1, xp, ybottom );
					painter->drawLine( xp, rect.y, x2, y2 );
				}
				else // that's normal
				{
					painter->drawLine( x1, y1, x2, y2 );
				}
			}
			else // non retrograde
			{
				if (( l1 > l2 ) && ! expert->getPlanetRetro( i1, day+1 )) // handle jumps
				{
					yp = max_deg - l1;
					yp2 = l2;
					ydiff = yp / ( yp + yp2 );
					xp = x1 + ydiff * xstep;
					//printf( "2 planet %d yp %f yp2 %f x1 %d x2 %d xp %d l1 %f l2 %f ydiff %f\n", p, yp, yp2, x1, x2, xp, l1, l2, ydiff );
					painter->drawLine( x1, y1, xp, rect.y );
					painter->drawLine( xp, ybottom, x2, y2 );
				}
				else // that happens normally
				{
					painter->drawLine( x1, y1, x2, y2 );
				}
			}
		}
		if ( config->writer->planetSymbols )
		{
			painter->setSymbolFont();
			s = SymbolProvider().getPlanetCode( p );
		}
		else
		{
			painter->setGraphicFont();
			s = lang.getObjectName( p, TF_MEDIUM, props->isVedic() );
		}
		// Planet name on left side
		y1 = ybottom - a_red( expert->getPlanetLongitude( i1, 0 ), max_deg ) * rect.height / max_deg;

		assert( rect.height != 0 );
		ylshift = a_red( sshift * y1 / rect.height, 60 );

		painter->drawTextFormatted(
			wxRect( Max( rect.x - xshiftunit * lsymbolshift[ylshift] - 10, 0 ), y1 - 5, 10, 10 ), s, Align::Right+Align::VCenter );
		lsymbolshift[ylshift]++;

		// Planet name on right side
		y1 = ybottom - a_red( expert->getPlanetLongitude( i1, mlen ), max_deg ) * rect.height / max_deg;
		yrshift = a_red( sshift * y1 / rect.height, 60 );
		painter->drawTextFormatted( wxRect( xright + xshiftunit * rsymbolshift[yrshift], y1 - 5, 20, 10 ), s, Align::Left+Align::VCenter );
		rsymbolshift[yrshift]++;
	}
}