示例#1
0
/*****************************************************
**
**   BasicVedicChart   ---   writeChartContents
**
******************************************************/
void BasicVedicChart::writeChartContents( const int &chart_id, const bool applyFilter )
{
	ObjectId planet;
	uint f;
	wxString lname, sname, symbol, av;
	bool retro, avmode;
	SymbolProvider sp;
	SheetFormatter fmt;

	if ( chart_id == 0 && ! h1set ) printf( "WARN BasicVedicChart::writeChartContents no chart set for id 0\n" );
	if ( chart_id == 1 && ! h2set ) printf( "WARN BasicVedicChart::writeChartContents no chart set for id 1\n" );

	ObjectArray o = applyFilter ? chartprops->getVedicPlanetList( chartprops->getObjectFilter()) : obs;
	for ( uint i = 0; i < o.size(); i++ )
	{
		planet = o[i];

		// do not paint ascendant in north indian chart
		if ( field_count == 12 && chart_id == 0 && planet == OASCENDANT && chartprops->getVedicChartDisplayConfig().indianChartType == VCT_NORTH ) continue;

		// do not paint ascendant in south indian chart if markup of AS is enabled
		if ( field_count == 12 && ! h2set && planet == OASCENDANT && chartprops->getVedicChartDisplayConfig().southIndianAscendantMarkup ) continue;

		f = a_red( getPlanetField( planet, chart_id ) - positionOffset, field_count );
		//printf( "positionOffset %d\n", positionOffset );
		assert( f < fields.size());

		ChartContents &cc = fields[f].getContents( chart_id );

		cc.planets.push_back( planet );

		lname = fmt.getObjectNamePlain( planet, TF_LONG, true );
		sname = fmt.getObjectNamePlain( planet, TF_MEDIUM, true );

		// retrogression
		retro = ( chartprops->getVedicChartDisplayConfig().showRetro ) && getPlanetRetro( planet, chart_id )
		        && planet != OMEANNODE && planet != OMEANDESCNODE;
		if ( retro )
		{
			//lname += wxT( " " );
			lname += wxT( "(R)" );
			sname += wxT( "R" );
		}

		// see if transit mode, varga, av and valid planet
		avmode = ( IS_AVPLANET( planet )
			&& charttype == CT_TRANSIT
			&& chart_id == 1
			&& field_count == 12
			&& chartprops->getVedicChartDisplayConfig().showAshtakavarga );

		if ( avmode )
		{
			av = wxString::Format( wxT( " %d" ), getAshtakavargaPoints( planet, f ));
			sname += av;
			lname += av;
		}

		// symbol
		symbol.Clear();
		if ( ! avmode && config->writer->planetSymbols && getVChartConfig()->useSymbols && planet <= MAX_EPHEM_OBJECTS ) symbol = sp.getPlanetCode( planet );
		if ( ! symbol.IsEmpty() )
		{
			cc.graphicitems.push_back( ChartGraphicItem( symbol, planet, retro ));
		}
		else
		{
			ChartTextItem item( lname, sname, retro );
			cc.textitems.push_back( item );
		}
	}
}
示例#2
0
/*****************************************************
**
**   TextHelper   ---   writeVedicPlanets
**
******************************************************/
int TextHelper::writeVedicPlanets()
{
#define HOUSE_QUALIFIER 1000
  wxString s;
  int pindex, rowindex = 1, shast, col = 1, p, ret = 0, lord, sublord;
  int numcols;
  unsigned int i;
  ObjectPosition pos;
  Formatter *f = Formatter::get();
  Lang lang;

  int nakshatramode =  ( config->vNakshatraMode28 ? N28 : N27 );
  VargaHoroscope chart( horoscope, VARGA_RASI );
  VargaHoroscope bchart( horoscope, VARGA_BHAVA );
  JaiminiExpert expert( &chart );
  AshtakavargaExpert aexpert( &chart );
  Planet *planet;
  int istyle = chartprops->getVedicMainStyle();

  int extraObjects = 0;
  if ( chartprops->getVedicObjectStyle() & OBJECTS_INCLUDE_D9_LAGNA ) extraObjects |= OBJECTS_INCLUDE_D9_LAGNA;
  vector<int> obs = chartprops->getVedicPlanetList( extraObjects );

  int opt_lord, opt_dig, opt_nav, opt_kara, opt_shast, opt_nak, opt_dasa, opt_bha, opt_kp, opt_ashtaka, opt_pada,
    opt_houses, opt_declinations;

  opt_lord = opt_dig = opt_nav = opt_kara = opt_shast = opt_nak = opt_dasa = opt_bha = opt_kp = opt_ashtaka = opt_pada
    = opt_houses = opt_declinations = 0;

  numcols = 2;
  if ( istyle & MAIN_CHILD_SHOW_LORD        ) { opt_lord = true; numcols++; }
  if ( istyle & MAIN_CHILD_SHOW_DIGNITY     ) { opt_dig = true; numcols++; }
  if ( istyle & MAIN_CHILD_SHOW_NAVAMSA     ) { opt_nav = true; numcols++; }
  if ( istyle & MAIN_CHILD_SHOW_KARAKA      ) { opt_kara = true; expert.calcCharaKarakas(); numcols++; }
  if ( istyle & MAIN_CHILD_SHOW_SHASTIAMSA  ) { opt_shast = true; numcols++; }
  if ( istyle & MAIN_CHILD_SHOW_NAKSHATRA   ) { opt_nak = true; numcols++; }
  if ( istyle & MAIN_CHILD_SHOW_DASAVARGA   ) { opt_dasa = true; numcols++; }
  if ( istyle & MAIN_CHILD_SHOW_HOUSEPOS    ) { opt_bha = true; numcols++; }
  if ( istyle & MAIN_CHILD_SHOW_ASHTAKA     ) { opt_ashtaka = true; aexpert.update(); numcols += 1; }
  if ( istyle & MAIN_CHILD_SHOW_PADA        ) { opt_pada = true; numcols += 1; }
  if ( istyle & MAIN_CHILD_SHOW_KP          ) { opt_kp = true; horoscope->updateKP( 0 ); numcols += 2; }
  if ( istyle & MAIN_CHILD_SHOW_DECLINATION ) { opt_declinations = true; numcols ++; }

  if ( istyle & MAIN_CHILD_SHOW_HOUSES )
  {
    opt_houses = true;
    for( i = HOUSE1; i <= HOUSE12; i++ ) obs.push_back( i + HOUSE_QUALIFIER );
  }

  Table table( numcols, obs.size() + 1 );
  table.setHeader( 0,  _( "Planet" ));
  table.setHeader( 1,  _( "Length" ));
  i = 2;
  if ( opt_declinations ) table.setHeader( i++, _( "Declination" ));
  if ( opt_lord ) table.setHeader( i++, _( "Lord" ));
  if ( opt_dig ) table.setHeader( i++, _( "Dignity" ));
  if ( opt_nav ) table.setHeader( i++, _( "D-9" ));
  if ( opt_nak ) table.setHeader( i++, _( "Nakshatra" ));
  if ( opt_pada ) table.setHeader( i++, _( "Pada" ));
  if ( opt_kp )
  {
    table.setHeader( i++, _( "KP Lord" ));
    table.setHeader( i++, _( "Sublord" ));
  }
  if ( opt_shast ) table.setHeader( i++, _( "Shastiamsa" ));
  if ( opt_dasa ) table.setHeader( i++, _( "Dasa Varga" ));
  if ( opt_bha ) table.setHeader( i++, _( "Bhava" ));
  if ( opt_kara ) table.setHeader( i++, _( "Karaka" ));
  if ( opt_ashtaka ) table.setHeader( i++, _( "AV" ));

  bool ishouse;
  for( i = 0; i < obs.size(); i++ )
  {
    pindex = obs[i];
    ishouse = false;

    if ( pindex >= HOUSE_QUALIFIER )
    {
      pos.length = horoscope->getHouse( pindex - HOUSE_QUALIFIER, true, false );
      pos.latitude = 0;
      pos.retro = false;
    }
    else
    {
      pos = horoscope->getObjectPosition( pindex, true );

      // pos.length is 0 for unclaculated planets because Ayanamsa isn't subtracted in that case
      if ( pos.length == 0 && pindex != OARIES ) ret++;
    }

    planet = 0;
    col = 2;
    assert( (int)table.nb_rows >= rowindex );

    table.setEntry( 0, rowindex,
      ( pindex <= LAST_ARABIC_OBJECT ? writer->getObjectName( pindex, TLARGE, true ) : lang.getBhavaName( pindex - HOUSE_QUALIFIER )));
    if ( pindex <= OSATURN ) planet = horoscope->getPlanet( pindex );

    table.setEntry( 1, rowindex, writer->getPosFormatted( pos.length, pos.retro ));

    // Declination
    if ( opt_declinations )
      table.setEntry( col++, rowindex, f->getLatitudeFormatted( pos.latitude, DEG_PRECISION_SECOND ));

    // Lord
    if ( opt_lord )
      table.setEntry( col++, rowindex, writer->getObjectName( getLord( getRasi( pos.length )), TLARGE, true ));

    // Dignity
    if ( opt_dig )
    {
      if ( pindex >= OSUN && pindex <= OSATURN && obs[i] < MAX_EPHEM_OBJECTS )
        table.setEntry( col, rowindex, lang.getDignityName( horoscope->getVargaData( pindex, VARGA_RASI )->getDignity(), TLARGE ));
      col++;
    }

    // Navamsa
    if ( opt_nav )
      table.setEntry( col++, rowindex, writer->getSignName( getRasi( pos.length * 9 ), config->signPrecision ));

    // Nakshatra
    if ( opt_nak )
      table.setEntry( col++, rowindex,
        lang.getNakshatraName( getNakshatra( pos.length, nakshatramode ), nakshatramode, TMEDIUM ));

    // Pada
    if ( opt_pada )
    {
      s.Printf( wxT( "%d" ), (int)(getNakshatraLength( pos.length, nakshatramode ) / 3.3333333333 ) + 1 );
      table.setEntry( col++, rowindex, s );
    }

    // Krishnamurti
    if ( opt_kp )
    {
      if ( pindex <= LAST_ARABIC_OBJECT ) horoscope->getKPLords( obs[i], &lord, &sublord );
      else horoscope->getHouseKPLords( pindex - HOUSE_QUALIFIER, &lord, &sublord );
      table.setEntry( col++, rowindex, writer->getObjectName( lord, TLARGE, true ));
      table.setEntry( col++, rowindex, writer->getObjectName( sublord, TLARGE, true ));
    }

    // Shastiamsa
    if ( opt_shast )
    {
      shast = (int)( a_red( pos.length, 30 ) * 2 );
      if ( isEvenRasi( pos.length )) shast = 59 - shast;
      assert( shast >= 0 && shast < 60 );
      s.Printf( wxT( "%s (%c)" ), (const wxChar*)lang.getShastiamsaName( shast),
        ( k_shastiamsa_benefic[(int)shast] ? 'B' : 'M' ));
      table.setEntry( col, rowindex, s );
      col++;
    }

    // Dasavarga Dignity
    if ( opt_dasa )
    {
      if ( pindex <= OSATURN  && obs[i] < MAX_EPHEM_OBJECTS )
      {
        VargaExpert expert;
        table.setEntry( col, rowindex, lang.getVimsopakaDignityName( 2, planet->getVimsopakaBalaGoodVargas( 2 )) );
      }
      col++;
    }

    // Bhava
    if ( opt_bha  && obs[i] <= MAX_EPHEM_OBJECTS )
    {
      s.Printf( wxT( "%d" ), red12( bchart.getRasi( pindex ) - bchart.getRasi( OASCENDANT )) + 1 );
      table.setEntry( col++, rowindex, s );
    }

    // Karaka
    if ( opt_kara )
    {
      if ( pindex <= OSATURN ) p = pindex;
      else if ( pindex == OMEANNODE || pindex == OTRUENODE ) p = 7;
      else p = -1;
      if ( p >= 0 ) table.setEntry( col, rowindex, lang.getKarakaName( expert.getCharaKarakaProperty( p )) );
      col++;
    }


    // Ashtaka Varga
    if ( opt_ashtaka )
    {
      if ((( pindex >= OSUN && pindex <= OSATURN ) || pindex == OASCENDANT )  && obs[i] <= MAX_EPHEM_OBJECTS )
      {
        s.Printf( wxT( "%d" ), aexpert.getItem( REKHA, pindex, getRasi( pos.length )));
        table.setEntry( col++, rowindex, s );
      }
      col++;
    }
    rowindex++;
  }
  writer->writeTable( table );
  return ret;
}
示例#3
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 );
}
示例#4
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]++;
	}
}