src/storage/storage.c \
src/storage/individual.c \
src/storage/family.c \
+ src/storage/positions.c \
+ src/math/positions.c \
src/gedcom/familia_gedcom.c \
src/memory_stack.c \
src/gui.c \
--- /dev/null
+/****************************************************************************
+ * 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_3D_H
+#define _FAMILIA_MATH_3D_H
+
+/**
+ *
+ */
+struct position {
+ /** x coordinate */
+ float x;
+
+ /** y coordinate */
+ float y;
+
+ /** z coordinate */
+ float z;
+};
+
+struct quaternion {
+ /** Quaternion angle */
+ float w;
+
+ /** Quaternion x coordinate */
+ float x;
+
+ /** Quaternion y coordinate */
+ float y;
+
+ /** Quaternion z coordinate */
+ float z;
+};
+
+/*
+struct matrix quaternion_to_matrix(struct quaternion q);
+struct quaternion matrix_to_quaternion(struct matrix4 m);
+
+struct quaternion slerp(struct quaternion q1, struct quaternion q2, float time);
+
+struct quaternion quaternion_normalise(struct quaternion q)
+*/
+
+#endif /* _FAMILIA_MATH_3D_H */
--- /dev/null
+/****************************************************************************
+ * 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_POSITIONS_H
+#define _FAMILIA_MATH_POSITIONS_H
+
+#include <stdlib.h>
+
+#include "positions.h"
+#include "storage/individual.h"
+#include "storage/family.h"
+
+struct position * familia_position_calculate_individual_position(struct familia_individual * individual)
+{
+/* TODO: Implement this function*/
+ return NULL;
+}
+
+struct position * familia_position_calculate_family_position(struct familia_family * family)
+{
+/* TODO: Implement this function*/
+ return NULL;
+}
+
+#endif /* _FAMILIA_MATH_3D_H */
--- /dev/null
+/****************************************************************************
+ * 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_POSITIONS_H
+#define _FAMILIA_MATH_POSITIONS_H
+
+#include "3d.h"
+
+#include "storage/individual.h"
+#include "storage/family.h"
+
+/**
+ * Calculates local position of given individual
+ * @parameter individual to calculate position
+ * @return calculated local position of the individual
+ */
+struct position * familia_position_calculate_individual_position(struct familia_individual * individual);
+
+/**
+ * Calculates local position of given family
+ * @parameter family to calculate position
+ * @return calculated local position of the family
+ */
+struct position * familia_position_calculate_family_position(struct familia_family * family);
+
+#endif /* _FAMILIA_MATH_3D_H */
--- /dev/null
+/****************************************************************************
+ * 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. *
+ * *
+ ****************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "../debug.h"
+
+#include "positions.h"
+
+/**
+ * Structure holding individual and position pair
+ */
+struct familia_storage_individual_position {
+ struct familia_individual *ind;
+ struct position *pos;
+};
+
+/**
+ * Structure holding family and position pair
+ */
+struct familia_storage_family_position {
+ struct familia_family *fam;
+ struct position *pos;
+};
+
+/**
+ * Structure holding individual and family positions
+ */
+struct familia_storage_positions {
+ struct familia_storage_individual_position **individuals;
+
+ unsigned int individuals_no;
+
+ struct familia_storage_family_position **families;
+
+ unsigned int families_no;
+};
+
+/**
+ * Global variable for storing positions of graphic objects.
+ *
+ * Example graphic object is an individual or family...
+ */
+struct familia_storage_positions * storage_positions;
+
+/**
+ * Initializes storage for individual and family positions.
+ */
+void _familia_storage_positions_init()
+{
+ if (!storage_positions) {
+ storage_positions = malloc(sizeof(struct familia_storage_positions));
+
+ if (!storage_positions) {
+ debug("["__FILE__ "] There was a problem with allocating memory for storage of positions.\n");
+ }
+ else {
+ storage_positions->individuals_no = 0;
+ storage_positions->families_no = 0;
+ }
+ }
+}
+
+/**
+ * Frees storage for the positions
+ */
+void _familia_storage_positions_free()
+{
+ if (storage_positions) {
+ if (storage_positions->individuals) {
+ free(storage_positions->individuals);
+ }
+
+ if (storage_positions->families) {
+ free(storage_positions->families);
+ }
+
+ free(storage_positions);
+ storage_positions = NULL;
+ }
+}
+
+/**
+ * Adds new position for the given individual.
+ *
+ * This function should be invoked only internaly and thus is not declared in
+ * header. Usage without caution can create duplicates in global variable
+ * storage_positions. Variable storage_positions is not prepared for such duplicates
+ * and this can provide to errors.
+ */
+void _familia_positions_add_individual_position(struct familia_individual *individual, struct position *pos)
+{
+ struct familia_storage_individual_position ** tmp = NULL;
+ unsigned int alloc_size = sizeof(struct familia_storage_individual_position *);
+
+ int size = (storage_positions->individuals_no + 1);
+
+ tmp = realloc(storage_positions->individuals, size * alloc_size);
+
+ if (tmp) {
+ storage_positions->individuals = tmp;
+ storage_positions->individuals[storage_positions->individuals_no]->ind = individual;
+ storage_positions->individuals[storage_positions->individuals_no]->pos = pos;
+ storage_positions->individuals_no++;
+ }
+ else {
+ debug("There were problems with allocating memory for storage of individual positions->\n");
+ }
+}
+
+/**
+ * Adds new position for the given family.
+ *
+ * This function should be invoked only internaly and thus is not declared in
+ * header. Usage without caution can create duplicates in global variable
+ * storage_positions. Variable storage_positions is not prepared for such duplicates
+ * and this can provide to errors.
+ */
+void _familia_positions_add_family_position(struct familia_family *family, struct position *pos)
+{
+ struct familia_storage_family_position ** tmp = NULL;
+ unsigned int alloc_size = sizeof(struct familia_storage_family_position *);
+
+ int size = (storage_positions->families_no + 1);
+
+ tmp = realloc(storage_positions->families, size * alloc_size);
+
+ if (tmp) {
+ storage_positions->families = tmp;
+ storage_positions->families[storage_positions->families_no]->fam = family;
+ storage_positions->families[storage_positions->families_no]->pos = pos;
+ storage_positions->families_no++;
+ }
+ else {
+ debug("There were problems with allocating memory for storage of family positions.\n");
+ }
+}
+
+void familia_positions_set_individual_position(struct familia_individual *individual, struct position *pos)
+{
+ struct position * p = NULL;
+
+ p = familia_position_get_individual_position(individual);
+
+ /* If not found create a new one */
+ if (p == NULL) {
+ _familia_positions_add_individual_position(individual, pos);
+ }
+}
+
+void familia_positions_set_family_position(struct familia_family *family, struct position *pos)
+{
+ struct position * p = NULL;
+
+ p = familia_position_get_family_position(family);
+
+ /* If not found create a new one */
+ if (p == NULL) {
+ _familia_positions_add_family_position(family, pos);
+ }
+}
+
+struct position * familia_position_get_individual_position(struct familia_individual *individual)
+{
+ unsigned int i;
+ unsigned int id;
+
+ /*
+ * Uninitialized global. Return error.
+ */
+ if (!storage_positions || !storage_positions->individuals) {
+ debug("Trying to request individual position, but positions storage is not initialized.\n");
+ return NULL;
+ }
+
+ id = individual->id;
+
+ for (i = 0; i < storage_positions->individuals_no; i++) {
+ if (storage_positions->individuals[i]->ind->id == id) {
+ return storage_positions->individuals[i]->pos;
+ }
+ }
+
+ /*
+ * Entry not found for a given individual. Return error.
+ */
+ return NULL;
+}
+
+struct position * familia_position_get_family_position(struct familia_family *family)
+{
+ unsigned int i;
+ unsigned int id;
+
+ /*
+ * Uninitialized global. Return error.
+ */
+ if (!storage_positions || !storage_positions->families) {
+ debug("Trying to request family position, but positions storage is not initialized.\n");
+ return NULL;
+ }
+
+ id = family->id;
+
+ for (i = 0; i < storage_positions->families_no; i++) {
+ if (storage_positions->families[i]->fam->id == id) {
+ return storage_positions->families[i]->pos;
+ }
+ }
+
+ /*
+ * Entry not found for a given individual. Return error.
+ */
+ return NULL;
+}
+
--- /dev/null
+/****************************************************************************
+ * 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_STORAGE_POSITIONS_H
+#define _FAMILIA_STORAGE_POSITIONS_H
+
+#include "../math/3d.h"
+
+#include "individual.h"
+#include "family.h"
+
+/**
+ * Sets position for the given individual.
+ * @parameter individual individual to set the position
+ * @parameter position position which will be used for individual
+ */
+void familia_positions_set_individual_position(struct familia_individual *individual, struct position *pos);
+
+/**
+ * Sets position for the given family.
+ * @parameter family family to set the position
+ * @parameter position position which will be used for family
+ */
+void familia_positions_set_family_position(struct familia_family *family, struct position *pos);
+
+/**
+ * Gets position of the given individual.
+ * @parameter individual individual for which the position will be get
+ * @return position of the individual or NULL on error
+ */
+struct position * familia_position_get_individual_position(struct familia_individual *individual);
+
+/**
+ * Gets position of the given family
+ * @parameter family family for which the position will be get
+ * @return position of the family or NULL on error
+ */
+struct position * familia_position_get_family_position(struct familia_family *family);
+
+#endif /* _FAMILIA_STORAGE_POSITIONS_H */
struct familia_storage * _familia_storage_current;
+extern void _familia_storage_positions_init();
+extern void _familia_storage_positions_free();
+
struct familia_storage * familia_storage_get_current()
{
return _familia_storage_current;
storage->families = NULL;
storage->families_no = 0;
+ _familia_storage_positions_init();
+
return storage;
}
storage->families = NULL;
storage->families_no = 0;
}
+
+ _familia_storage_positions_free();
}
void familia_storage_add_individual(struct familia_storage * storage, struct familia_individual * individual)