Connect Moon and Milky Way UI elements to calculations

master
Zwarf 2022-03-11 14:56:33 +01:00
rodzic b9096e1d7f
commit bff1fe273d
10 zmienionych plików z 253 dodań i 76 usunięć

Wyświetl plik

@ -17,8 +17,6 @@ picplanner_deps = [
dependency('gtk4'),
dependency('libadwaita-1'),
dependency('shumate-1.0'),
dependency('libsoup-2.4'),
dependency('json-glib-1.0'),
meson.get_compiler('c').find_library('m', required: false),
]

Wyświetl plik

@ -4,25 +4,67 @@
struct _PicplannerMilkyway
{
GtkBox parent_instance;
GtkWidget *label_rise_time;
GtkWidget *label_rise_azimuth;
GtkWidget *label_upper_time;
GtkWidget *label_upper_azimuth;
GtkWidget *label_upper_elevation;
GtkWidget *label_set_time;
GtkWidget *label_set_azimuth;
};
G_DEFINE_TYPE (PicplannerMilkyway, picplanner_milkyway, GTK_TYPE_BOX)
void
picplanner_milky_way_set_rise_upper_set (GDateTime *date_time,
picplanner_milky_way_set_rise_upper_set (PicplannerMilkyway *milky_way,
GDateTime *date_time,
double *coordinates_array,
int *index_rise_upper_set)
{
char *char_rise_time;
char *char_rise_azimuth;
char *char_upper_time;
char *char_upper_azimuth;
char *char_upper_elevation;
char *char_set_time;
char *char_set_azimuth;
GDateTime *date_time_rise;
GDateTime *date_time_upper;
GDateTime *date_time_set;
(void) coordinates_array;
date_time_rise = g_date_time_add_minutes (date_time, index_rise_upper_set[0]*24*60/NUM_DATA_POINTS-12*60);
date_time_upper = g_date_time_add_minutes (date_time, index_rise_upper_set[1]*24*60/NUM_DATA_POINTS-12*60);
date_time_set = g_date_time_add_minutes (date_time, index_rise_upper_set[2]*24*60/NUM_DATA_POINTS-12*60);
char_rise_time = g_strdup_printf ("%02d:%02d",
g_date_time_get_hour (date_time_rise),
g_date_time_get_minute (date_time_rise));
char_rise_azimuth = g_strdup_printf ("Azimuth: %.0f\u00B0",
coordinates_array[index_rise_upper_set[0]*2]);
char_upper_time = g_strdup_printf ("%02d:%02d",
g_date_time_get_hour (date_time_upper),
g_date_time_get_minute (date_time_upper));
char_upper_azimuth = g_strdup_printf ("Azimuth: %.0f\u00B0",
coordinates_array[index_rise_upper_set[1]*2]);
char_upper_elevation = g_strdup_printf ("Elevation: %.0f\u00B0",
coordinates_array[index_rise_upper_set[1]*2+1]);
char_set_time = g_strdup_printf ("%02d:%02d",
g_date_time_get_hour (date_time_set),
g_date_time_get_minute (date_time_set));
char_set_azimuth = g_strdup_printf ("Azimuth: %.0f\u00B0",
coordinates_array[index_rise_upper_set[2]*2]);
gtk_label_set_text (GTK_LABEL (milky_way->label_rise_time), char_rise_time);
gtk_label_set_text (GTK_LABEL (milky_way->label_rise_azimuth), char_rise_azimuth);
gtk_label_set_text (GTK_LABEL (milky_way->label_upper_time), char_upper_time);
gtk_label_set_text (GTK_LABEL (milky_way->label_upper_azimuth), char_upper_azimuth);
gtk_label_set_text (GTK_LABEL (milky_way->label_upper_elevation), char_upper_elevation);
gtk_label_set_text (GTK_LABEL (milky_way->label_set_time), char_set_time);
gtk_label_set_text (GTK_LABEL (milky_way->label_set_azimuth), char_set_azimuth);
g_date_time_unref (date_time_rise);
g_date_time_unref (date_time_upper);
g_date_time_unref (date_time_set);
@ -40,6 +82,13 @@ picplanner_milkyway_class_init (PicplannerMilkywayClass *class)
{
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/de/zwarf/picplanner/window/milky-way-page/milky-way-view.ui");
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerMilkyway, label_rise_time);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerMilkyway, label_rise_azimuth);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerMilkyway, label_upper_time);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerMilkyway, label_upper_azimuth);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerMilkyway, label_upper_elevation);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerMilkyway, label_set_time);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerMilkyway, label_set_azimuth);
}
PicplannerMilkyway *

