Added missing yearline files.
authorRafał Długołęcki <rafal@dlugolecki.net.pl>
Thu, 6 Feb 2014 14:12:19 +0000 (15:12 +0100)
committerRafał Długołęcki <rafal@dlugolecki.net.pl>
Thu, 6 Feb 2014 14:12:19 +0000 (15:12 +0100)
src/math/yearline.c [new file with mode: 0644]
src/math/yearline.h [new file with mode: 0644]

diff --git a/src/math/yearline.c b/src/math/yearline.c
new file mode 100644 (file)
index 0000000..6ab691a
--- /dev/null
@@ -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 (file)
index 0000000..a9a5650
--- /dev/null
@@ -0,0 +1,45 @@
+/****************************************************************************
+ *  Familia Lignum - Genealogical program                                   *
+ *  Copyright (C) 2011-2012 Rafał Długołęcki <rafal@dlugolecki.net.pl>      *
+ *                                                                          *
+ *  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 <gedcom.h>
+
+/**
+ * @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 */