Moved GsweAntiscionData to its own source files

This commit is contained in:
Gergely Polonkai 2013-09-23 22:27:18 +02:00
parent eb5b3fff5d
commit 6ee6650d84
14 changed files with 275 additions and 60 deletions

View File

@ -62,9 +62,11 @@ IGNORE_HFILES = \
swe-glib-private.h \
gswe-enumtypes.h \
gswe-moon-phase-data-private.h \
gswe-planet-data-private.h \
gswe-aspect-info-private.h \
gswe-aspect-data-private.h \
gswe-planet-data-private.h
gswe-antiscion-data-private.h \
$(NULL)
# Images to copy into HTML directory.
# e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png

View File

@ -23,6 +23,7 @@
<xi:include href="xml/gswe-moon-phase-data.xml"/>
<xi:include href="xml/gswe-aspect-data.xml" />
<xi:include href="xml/gswe-aspect-info.xml" />
<xi:include href="xml/gswe-antiscion-data.xml" />
<xi:include href="xml/swe-glib.xml"/>
<xi:include href="xml/gswe-moment.xml"/>
<xi:include href="xml/gswe-timestamp.xml"/>

View File

@ -97,6 +97,19 @@ GSWE_TYPE_ASPECT_DATA
gswe_aspect_data_get_type
</SECTION>
<SECTION>
<FILE>gswe-antiscion-data</FILE>
GsweAntiscionData
gswe_antiscion_data_get_antiscion_axis_info
gswe_antiscion_data_get_axis
gswe_antiscion_data_get_difference
gswe_antiscion_data_get_planet1
gswe_antiscion_data_get_planet2
<SUBSECTION Standard>
GSWE_TYPE_ANTISCION_DATA
gswe_antiscion_data_get_type
</SECTION>
<SECTION>
<FILE>gswe-timestamp</FILE>
<TITLE>GsweTimestamp</TITLE>
@ -156,12 +169,9 @@ GsweHouseSystemInfo
GsweAntiscionAxisInfo
GsweCoordinates
GsweHouseData
GsweAntiscionData
<SUBSECTION Standard>
GSWE_TYPE_ANTISCION_DATA
GSWE_TYPE_COORDINATES
GSWE_TYPE_HOUSE_DATA
gswe_antiscion_data_get_type
gswe_coordinates_get_type
gswe_house_data_get_type
</SECTION>

View File

@ -9,6 +9,7 @@ INST_H_SRC_FILES = \
gswe-moon-phase-data.h \
gswe-aspect-info.h \
gswe-aspect-data.h \
gswe-antiscion-data.h \
gswe-planet-data.h \
gswe-moment.h \
gswe-timestamp.h
@ -25,6 +26,7 @@ libswe_glib_1_0_la_SOURCES = \
gswe-planet-data.c \
gswe-aspect-info.c \
gswe-aspect-data.c \
gswe-antiscion-data.c \
gswe-moment.c \
gswe-timestamp.c \
gswe-enumtypes.c \

View File

@ -0,0 +1,45 @@
/* gswe-antiscion-data-private.h: Private parts of GsweAntiscionData
*
* Copyright © 2013 Gergely Polonkai
*
* SWE-GLib is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* SWE-GLib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#ifdef __SWE_GLIB_BUILDING__
#ifndef __SWE_GLIB_GSWE_ANTISCION_DATA_PRIVATE_H__
#define __SWE_GLIB_GSWE_ANTISCION_DATA_PRIVATE_H__
#include "gswe-planet-data.h"
#include "gswe-antiscion-data.h"
struct _GsweAntiscionData {
/* the first planet in the antiscion */
GswePlanetData *planet1;
/* the second planet in the antiscion */
GswePlanetData *planet2;
/* the axis on which this antiscion is */
GsweAntiscionAxis axis;
/* the #GsweAntiscionAxisInfo structure associated with this antiscion */
GsweAntiscionAxisInfo *antiscion_axis_info;
/* the difference in degrees between an exact antiscion and this given antiscion */
gdouble difference;
};
GsweAntiscionData *gswe_antiscion_data_copy(GsweAntiscionData *antiscion_data);
#endif /* __SWE_GLIB_GSWE_ANTISCION_DATA_PRIVATE_H__ */
#else /* not defined __SWE_GLIB_BUILDING__ */
#error __FILE__ "Can not be included, unless building SWE-GLib"
#endif /* __SWE_GLIB_BUILDING__ */

