Compare commits
No commits in common. "68e7d52cd8d0e32f0697ac7f81524a31a59b1282" and "845da756b72ffeec10497f2a164551ed1c7684be" have entirely different histories.
68e7d52cd8
...
845da756b7
@ -113,7 +113,7 @@
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">6</property>
|
||||
</packing>
|
||||
@ -151,38 +151,5 @@
|
||||
<property name="position">7</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="x-output-label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="y-output-label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">8</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
|
@ -250,14 +250,13 @@ static void on_convert_clicked(gpointer button, gpointer user)
|
||||
bounding_box_prepare_empty(&cell_box);
|
||||
calculate_cell_bounding_box(&cell_box, cell_to_render);
|
||||
|
||||
/* Calculate size in meters database units */
|
||||
height = (cell_box.vectors.upper_right.y - cell_box.vectors.lower_left.y);
|
||||
width = (cell_box.vectors.upper_right.x - cell_box.vectors.lower_left.x);
|
||||
/* Calculate size in meters */
|
||||
height = (cell_box.vectors.upper_right.y - cell_box.vectors.lower_left.y) * cell_to_render->parent_library->unit_in_meters;
|
||||
width = (cell_box.vectors.upper_right.x - cell_box.vectors.lower_left.x) * cell_to_render->parent_library->unit_in_meters;
|
||||
|
||||
/* Show settings dialog */
|
||||
settings = renderer_settings_dialog_new(GTK_WINDOW(data->main_window));
|
||||
renderer_settings_dialog_set_settings(settings, &sett);
|
||||
renderer_settings_dialog_set_database_unit_scale(settings, cell_to_render->parent_library->unit_in_meters);
|
||||
renderer_settings_dialog_set_cell_height(settings, height);
|
||||
renderer_settings_dialog_set_cell_width(settings, width);
|
||||
|
||||
|
@ -165,10 +165,11 @@ void bounding_box_update_point(union bounding_box *destination, conv_generic_to_
|
||||
{
|
||||
struct vector_2d point;
|
||||
|
||||
if (!destination || !pt)
|
||||
if (!destination || !pt) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (conv_func)
|
||||
if (!conv_func)
|
||||
conv_func(pt, &point);
|
||||
else
|
||||
(void)vector_2d_copy(&point, (struct vector_2d *)pt);
|
||||
|
@ -43,12 +43,8 @@ struct _RendererSettingsDialog {
|
||||
GtkLabel *x_label;
|
||||
GtkLabel *y_label;
|
||||
|
||||
GtkLabel *x_output_label;
|
||||
GtkLabel *y_output_label;
|
||||
|
||||
unsigned int cell_height;
|
||||
unsigned int cell_width;
|
||||
double unit_in_meters;
|
||||
double cell_height;
|
||||
double cell_width;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE(RendererSettingsDialog, renderer_settings_dialog, GTK_TYPE_DIALOG)
|
||||
@ -114,13 +110,13 @@ static gboolean shape_drawer_drawing_callback(GtkWidget *widget, cairo_t *cr, gp
|
||||
usable_width = (0.95*(double)width) - 15.0;
|
||||
usable_height = (0.95*(double)height) - 15.0;
|
||||
|
||||
width_scale = usable_width/(double)dialog->cell_width;
|
||||
height_scale = usable_height/(double)dialog->cell_height;
|
||||
width_scale = usable_width/dialog->cell_width;
|
||||
height_scale = usable_height/dialog->cell_height;
|
||||
|
||||
final_scale_value = (width_scale < height_scale ? width_scale : height_scale);
|
||||
|
||||
cairo_rectangle(cr, -(double)dialog->cell_width*final_scale_value/2.0, -(double)dialog->cell_height*final_scale_value/2.0,
|
||||
(double)dialog->cell_width*final_scale_value, (double)dialog->cell_height*final_scale_value);
|
||||
cairo_rectangle(cr, -dialog->cell_width*final_scale_value/2, -dialog->cell_height*final_scale_value/2,
|
||||
dialog->cell_width*final_scale_value, dialog->cell_height*final_scale_value);
|
||||
cairo_stroke(cr);
|
||||
cairo_restore(cr);
|
||||
|
||||
@ -130,31 +126,11 @@ static gboolean shape_drawer_drawing_callback(GtkWidget *widget, cairo_t *cr, gp
|
||||
static void renderer_settings_dialog_update_labels(RendererSettingsDialog *self)
|
||||
{
|
||||
char default_buff[100];
|
||||
double scale;
|
||||
|
||||
if (!self)
|
||||
return;
|
||||
|
||||
snprintf(default_buff, sizeof(default_buff), "Width: %E", self->cell_width * self->unit_in_meters);
|
||||
snprintf(default_buff, sizeof(default_buff), "Width: %E", self->cell_width);
|
||||
gtk_label_set_text(self->x_label, default_buff);
|
||||
snprintf(default_buff, sizeof(default_buff), "Height: %E", self->cell_height * self->unit_in_meters);
|
||||
snprintf(default_buff, sizeof(default_buff), "Height: %E", self->cell_height);
|
||||
gtk_label_set_text(self->y_label, default_buff);
|
||||
|
||||
scale = gtk_range_get_value(GTK_RANGE(self->scale));
|
||||
|
||||
snprintf(default_buff, sizeof(default_buff), "Output Width: %u px", (unsigned int)((double)self->cell_width / scale));
|
||||
gtk_label_set_text(self->x_output_label, default_buff);
|
||||
snprintf(default_buff, sizeof(default_buff), "Output Height: %u px", (unsigned int)((double)self->cell_height / scale));
|
||||
gtk_label_set_text(self->y_output_label, default_buff);
|
||||
}
|
||||
|
||||
static void scale_value_changed(GtkRange *range, gpointer user_data)
|
||||
{
|
||||
(void)range;
|
||||
RendererSettingsDialog *dialog;
|
||||
|
||||
dialog = RENDERER_SETTINGS_DIALOG(user_data);
|
||||
renderer_settings_dialog_update_labels(dialog);
|
||||
}
|
||||
|
||||
static void renderer_settings_dialog_init(RendererSettingsDialog *self)
|
||||
@ -176,8 +152,6 @@ static void renderer_settings_dialog_init(RendererSettingsDialog *self)
|
||||
self->shape_drawing = GTK_DRAWING_AREA(gtk_builder_get_object(builder, "shape-drawer"));
|
||||
self->x_label = GTK_LABEL(gtk_builder_get_object(builder, "x-label"));
|
||||
self->y_label = GTK_LABEL(gtk_builder_get_object(builder, "y-label"));
|
||||
self->x_output_label = GTK_LABEL(gtk_builder_get_object(builder, "x-output-label"));
|
||||
self->y_output_label = GTK_LABEL(gtk_builder_get_object(builder, "y-output-label"));
|
||||
|
||||
gtk_dialog_add_buttons(dialog, "Cancel", GTK_RESPONSE_CANCEL, "OK", GTK_RESPONSE_OK, NULL);
|
||||
gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(dialog)), box);
|
||||
@ -187,12 +161,9 @@ static void renderer_settings_dialog_init(RendererSettingsDialog *self)
|
||||
g_signal_connect(G_OBJECT(self->shape_drawing),
|
||||
"draw", G_CALLBACK(shape_drawer_drawing_callback), (gpointer)self);
|
||||
|
||||
g_signal_connect(self->scale, "value-changed", G_CALLBACK(scale_value_changed), (gpointer)self);
|
||||
|
||||
/* Default values */
|
||||
self->cell_width = 1;
|
||||
self->cell_height = 1;
|
||||
self->unit_in_meters = 1E-6;
|
||||
self->cell_width = 1E-6;
|
||||
self->cell_height = 1E-6;
|
||||
renderer_settings_dialog_update_labels(self);
|
||||
|
||||
g_object_unref(builder);
|
||||
@ -257,41 +228,34 @@ void renderer_settings_dialog_set_settings(RendererSettingsDialog *dialog, struc
|
||||
}
|
||||
}
|
||||
|
||||
void renderer_settings_dialog_set_cell_width(RendererSettingsDialog *dialog, unsigned int width)
|
||||
void renderer_settings_dialog_set_cell_width(RendererSettingsDialog *dialog, double width)
|
||||
{
|
||||
if (!dialog)
|
||||
return;
|
||||
|
||||
if (width == 0)
|
||||
width = 1;
|
||||
if (width == 0.0)
|
||||
width = 1E-6;
|
||||
|
||||
if (width < 0.0)
|
||||
width = -width;
|
||||
|
||||
dialog->cell_width = width;
|
||||
renderer_settings_dialog_update_labels(dialog);
|
||||
}
|
||||
|
||||
void renderer_settings_dialog_set_cell_height(RendererSettingsDialog *dialog, unsigned int height)
|
||||
void renderer_settings_dialog_set_cell_height(RendererSettingsDialog *dialog, double height)
|
||||
{
|
||||
if (!dialog)
|
||||
return;
|
||||
|
||||
if (height == 0)
|
||||
height = 1;
|
||||
if (height == 0.0)
|
||||
height = 1E-6;
|
||||
|
||||
if (height < 0.0)
|
||||
height = -height;
|
||||
|
||||
dialog->cell_height = height;
|
||||
renderer_settings_dialog_update_labels(dialog);
|
||||
}
|
||||
|
||||
void renderer_settings_dialog_set_database_unit_scale(RendererSettingsDialog *dialog, double unit_in_meters)
|
||||
{
|
||||
if (!dialog)
|
||||
return;
|
||||
|
||||
if (unit_in_meters < 0)
|
||||
unit_in_meters *= -1;
|
||||
|
||||
dialog->unit_in_meters = unit_in_meters;
|
||||
renderer_settings_dialog_update_labels(dialog);
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
@ -78,23 +78,16 @@ void renderer_settings_dialog_get_settings(RendererSettingsDialog *dialog, struc
|
||||
/**
|
||||
* @brief renderer_settings_dialog_set_cell_width Set width for rendered cell
|
||||
* @param dialog
|
||||
* @param width Width in database units
|
||||
* @param width Width in meters
|
||||
*/
|
||||
void renderer_settings_dialog_set_cell_width(RendererSettingsDialog *dialog, unsigned int width);
|
||||
void renderer_settings_dialog_set_cell_width(RendererSettingsDialog *dialog, double width);
|
||||
|
||||
/**
|
||||
* @brief renderer_settings_dialog_set_cell_height Set height for rendered cell
|
||||
* @param dialog
|
||||
* @param height Height in database units
|
||||
* @param height Height in meters
|
||||
*/
|
||||
void renderer_settings_dialog_set_cell_height(RendererSettingsDialog *dialog, unsigned int height);
|
||||
|
||||
/**
|
||||
* @brief renderer_settings_dialog_set_database_unit_scale Set database scale
|
||||
* @param dialog dialog element
|
||||
* @param unit_in_meters Database unit in meters
|
||||
*/
|
||||
void renderer_settings_dialog_set_database_unit_scale(RendererSettingsDialog *dialog, double unit_in_meters);
|
||||
void renderer_settings_dialog_set_cell_height(RendererSettingsDialog *dialog, double height);
|
||||
|
||||
#endif /* __CONV_SETTINGS_DIALOG_H__ */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user