summaryrefslogtreecommitdiffstats
path: root/bin/gui
diff options
context:
space:
mode:
authorMaria <matveeva.maria@gmail.com>2013-09-19 14:09:19 +0200
committerMaria <matveeva.maria@gmail.com>2013-09-19 14:16:24 +0200
commitbbfec5e1eef0286df7315931238a9f588e265328 (patch)
tree2b3a0c66bb86902504f3ae30d0232cf19dbeba35 /bin/gui
parent43829f61cb6ea65b55cc6a75c788a9cc0521217d (diff)
downloaduca-bbfec5e1eef0286df7315931238a9f588e265328.tar.gz
uca-bbfec5e1eef0286df7315931238a9f588e265328.tar.bz2
uca-bbfec5e1eef0286df7315931238a9f588e265328.tar.xz
uca-bbfec5e1eef0286df7315931238a9f588e265328.zip
Added ROI.
Diffstat (limited to 'bin/gui')
-rw-r--r--bin/gui/control.c124
-rw-r--r--bin/gui/control.glade18
2 files changed, 109 insertions, 33 deletions
diff --git a/bin/gui/control.c b/bin/gui/control.c
index 69a2cda..504eb86 100644
--- a/bin/gui/control.c
+++ b/bin/gui/control.c
@@ -56,6 +56,10 @@ typedef struct {
GtkWidget *download_close_button;
GtkAdjustment *download_adjustment;
GtkAdjustment *count;
+ GtkAdjustment *hadjustment, *vadjustment;
+
+ GtkPaned *paned;
+ GtkRequisition child_requisition;
GtkWidget *histogram_view;
GtkToggleButton *histogram_button;
@@ -65,6 +69,7 @@ typedef struct {
RingBuffer *buffer;
guchar *pixels;
gint display_width, display_height;
+ gint page_width, page_height;
gdouble zoom_factor;
State state;
guint n_recorded;
@@ -76,7 +81,7 @@ typedef struct {
} ThreadData;
static UcaPluginManager *plugin_manager;
-static gsize mem_size = 2048;
+static gsize mem_size = 2048;
static void
down_scale (ThreadData *data, gpointer buffer)
@@ -87,55 +92,80 @@ down_scale (ThreadData *data, gpointer buffer)
gdouble dval;
guint8 *output;
gint stride;
- gint i = 0;
+ gint i = 0;
+ gint start_wval;
+ gint start_hval;
egg_histogram_get_range (EGG_HISTOGRAM_VIEW (data->histogram_view), &min, &max);
factor = 255.0 / (max - min);
output = data->pixels;
stride = (gint) 1 / data->zoom_factor;
+ if (data->state == RUNNING) {
+ gint page_width = gtk_adjustment_get_page_size (GTK_ADJUSTMENT (data->hadjustment));
+ gint page_height = gtk_adjustment_get_page_size (GTK_ADJUSTMENT (data->vadjustment));
+ start_wval = gtk_adjustment_get_value (GTK_ADJUSTMENT (data->hadjustment));
+ start_hval = gtk_adjustment_get_value (GTK_ADJUSTMENT (data->vadjustment));
+ data->page_width = (page_width + start_wval);
+ data->page_height = (page_height + start_hval);
+ } else {
+ start_wval = 0;
+ start_hval = 0;
+ data->page_width = data->display_width;
+ data->page_height = data->display_height;
+ }
+
if (data->pixel_size == 1) {
guint8 *input = (guint8 *) buffer;
- for (gint y = 0; y < data->display_height; y++) {
+ for (gint y = 0; y < data->display_height; y++){
gint offset = y * stride * data->width;
for (gint x = 0; x < data->display_width; x++, offset += stride) {
-
- if (gtk_toggle_button_get_active (data->log_button))
- {
- dval = log((input[offset] - min) * factor);
- } else {
- dval = (input[offset] - min) * factor;
+
+ if (y >= start_hval && y < data->page_height) {
+ if (x >= start_wval && x < data->page_width) {
+
+ if (gtk_toggle_button_get_active (data->log_button))
+ {
+ dval = log((input[offset] - min) * factor);
+ } else {
+ dval = (input[offset] - min) * factor;
+ }
+ }
}
guchar val = (guchar) CLAMP(dval, 0.0, 255.0);
output[i++] = val;
output[i++] = val;
- output[i++] = val;
+ output[i++] = val;
}
}
}
else if (data->pixel_size == 2) {
guint16 *input = (guint16 *) buffer;
- for (gint y = 0; y < data->display_height; y++) {
+ for (gint y = 0; y < data->display_height; y++){
gint offset = y * stride * data->width;
for (gint x = 0; x < data->display_width; x++, offset += stride) {
- if (gtk_toggle_button_get_active (data->log_button))
- {
- dval = log((input[offset] - min) * factor);
- } else {
- dval = (input[offset] - min) * factor;
+ if (y >= start_hval && y < data->page_height) {
+ if (x >= start_wval && x < data->page_width) {
+
+ if (gtk_toggle_button_get_active (data->log_button))
+ {
+ dval = log((input[offset] - min) * factor);
+ } else {
+ dval = (input[offset] - min) * factor;
+ }
+ }
}
guchar val = (guchar) CLAMP(dval, 0.0, 255.0);
output[i++] = val;
output[i++] = val;
- output[i++] = val;
-
+ output[i++] = val;
}
}
}
@@ -151,24 +181,45 @@ up_scale (ThreadData *data, gpointer buffer)
guint8 *output;
gint i = 0;
gint zoom;
+ gint start_wval;
+ gint start_hval;
egg_histogram_get_range (EGG_HISTOGRAM_VIEW (data->histogram_view), &min, &max);
factor = 255.0 / (max - min);
output = data->pixels;
zoom = (gint) data->zoom_factor;
+ if (data->state == RUNNING) {
+ gint page_width = gtk_adjustment_get_page_size (GTK_ADJUSTMENT (data->hadjustment));
+ gint page_height = gtk_adjustment_get_page_size (GTK_ADJUSTMENT (data->vadjustment));
+ start_wval = gtk_adjustment_get_value (GTK_ADJUSTMENT (data->hadjustment));
+ start_hval = gtk_adjustment_get_value (GTK_ADJUSTMENT (data->vadjustment));
+ data->page_width = (page_width + start_wval);
+ data->page_height = (page_height + start_hval);
+ } else {
+ start_wval = 0;
+ start_hval = 0;
+ data->page_width = data->display_width;
+ data->page_height = data->display_height;
+ }
+
if (data->pixel_size == 1) {
guint8 *input = (guint8 *) buffer;
for (gint y = 0; y < data->display_height; y++) {
for (gint x = 0; x < data->display_width; x++) {
gint offset = ((gint) (y / zoom) * data->width) + ((gint) (x / zoom));
-
- if (gtk_toggle_button_get_active (data->log_button))
- {
- dval = log((input[offset] - min) * factor);
- } else {
- dval = (input[offset] - min) * factor;
+
+ if (y >= start_hval && y < data->page_height) {
+ if (x >= start_wval && x < data->page_width) {
+
+ if (gtk_toggle_button_get_active (data->log_button))
+ {
+ dval = log((input[offset] - min) * factor);
+ } else {
+ dval = (input[offset] - min) * factor;
+ }
+ }
}
guchar val = (guchar) CLAMP(dval, 0.0, 255.0);
@@ -184,17 +235,23 @@ up_scale (ThreadData *data, gpointer buffer)
for (gint y = 0; y < data->display_height; y++) {
for (gint x = 0; x < data->display_width; x++) {
gint offset = ((gint) (y / zoom) * data->width) + ((gint) (x / zoom));
- if (gtk_toggle_button_get_active (data->log_button))
- {
- dval = log((input[offset] - min) * factor);
- } else {
- dval = (input[offset] - min) * factor;
+
+ if (y >= start_hval && y < data->page_height) {
+ if (x >= start_wval && x < data->page_width) {
+
+ if (gtk_toggle_button_get_active (data->log_button))
+ {
+ dval = log((input[offset] - min) * factor);
+ } else {
+ dval = (input[offset] - min) * factor;
+ }
+ }
}
guchar val = (guchar) CLAMP(dval, 0.0, 255.0);
output[i++] = val;
output[i++] = val;
- output[i++] = val;
+ output[i++] = val;
}
}
}
@@ -308,6 +365,7 @@ update_pixbuf_dimensions (ThreadData *data)
data->display_width = (gint) data->width * data->zoom_factor;
data->display_height = (gint) data->height * data->zoom_factor;
+
data->pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, data->display_width, data->display_height);
data->pixels = gdk_pixbuf_get_pixels (data->pixbuf);
gtk_image_set_from_pixbuf (GTK_IMAGE (data->image), data->pixbuf);
@@ -351,6 +409,7 @@ preview_frames (void *args)
gpointer buffer;
buffer = ring_buffer_get_current_pointer (data->buffer);
+ uca_camera_trigger (data->camera, &error);
uca_camera_grab (data->camera, buffer, &error);
if (error == NULL) {
@@ -739,6 +798,11 @@ create_main_window (GtkBuilder *builder, const gchar* camera_name)
td.frame_slider = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "frames-adjustment"));
td.count = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "acquisitions-adjustment"));
+ td.hadjustment = GTK_ADJUSTMENT (gtk_builder_get_object(builder, "adjustment1"));
+ td.vadjustment = GTK_ADJUSTMENT (gtk_builder_get_object(builder, "adjustment2"));
+ td.page_width = gtk_adjustment_get_page_size(GTK_ADJUSTMENT(td.hadjustment));
+ td.page_height = gtk_adjustment_get_page_size(GTK_ADJUSTMENT(td.vadjustment));
+
td.mean_label = GTK_LABEL (gtk_builder_get_object (builder, "mean-label"));
td.sigma_label = GTK_LABEL (gtk_builder_get_object (builder, "sigma-label"));
td.max_label = GTK_LABEL (gtk_builder_get_object (builder, "max-label"));
diff --git a/bin/gui/control.glade b/bin/gui/control.glade
index 3467ed7..e713371 100644
--- a/bin/gui/control.glade
+++ b/bin/gui/control.glade
@@ -6,6 +6,16 @@
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
+ <object class="GtkAdjustment" id="adjustment1">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment2">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
<object class="GtkListStore" id="camera-properties">
<columns>
<!-- column-name PropertyName -->
@@ -252,7 +262,7 @@
<property name="can_focus">False</property>
<property name="title" translatable="yes">Camera Control</property>
<property name="default_width">1024</property>
- <property name="default_height">768</property>
+ <property name="default_height">767</property>
<signal name="delete-event" handler="on_delete_event" swapped="no"/>
<child>
<object class="GtkVBox" id="vbox1">
@@ -434,6 +444,8 @@
<property name="height_request">480</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="hadjustment">adjustment1</property>
+ <property name="vadjustment">adjustment2</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<child>
@@ -452,8 +464,8 @@
</child>
</object>
<packing>
- <property name="resize">True</property>
- <property name="shrink">True</property>
+ <property name="resize">False</property>
+ <property name="shrink">False</property>
</packing>
</child>
<child>