From b4dc99f6d2dacb360ed4e0f9aa0cff5415763dc9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20D=C5=82ugo=C5=82=C4=99cki?= Date: Thu, 6 Feb 2014 15:12:19 +0100 Subject: [PATCH] Added missing yearline files. --- src/math/yearline.c | 26 ++++++++++++++++++++++++++ src/math/yearline.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 src/math/yearline.c create mode 100644 src/math/yearline.h diff --git a/src/math/yearline.c b/src/math/yearline.c new file mode 100644 index 0000000..6ab691a --- /dev/null +++ b/src/math/yearline.c @@ -0,0 +1,26 @@ +#include "yearline.h" + +int convert_date_to_height(struct date_value *dv) +{ + struct date_value * date = gedcom_new_date_value(dv); + + if (date->date1.year_type != YEAR_SINGLE) { + debug("Date->OY conversion when type != YEAR_SINGLE"); + } + + if (date->date1.cal != CAL_GREGORIAN) { + debug("Not a gregorian calendar. Converting..."); + date->date1.cal = CAL_GREGORIAN; + date->date1.year_type = YEAR_SINGLE; + } + + if (gedcom_normalize_date(DI_FROM_SDN, date) != 0) { + debug("Error when normalizing date"); + } + + int year = date->date1.year; + + free(date); + + return year; +} \ No newline at end of file diff --git a/src/math/yearline.h b/src/math/yearline.h new file mode 100644 index 0000000..a9a5650 --- /dev/null +++ b/src/math/yearline.h @@ -0,0 +1,45 @@ +/**************************************************************************** + * Familia Lignum - Genealogical program * + * Copyright (C) 2011-2012 Rafał Długołęcki * + * * + * This program 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; version 2 of the License. * + * * + * This program 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 program; if not, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * + ****************************************************************************/ + +#ifndef _FAMILIA_MATH_YEARLINE_H +#define _FAMILIA_MATH_YEARLINE_H + +#include + +/** + * @file math/yearline.h + * @brief Code for calculating year->position conversion. + * + */ + +/** + * Return normalized year, which is used as a point value on the Y axis. + * + * This function is used as a common place for converting date years to global + * Y coords. If there will be a change in displaying height position, it will be + * changed in this function. + * + * @param dv Date for which to convert to the Y position. + * @return GLOBAL coordinate for Y axis for the given date. + */ +int convert_date_to_height(struct date_value *dv); + + + +#endif /* _FAMILIA_MATH_YEARLINE_H */ -- 2.30.2