From: Rafał Długołęcki Date: Sun, 2 Feb 2014 17:27:30 +0000 (+0100) Subject: Displaying all loaded objects horizontally. X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=961bbb87dca7f5406440d32c06dfc7552044e08a;p=familia.git Displaying all loaded objects horizontally. --- diff --git a/Makefile.am b/Makefile.am index a1b977a..62441d7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -34,13 +34,16 @@ dist_noinst_SCRIPTS = autogen.sh bin_familia_SOURCES = \ src/dialogs/about_dialog.c \ src/dialogs/openfile_dialog.c \ - src/viewport/drawing_area.c \ + src/ui/drawing_area.c \ + src/ui/scrollbars.c \ src/storage/storage.c \ src/storage/individual.c \ src/storage/family.c \ src/storage/positions.c \ src/math/positions.c \ + src/math/camera.c \ src/graphics/individual.c \ + src/graphics/family.c \ src/gedcom/familia_gedcom.c \ src/memory_stack.c \ src/gui.c \ diff --git a/configure.ac b/configure.ac index 4889595..a4c813f 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,5 @@ AC_INIT([Familia Lignum], [0.1.2-reboot], [bugz@dlugolecki.net.pl], [familia], [http://dlugolecki.net.pl/software/familia/]) +AC_CANONICAL_SYSTEM AC_PREREQ([2.59]) AM_INIT_AUTOMAKE([1.10 -Wall]) AC_CONFIG_HEADERS([config.h]) diff --git a/data/gui.glade b/data/gui.glade index 1c512ed..8b559af 100644 --- a/data/gui.glade +++ b/data/gui.glade @@ -86,6 +86,14 @@ + + -100 + 100 + 0.10000000000000001 + 10 + + + True False @@ -97,16 +105,6 @@ False gtk-missing-image - - False - center - - - True - True - - - False 400 @@ -308,18 +306,63 @@ - + True False + vertical + + + True + False + + + 450 + 240 + True + True + False + + + + + + + True + True + 0 + + + + + True + False + vertical + vertical-adjustment + + + False + True + 1 + + + + + True + True + 0 + + - + True False - - - - + horizontal-adjustment + + False + True + 1 + @@ -392,4 +435,12 @@ openfiledialog-ok + + -100 + 100 + 0.10000000000000001 + 10 + + + diff --git a/src/graphics/constants.h b/src/graphics/constants.h new file mode 100644 index 0000000..227c16e --- /dev/null +++ b/src/graphics/constants.h @@ -0,0 +1,26 @@ +/**************************************************************************** + * 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_GRAPHICS_CONSTANTS_H +#define _FAMILIA_GRAPHICS_CONSTANTS_H + +#define GR_IND_RADIUS 0.5 +#define GR_FAM_RADIUS 0.4 + +#endif /* _FAMILIA_GRAPHICS_CONSTANTS_H */ diff --git a/src/graphics/family.c b/src/graphics/family.c new file mode 100644 index 0000000..954d6fa --- /dev/null +++ b/src/graphics/family.c @@ -0,0 +1,41 @@ +/**************************************************************************** + * 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_GRAPHICS_INDIVIDUAL_H +#define _FAMILIA_GRAPHICS_INDIVIDUAL_H + +#include +#include + +#include "constants.h" +#include "family.h" + +void graphics_render_family() { + GLUquadric* quad = NULL; + quad = gluNewQuadric(); + gluQuadricDrawStyle(quad, GLU_LINE); + + if (quad) { + gluSphere(quad, GR_FAM_RADIUS, 4, 4); + gluDeleteQuadric(quad); + quad = NULL; + } +} + +#endif /* _FAMILIA_GRAPHICS_INDIVIDUAL_H */ diff --git a/src/graphics/family.h b/src/graphics/family.h index f084657..3a3adb0 100644 --- a/src/graphics/family.h +++ b/src/graphics/family.h @@ -20,5 +20,6 @@ #ifndef _FAMILIA_GRAPHICS_FAMILY_H #define _FAMILIA_GRAPHICS_FAMILY_H +void graphics_render_family(); #endif /* _FAMILIA_GRAPHICS_FAMILY_H */ diff --git a/src/graphics/individual.c b/src/graphics/individual.c index 0d837ab..5396c2b 100644 --- a/src/graphics/individual.c +++ b/src/graphics/individual.c @@ -23,6 +23,7 @@ #include #include +#include "constants.h" #include "individual.h" void graphics_render_individual() { @@ -31,7 +32,7 @@ void graphics_render_individual() { gluQuadricDrawStyle(quad, GLU_LINE); if (quad) { - gluSphere(quad, 1, 10, 10); + gluSphere(quad, GR_IND_RADIUS, 10, 10); gluDeleteQuadric(quad); quad = NULL; } diff --git a/src/main.c b/src/main.c index 096e9ca..2d40638 100644 --- a/src/main.c +++ b/src/main.c @@ -33,6 +33,8 @@ #include "storage/storage.h" #include "gedcom/familia_gedcom.h" +extern GtkDrawingArea * drawing_area; + const char * get_guidatafile() { if (g_file_test (DATADIR "/gui.glade", G_FILE_TEST_EXISTS)) { @@ -44,7 +46,6 @@ const char * get_guidatafile() int main(int argc, char** argv) { GtkBuilder *builder = NULL; GtkWidget *window = NULL; - GtkWidget *area = NULL; GdkGLConfig *glconfig = NULL; struct familia_storage * storage = NULL; @@ -85,17 +86,17 @@ int main(int argc, char** argv) { gtk_builder_connect_signals(builder, NULL); window = GTK_WIDGET(gtk_builder_get_object(builder, "main-window")); - area = GTK_WIDGET(gtk_builder_get_object(builder, "drawing-area")); + drawing_area = GTK_WIDGET(gtk_builder_get_object(builder, "drawing-area")); gtk_window_set_title(GTK_WINDOW(window), g_get_application_name()); /* Set OpenGL-capability to the widget. */ - gtk_widget_set_gl_capability (area, glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE); + gtk_widget_set_gl_capability (drawing_area, glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE); gtk_widget_show(window); gtk_main(); - + if (familia_storage_get_current()) { storage = familia_storage_get_current(); familia_storage_free(storage); diff --git a/src/math/camera.c b/src/math/camera.c new file mode 100644 index 0000000..3ab2cfc --- /dev/null +++ b/src/math/camera.c @@ -0,0 +1,6 @@ + +#include + +GLdouble camera_pos_x = 0; +GLdouble camera_pos_y = 0; +GLdouble camera_pos_z = 0; \ No newline at end of file diff --git a/src/math/positions.c b/src/math/positions.c index dfd8fc0..03d5b44 100644 --- a/src/math/positions.c +++ b/src/math/positions.c @@ -4,13 +4,13 @@ #include "storage/individual.h" #include "storage/family.h" -struct position * familia_position_calculate_individual_position(struct familia_individual * individual) +struct 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) +struct position * calculate_family_position(struct familia_family * family) { /* TODO: Implement this function*/ return NULL; diff --git a/src/math/positions.h b/src/math/positions.h index 058cfc5..c5a4fa4 100644 --- a/src/math/positions.h +++ b/src/math/positions.h @@ -25,18 +25,25 @@ #include "storage/individual.h" #include "storage/family.h" +struct objects_boundaries { + double top; + double right; + double bottom; + double left; +}; + /** * 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); +struct 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); +struct position * calculate_family_position(struct familia_family * family); #endif /* _FAMILIA_MATH_POSITIONS_H */ diff --git a/src/storage/positions.c b/src/storage/positions.c index b2e977e..e628997 100644 --- a/src/storage/positions.c +++ b/src/storage/positions.c @@ -199,7 +199,7 @@ struct position * familia_position_get_individual_position(struct familia_indivi } /* - * Entry not found for a given individual. Return error. + * Entry not found for a given individual. Return NULL. */ return NULL; } diff --git a/src/viewport/drawing_area.c b/src/ui/drawing_area.c similarity index 71% rename from src/viewport/drawing_area.c rename to src/ui/drawing_area.c index 9cb96b0..ee915e9 100644 --- a/src/viewport/drawing_area.c +++ b/src/ui/drawing_area.c @@ -1,10 +1,20 @@ #include #include #include +#include #include "../debug.h" #include "drawing_area.h" +#include "../graphics/constants.h" #include "../graphics/individual.h" +#include "../graphics/family.h" +#include "../storage/storage.h" + +extern GLdouble camera_pos_x; +extern GLdouble camera_pos_y; +extern GLdouble camera_pos_z; + +GtkDrawingArea * drawing_area = NULL; /** * The "draw" signal handler. All the OpenGL re-drawing should @@ -13,19 +23,40 @@ */ gboolean drawing_area_draw(GtkWidget *widget, cairo_t *cr, gpointer user_data) { + unsigned int i; + unsigned int individuals_no; + unsigned int families_no; + /*** OpenGL BEGIN ***/ if (!gtk_widget_begin_gl (widget)) { return FALSE; } + glMatrixMode (GL_MODELVIEW); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glLoadIdentity (); + gluLookAt (camera_pos_x, camera_pos_y, camera_pos_z, 0.0, 0.0, -100.0, 0.0, 1.0, 0.0); + + individuals_no = familia_storage_get_current()->individuals_no; + + for (i = 0; i < individuals_no; i++) { glPushMatrix (); - glLoadIdentity (); - glTranslatef(0, 0, -10); + glTranslatef(i * (GR_IND_RADIUS + 1), 0, -10); glColor3f (1.0, 1.0, 1.0); graphics_render_individual(); glPopMatrix (); + } + + families_no = familia_storage_get_current()->families_no; + + for (i = 0; i < families_no; i++) { + glPushMatrix (); + glTranslatef(i * (GR_FAM_RADIUS + 1), -3, -10); + glColor3f (1.0, 1.0, 1.0); + graphics_render_family(); + glPopMatrix (); + } gtk_widget_end_gl (widget, TRUE); /*** OpenGL END ***/ @@ -64,7 +95,7 @@ gboolean drawing_area_configure_event (GtkWidget *widget, glMatrixMode (GL_PROJECTION); glLoadIdentity (); - gluPerspective (60.0, aspect, 1.0, 60.0); + gluPerspective (60.0, aspect, 0.1, 60.0); glMatrixMode(GL_MODELVIEW); gtk_widget_end_gl (widget, FALSE); diff --git a/src/ui/scrollbars.c b/src/ui/scrollbars.c new file mode 100644 index 0000000..96e946f --- /dev/null +++ b/src/ui/scrollbars.c @@ -0,0 +1,36 @@ +#include +#include + +#include "scrollbars.h" + +extern GLdouble camera_pos_x; +extern GLdouble camera_pos_y; +extern GLdouble camera_pos_z; + +extern GtkDrawingArea * drawing_area; + +void horizontal_scrollbar_changed (GtkAdjustment *adjustment, gpointer user_data) +{ + fprintf (stderr, "HS_changed\n"); +} + +void horizontal_scrollbar_value_changed (GtkAdjustment *adjustment, gpointer user_data) +{ + //gdk_window_invalidate_rect(gtk_widget_get_window (adjustment), NULL, TRUE); + camera_pos_x = gtk_adjustment_get_value(adjustment); + fprintf (stderr, "HS_value_changed, camera_pos_x: %f\n", camera_pos_x); + gtk_widget_queue_draw(GTK_WIDGET(drawing_area)); +} + +void vertical_scrollbar_changed (GtkAdjustment *adjustment, gpointer user_data) +{ + fprintf (stderr, "VS_changed\n"); +} + +void vertical_scrollbar_value_changed (GtkAdjustment *adjustment, gpointer user_data) +{ + //gdk_window_invalidate_rect(gtk_widget_get_window (adjustment), NULL, TRUE); + camera_pos_y = -gtk_adjustment_get_value(adjustment); + fprintf (stderr, "VS_value_changed, camera_pos_y: %f\n", camera_pos_y); + gtk_widget_queue_draw(GTK_WIDGET(drawing_area)); +} \ No newline at end of file diff --git a/src/ui/scrollbars.h b/src/ui/scrollbars.h new file mode 100644 index 0000000..11df742 --- /dev/null +++ b/src/ui/scrollbars.h @@ -0,0 +1,61 @@ +/**************************************************************************** + * 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 _UI_SCROLLBARS_H +#define _UI_SCROLLBARS_H + +#include + +/** + * Maintains changes in properties in main horizontal scrollbar. + * + * Emitted when one or more of the GtkAdjustment properties have been changed, other than the "value" property. + * @param adjustment the object which received the signal. + * @param user_data user data set when the signal handler was connected. + */ +void horizontal_scrollbar_changed (GtkAdjustment *adjustment, gpointer user_data); + +/** + * Maintains value changes in main horizontal scrollbar. + * + * Emitted when the "value" property has been changed. + * @param adjustment the object which received the signal. + * @param user_data user data set when the signal handler was connected. + */ +void horizontal_scrollbar_value_changed (GtkAdjustment *adjustment, gpointer user_data); + +/** + * Maintains changes in properties in main vertical scrollbar. + * + * Emitted when one or more of the GtkAdjustment properties have been changed, other than the "value" property. + * @param adjustment the object which received the signal. + * @param user_data user data set when the signal handler was connected. + */ +void vertical_scrollbar_changed (GtkAdjustment *adjustment, gpointer user_data); + +/** + * Maintains value changes in main vertical scrollbar. + * + * Emitted when the "value" property has been changed. + * @param adjustment the object which received the signal. + * @param user_data user data set when the signal handler was connected. + */ +void vertical_scrollbar_value_changed (GtkAdjustment *adjustment, gpointer user_data); + +#endif /* _UI_SCROLLBARS_H */ diff --git a/src/viewport/drawing_area.h b/src/viewport/drawing_area.h deleted file mode 100644 index 37f3352..0000000 --- a/src/viewport/drawing_area.h +++ /dev/null @@ -1,23 +0,0 @@ -/**************************************************************************** - * MnumiEditor - * - * Copyright (C) 2011-2013 Rafał Długołęcki * - * * - ****************************************************************************/ - -#ifndef _DRAWING_AREA_H -#define _DRAWING_AREA_H - -/** - * Function responsible for drawing content on each frame. - */ -gboolean drawing_area_draw(GtkWidget *widget, cairo_t *cr, - gpointer user_data); - -/** - * Function responsible for configuration of drawing area widget. - */ -gboolean drawing_area_configure_event (GtkWidget *widget, - GdkEventConfigure *event, gpointer data); - -#endif /* _DRAWING_AREA_H */ -