140
src/gswe-antiscion-data.c Normal file
View File

@ -0,0 +1,140 @@
/* gswe-antiscion-data.c: Antiscia related data
*
* Copyright © 2013 Gergely Polonkai
*
* SWE-GLib is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* SWE-GLib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include <glib-object.h>
#include "gswe-antiscion-data.h"
#include "gswe-antiscion-data-private.h"
/**
* SECTION:gswe-antiscion-data
* @short_description: a structure representing a planet's position-related data
* @title: GsweAntiscionData
* @stability: Stable
* @include: swe-glib.h
* @see_also: #GsweAntiscionInfo
*
* #GsweAntiscionData is a structure that represents an antiscion relationship
* between two planets, based on a specified axis.
*/
GsweAntiscionData *
gswe_antiscion_data_copy(GsweAntiscionData *antiscion_data)
{
GsweAntiscionData *ret = g_new0(GsweAntiscionData, 1);
ret->planet1 = antiscion_data->planet1;
ret->planet2 = antiscion_data->planet2;
ret->axis = antiscion_data->axis;
ret->antiscion_axis_info = antiscion_data->antiscion_axis_info;
ret->difference = antiscion_data->difference;
return ret;
}
G_DEFINE_BOXED_TYPE(GsweAntiscionData, gswe_antiscion_data, (GBoxedCopyFunc)gswe_antiscion_data_copy, (GBoxedFreeFunc)g_free);
/**
* gswe_antiscion_data_get_planet1:
* @antiscion_data: a #GsweAntiscionData
*
* Gets the first in the antiscion relationship.
*
* Returns: (transfer none): The #GswePlanetData associated with the first planet.
*/
GswePlanetData *
gswe_antiscion_data_get_planet1(GsweAntiscionData *antiscion_data)
{
if (antiscion_data) {
return antiscion_data->planet1;
} else {
return NULL;
}
}
/**
* gswe_antiscion_data_get_planet2:
* @antiscion_data: a #GsweAntiscionData
*
* Gets the second in the antiscion relationship.
*
* Returns: (transfer none): The #GswePlanetData associated with the second planet.
*/
GswePlanetData *
gswe_antiscion_data_get_planet2(GsweAntiscionData *antiscion_data)
{
if (antiscion_data) {
return antiscion_data->planet2;
} else {
return NULL;
}
}
/**
* gswe_antiscion_data_get_axis:
* @antiscion_data: a #GsweAntiscionData
*
* Gets the axis on which the antiscion relationship exists.
*
* Returns: the axis ID
*/
GsweAntiscionAxis
gswe_antiscion_data_get_axis(GsweAntiscionData *antiscion_data)
{
if (antiscion_data) {
return antiscion_data->axis;
} else {
return GSWE_ANTISCION_AXIS_NONE;
}
}
/**
* gswe_antiscion_data_get_antiscion_axis_info:
* @antiscion_data: a #GsweAntiscionData
*
* Gets the axis information related to the antiscion relationship's axis.
*
* Returns: (transfer none): the #GsweAntiscionInfo associated with this axis
*/
GsweAntiscionAxisInfo *
gswe_antiscion_data_get_antiscion_axis_info(GsweAntiscionData *antiscion_data)
{
if (antiscion_data) {
return antiscion_data->antiscion_axis_info;
} else {
return NULL;
}
}
/**
* gswe_antiscion_data_get_difference:
* @antiscion_data: a #GsweAntiscionData
*
* Gets the difference between an exact antiscion and this antiscion relationship.
*
* Returns: the difference, in degrees
*/
gdouble
gswe_antiscion_data_get_difference(GsweAntiscionData *antiscion_data)
{
if (antiscion_data) {
return antiscion_data->difference;
} else {
return 0.0;
}
}