Wyświetl plik

@ -9,7 +9,8 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (PicplannerMilkyway, picplanner_milkyway, PICPLANNER, MILKYWAY, GtkBox)
void
picplanner_milky_way_set_rise_upper_set (GDateTime *date_time,
picplanner_milky_way_set_rise_upper_set (PicplannerMilkyway *milky_way,
GDateTime *date_time,
double *coordinates_array,
int *index_rise_upper_set);

Wyświetl plik

@ -45,12 +45,12 @@
<property name="orientation">vertical</property>
<property name="valign">center</property>
<child>
<object class="GtkLabel" id="label-morining-rise-time">
<object class="GtkLabel" id="label_rise_time">
<property name="label">08:00</property>
</object>
</child>
<child>
<object class="GtkLabel" id="label-morning-rise-azimuth">
<object class="GtkLabel" id="label_rise_azimuth">
<property name="label">Azimuth: 90,0°</property>
<attributes>
<attribute name="scale" value="0.85"/>
@ -62,31 +62,6 @@
</object>
</child>
<child>
<object class="AdwActionRow">
<property name="title">Set</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="valign">center</property>
<child>
<object class="GtkLabel" id="label-evening-set-time">
<property name="label">20:00</property>
</object>
</child>
<child>
<object class="GtkLabel" id="label-evening-set-azimuth">
<property name="label">Azimuth: 270,0°</property>
<attributes>
<attribute name="scale" value="0.85"/>
</attributes>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="AdwActionRow">
<property name="title">Upper Culmination</property>
@ -95,12 +70,12 @@
<property name="orientation">vertical</property>
<property name="valign">center</property>
<child>
<object class="GtkLabel" id="label-upper-time">
<object class="GtkLabel" id="label_upper_time">
<property name="label">15:00</property>
</object>
</child>
<child>
<object class="GtkLabel" id="label-upper-azimuth">
<object class="GtkLabel" id="label_upper_azimuth">
<property name="label">Azimuth: 180,0°</property>
<attributes>
<attribute name="scale" value="0.85"/>
@ -108,7 +83,7 @@
</object>
</child>
<child>
<object class="GtkLabel" id="label-upper-elevation">
<object class="GtkLabel" id="label_upper_elevation">
<property name="label">Elevation: 80,0°</property>
<attributes>
<attribute name="scale" value="0.85"/>
@ -120,6 +95,107 @@
</object>
</child>
<child>
<object class="AdwActionRow">
<property name="title">Set</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="valign">center</property>
<child>
<object class="GtkLabel" id="label_set_time">
<property name="label">20:00</property>
</object>
</child>
<child>
<object class="GtkLabel" id="label_set_azimuth">
<property name="label">Azimuth: 270,0°</property>
<attributes>
<attribute name="scale" value="0.85"/>
</attributes>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Visibility</property>
<property name="halign">start</property>
<property name="margin-start">15</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<attributes>
<attribute name="weight" value="ultrabold"/>
</attributes>
</object>
</child>
<child>
<object class="AdwPreferencesGroup">
<property name="hexpand">true</property>
<property name="halign">fill</property>
<property name="vexpand">true</property>
<property name="valign">fill</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<child>
<object class="AdwActionRow">
<property name="title">Disturbance by Sun</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="valign">center</property>
<child>
<object class="GtkLabel" id="label_disturbance_sun">
<property name="label">Feature will be available soon!</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="AdwActionRow">
<property name="title">Disturbance by Moon</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="valign">center</property>
<child>
<object class="GtkLabel" id="label_disturbance_moon">
<property name="label">Feature will be available soon!</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="AdwActionRow">
<property name="title">Visibility Rating</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="valign">center</property>
<child>
<object class="GtkLabel" id="label_visibility">
<property name="label">Feature will be available soon!</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>

Wyświetl plik

@ -4,25 +4,68 @@
struct _PicplannerMoon
{
GtkBox parent_instance;
GtkWidget *label_rise_time;
GtkWidget *label_rise_azimuth;
GtkWidget *label_upper_time;
GtkWidget *label_upper_azimuth;
GtkWidget *label_upper_elevation;
GtkWidget *label_set_time;
GtkWidget *label_set_azimuth;
};
G_DEFINE_TYPE (PicplannerMoon, picplanner_moon, GTK_TYPE_BOX)
void
picplanner_moon_set_rise_upper_set (GDateTime *date_time,
picplanner_moon_set_rise_upper_set (PicplannerMoon *moon,
GDateTime *date_time,
double *coordinates_array,
int *index_rise_upper_set)
{
char *char_rise_time;
char *char_rise_azimuth;
char *char_upper_time;
char *char_upper_azimuth;
char *char_upper_elevation;
char *char_set_time;
char *char_set_azimuth;
GDateTime *date_time_rise;
GDateTime *date_time_upper;
GDateTime *date_time_set;
(void) coordinates_array;
date_time_rise = g_date_time_add_minutes (date_time, index_rise_upper_set[0]*24*60/NUM_DATA_POINTS-12*60);
date_time_upper = g_date_time_add_minutes (date_time, index_rise_upper_set[1]*24*60/NUM_DATA_POINTS-12*60);
date_time_set = g_date_time_add_minutes (date_time, index_rise_upper_set[2]*24*60/NUM_DATA_POINTS-12*60);
char_rise_time = g_strdup_printf ("%02d:%02d",
g_date_time_get_hour (date_time_rise),
g_date_time_get_minute (date_time_rise));
char_rise_azimuth = g_strdup_printf ("Azimuth: %.0f\u00B0",
coordinates_array[index_rise_upper_set[0]*2]);
char_upper_time = g_strdup_printf ("%02d:%02d",
g_date_time_get_hour (date_time_upper),
g_date_time_get_minute (date_time_upper));
char_upper_azimuth = g_strdup_printf ("Azimuth: %.0f\u00B0",
coordinates_array[index_rise_upper_set[1]*2]);
char_upper_elevation = g_strdup_printf ("Elevation: %.0f\u00B0",
coordinates_array[index_rise_upper_set[1]*2+1]);
char_set_time = g_strdup_printf ("%02d:%02d",
g_date_time_get_hour (date_time_set),
g_date_time_get_minute (date_time_set));
char_set_azimuth = g_strdup_printf ("Azimuth: %.0f\u00B0",
coordinates_array[index_rise_upper_set[2]*2]);
gtk_label_set_text (GTK_LABEL (moon->label_rise_time), char_rise_time);
gtk_label_set_text (GTK_LABEL (moon->label_rise_azimuth), char_rise_azimuth);
gtk_label_set_text (GTK_LABEL (moon->label_upper_time), char_upper_time);
gtk_label_set_text (GTK_LABEL (moon->label_upper_azimuth), char_upper_azimuth);
gtk_label_set_text (GTK_LABEL (moon->label_upper_elevation), char_upper_elevation);
gtk_label_set_text (GTK_LABEL (moon->label_set_time), char_set_time);
gtk_label_set_text (GTK_LABEL (moon->label_set_azimuth), char_set_azimuth);
g_date_time_unref (date_time_rise);
g_date_time_unref (date_time_upper);
g_date_time_unref (date_time_set);
@ -40,6 +83,13 @@ picplanner_moon_class_init (PicplannerMoonClass *class)
{
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/de/zwarf/picplanner/window/moon-page/moon-view.ui");
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerMoon, label_rise_time);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerMoon, label_rise_azimuth);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerMoon, label_upper_time);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerMoon, label_upper_azimuth);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerMoon, label_upper_elevation);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerMoon, label_set_time);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerMoon, label_set_azimuth);
}
PicplannerMoon *

