Пример #1
0
/*****************************************************
**
**   EphemExpert   ---   writeDetails
**
******************************************************/
void EphemExpert::writeDetails( Writer *writer )
{
	int i;
	wxString s, tz_str, thetime;
	Lang lang;
	Formatter *formatter = Formatter::get();
	TzUtil tzu;

	if ( ! cdetails ) calcDetails();

	s.Printf( wxT ( "%s %d" ), (const wxChar*)lang.getMonthName( month-1 ), year );
	writer->writeHeader1( s );

	int line = 1;
	int nb_leaps = 0;
	for ( i = 0; i < nb_days; i++ )
	{
		if ( i > 0 && weekday[i] == 0 ) nb_leaps++;
	}
	Table table( 5, nb_days+1+nb_leaps );
	table.setHeader( 0, _( "Day" ));
	table.setHeader( 1, _( "Sidereal Time" ));
	table.setHeader( 2, _( "Sunrise" ));
	table.setHeader( 3, _( "Sunset" ));
	table.setHeader( 4, _( "Tithi (Sunrise)" ));

	line = 1;
	for ( i = 0; i < nb_days; i++ )
	{
		// blank line on weekend
		if ( i > 0 && weekday[i] == 0 )
		{
			for ( int j = 0; j < 5; j++ ) table.setHeaderEntry( j, line, wxEmptyString );
			line++;
		}

		s.Printf( wxT( "%02d %s" ), i+1, (const wxChar*)lang.getWeekdayName( weekday[i] ).Left(2) );
		if ( testDayIndexForCurrent( i+1 )) table.setHeaderEntry( 0, line, s );
		else	table.setEntry( 0, line, s );

		table.setEntry( 1, line, formatter->getTimeFormatted( st[i] ) );

		TzFormattedDate fd = tzu.getDateFormatted( sunrise[i], isLocaltime );
		thetime = fd.timeFormatted;
		//if ( dstchange ) thetime << wxT( " " ) << fd.timezoneFormatted;
		table.setEntry( 2, line, thetime );

		fd = tzu.getDateFormatted( sunset[i], isLocaltime );
		table.setEntry( 3, line, fd.timeFormatted );

		table.setEntry( 4, line, lang.getTithiName( tithi[i] ));
		line++;
	}
	writer->writeTable( table );
}
Пример #2
0
/*****************************************************
**
**   EphemExpert   ---   writeDefaultEphemeris
**
******************************************************/
int EphemExpert::writeDefaultEphemeris( Writer *writer )
{
	int ret = 0;
	wxString tz_str, s, rasi_str, nak_str;
	int i, j, deg, min, numcols;
	unsigned int i1;
	double rasilen;
	bool showrasi, shownak;
	wxString d;
	Lang lang;

	if ( !clen  ) ret = calcLength();
	writeHeaderInfo( writer );
	numcols = planetdata.size() + 1;

	int line = 1;
	int nb_leaps = 0;
	for ( i = 0; i < nb_days; i++ )
	{
		if ( i > 0 && weekday[i] == 0 ) nb_leaps++;
	}
	Table table( numcols, nb_days+nb_leaps+2 );
	table.setHeader( 0, _( "Day" ));

	// Header
	int col = 1;
	for ( i1 = 0; i1 < planetdata.size(); i1++ )
	{
		table.setHeader( col, writer->getObjectName( planetdata[i1].pindex, TLARGE, chartprops->isVedic() ));
		col++;
	}
	line = 1;
	for ( i = 0; i < nb_days; i++ )
	{
		//if ( i > 0 && weekday[i] == 0 ) o << Endl; // blank line on weekend
		if ( i > 0 && weekday[i] == 0 )
		{
			for ( j = 0; j < numcols; j++ ) table.setHeaderEntry( j, line, wxEmptyString );
			line++;
		}

		s.Printf( wxT( "%02d %s" ), i+1, (const wxChar*)lang.getWeekdayName( weekday[i] ).Left(2) );

		// write TZ if change during month
		/*
		if ( dstchange )
		{
			TzFormattedDate fd = tzutil.getDateFormatted( jd[i], isLocaltime );
			s << wxT( " " ) << fd.timezoneFormatted;
		}
		*/

		if ( testDayIndexForCurrent( i+1 )) table.setHeaderEntry( 0, line, s );
		else	table.setEntry( 0, line, s );

		col = 1;
		for ( i1 = 0; i1 < planetdata.size(); i1++ )
		{
			rasilen = getRasiLen( planetdata[i1].len[i] ) + .008333333;
			deg = (int)rasilen;
			min = (int)( 60 * ( rasilen - (double)deg ));

			// symbol for retrogression
			d = wxT( " " );
			if ( planetdata[i1].retro[i] ) {
				d = writer->getRetroSymbol();
			}
			else if ( i > 1 && planetdata[i1].retro[i] != planetdata[i1].retro[i-1] )
			{
				planetdata[i1].retro[i] ? d = writer->getRetroSymbol(): d = writer->getRetroSymbol( 1 );
			}
			else if ( i == nb_days - 1 && planetdata[i1].retro[i] ) {
				d = writer->getRetroSymbol();
			}

			showrasi = shownak = true;
			rasi_str = showrasi ? writer->getSignName( planetdata[i1].rasi[i] ) : wxT( "  " );
			nak_str = shownak ? lang.getNakshatraName( planetdata[i1].nakshatra[i], N27 ) : wxT( "   " );

			// ready to print now
			if ( config->useVedicPositions )
			{
				if ( chartprops->isVedic() )
				{
					s.Printf( wxT( "%s%02d-%02d-%02d %s" ), (const wxChar*)d, planetdata[i1].rasi[i], deg, min, (const wxChar*)nak_str );
				}
				else
				{
					s.Printf( wxT( "%s%02d-%02d-%02d" ), (const wxChar*)d, planetdata[i1].rasi[i], deg, min );
				}
			}
			else
			{
				if ( chartprops->isVedic() )
				{
					s.Printf( wxT( "%s%02d%s%02d %s" ), (const wxChar*)d, deg, (const wxChar*)rasi_str, min, (const wxChar*)nak_str );
				}
				else
				{
					s.Printf( wxT( "%s%02d%s%02d" ), (const wxChar*)d, deg, (const wxChar*)rasi_str, min );
				}
			}
			table.setEntry( col, line, s );

			col++;
		}

		line++;
	}
	// Header
	table.setHeaderEntry( 0, line, _( "Day" ));
	col = 1;
	for ( i1 = 0; i1 < planetdata.size(); i1++ )
	{
		table.setHeaderEntry( col, line, writer->getObjectName( planetdata[i1].pindex, TLARGE, chartprops->isVedic() ));
		col++;
	}
	writer->writeTable( table );
	return ret;
}
Пример #3
0
/*****************************************************
**
**   GenericTableWriter   ---   writeCustomDataEntry
**
******************************************************/
void GenericTableWriter::writeCustomDataEntry( const uint &col, const uint &row, const TAB_CELL_TYPE &type )
{
	assert( table->getNbCols() > col );
	assert( table->getNbRows() > row );
	Formatter *f = Formatter::get();
	DateTimeFormatter *df = DateTimeFormatter::get();
	Lang lang;
	wxString s;
	
	switch( type )
	{
		case TAB_CELL_NAME:
			table->setEntry( col, row,  _( "Name" ));
			table->setEntry( col + 1, row, h->getHName() );
		break;
		case TAB_CELL_FULL_DATE:
		{
			table->setEntry( col, row,  _( "Date" ));
			Location *loc = h->getDataSet()->getLocation();
			table->setEntry( col + 1, row, df->formatDateString( h->getJD(), loc->getTimeZone() + loc->getDST()));
		}
		break;
		case TAB_CELL_LOCAL_TIME:
		{
			table->setEntry( col, row,  _( "Local Time" ));
			Location *loc = h->getDataSet()->getLocation();
			table->setEntry( col + 1, row, f->getTimeFormatted( a_red( getTimeFromJD( h->getDataSet()->getDate()->getJD()) + loc->getTimeZone() + loc->getDST(), 24 )));
		}
		break;
		case TAB_CELL_LOCATION_NAME:
			table->setEntry( col, row,  _( "Location" ));
			table->setEntry( col + 1, row, h->getDataSet()->getLocation()->getLocName() );
		break;
		case TAB_CELL_LOCATION_LONGITUDE:
		{
			table->setEntry( col, row,  _( "Longitude" ));
			Location *loc = h->getDataSet()->getLocation();
			table->setEntry( col + 1, row, f->getLongitudeFormatted( loc->getLongitude()));
		}
		break;
		case TAB_CELL_LOCATION_LATITUDE:
		{
			table->setEntry( col, row,  _( "Latitude" ));
			Location *loc = h->getDataSet()->getLocation();
			table->setEntry( col + 1, row, f->getLatitudeFormatted( loc->getLatitude()));
		}
		break;
		case TAB_CELL_TZ_NAME:
		{
			table->setEntry( col, row,  _( "Time Zone" ));
			Location *loc = h->getDataSet()->getLocation();
			const double tz = loc->getTimeZone();
			table->setEntry( col + 1, row, wxString::Format( wxT( "%s %c%.1f" ), _( "UT" ), ( tz >= 0 ? '+' : ' ' ), tz ));
		}
		break;
		case TAB_CELL_DST:
		{
			table->setEntry( col, row,  _( "Daylight Saving" ));
			Location *loc = h->getDataSet()->getLocation();
			table->setEntry( col + 1, row, wxString::Format( wxT( "%.1f" ), loc->getDST()));
		}
		break;
		case TAB_CELL_UNIVERSAL_TIME:
			table->setEntry( col, row,  _( "Universal Time" ));
			table->setEntry( col + 1, row, f->getTimeFormatted( getTimeFromJD( h->getJD() )));
		break;
		case TAB_CELL_SIDEREAL_TIME:
			table->setEntry( col, row,  _( "Sidereal Time" ));
			table->setEntry( col + 1, row, f->getTimeFormatted( h->getSiderealTime()));
		break;
		case TAB_CELL_JULIAN_DATE:
			table->setEntry( col, row,  _( "Julian Date" ));
			table->setEntry( col + 1, row, wxString::Format( wxT( "%8.5f" ), h->getJD()));
		break;
		case TAB_CELL_SUNRISE:
		{
			table->setEntry( col, row,  _( "Sunrise" ));
			Location *loc = h->getLocation();
			if ( h->getSunrise() != 0 )
			{
				s = f->getTimeFormatted( getTimeFromJD( h->getSunrise() + ( loc->getTimeZone() + loc->getDST()) / 24.0 ));
			}
			else s = _( "n.a." );
			table->setEntry( col + 1, row, s );
		}
		break;
		case TAB_CELL_SUNSET:
		{
			table->setEntry( col, row,  _( "Sunset" ));
			Location *loc = h->getLocation();
			if ( h->getSunset() != 0 )
			{
				s = f->getTimeFormatted( getTimeFromJD( h->getSunset() + ( loc->getTimeZone() + loc->getDST()) / 24.0 ));
			}
			else s = _( "n.a." );
			table->setEntry( col + 1, row, s );
		}
		break;
		case TAB_CELL_VEDIC_AYANAMSA:
			table->setEntry( col, row,  _( "Vedic Ayanamsa" ));
			table->setEntry( col + 1, row, f->getAyanamsaNameAndValue( h->getAyanamsaType( true ), h->getAyanamsa( true )));
		break;
		case TAB_CELL_WESTERN_AYANAMSA:
			table->setEntry( col, row,  _( "Western Ayanamsa" ));
			table->setEntry( col + 1, row, f->getAyanamsaNameAndValue( h->getAyanamsaType( false ), h->getAyanamsa( false )));
		break;
		case TAB_CELL_VARNA:
			table->setEntry( col, row,  _( "Varna" ));
			table->setEntry( col + 1, row, lang.getVarnaName( getVarna( h->getVedicLongitude( OMOON ))));
		break;
		case TAB_CELL_GANA:
			table->setEntry( col, row,  _( "Gana" ));
			table->setEntry( col + 1, row, lang.getGanaName( NakshatraExpert().getGana( h->getVedicLongitude( OMOON ))));
		break;
		case TAB_CELL_YONI:
		{
			Yoni yoni = NakshatraExpert().getYoni( h->getVedicLongitude( OMOON ));
			table->setEntry( col, row,  _( "Yoni" ));
			table->setEntry( col + 1, row, yoni.name );
		}
		break;
		case TAB_CELL_NADI:
			table->setEntry( col, row,  _( "Nadi" ));
			table->setEntry( col + 1, row, lang.getNadiName( NakshatraExpert().getNadi( h->getVedicLongitude( OMOON ))));
		break;
		case TAB_CELL_RAJJU:
		{
			Rajju rajju = NakshatraExpert().getRajju( getNakshatra27( h->getVedicLongitude( OMOON )));
			table->setEntry( col, row,  _( "Rajju" ));
			table->setEntry( col + 1, row, lang.getRajjuName( rajju.aroha, rajju.type ));
		}
		break;
		case TAB_CELL_INCFLUENCE_TIME:
		{
			DasaExpert *expert = DasaExpertFactory().getDasaExpert( D_VIMSOTTARI, h );
			table->setEntry( col, row,  _( "Influence" ));
			table->setEntry( col + 1, row, expert->getDasaLordNameF( expert->getBirthMahaDasaLord(), TF_LONG ));
		}
		break;

		case TAB_CELL_LUNAR_TITHI:
		{
			double angle = red_deg( h->getVedicLongitude( OMOON ) - h->getVedicLongitude( OSUN ));
			table->setEntry( col, row,  _( "Lunar Tithi" ));
			table->setEntry( col + 1, row,  lang.getTithiName( angle / 12 ));
		}
		break;
		case TAB_CELL_WEEKDAY:
			table->setEntry( col, row,  _( "Weekday" ));
			table->setEntry( col + 1, row,  lang.getWeekdayName( h->getDataSet()->getWeekDay() ));
		break;

		case TAB_CELL_HORA_LORD:
		case TAB_CELL_DINA_LORD:
		case TAB_CELL_MASA_LORD:
		case TAB_CELL_VARSHA_LORD:
			writeHoraEntry( col, row, type );
		break;
		default:
			table->setEntry( col, row,  wxString::Format( wxT( "Error, wrong custom data entry id %d" ), (int)type ));
		break;
	};
}
Пример #4
0
/*****************************************************
**
**   EphemExpert   ---   writeKp
**
******************************************************/
void EphemExpert::writeKp( Writer *writer, const int &dasa )
{
	Lang lang;
	KPEvent *e;
	int d, m, y, lord, wd;
	vector<KPEvent>::iterator iter;
	TzUtil tzu;
	wxString s, thetime;
	vector<wxString> v;
	Table *table = 0;
	DasaExpert *expert = DasaExpertFactory::get()->getDasaExpert( dasa );
	if ( ! expert->hasKpFeatures() || dasa == 2 )
	{
		s.Printf( _( "K.P. events not supported for %s Dasa." ), expert->getName());
		writer->writeLine( s );
		return;
	}

	Formatter *formatter = Formatter::get();
	if ( ! chartprops->isVedic() )
	{
		writer->writeLine( _( "Not supported in western mode." ));
		return;
	}
	if ( ! ckp || mydasa != dasa ) calcKP( dasa );
	writeHeaderInfo( writer );

	//s.Printf( _( "%s Dasa" ), expert->getName());
	//writer->writeParagraph( s );

	lord = -1;
	int line = 1;
	int index = -1;
	for ( iter = kpevents.begin(); iter != kpevents.end(); iter++ )
	{
		e = (KPEvent*)(&(*iter));
		if ( e->dasaindex != index )
		{
			index = e->dasaindex;
			if ( table )
			{
				if ( expert->isRasiDasaExpert()) writer->writeHeader2( writer->getSignName( lord, TLARGE ));
				else writer->writeHeader2( writer->getObjectName( lord, TLARGE ));
				writer->writeTable( *table );
				delete table;
				table = 0;
			}
			table = new Table ( 5, 10 );
			table->setHeader( 0, _( "Day" ));
			table->setHeader( 1, _( "Time" ));
			table->setHeader( 2, _( "Lord" ));
			table->setHeader( 3, _( "Sublord" ));
			table->setHeader( 4, _( "Lunar Position" ));
			line = 1;
		}
		assert( table );
		formatter->getDateIntsFromJD( e->jd, d, m, y );
		wd = ((int)(e->jd + 1.5 )) % 7;
		assert( wd >= 0 && wd < 7 );
		s.Printf( wxT( "%02d %s" ), d, (const wxChar*)wxString( (const wxChar*)lang.getWeekdayName( wd )).Left(2) );
		table->setEntry( 0, line, s );

		TzFormattedDate fd = tzu.getDateFormatted( e->jd, isLocaltime );
		thetime = fd.timeFormatted;
		//if ( dstchange ) thetime << wxT( " " ) << fd.timezoneFormatted;
		table->setEntry( 1, line, thetime );
		//table->setEntry( 1, line, formatter->getTimeFormatted( getTimeFromJD( e->jd  + tz/24 )) );

		if ( expert->isRasiDasaExpert() )
		{
			table->setEntry( 2, line, writer->getSignName( e->lord, TLARGE ));
			table->setEntry( 3, line, writer->getSignName( e->sublord, TLARGE ));
		}
		else
		{
			table->setEntry( 2, line, writer->getObjectName( e->lord, TLARGE ));
			table->setEntry( 3, line, writer->getObjectName( e->sublord, TLARGE ));
		}
		table->setEntry( 4, line, writer->getPosFormatted( e->len, false ) );

		lord = e->lord;
		line++;
	}
	if ( table )
	{
		if ( expert->isRasiDasaExpert() )	writer->writeHeader2( writer->getSignName( e->lord, TLARGE ));
		else writer->writeHeader2( writer->getObjectName( e->lord, TLARGE ));
		writer->writeTable( *table );
		delete table;
		table = 0;
	}
}
Пример #5
0
/*****************************************************
**
**   TextHelper   ---   writeBaseData
**
******************************************************/
void TextHelper::writeBaseData()
{
	wxString s;
	double time;

	Formatter *f = Formatter::get();
	Lang lang;

	DataSet *ds = horoscope->getDataSet();
	Location *loc = ds->getLocation();
	JDate *date = ds->getDate();

	if ( show_header ) writer->writeHeader1( _( "Base Data" ));
	Table table( 2, 17 );

	int line = 0;
	table.setEntry( 0, line,  _( "Name" ));
	table.setEntry( 1, line++, horoscope->getHName() );

	table.setEntry( 0, line,  _( "Date" ));
	s << f->getDateStringFromJD( horoscope->getJD() + ( loc->getTimeZone() + loc->getDST() )/24 )
	<< wxT( " " ) << lang.getWeekdayName( ds->getWeekDay() );
	table.setEntry( 1, line++, s );

	table.setEntry( 0, line,  _( "Local Time" ));
	time = a_red( getTimeFromJD( date->getJD()) + loc->getTimeZone() + loc->getDST(), 24 );
	table.setEntry( 1, line++, f->getTimeFormatted( time ));

	table.setEntry( 0, line,  _( "Location" ));
	table.setEntry( 1, line++, loc->getLocName() );

	table.setEntry( 0, line,  _( "Longitude" ));
	table.setEntry( 1, line++, f->getLongitudeFormatted( loc->getLongitude()));

	table.setEntry( 0, line,  _( "Latitude" ));
	table.setEntry( 1, line++, f->getLatitudeFormatted( loc->getLatitude()));

	table.setEntry( 0, line,  _( "Time Zone" ));
	double tz = loc->getTimeZone();
	s.Printf( wxT( "%s %c%.1f %s" ), _( "UT" ), ( tz >= 0 ? '+' : ' ' ), tz, _( "Hours" ));
	table.setEntry( 1, line++, s );

	table.setEntry( 0, line,  _( "Daylight Saving" ));
	s.Printf( wxT( "%.1f %s" ), loc->getDST(), _( "Hours" ));
	table.setEntry( 1, line++, s );

	table.setEntry( 0, line,  _( "Universal Time" ));
	table.setEntry( 1, line++, f->getTimeFormatted( getTimeFromJD( horoscope->getJD() )));

	table.setEntry( 0, line,  _( "Sidereal Time" ));
	table.setEntry( 1, line++, f->getTimeFormatted( horoscope->getSiderealTime()));

	table.setEntry( 0, line,  _( "Julian Date" ));
	s.Printf( wxT( "%8.5f" ), horoscope->getJD());
	table.setEntry( 1, line++, s );

	table.setEntry( 0, line,  _( "Vedic Ayanamsa" ));
	table.setEntry( 1, line++, lang.getAyanamsaName( horoscope->getAyanamsaType( true ) ));

	table.setEntry( 0, line,  _( "Ayanamsa Value" ));
	table.setEntry( 1, line++, f->getDegreesFormatted( horoscope->getAyanamsa( true )));

	table.setEntry( 0, line,  _( "Western Ayanamsa" ));
	table.setEntry( 1, line++, lang.getAyanamsaName( horoscope->getAyanamsaType( false )));

	table.setEntry( 0, line,  _( "Ayanamsa Value" ));
	table.setEntry( 1, line++, f->getDegreesFormatted( horoscope->getAyanamsa( false )));

	table.setEntry( 0, line,  _( "Sunrise" ));
	if ( horoscope->getSunrise() != 0 )
		s = f->getFullDateStringFromJD( horoscope->getSunrise() + ( loc->getTimeZone() + loc->getDST() ) / 24.0 );
	else s = _( "n.a." );
	table.setEntry( 1, line++, s );

	table.setEntry( 0, line,  _( "Sunset" ));
	if ( horoscope->getSunset() != 0 )
		s = f->getFullDateStringFromJD( horoscope->getSunset() + ( loc->getTimeZone() + loc->getDST() ) / 24.0 );
	else s = _( "n.a." );
	table.setEntry( 1, line++, s );

	writer->writeTable( table );
}