50
src/gswe-antiscion-data.h Normal file
View File

@ -0,0 +1,50 @@
/* gswe-antiscion-data.h: Antiscia related data
*
* Copyright © 2013 Gergely Polonkai
*
* SWE-GLib is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* SWE-GLib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __SWE_GLIB_GSWE_ANTISCION_DATA_H__
#define __SWE_GLIB_GSWE_ANTISCION_DATA_H__
#include <glib-object.h>
#include "gswe-planet-data.h"
#include "gswe-antiscion-axis-info.h"
G_BEGIN_DECLS
/**
* GsweAntiscionData:
*
* <structname>GsweAntiscionData</structname> is an opaque structure whose members
* cannot be accessed directly.
*
* Since: 1.1
*/
typedef struct _GsweAntiscionData GsweAntiscionData;
GType gswe_antiscion_data_get_type(void);
#define GSWE_TYPE_ANTISCION_DATA (gswe_antiscion_data_get_type())
GswePlanetData *gswe_antiscion_data_get_planet1(GsweAntiscionData *antiscion_data);
GswePlanetData *gswe_antiscion_data_get_planet2(GsweAntiscionData *antiscion_data);
GsweAntiscionAxis gswe_antiscion_data_get_axis(GsweAntiscionData *antiscion_data);
GsweAntiscionAxisInfo *gswe_antiscion_data_get_antiscion_axis_info(GsweAntiscionData *antiscion_data);
gdouble gswe_antiscion_data_get_difference(GsweAntiscionData *antiscion_data);
G_END_DECLS
#endif /* __SWE_GLIB_GSWE_ANTISCION_DATA_H__ */

View File

