From e06c73c23dd36a3cbaa80e75073951ea0b96b599 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Mon, 23 Sep 2013 23:12:50 +0200 Subject: [PATCH] Moved GsweAntiscionAxisInfo to its own source files --- docs/reference/swe-glib/Makefile.am | 1 + docs/reference/swe-glib/swe-glib-docs.xml | 1 + docs/reference/swe-glib/swe-glib-sections.txt | 13 +- src/Makefile.am | 42 +++--- src/gswe-antiscion-axis-info-private.h | 46 ++++++ src/gswe-antiscion-axis-info.c | 134 ++++++++++++++++++ src/gswe-antiscion-axis-info.h | 48 +++++++ src/gswe-moment.c | 4 +- src/gswe-types.h | 16 --- src/swe-glib-private.h | 1 + src/swe-glib.c | 14 +- src/swe-glib.h | 1 + 12 files changed, 275 insertions(+), 46 deletions(-) create mode 100644 src/gswe-antiscion-axis-info-private.h create mode 100644 src/gswe-antiscion-axis-info.c create mode 100644 src/gswe-antiscion-axis-info.h diff --git a/docs/reference/swe-glib/Makefile.am b/docs/reference/swe-glib/Makefile.am index 479db7c..0792a53 100644 --- a/docs/reference/swe-glib/Makefile.am +++ b/docs/reference/swe-glib/Makefile.am @@ -65,6 +65,7 @@ IGNORE_HFILES = \ gswe-planet-data-private.h \ gswe-aspect-info-private.h \ gswe-aspect-data-private.h \ + gswe-antiscion-axis-info-private.h \ gswe-antiscion-data-private.h \ $(NULL) diff --git a/docs/reference/swe-glib/swe-glib-docs.xml b/docs/reference/swe-glib/swe-glib-docs.xml index 39435b0..b9cd0c9 100644 --- a/docs/reference/swe-glib/swe-glib-docs.xml +++ b/docs/reference/swe-glib/swe-glib-docs.xml @@ -23,6 +23,7 @@ + diff --git a/docs/reference/swe-glib/swe-glib-sections.txt b/docs/reference/swe-glib/swe-glib-sections.txt index c311063..b399414 100644 --- a/docs/reference/swe-glib/swe-glib-sections.txt +++ b/docs/reference/swe-glib/swe-glib-sections.txt @@ -97,6 +97,18 @@ GSWE_TYPE_ASPECT_DATA gswe_aspect_data_get_type +
+gswe-antiscion-axis-info +GsweAntiscionAxisInfo +gswe_antiscion_axis_info_get_axis +gswe_antiscion_axis_info_get_name +gswe_antiscion_axis_info_get_sign_offset +gswe_antiscion_axis_info_get_start_sign + +GSWE_TYPE_ANTISCION_AXIS_INFO +gswe_antiscion_axis_info_get_type +
+
gswe-antiscion-data GsweAntiscionData @@ -166,7 +178,6 @@ GsweMoonPhase GswePlanetInfo GsweSignInfo GsweHouseSystemInfo -GsweAntiscionAxisInfo GsweCoordinates GsweHouseData diff --git a/src/Makefile.am b/src/Makefile.am index bfedb92..ad5c9fa 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,15 +4,17 @@ AM_CPPFLAGS = -DG_LOG_DOMAIN=\"SWE-GLib\" -DLOCALEDIR=\"$(localedir)\" -D__SWE_G lib_LTLIBRARIES = libswe-glib-1.0.la INST_H_SRC_FILES = \ - swe-glib.h \ - gswe-types.h \ - 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 + swe-glib.h \ + gswe-types.h \ + gswe-moon-phase-data.h \ + gswe-aspect-info.h \ + gswe-aspect-data.h \ + gswe-antiscion-axis-info.h \ + gswe-antiscion-data.h \ + gswe-planet-data.h \ + gswe-moment.h \ + gswe-timestamp.h \ + $(NULL) INST_H_BUILT_FILES = \ gswe-enumtypes.h @@ -20,17 +22,19 @@ INST_H_BUILT_FILES = \ gswe_enum_headers = gswe-timestamp.h gswe-types.h libswe_glib_1_0_la_SOURCES = \ - swe-glib.c \ - gswe-types.c \ - gswe-moon-phase-data.c \ - 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 \ + swe-glib.c \ + gswe-types.c \ + gswe-moon-phase-data.c \ + gswe-planet-data.c \ + gswe-aspect-info.c \ + gswe-aspect-data.c \ + gswe-antiscion-axis-info.c \ + gswe-antiscion-data.c \ + gswe-moment.c \ + gswe-timestamp.c \ + gswe-enumtypes.c \ $(NULL) + libswe_glib_1_0_la_CFLAGS = $(GLIB_CFLAGS) $(GOBJECT_CFLAGS) -Wall libswe_glib_1_0_la_LIBADD = $(GLIB_LIBS) $(GOBJECT_LIBS) $(LIBSWE_LIBS) diff --git a/src/gswe-antiscion-axis-info-private.h b/src/gswe-antiscion-axis-info-private.h new file mode 100644 index 0000000..55d1ffa --- /dev/null +++ b/src/gswe-antiscion-axis-info-private.h @@ -0,0 +1,46 @@ +/* gswe-antiscion-axis-info-private.h: Private parts of GsweAntiscionAxisInfo + * + * 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 . + */ +#ifdef __SWE_GLIB_BUILDING__ +#ifndef __SWE_GLIB_GSWE_ANTISCION_AXIS_INFO_PRIVATE_H__ +#define __SWE_GLIB_GSWE_ANTISCION_AXIS_INFO_PRIVATE_H__ + +#include "gswe-types.h" +#include "gswe-antiscion-axis-info.h" + +struct _GsweAntiscionAxisInfo { + /* the identifier of this mirror's axis */ + GsweAntiscionAxis axis; + + /* represents the sign in whict the mirror axis starts */ + GsweSignInfo *start_sign; + + /* the name of the mirror */ + gchar *name; + + /* if TRUE, the axis runs through the middle of its starting sign */ + gdouble sign_offset; +}; + +GsweAntiscionAxisInfo *gswe_antiscion_axis_info_copy(GsweAntiscionAxisInfo *antiscion_axis_info); +void gswe_antiscion_axis_info_free(GsweAntiscionAxisInfo *antiscion_axis_info); + +#endif /* __SWE_GLIB_GSWE_ANTISCION_AXIS_INFO_PRIVATE_H__ */ +#else /* not defined __SWE_GLIB_BUILDING__ */ +#error __FILE__ "Can not be included, unless building SWE-GLib" +#endif /* __SWE_GLIB_BUILDING__ */ + diff --git a/src/gswe-antiscion-axis-info.c b/src/gswe-antiscion-axis-info.c new file mode 100644 index 0000000..0a3fbeb --- /dev/null +++ b/src/gswe-antiscion-axis-info.c @@ -0,0 +1,134 @@ +/* gswe-antiscion-axis-info.c: Antiscion axis related information + * + * 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 . + */ +#include "gswe-antiscion-axis-info.h" +#include "gswe-antiscion-axis-info-private.h" + +/** + * SECTION:gswe-antiscion-axis-info + * @short_description: a structure storing information about antiscion axes + * @title: GsweAntiscionAxisInfo + * @stability: Stable + * @include: swe-glib.h + * + * The #GsweAntiscionAxisInfo stores information about an antiscion axis. + */ + +G_DEFINE_BOXED_TYPE(GsweAntiscionAxisInfo, gswe_antiscion_axis_info, (GBoxedCopyFunc)gswe_antiscion_axis_info_copy, (GBoxedFreeFunc)gswe_antiscion_axis_info_free); + +GsweAntiscionAxisInfo * +gswe_antiscion_axis_info_copy(GsweAntiscionAxisInfo *antiscion_axis_info) +{ + GsweAntiscionAxisInfo *ret; + + if (antiscion_axis_info == NULL) { + return NULL; + } + + ret = g_new0(GsweAntiscionAxisInfo, 1); + ret->axis = antiscion_axis_info->axis; + ret->start_sign = antiscion_axis_info->start_sign; + ret->name = g_strdup(antiscion_axis_info->name); + ret->sign_offset = antiscion_axis_info->sign_offset; + + return ret; +} + +void +gswe_antiscion_axis_info_free(GsweAntiscionAxisInfo *antiscion_axis_info) +{ + if (antiscion_axis_info) { + if (antiscion_axis_info->name) { + g_free(antiscion_axis_info->name); + } + + g_free(antiscion_axis_info); + } +} + +/** + * gswe_antiscion_axis_info_get_axis: + * @antiscion_axis_info: (in) (allow-none): a #GsweAntiscionAxisInfo + * + * Gets the axis ID. + * + * Returns: the axis this #GsweAntiscionAxisInfo represents + */ +GsweAntiscionAxis +gswe_antiscion_axis_info_get_axis(GsweAntiscionAxisInfo *antiscion_axis_info) +{ + if (antiscion_axis_info) { + return antiscion_axis_info->axis; + } else { + return GSWE_ANTISCION_AXIS_NONE; + } +} + +/** + * gswe_antiscion_axis_info_get_start_sign: + * @antiscion_axis_info: (in) (allow-none): a #GsweAntiscionAxisInfo + * + * Gets the starting sign of the axis. + * + * Returns: (transfer none): the #GsweSignInfo of the sign in which this axis starts + */ +GsweSignInfo * +gswe_antiscion_axis_info_get_start_sign(GsweAntiscionAxisInfo *antiscion_axis_info) +{ + if (antiscion_axis_info) { + return antiscion_axis_info->start_sign; + } else { + return NULL; + } +} + +/** + * gswe_antiscion_axis_info_get_name: + * @antiscion_axis_info: (in) (allow-none): a #GsweAntiscionAxisInfo + * + * Gets the name of the axis. + * + * Returns: (transfer none): the name of the axis + */ +const gchar * +gswe_antiscion_axis_info_get_name(GsweAntiscionAxisInfo *antiscion_axis_info) +{ + if (antiscion_axis_info) { + return antiscion_axis_info->name; + } else { + return NULL; + } +} + +/** + * gswe_antiscion_axis_info_get_sign_offset: + * @antiscion_axis_info: (in) (allow-none): a #GsweAntiscionAxisInfo + * + * Gets the offset at which the axis starts. + * + * Returns: the offset, in degrees + */ +gboolean +gswe_antiscion_axis_info_get_sign_offset(GsweAntiscionAxisInfo *antiscion_axis_info) +{ + if (antiscion_axis_info) { + return antiscion_axis_info->sign_offset; + } else { + return 0.0; + } +} + diff --git a/src/gswe-antiscion-axis-info.h b/src/gswe-antiscion-axis-info.h new file mode 100644 index 0000000..9bd5a80 --- /dev/null +++ b/src/gswe-antiscion-axis-info.h @@ -0,0 +1,48 @@ +/* gswe-antiscion-axis-info.h: Antiscion axis related information + * + * 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 . + */ +#ifndef __SWE_GLIB_GSWE_ANTISCION_AXIS_INFO_H__ +#define __SWE_GLIB_GSWE_ANTISCION_AXIS_INFO_H__ + +#include + +#include "gswe-types.h" + +G_BEGIN_DECLS + +/** + * GsweAntiscionAxisInfo: + * + * GsweAntiscionAxisInfo is an opaque structure whose members + * cannot be accessed directly. + * + * Since: 1.1 + */ +typedef struct _GsweAntiscionAxisInfo GsweAntiscionAxisInfo; + +GType gswe_antiscion_axis_info_get_type(void); +#define GSWE_TYPE_ANTISCION_AXIS_INFO (gswe_antiscion_axis_info_get_type()) + +GsweAntiscionAxis gswe_antiscion_axis_info_get_axis(GsweAntiscionAxisInfo *antiscion_axis_info); +GsweSignInfo *gswe_antiscion_axis_info_get_start_sign(GsweAntiscionAxisInfo *antiscion_axis_info); +const gchar *gswe_antiscion_axis_info_get_name(GsweAntiscionAxisInfo *antiscion_axis_info); +gboolean gswe_antiscion_axis_info_get_sign_offset(GsweAntiscionAxisInfo *antiscion_axis_info); + +G_END_DECLS + +#endif /* __SWE_GLIB_GSWE_ANTISCION_AXIS_INFO_H__ */ + diff --git a/src/gswe-moment.c b/src/gswe-moment.c index abb9a5c..d68bef0 100644 --- a/src/gswe-moment.c +++ b/src/gswe-moment.c @@ -1190,9 +1190,7 @@ find_antiscion(gpointer axis_p, GsweAntiscionAxisInfo *antiscion_axis_info, Gswe planet_orb = fmin(antiscion_data->planet1->planet_info->orb, antiscion_data->planet2->planet_info->orb); start_point = (antiscion_axis_info->start_sign->sign_id - 1) * 30.0; - if (antiscion_axis_info->middle_axis == TRUE) { - start_point += 15.0; - } + start_point += antiscion_axis_info->sign_offset; axis_position = 2 * start_point - antiscion_data->planet1->position; diff --git a/src/gswe-types.h b/src/gswe-types.h index ab8f53e..fc53b6a 100644 --- a/src/gswe-types.h +++ b/src/gswe-types.h @@ -317,22 +317,6 @@ typedef struct { gchar *name; } GsweHouseSystemInfo; -/** - * GsweAntiscionAxisInfo: - * @axis_id: the identifier of this mirror's axis - * @start_sign: represents the sign in whict the mirror axis starts - * @name: the name of the mirror - * @middle_axis: if TRUE, the axis runs through the middle of its starting sign - * - * Holds information of antiscion axes. - */ -typedef struct { - GsweAntiscionAxis axis_id; - GsweSignInfo *start_sign; - gchar *name; - gboolean middle_axis; -} GsweAntiscionAxisInfo; - /** * GsweCoordinates: * @longitude: longitude part of the coordinates diff --git a/src/swe-glib-private.h b/src/swe-glib-private.h index ca1fd8b..f0640f0 100644 --- a/src/swe-glib-private.h +++ b/src/swe-glib-private.h @@ -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-axis-info-private.h" #include "gswe-antiscion-data-private.h" extern gchar *gswe_ephe_path; diff --git a/src/swe-glib.c b/src/swe-glib.c index 04913b5..6f0f450 100644 --- a/src/swe-glib.c +++ b/src/swe-glib.c @@ -82,10 +82,10 @@ GsweTimestamp *gswe_full_moon_base_date; #define ADD_ANTISCION(ht, v, hts, vs, i, n, s, m) (v) = g_new0(GsweAntiscionAxisInfo, 1); \ (vs) = g_hash_table_lookup((hts), GINT_TO_POINTER(i)); \ - (v)->axis_id = (i); \ + (v)->axis = (i); \ (v)->start_sign = (vs); \ (v)->name = g_strdup(n); \ - (v)->middle_axis = m; \ + (v)->sign_offset = m; \ g_hash_table_replace((ht), GINT_TO_POINTER(i), (v)); void gswe_free_planet_info(gpointer planet_info) @@ -204,11 +204,11 @@ gswe_init(void) 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_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); + ADD_ANTISCION(gswe_antiscion_axis_info_table, antiscion_axis_info, gswe_sign_info_table, sign_info, GSWE_ANTISCION_AXIS_NONE, _("None"), GSWE_SIGN_NONE, 0.0); + 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, 0.0); + 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, 15.0); + 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, 0.0); + 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, 15.0); gswe_full_moon_base_date = gswe_timestamp_new_from_gregorian_full(2005, 5, 8, 3, 48, 0, 0, 0.0); diff --git a/src/swe-glib.h b/src/swe-glib.h index b0ae639..e3ab838 100644 --- a/src/swe-glib.h +++ b/src/swe-glib.h @@ -24,6 +24,7 @@ #include "gswe-planet-data.h" #include "gswe-aspect-info.h" #include "gswe-aspect-data.h" +#include "gswe-antiscion-axis-info.h" #include "gswe-antiscion-data.h" #include "gswe-timestamp.h" #include "gswe-moment.h"