summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorMaria <matveeva.maria@gmail.com>2014-01-08 18:06:56 +0100
committerMaria <matveeva.maria@gmail.com>2014-01-08 18:06:56 +0100
commit16c3140d19054c41ba858e87787ff6a688291333 (patch)
tree634cb7359e1d7157113c552bf34e230acaa6bdbf /bin
parentc937734ceab15c51c551274435f20128d1904485 (diff)
downloadlibuca-16c3140d19054c41ba858e87787ff6a688291333.tar.gz
libuca-16c3140d19054c41ba858e87787ff6a688291333.tar.bz2
libuca-16c3140d19054c41ba858e87787ff6a688291333.tar.xz
libuca-16c3140d19054c41ba858e87787ff6a688291333.zip
Draw ROI-rectangle
Diffstat (limited to 'bin')
-rw-r--r--bin/gui/control.c48
-rw-r--r--bin/gui/control.glade74
2 files changed, 93 insertions, 29 deletions
diff --git a/bin/gui/control.c b/bin/gui/control.c
index c4248f0..71a94c5 100644
--- a/bin/gui/control.c
+++ b/bin/gui/control.c
@@ -20,6 +20,7 @@
#include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h>
#include <math.h>
+#include <cairo.h>
#include "config.h"
#include "uca-camera.h"
@@ -47,6 +48,7 @@ typedef struct {
GtkWidget *zoom_in_button;
GtkWidget *zoom_out_button;
GtkWidget *zoom_normal_button;
+ GtkWidget *rect_color_button;
GtkWidget *acquisition_expander;
GtkWidget *properties_expander;
GtkWidget *colormap_box;
@@ -98,6 +100,10 @@ typedef struct {
gint from_x, from_y;
gint to_x, to_y;
gint adj_width, adj_height;
+ gint rect_x, rect_y;
+ gint rect_evx, rect_evy;
+ cairo_t *cr;
+ gdouble red, green, blue;
} ThreadData;
static UcaPluginManager *plugin_manager;
@@ -357,6 +363,8 @@ on_motion_notify (GtkWidget *event_box, GdkEventMotion *event, ThreadData *data)
gint start_hval = gtk_adjustment_get_value (GTK_ADJUSTMENT (data->vadjustment));
page_width += start_wval;
page_height += start_hval;
+ data->rect_evx = event->x;
+ data->rect_evy = event->y;
if ((data->display_width < page_width) && (data->display_height < page_height)) {
gint startx = (page_width - data->display_width) / 2;
@@ -445,6 +453,10 @@ normalize_event_coords (ThreadData *data)
static void
on_button_press (GtkWidget *event_box, GdkEventMotion *event, ThreadData *data)
{
+ data->cr = gdk_cairo_create(event_box->window);
+ data->rect_x = event->x;
+ data->rect_y = event->y;
+
normalize_event_coords (data);
gtk_adjustment_set_upper (GTK_ADJUSTMENT (data->x_adjustment), data->display_width);
@@ -461,6 +473,8 @@ on_button_press (GtkWidget *event_box, GdkEventMotion *event, ThreadData *data)
static void
on_button_release (GtkWidget *event_box, GdkEventMotion *event, ThreadData *data)
{
+ cairo_destroy (data->cr);
+
normalize_event_coords (data);
gtk_adjustment_set_upper (GTK_ADJUSTMENT (data->width_adjustment), data->display_width);
@@ -494,6 +508,22 @@ on_button_release (GtkWidget *event_box, GdkEventMotion *event, ThreadData *data
update_pixbuf (data);
}
+static gboolean
+on_expose (GtkWidget *event_box, GdkEventExpose *event, ThreadData *data)
+{
+ if (data->cr != NULL) {
+ gdouble dash = 5.0;
+ cairo_set_source_rgb (data->cr, data->red, data->green, data->blue);
+ gint rect_width = data->rect_evx - data->rect_x;
+ gint rect_height = data->rect_evy - data->rect_y;
+ cairo_rectangle (data->cr, data->rect_x, data->rect_y, rect_width, rect_height);
+ cairo_set_dash (data->cr, &dash, 1, 0);
+ cairo_stroke (data->cr);
+ gtk_widget_queue_draw (event_box);
+ }
+ return FALSE;
+}
+
static void
update_pixbuf (ThreadData *data)
{
@@ -987,6 +1017,21 @@ on_zoom_normal_button_clicked (GtkWidget *widget, ThreadData *data)
}
static void
+on_rect_color_button_clicked (GtkWidget *widget, ThreadData *data)
+{
+ if ((data->red == 0.0 && data->green == 0.0) && data->blue == 0.0) {
+ data->red = 1.0;
+ data->green = 1.0;
+ data->blue = 1.0;
+ }
+ else {
+ data->red = 0.0;
+ data->green = 0.0;
+ data->blue = 0.0;
+ }
+}
+
+static void
on_histogram_changed (EggHistogramView *view, ThreadData *data)
{
if (data->state == IDLE)
@@ -1084,6 +1129,7 @@ create_main_window (GtkBuilder *builder, const gchar* camera_name)
td.zoom_in_button = GTK_WIDGET (gtk_builder_get_object (builder, "zoom-in-button"));
td.zoom_out_button = GTK_WIDGET (gtk_builder_get_object (builder, "zoom-out-button"));
td.zoom_normal_button = GTK_WIDGET (gtk_builder_get_object (builder, "zoom-normal-button"));
+ td.rect_color_button = GTK_WIDGET (gtk_builder_get_object (builder, "rectangle-button"));
td.download_button = GTK_WIDGET (gtk_builder_get_object (builder, "download-button"));
td.histogram_button = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "histogram-checkbutton"));
td.log_button = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "logarithm-checkbutton"));
@@ -1175,6 +1221,7 @@ create_main_window (GtkBuilder *builder, const gchar* camera_name)
g_signal_connect (td.event_box, "motion-notify-event", G_CALLBACK (on_motion_notify), &td);
g_signal_connect (td.event_box, "button-press-event", G_CALLBACK (on_button_press), &td);
g_signal_connect (td.event_box, "button-release-event", G_CALLBACK (on_button_release), &td);
+ g_signal_connect (td.event_box, "expose-event", G_CALLBACK (on_expose), &td);
g_signal_connect (td.frame_slider, "value-changed", G_CALLBACK (on_frame_slider_changed), &td);
g_signal_connect (td.start_button, "clicked", G_CALLBACK (on_start_button_clicked), &td);
g_signal_connect (td.stop_button, "clicked", G_CALLBACK (on_stop_button_clicked), &td);
@@ -1183,6 +1230,7 @@ create_main_window (GtkBuilder *builder, const gchar* camera_name)
g_signal_connect (td.zoom_in_button, "clicked", G_CALLBACK (on_zoom_in_button_clicked), &td);
g_signal_connect (td.zoom_out_button, "clicked", G_CALLBACK (on_zoom_out_button_clicked), &td);
g_signal_connect (td.zoom_normal_button, "clicked", G_CALLBACK (on_zoom_normal_button_clicked), &td);
+ g_signal_connect (td.rect_color_button, "clicked", G_CALLBACK (on_rect_color_button_clicked), &td);
g_signal_connect (histogram_view, "changed", G_CALLBACK (on_histogram_changed), &td);
g_signal_connect (window, "destroy", G_CALLBACK (on_destroy), &td);
diff --git a/bin/gui/control.glade b/bin/gui/control.glade
index 95184ed..967fdf0 100644
--- a/bin/gui/control.glade
+++ b/bin/gui/control.glade
@@ -72,10 +72,10 @@
<child>
<object class="GtkButton" id="cancel-button">
<property name="label">gtk-quit</property>
+ <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="gtk_main_quit" swapped="no"/>
</object>
@@ -88,10 +88,10 @@
<child>
<object class="GtkButton" id="proceed-button">
<property name="label">gtk-ok</property>
+ <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
</object>
<packing>
@@ -152,10 +152,10 @@
<child>
<object class="GtkButton" id="download-close-button">
<property name="label">gtk-close</property>
+ <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
</object>
<packing>
@@ -230,17 +230,17 @@
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
- <object class="GtkAdjustment" id="height_adjustment">
- <property name="upper">100</property>
- <property name="step_increment">1</property>
- <property name="page_increment">10</property>
- </object>
<object class="GtkAdjustment" id="max-bin-value-adjustment">
<property name="upper">65535</property>
<property name="value">256</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
+ <object class="GtkAdjustment" id="height_adjustment">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
<object class="GtkAdjustment" id="min-bin-value-adjustment">
<property name="upper">65535</property>
<property name="step_increment">1</property>
@@ -272,9 +272,9 @@
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem" id="menuitem1">
+ <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
<property name="label" translatable="yes">_File</property>
<property name="use_underline">True</property>
<child type="submenu">
@@ -284,9 +284,9 @@
<child>
<object class="GtkImageMenuItem" id="imagemenuitem1">
<property name="label">gtk-new</property>
+ <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
@@ -294,9 +294,9 @@
<child>
<object class="GtkImageMenuItem" id="imagemenuitem2">
<property name="label">gtk-open</property>
+ <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
@@ -304,9 +304,9 @@
<child>
<object class="GtkImageMenuItem" id="save-item">
<property name="label">gtk-save-as</property>
+ <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
@@ -320,9 +320,9 @@
<child>
<object class="GtkImageMenuItem" id="imagemenuitem_quit">
<property name="label">gtk-quit</property>
+ <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="gtk_main_quit" swapped="no"/>
@@ -334,9 +334,9 @@
</child>
<child>
<object class="GtkMenuItem" id="menuitem4">
+ <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
<property name="label" translatable="yes">_Help</property>
<property name="use_underline">True</property>
<child type="submenu">
@@ -346,9 +346,9 @@
<child>
<object class="GtkImageMenuItem" id="imagemenuitem_about">
<property name="label">gtk-about</property>
+ <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
@@ -370,9 +370,9 @@
<property name="can_focus">False</property>
<child>
<object class="GtkToolButton" id="start-button">
+ <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Run</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-media-play</property>
@@ -384,9 +384,9 @@
</child>
<child>
<object class="GtkToolButton" id="record-button">
+ <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Record</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-media-record</property>
@@ -398,9 +398,9 @@
</child>
<child>
<object class="GtkToolButton" id="stop-button">
+ <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Stop</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-media-stop</property>
@@ -412,9 +412,9 @@
</child>
<child>
<object class="GtkToolButton" id="download-button">
+ <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Download</property>
<property name="use_underline">True</property>
<property name="icon_name">network-receive</property>
@@ -426,9 +426,9 @@
</child>
<child>
<object class="GtkSeparatorToolItem" id="toolbutton1">
+ <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
</object>
<packing>
<property name="expand">False</property>
@@ -437,9 +437,9 @@
</child>
<child>
<object class="GtkToolButton" id="zoom-in-button">
+ <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Zoom in</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-zoom-in</property>
@@ -451,9 +451,9 @@
</child>
<child>
<object class="GtkToolButton" id="zoom-out-button">
+ <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Zoom out</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-zoom-out</property>
@@ -465,9 +465,9 @@
</child>
<child>
<object class="GtkToolButton" id="zoom-normal-button">
+ <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
<property name="label" translatable="yes">100 %</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-zoom-100</property>
@@ -477,6 +477,20 @@
<property name="homogeneous">True</property>
</packing>
</child>
+ <child>
+ <object class="GtkToggleToolButton" id="rectangle-button">
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">rectangle color</property>
+ <property name="use_underline">True</property>
+ <property name="stock_id">gtk-color-picker</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
@@ -507,9 +521,11 @@
<child>
<object class="GtkEventBox" id="eventbox">
<property name="visible">True</property>
+ <property name="app_paintable">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK</property>
<property name="resize_mode">queue</property>
+ <property name="above_child">True</property>
<child>
<object class="GtkImage" id="image">
<property name="visible">True</property>
@@ -685,10 +701,10 @@
<child>
<object class="GtkCheckButton" id="repeat-checkbutton">
<property name="label" translatable="yes">Repeat</property>
+ <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
@@ -925,11 +941,11 @@
<child>
<object class="GtkCheckButton" id="histogram-checkbutton">
<property name="label" translatable="yes">Live Update</property>
+ <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="border_width">6</property>
- <property name="use_action_appearance">False</property>
<property name="xalign">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
@@ -957,6 +973,9 @@
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
<child>
+ <placeholder/>
+ </child>
+ <child>
<object class="GtkLabel" id="label21">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -1088,9 +1107,6 @@
<property name="y_options"></property>
</packing>
</child>
- <child>
- <placeholder/>
- </child>
</object>
<packing>
<property name="expand">True</property>
@@ -1262,11 +1278,11 @@
<child>
<object class="GtkCheckButton" id="logarithm-checkbutton">
<property name="label" translatable="yes">Logarithm</property>
+ <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="border_width">10</property>
- <property name="use_action_appearance">False</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>