@ -1176,7 +1176,7 @@ gswe_moment_get_planet_aspects(GsweMoment *moment, GswePlanet planet, GError **e
}
static gboolean
find_antiscion(gpointer axis_p, GsweAntiscionAxisInfo *antiscion_info, GsweAntiscionData *antiscion_data)
find_antiscion(gpointer axis_p, GsweAntiscionAxisInfo *antiscion_axis_info, GsweAntiscionData *antiscion_data)
{
GsweAntiscionAxis axis;
gdouble start_point,
@ -1188,9 +1188,9 @@ find_antiscion(gpointer axis_p, GsweAntiscionAxisInfo *antiscion_info, GsweAntis
}
planet_orb = fmin(antiscion_data->planet1->planet_info->orb, antiscion_data->planet2->planet_info->orb);
start_point = (antiscion_info->start_sign->sign_id - 1) * 30.0;
start_point = (antiscion_axis_info->start_sign->sign_id - 1) * 30.0;
if (antiscion_info->middle_axis == TRUE) {
if (antiscion_axis_info->middle_axis == TRUE) {
start_point += 15.0;
}
@ -1201,7 +1201,7 @@ find_antiscion(gpointer axis_p, GsweAntiscionAxisInfo *antiscion_info, GsweAntis
}
if ((antiscion_data->difference = fabs(antiscion_data->planet2->position - axis_position)) <= planet_orb) {
antiscion_data->antiscion_info = antiscion_info;
antiscion_data->antiscion_axis_info = antiscion_axis_info;
antiscion_data->axis = axis;
return TRUE;
@ -1259,10 +1259,10 @@ gswe_moment_calculate_antiscia(GsweMoment *moment)
antiscion_data->planet2 = inner_planet;
antiscion_data->axis = GSWE_ANTISCION_AXIS_NONE;
(void)g_hash_table_find(gswe_antiscion_info_table, (GHRFunc)find_antiscion, antiscion_data);
(void)g_hash_table_find(gswe_antiscion_axis_info_table, (GHRFunc)find_antiscion, antiscion_data);
if (antiscion_data->axis == GSWE_ANTISCION_AXIS_NONE) {
antiscion_data->antiscion_info = g_hash_table_lookup(gswe_antiscion_info_table, GINT_TO_POINTER(GSWE_ANTISCION_AXIS_NONE));
antiscion_data->antiscion_axis_info = g_hash_table_lookup(gswe_antiscion_axis_info_table, GINT_TO_POINTER(GSWE_ANTISCION_AXIS_NONE));
}
moment->priv->antiscia_list = g_list_prepend(moment->priv->antiscia_list, antiscion_data);

View File

@ -50,3 +50,4 @@ GswePlanetData *gswe_planet_data_copy(GswePlanetData *planet_data);
#else /* not defined __SWE_GLIB_BUILDING__ */
#error __FILE__ "Can not be included, unless building SWE-GLib"
#endif /* __SWE_GLIB_BUILDING__ */

View File

@ -46,18 +46,3 @@ gswe_house_data_copy(GsweHouseData *house_data)
G_DEFINE_BOXED_TYPE(GsweHouseData, gswe_house_data, (GBoxedCopyFunc)gswe_house_data_copy, (GBoxedFreeFunc)g_free);
static GsweAntiscionData *
gswe_antiscion_data_copy(GsweAntiscionData *antiscion_data)
{
GsweAntiscionData *ret = g_new0(GsweAntiscionData, 1);
ret->planet1 = antiscion_data->planet1;
ret->planet2 = antiscion_data->planet2;
ret->axis = antiscion_data->axis;
ret->antiscion_info = antiscion_data->antiscion_info;
ret->difference = antiscion_data->difference;
return ret;
}
G_DEFINE_BOXED_TYPE(GsweAntiscionData, gswe_antiscion_data, (GBoxedCopyFunc)gswe_antiscion_data_copy, (GBoxedFreeFunc)g_free);

View File

@ -369,28 +369,5 @@ typedef struct {
GType gswe_house_data_get_type(void);
#define GSWE_TYPE_HOUSE_DATA (gswe_house_data_get_type())
/**
* GsweAntiscionData:
* @planet1: the first planet in the antiscion
* @planet2: the second planet in the antiscion
* @axis: the axis on which this antiscion is
* @antiscion_info: the #GsweAntiscionAxisInfo structure associated with this
* antiscion
* @difference: the difference in degrees between an exact antiscion and this
* given antiscion
*
* Holds information about a given antiscion.
*/
typedef struct {
GswePlanetData *planet1;
GswePlanetData *planet2;
GsweAntiscionAxis axis;
GsweAntiscionAxisInfo *antiscion_info;
gdouble difference;
} GsweAntiscionData;
GType gswe_antiscion_data_get_type(void);
#define GSWE_TYPE_ANTISCION_DATA (gswe_antiscion_data_get_type())
#endif /* __SWE_GLIB_GSWE_TYPES_H__ */

View File

@ -23,6 +23,7 @@
#include "gswe-planet-data-private.h"
#include "gswe-aspect-info-private.h"
#include "gswe-aspect-data-private.h"
#include "gswe-antiscion-data-private.h"
extern gchar *gswe_ephe_path;
extern GsweTimestamp *gswe_full_moon_base_date;
@ -30,7 +31,7 @@ extern GHashTable *gswe_planet_info_table;
extern GHashTable *gswe_sign_info_table;
extern GHashTable *gswe_house_system_info_table;
extern GHashTable *gswe_aspect_info_table;
extern GHashTable *gswe_antiscion_info_table;
extern GHashTable *gswe_antiscion_axis_info_table;
GsweCoordinates *gswe_coordinates_copy(GsweCoordinates *coordinates);

View File

@ -40,7 +40,7 @@ GHashTable *gswe_planet_info_table;
GHashTable *gswe_sign_info_table;
GHashTable *gswe_house_system_info_table;
GHashTable *gswe_aspect_info_table;
GHashTable *gswe_antiscion_info_table;
GHashTable *gswe_antiscion_axis_info_table;
GsweTimestamp *gswe_full_moon_base_date;
#define ADD_PLANET(ht, v, i, s, r, n, o, h, dom1, dom2, exi1, exi2, exa, fal) (v) = g_new0(GswePlanetInfo, 1); \
@ -116,10 +116,10 @@ gswe_free_aspect_info(gpointer aspect_info)
}
void
gswe_free_antiscion_info(GsweAntiscionAxisInfo *antiscion_info)
gswe_free_antiscion_axis_info(GsweAntiscionAxisInfo *antiscion_axis_info)
{
g_free(antiscion_info->name);
g_free(antiscion_info);
g_free(antiscion_axis_info->name);
g_free(antiscion_axis_info);
}
/**
@ -135,7 +135,7 @@ gswe_init(void)
GsweSignInfo *sign_info;
GsweHouseSystemInfo *house_system_info;
GsweAspectInfo *aspect_info;
GsweAntiscionAxisInfo *antiscion_info;
GsweAntiscionAxisInfo *antiscion_axis_info;
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
@ -202,13 +202,13 @@ gswe_init(void)
ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_QUINTILE, _("Quintile"), 72, 3, TRUE, FALSE);
ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_BIQUINTILE, _("Bi-quintile"), 144, 3, TRUE, FALSE);
gswe_antiscion_info_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)gswe_free_antiscion_info);
gswe_antiscion_axis_info_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)gswe_free_antiscion_axis_info);
ADD_ANTISCION(gswe_antiscion_info_table, antiscion_info, gswe_sign_info_table, sign_info, GSWE_ANTISCION_AXIS_NONE, _("None"), GSWE_SIGN_NONE, FALSE);
ADD_ANTISCION(gswe_antiscion_info_table, antiscion_info, gswe_sign_info_table, sign_info, GSWE_ANTISCION_AXIS_ARIES, _("Aries/Libra"), GSWE_SIGN_ARIES, FALSE);
ADD_ANTISCION(gswe_antiscion_info_table, antiscion_info, gswe_sign_info_table, sign_info, GSWE_ANTISCION_AXIS_MID_TAURUS, _("mid Taurus/Scorpio"), GSWE_SIGN_TAURUS, TRUE);
ADD_ANTISCION(gswe_antiscion_info_table, antiscion_info, gswe_sign_info_table, sign_info, GSWE_ANTISCION_AXIS_CANCER, _("Cancer/Capricorn"), GSWE_SIGN_CANCER, FALSE);
ADD_ANTISCION(gswe_antiscion_info_table, antiscion_info, gswe_sign_info_table, sign_info, GSWE_ANTISCION_AXIS_MID_LEO, _("mid Leo/Aquarius"), GSWE_SIGN_LEO, TRUE);
ADD_ANTISCION(gswe_antiscion_axis_info_table, antiscion_axis_info, gswe_sign_info_table, sign_info, GSWE_ANTISCION_AXIS_NONE, _("None"), GSWE_SIGN_NONE, FALSE);
ADD_ANTISCION(gswe_antiscion_axis_info_table, antiscion_axis_info, gswe_sign_info_table, sign_info, GSWE_ANTISCION_AXIS_ARIES, _("Aries/Libra"), GSWE_SIGN_ARIES, FALSE);
ADD_ANTISCION(gswe_antiscion_axis_info_table, antiscion_axis_info, gswe_sign_info_table, sign_info, GSWE_ANTISCION_AXIS_MID_TAURUS, _("mid Taurus/Scorpio"), GSWE_SIGN_TAURUS, TRUE);
ADD_ANTISCION(gswe_antiscion_axis_info_table, antiscion_axis_info, gswe_sign_info_table, sign_info, GSWE_ANTISCION_AXIS_CANCER, _("Cancer/Capricorn"), GSWE_SIGN_CANCER, FALSE);
ADD_ANTISCION(gswe_antiscion_axis_info_table, antiscion_axis_info, gswe_sign_info_table, sign_info, GSWE_ANTISCION_AXIS_MID_LEO, _("mid Leo/Aquarius"), GSWE_SIGN_LEO, TRUE);
gswe_full_moon_base_date = gswe_timestamp_new_from_gregorian_full(2005, 5, 8, 3, 48, 0, 0, 0.0);

View File

@ -24,6 +24,7 @@
#include "gswe-planet-data.h"
#include "gswe-aspect-info.h"
#include "gswe-aspect-data.h"
#include "gswe-antiscion-data.h"
#include "gswe-timestamp.h"
#include "gswe-moment.h"
#include "gswe-enumtypes.h"