Displaying all loaded objects horizontally.
authorRafał Długołęcki <rafal@dlugolecki.net.pl>
Sun, 2 Feb 2014 17:27:30 +0000 (18:27 +0100)
committerRafał Długołęcki <rafal@dlugolecki.net.pl>
Sun, 2 Feb 2014 17:27:30 +0000 (18:27 +0100)
16 files changed:
Makefile.am
configure.ac
data/gui.glade
src/graphics/constants.h [new file with mode: 0644]
src/graphics/family.c [new file with mode: 0644]
src/graphics/family.h
src/graphics/individual.c
src/main.c
src/math/camera.c [new file with mode: 0644]
src/math/positions.c
src/math/positions.h
src/storage/positions.c
src/ui/drawing_area.c [moved from src/viewport/drawing_area.c with 71% similarity]
src/ui/scrollbars.c [new file with mode: 0644]
src/ui/scrollbars.h [new file with mode: 0644]
src/viewport/drawing_area.h [deleted file]

index a1b977a2fccb3e422a188e683e781a807add00cb..62441d7930410b85bf514b1f67c86aef0f8eb68e 100644 (file)
@@ -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 \
index 4889595a176fca562fa88492bd1e2f1a77d291b0..a4c813fc1737353a398876bee23ef486e35d9271 100644 (file)
@@ -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])
index 1c512edfa509ec0a3d5843bcb513030f233e0116..8b559aff5811899c4142aff00eb7377bd6a12074 100644 (file)
       <accelerator key="q" modifiers="GDK_CONTROL_MASK"/>
     </child>
   </object>
+  <object class="GtkAdjustment" id="horizontal-adjustment">
+    <property name="lower">-100</property>
+    <property name="upper">100</property>
+    <property name="step_increment">0.10000000000000001</property>
+    <property name="page_increment">10</property>
+    <signal name="changed" handler="horizontal_scrollbar_changed" swapped="no"/>
+    <signal name="value-changed" handler="horizontal_scrollbar_value_changed" swapped="no"/>
+  </object>
   <object class="GtkImage" id="image1">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
     <property name="can_focus">False</property>
     <property name="stock">gtk-missing-image</property>
   </object>
-  <object class="GtkWindow" id="logger-window">
-    <property name="can_focus">False</property>
-    <property name="window_position">center</property>
-    <child>
-      <object class="GtkTextView" id="textview">
-        <property name="visible">True</property>
-        <property name="can_focus">True</property>
-      </object>
-    </child>
-  </object>
   <object class="GtkWindow" id="main-window">
     <property name="can_focus">False</property>
     <property name="default_width">400</property>
           </packing>
         </child>
         <child>
-          <object class="GtkViewport" id="viewport">
+          <object class="GtkBox" id="box2">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
+            <property name="orientation">vertical</property>
+            <child>
+              <object class="GtkBox" id="box3">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <child>
+                  <object class="GtkDrawingArea" id="drawing-area">
+                    <property name="width_request">450</property>
+                    <property name="height_request">240</property>
+                    <property name="visible">True</property>
+                    <property name="app_paintable">True</property>
+                    <property name="can_focus">False</property>
+                    <signal name="draw" handler="drawing_area_draw" swapped="no"/>
+                    <signal name="configure-event" handler="drawing_area_configure_event" swapped="no"/>
+                    <signal name="unrealize" handler="drawing_area_unrealize" swapped="no"/>
+                    <signal name="realize" handler="drawing_area_realize" swapped="no"/>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkScrollbar" id="vertical-scrollbar">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="orientation">vertical</property>
+                    <property name="adjustment">vertical-adjustment</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
             <child>
-              <object class="GtkDrawingArea" id="drawing-area">
+              <object class="GtkScrollbar" id="horizontal-scrollbar">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <signal name="draw" handler="drawing_area_draw" swapped="no"/>
-                <signal name="configure-event" handler="drawing_area_configure_event" swapped="no"/>
-                <signal name="unrealize" handler="drawing_area_unrealize" swapped="no"/>
-                <signal name="realize" handler="drawing_area_realize" swapped="no"/>
+                <property name="adjustment">horizontal-adjustment</property>
               </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
             </child>
           </object>
           <packing>
       <action-widget response="-5">openfiledialog-ok</action-widget>
     </action-widgets>
   </object>
