kopia lustrzana https://gitlab.com/Zwarf/picplanner
Show position of the sun directly on the map
rodzic
614e77ea69
commit
9ee791f70a
|
@ -20,3 +20,7 @@ install_data(
|
|||
'location-icon-symbolic-red.svg',
|
||||
install_dir: join_paths(get_option('datadir'), 'icons')
|
||||
)
|
||||
install_data(
|
||||
'sun.png',
|
||||
install_dir: join_paths(get_option('datadir'), 'icons')
|
||||
)
|
||||
|
|
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 14 KiB |
|
@ -9,5 +9,6 @@
|
|||
<file>window/milky-way-page/milky-way-view.ui</file>
|
||||
<file>../data/icons/milky-way-symbolic.svg</file>
|
||||
<file>../data/icons/location-icon-symbolic-red.svg</file>
|
||||
<file>../data/icons/sun.png</file>
|
||||
</gresource>
|
||||
</gresources>
|
||||
|
|
|
@ -22,12 +22,19 @@ struct _PicplannerOverview
|
|||
GtkWidget *label_moon_set;
|
||||
GtkWidget *label_milky_way_rise;
|
||||
GtkWidget *label_milky_way_set;
|
||||
GtkWidget *expander_date_time;
|
||||
GtkWidget *expander_basic_information;
|
||||
|
||||
ShumateSimpleMap *map;
|
||||
ShumateViewport *viewport;
|
||||
ShumateMarker *marker_central;
|
||||
ShumateMarker *marker_sun;
|
||||
ShumateMarkerLayer *marker_layer;
|
||||
ShumateMarker *marker_sun_rise;
|
||||
ShumateMarker *marker_sun_set;
|
||||
ShumateMarkerLayer *marker_layer_sun;
|
||||
ShumatePathLayer *path_layer_sun;
|
||||
ShumatePathLayer *path_layer_sun_rise_set;
|
||||
|
||||
|
||||
GDateTime *date_time;
|
||||
|
||||
|
@ -38,6 +45,21 @@ struct _PicplannerOverview
|
|||
G_DEFINE_TYPE (PicplannerOverview, picplanner_overview, GTK_TYPE_BOX)
|
||||
|
||||
|
||||
static void
|
||||
emit_signal_input_changed (GtkWidget *self,
|
||||
gpointer overview_user_input,
|
||||
gpointer overview_view_size_change)
|
||||
{
|
||||
(void) self;
|
||||
PicplannerOverview *overview;
|
||||
if (PICPLANNER_IS_OVERVIEW (overview_user_input))
|
||||
overview = PICPLANNER_OVERVIEW (overview_user_input);
|
||||
else
|
||||
overview = PICPLANNER_OVERVIEW (overview_view_size_change);
|
||||
|
||||
g_signal_emit (overview, signal_input_changed, 0, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Create all the "get" functions.
|
||||
* These are used so the main window function can collect all the information inputed
|
||||
|
@ -159,50 +181,133 @@ picplanner_overview_set_current_coordinates_milky_way (PicplannerOverview *overv
|
|||
}
|
||||
|
||||
void
|
||||
picplanner_overview_update_map (PicplannerOverview *overview,
|
||||
double latitude,
|
||||
double longitude,
|
||||
double *array_coordinates_sun)
|
||||
picplanner_overview_update_map_sun (PicplannerOverview *overview,
|
||||
double latitude,
|
||||
double longitude,
|
||||
double *array_coordinates_sun,
|
||||
int *rise_upper_set_sun)
|
||||
{
|
||||
int width, height;
|
||||
int x, y;
|
||||
int x_sun, y_sun;
|
||||
double latitude_sun, longitude_sun;
|
||||
int width, height, min_size;
|
||||
double x = 0, y = 0;
|
||||
double x_sun, y_sun;
|
||||
double x_sun_rise, y_sun_rise;
|
||||
double x_sun_set, y_sun_set;
|
||||
double azimuth_sun, latitude_sun, longitude_sun;
|
||||
double azimuth_sun_rise, latitude_sun_rise, longitude_sun_rise;
|
||||
double azimuth_sun_set, latitude_sun_set, longitude_sun_set;
|
||||
GdkRGBA sun_color = {1., 0.9, 0.0, 0.8};
|
||||
GdkRGBA sun_rise_set_color = {1., 0.7, 0.0, 0.8};
|
||||
|
||||
bool visible_sun = TRUE;
|
||||
GtkWidget *image_center;
|
||||
GtkWidget *image_sun;
|
||||
|
||||
width = gtk_widget_get_allocated_width (GTK_WIDGET (overview->marker_layer));
|
||||
height = gtk_widget_get_allocated_height (GTK_WIDGET (overview->marker_layer));
|
||||
g_print ("width %d\n", width);
|
||||
shumate_marker_layer_remove_all (overview->marker_layer_sun);
|
||||
shumate_path_layer_remove_all (overview->path_layer_sun);
|
||||
shumate_path_layer_remove_all (overview->path_layer_sun_rise_set);
|
||||
|
||||
width = gtk_widget_get_allocated_width (GTK_WIDGET (overview->map));
|
||||
height = gtk_widget_get_allocated_height (GTK_WIDGET (overview->map));
|
||||
if (width<height)
|
||||
min_size = width;
|
||||
else
|
||||
min_size = height;
|
||||
|
||||
/*
|
||||
* Center marker
|
||||
*/
|
||||
image_center = gtk_image_new_from_icon_name ("location-icon-symbolic-red");
|
||||
gtk_image_set_icon_size (GTK_IMAGE (image_center), GTK_ICON_SIZE_LARGE);
|
||||
shumate_location_set_location (SHUMATE_LOCATION (overview->marker_central),
|
||||
latitude,
|
||||
longitude);
|
||||
latitude, longitude);
|
||||
shumate_marker_set_child (overview->marker_central,
|
||||
image_center);
|
||||
shumate_viewport_location_to_widget_coords (overview->viewport,
|
||||
GTK_WIDGET (overview->map),
|
||||
latitude, longitude,
|
||||
&x, &y);
|
||||
|
||||
/*
|
||||
* Sun marker
|
||||
*/
|
||||
image_sun = gtk_image_new_from_icon_name ("weather-clear-small");
|
||||
gtk_image_set_icon_size (GTK_IMAGE (image_center), GTK_ICON_SIZE_LARGE);
|
||||
shumate_location_set_location (SHUMATE_LOCATION (overview->marker_sun),
|
||||
latitude-0.1,
|
||||
longitude-0.1);
|
||||
image_sun = gtk_image_new_from_icon_name ("sun");
|
||||
gtk_image_set_icon_size (GTK_IMAGE (image_sun), GTK_ICON_SIZE_LARGE);
|
||||
shumate_marker_set_child (overview->marker_sun,
|
||||
image_sun);
|
||||
|
||||
/* Calculate virtual positon of the sun on the map */
|
||||
azimuth_sun = array_coordinates_sun[NUM_DATA_POINTS];
|
||||
if (array_coordinates_sun[NUM_DATA_POINTS+1]<0)
|
||||
visible_sun = FALSE;
|
||||
x_sun = x + sin(calc_deg_to_rad (azimuth_sun)) * min_size * 0.40;
|
||||
y_sun = y - cos(calc_deg_to_rad (azimuth_sun)) * min_size * 0.40;
|
||||
|
||||
azimuth_sun_rise = array_coordinates_sun[rise_upper_set_sun[0]*2];
|
||||
x_sun_rise = x + sin(calc_deg_to_rad (azimuth_sun_rise)) * min_size * 0.40;
|
||||
y_sun_rise = y - cos(calc_deg_to_rad (azimuth_sun_rise)) * min_size * 0.40;
|
||||
|
||||
azimuth_sun_set = array_coordinates_sun[rise_upper_set_sun[2]*2];
|
||||
x_sun_set = x + sin(calc_deg_to_rad (azimuth_sun_set)) * min_size * 0.40;
|
||||
y_sun_set = y - cos(calc_deg_to_rad (azimuth_sun_set)) * min_size * 0.40;
|
||||
|
||||
shumate_viewport_widget_coords_to_location (overview->viewport,
|
||||
GTK_WIDGET (overview->map),
|
||||
x_sun,
|
||||
y_sun,
|
||||
&latitude_sun,
|
||||
&longitude_sun);
|
||||
|
||||
shumate_viewport_widget_coords_to_location (overview->viewport,
|
||||
GTK_WIDGET (overview->map),
|
||||
x_sun_rise,
|
||||
y_sun_rise,
|
||||
&latitude_sun_rise,
|
||||
&longitude_sun_rise);
|
||||
|
||||
shumate_viewport_widget_coords_to_location (overview->viewport,
|
||||
GTK_WIDGET (overview->map),
|
||||
x_sun_set,
|
||||
y_sun_set,
|
||||
&latitude_sun_set,
|
||||
&longitude_sun_set);
|
||||
|
||||
shumate_location_set_location (SHUMATE_LOCATION (overview->marker_sun),
|
||||
latitude_sun,
|
||||
longitude_sun);
|
||||
|
||||
shumate_location_set_location (SHUMATE_LOCATION (overview->marker_sun_rise),
|
||||
latitude_sun_rise,
|
||||
longitude_sun_rise);
|
||||
|
||||
shumate_location_set_location (SHUMATE_LOCATION (overview->marker_sun_set),
|
||||
latitude_sun_set,
|
||||
longitude_sun_set);
|
||||
|
||||
/*
|
||||
* Add markers to the marker layer
|
||||
* Add markers to the layer
|
||||
*/
|
||||
shumate_marker_layer_add_marker (overview->marker_layer,
|
||||
shumate_marker_layer_add_marker (overview->marker_layer_sun,
|
||||
overview->marker_central);
|
||||
shumate_marker_layer_add_marker (overview->marker_layer,
|
||||
overview->marker_sun);
|
||||
shumate_path_layer_add_node (overview->path_layer_sun_rise_set,
|
||||
SHUMATE_LOCATION (overview->marker_sun_rise));
|
||||
shumate_path_layer_add_node (overview->path_layer_sun_rise_set,
|
||||
SHUMATE_LOCATION (overview->marker_central));
|
||||
shumate_path_layer_add_node (overview->path_layer_sun_rise_set,
|
||||
SHUMATE_LOCATION (overview->marker_sun_set));
|
||||
shumate_path_layer_set_stroke_color (overview->path_layer_sun_rise_set, &sun_rise_set_color);
|
||||
shumate_path_layer_set_stroke_width (overview->path_layer_sun_rise_set, 6.);
|
||||
|
||||
if (visible_sun)
|
||||
{
|
||||
shumate_marker_layer_add_marker (overview->marker_layer_sun,
|
||||
overview->marker_sun);
|
||||
shumate_path_layer_add_node (overview->path_layer_sun,
|
||||
SHUMATE_LOCATION (overview->marker_central));
|
||||
shumate_path_layer_add_node (overview->path_layer_sun,
|
||||
SHUMATE_LOCATION (overview->marker_sun));
|
||||
shumate_path_layer_set_stroke_color (overview->path_layer_sun, &sun_color);
|
||||
shumate_path_layer_set_stroke_width (overview->path_layer_sun, 6.);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -246,7 +351,7 @@ change_date_time (GtkWidget *widget,
|
|||
/*
|
||||
* Emit a signal that the user changed the input.
|
||||
*/
|
||||
g_signal_emit (overview, signal_input_changed, 0, NULL);
|
||||
emit_signal_input_changed (widget, user_data, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -298,6 +403,8 @@ day_selected (GtkCalendar *self, PicplannerOverview *overview)
|
|||
|
||||
/*
|
||||
* Close Popover after the day was selected
|
||||
* TODO: Popdown happens automatically if a month is chosen which has less days then
|
||||
* the day number previously selected.
|
||||
*/
|
||||
popover = GTK_POPOVER(overview->calendar_popover);
|
||||
gtk_popover_popdown (popover);
|
||||
|
@ -337,10 +444,22 @@ picplanner_overview_init (PicplannerOverview *overview)
|
|||
map_source = shumate_map_source_registry_get_by_id (registry, SHUMATE_MAP_SOURCE_OSM_MAPNIK);
|
||||
shumate_simple_map_set_map_source (overview->map, map_source);
|
||||
overview->viewport = shumate_simple_map_get_viewport (overview->map);
|
||||
overview->marker_layer = shumate_marker_layer_new (overview->viewport);
|
||||
shumate_simple_map_add_overlay_layer (overview->map, SHUMATE_LAYER (overview->marker_layer));
|
||||
|
||||
overview->marker_central = shumate_marker_new ();
|
||||
overview->marker_sun = shumate_marker_new ();
|
||||
overview->marker_sun_rise = shumate_marker_new ();
|
||||
overview->marker_sun_set = shumate_marker_new ();
|
||||
g_object_ref (overview->marker_central);
|
||||
g_object_ref (overview->marker_sun);
|
||||
g_object_ref (overview->marker_sun_rise);
|
||||
g_object_ref (overview->marker_sun_set);
|
||||
|
||||
overview->path_layer_sun = shumate_path_layer_new (overview->viewport);
|
||||
shumate_simple_map_add_overlay_layer (overview->map, SHUMATE_LAYER (overview->path_layer_sun));
|
||||
overview->path_layer_sun_rise_set = shumate_path_layer_new (overview->viewport);
|
||||
shumate_simple_map_add_overlay_layer (overview->map, SHUMATE_LAYER (overview->path_layer_sun_rise_set));
|
||||
overview->marker_layer_sun = shumate_marker_layer_new (overview->viewport);
|
||||
shumate_simple_map_add_overlay_layer (overview->map, SHUMATE_LAYER (overview->marker_layer_sun));
|
||||
|
||||
/*
|
||||
* Make all the bindings between widget properties and g_settings.
|
||||
|
@ -379,6 +498,21 @@ picplanner_overview_init (PicplannerOverview *overview)
|
|||
"day-selected",
|
||||
G_CALLBACK (change_date_time),
|
||||
overview);
|
||||
|
||||
g_signal_connect (G_OBJECT (overview->viewport),
|
||||
"notify::zoom-level",
|
||||
G_CALLBACK (emit_signal_input_changed),
|
||||
overview);
|
||||
|
||||
g_signal_connect (G_OBJECT (overview->expander_date_time),
|
||||
"notify::expanded",
|
||||
G_CALLBACK (emit_signal_input_changed),
|
||||
overview);
|
||||
|
||||
g_signal_connect (G_OBJECT (overview->expander_basic_information),
|
||||
"notify::expanded",
|
||||
G_CALLBACK (emit_signal_input_changed),
|
||||
overview);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -401,6 +535,8 @@ picplanner_overview_class_init (PicplannerOverviewClass *class)
|
|||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerOverview, label_moon_set);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerOverview, label_milky_way_rise);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerOverview, label_milky_way_set);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerOverview, expander_date_time);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerOverview, expander_basic_information);
|
||||
|
||||
gtk_widget_class_bind_template_callback (class, day_selected);
|
||||
gtk_widget_class_bind_template_callback (class, time_spin_button_text);
|
||||
|
|
|
@ -25,9 +25,10 @@ picplanner_overview_set_current_coordinates_milky_way (PicplannerOverview *overv
|
|||
int *rise_upper_set_index);
|
||||
|
||||
void
|
||||
picplanner_overview_update_map (PicplannerOverview *overview,
|
||||
double latitude,
|
||||
double longitude,
|
||||
double *array_coordinates_sun);
|
||||
picplanner_overview_update_map_sun (PicplannerOverview *overview,
|
||||
double latitude,
|
||||
double longitude,
|
||||
double *array_coordinates_sun,
|
||||
int *rise_upper_set_index_sun);
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
<property name="margin-bottom">5</property>
|
||||
|
||||
<child>
|
||||
<object class="AdwExpanderRow">
|
||||
<object class="AdwExpanderRow" id="expander_date_time">
|
||||
<property name="title">Date and Time</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
|
@ -104,7 +104,7 @@
|
|||
</child>
|
||||
|
||||
<child>
|
||||
<object class="AdwExpanderRow">
|
||||
<object class="AdwExpanderRow" id="expander_basic_information">
|
||||
<property name="title">Basic Information</property>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
* The time of no input of map movement that has to pass until a calculation of the positions
|
||||
* of sun, moon or milky way starts.
|
||||
*/
|
||||
#define INPUT_CHANGED_TIMEOUT_LENGTH 300
|
||||
#define INPUT_CHANGED_TIMEOUT_LENGTH 150
|
||||
|
||||
|
||||
struct _PicplannerWindow
|
||||
|
@ -295,10 +295,11 @@ calculate_positions (PicplannerWindow *window)
|
|||
/*
|
||||
* Update Shumate Map
|
||||
*/
|
||||
picplanner_overview_update_map (PICPLANNER_OVERVIEW (window->overview_box),
|
||||
latitude,
|
||||
longitude,
|
||||
array_coordinates_sun);
|
||||
picplanner_overview_update_map_sun (PICPLANNER_OVERVIEW (window->overview_box),
|
||||
latitude,
|
||||
longitude,
|
||||
array_coordinates_sun,
|
||||
rise_upper_set_index_sun);
|
||||
|
||||
|
||||
g_free (rise_upper_set_index_sun);
|
||||
|
@ -426,6 +427,11 @@ picplanner_window_init (PicplannerWindow *window)
|
|||
G_CALLBACK (input_changed),
|
||||
window);
|
||||
|
||||
g_signal_connect (G_OBJECT (window->search_bar),
|
||||
"notify::search-mode-enabled",
|
||||
G_CALLBACK (input_changed),
|
||||
window);
|
||||
|
||||
g_signal_connect (G_OBJECT (window->search_result_box),
|
||||
"row-activated",
|
||||
G_CALLBACK (search_location_chosen),
|
||||
|
|
Ładowanie…
Reference in New Issue