Wyświetl plik

@ -10,7 +10,8 @@ G_DECLARE_FINAL_TYPE (PicplannerMoon, picplanner_moon, PICPLANNER, MOON, GtkBox)
void
picplanner_moon_set_rise_upper_set (GDateTime *date_time,
picplanner_moon_set_rise_upper_set (PicplannerMoon *moon,
GDateTime *date_time,
double *coordinates_array,
int *index_rise_upper_set);

Wyświetl plik

@ -45,12 +45,12 @@
<property name="orientation">vertical</property>
<property name="valign">center</property>
<child>
<object class="GtkLabel" id="label-morining-rise-time">
<object class="GtkLabel" id="label_rise_time">
<property name="label">08:00</property>
</object>
</child>
<child>
<object class="GtkLabel" id="label-morning-rise-azimuth">
<object class="GtkLabel" id="label_rise_azimuth">
<property name="label">Azimuth: 90,0°</property>
<attributes>
<attribute name="scale" value="0.85"/>
@ -62,31 +62,6 @@
</object>
</child>
<child>
<object class="AdwActionRow">
<property name="title">Set</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="valign">center</property>
<child>
<object class="GtkLabel" id="label-evening-set-time">
<property name="label">20:00</property>
</object>
</child>
<child>
<object class="GtkLabel" id="label-evening-set-azimuth">
<property name="label">Azimuth: 270,0°</property>
<attributes>
<attribute name="scale" value="0.85"/>
</attributes>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="AdwActionRow">
<property name="title">Upper Culmination</property>
@ -95,12 +70,12 @@
<property name="orientation">vertical</property>
<property name="valign">center</property>
<child>
<object class="GtkLabel" id="label-upper-time">
<object class="GtkLabel" id="label_upper_time">
<property name="label">15:00</property>
</object>
</child>
<child>
<object class="GtkLabel" id="label-upper-azimuth">
<object class="GtkLabel" id="label_upper_azimuth">
<property name="label">Azimuth: 180,0°</property>
<attributes>
<attribute name="scale" value="0.85"/>
@ -108,7 +83,7 @@
</object>
</child>
<child>
<object class="GtkLabel" id="label-upper-elevation">
<object class="GtkLabel" id="label_upper_elevation">
<property name="label">Elevation: 80,0°</property>
<attributes>
<attribute name="scale" value="0.85"/>
@ -120,6 +95,31 @@
</object>
</child>
<child>
<object class="AdwActionRow">
<property name="title">Set</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="valign">center</property>
<child>
<object class="GtkLabel" id="label_set_time">
<property name="label">20:00</property>
</object>
</child>
<child>
<object class="GtkLabel" id="label_set_azimuth">
<property name="label">Azimuth: 270,0°</property>
<attributes>
<attribute name="scale" value="0.85"/>
</attributes>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
@ -150,7 +150,7 @@
<property name="title">Illumination Intensity</property>
<child>
<object class="GtkLabel" id="label-illumination">
<property name="label">50%</property>
<property name="label">Feature will be available soon!</property>
</object>
</child>
</object>
@ -161,7 +161,7 @@
<property name="title">Phase Trend</property>
<child>
<object class="GtkLabel" id="label-phase-trend">
<property name="label">increasing</property>
<property name="label">Feature will be available soon!</property>
</object>
</child>
</object>

Wyświetl plik

@ -61,7 +61,7 @@ picplanner_overview_set_current_coordinates_sun (PicplannerOverview *overview,
from_time = g_date_time_add_minutes (overview->date_time, -12*60);
to_time = g_date_time_add_minutes (overview->date_time, 12*60);
g_print ("From: %02d.%02d.%02d %02d:%02d, To: %02d.%02d.%02d %02d:%02d",
g_print ("From: %02d.%02d.%02d %02d:%02d, To: %02d.%02d.%02d %02d:%02d\n",
g_date_time_get_day_of_month (from_time),
g_date_time_get_month (from_time),
g_date_time_get_year (from_time),

Wyświetl plik

@ -125,8 +125,9 @@ calculate_positions (PicplannerWindow *window)
picplanner_overview_set_current_coordinates_moon (PICPLANNER_OVERVIEW (window->overview_box),
rise_upper_set_index_moon);
picplanner_moon_set_rise_upper_set (date_time,
array_coordinates_sun,
picplanner_moon_set_rise_upper_set (PICPLANNER_MOON (window->moon_box),
date_time,
array_coordinates_moon,
rise_upper_set_index_moon);
@ -140,10 +141,12 @@ calculate_positions (PicplannerWindow *window)
picplanner_overview_set_current_coordinates_milky_way (PICPLANNER_OVERVIEW (window->overview_box),
rise_upper_set_index_milky_way);
picplanner_milky_way_set_rise_upper_set (date_time,
array_coordinates_sun,
picplanner_milky_way_set_rise_upper_set (PICPLANNER_MILKYWAY (window->milky_way_box),
date_time,
array_coordinates_milky_way,
rise_upper_set_index_milky_way);
g_free (rise_upper_set_index_sun);
g_free (rise_upper_set_index_moon);
g_free (rise_upper_set_index_milky_way);

Wyświetl plik

@ -21,7 +21,6 @@
#include <gtk/gtk.h>
#include <adwaita.h>
#include <libsoup/soup.h>
#include <json-glib/json-glib.h>
#include "picplanner-config.h"
#include "picplanner-application.h"