+  <object class="GtkAdjustment" id="vertical-adjustment">
+    <property name="lower">-100</property>
+    <property name="upper">100</property>
+    <property name="step_increment">0.10000000000000001</property>
+    <property name="page_increment">10</property>
+    <signal name="changed" handler="vertical_scrollbar_changed" swapped="no"/>
+    <signal name="value-changed" handler="vertical_scrollbar_value_changed" swapped="no"/>
+  </object>
 </interface>
diff --git a/src/graphics/constants.h b/src/graphics/constants.h
new file mode 100644 (file)
index 0000000..227c16e
--- /dev/null
@@ -0,0 +1,26 @@
+/****************************************************************************
+ *  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_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 (file)
index 0000000..954d6fa
--- /dev/null
@@ -0,0 +1,41 @@
+/****************************************************************************
+ *  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_GRAPHICS_INDIVIDUAL_H
+#define _FAMILIA_GRAPHICS_INDIVIDUAL_H
+
+#include <GL/gl.h>
+#include <GL/glu.h>
+
+#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 */
index f084657402e06a1b721550e76e9ae02b4f3e743a..3a3adb0ea15be7ed154ffdb965fbf7ad054db732 100644 (file)
@@ -20,5 +20,6 @@
 #ifndef _FAMILIA_GRAPHICS_FAMILY_H
 #define _FAMILIA_GRAPHICS_FAMILY_H
 
+void graphics_render_family();
 
 #endif /* _FAMILIA_GRAPHICS_FAMILY_H */
index 0d837abf607e0d16fe8a90cb6b143e715eac0bbc..5396c2b63e9a3c49c0336abc0e0a8b80fd528844 100644 (file)
@@ -23,6 +23,7 @@
 #include <GL/gl.h>
 #include <GL/glu.h>
 
+#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;
        }
index 096e9ca8ae1a4cc07090bace9827fde20893e486..2d406381e1dff4076473a9ad941f2bb75dd07c23 100644 (file)
@@ -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 (file)
index 0000000..3ab2cfc
--- /dev/null
@@ -0,0 +1,6 @@
+
+#include <GL/gl.h>
+
+GLdouble camera_pos_x = 0;
+GLdouble camera_pos_y = 0;
+GLdouble camera_pos_z = 0;
\ No newline at end of file
index dfd8fc0252a3a768e5ff821f3cc0e19c2553613c..03d5b4445f80fbe21b9f69a6705e623991253e32 100644 (file)
@@ -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;
index 058cfc599aa4ad943766b1f80ed7eb8ec8c8d013..c5a4fa4424d4eecfa61629769a36b6af2bfe08d9 100644 (file)
 #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 */
index b2e977eefc71873db4f49daf298c2d851143f476..e6289973c2352f49e1b50ef0b46b5be8373058a9 100644 (file)
@@ -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;
 }
similarity index 71%
rename from src/viewport/drawing_area.c
rename to src/ui/drawing_area.c
index 9cb96b0136136f54b517875ee4bec9b9fe04d872..ee915e941ac47f683f9139c146f3b40375d8c562 100644 (file)
@@ -1,10 +1,20 @@
 #include <gtk/gtk.h>
 #include <gtk/gtkgl.h>
 #include <GL/gl.h>
+#include <GL/glu.h>
 
 #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
  */
 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 (file)
index 0000000..96e946f
--- /dev/null
@@ -0,0 +1,36 @@
+#include <stdio.h>
+#include <GL/gl.h>
+
+#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 (file)
index 0000000..11df742
--- /dev/null
@@ -0,0 +1,61 @@
+/****************************************************************************
+ *  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 _UI_SCROLLBARS_H
+#define _UI_SCROLLBARS_H
+
+#include <gtk/gtk.h>
+
+/**
+ * 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 (file)
index 37f3352..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/****************************************************************************
- *  MnumiEditor -                                                           *
- *  Copyright (C) 2011-2013 Rafał Długołęcki <bugz@dlugolecki.net.pl>       *
- *                                                                          *
- ****************************************************************************/
-
-#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 */
-