summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@gmail.com>2012-10-18 10:56:30 +0200
committerMatthias Vogelgesang <matthias.vogelgesang@gmail.com>2012-10-18 10:56:30 +0200
commita1ab005916ba3aa50923294c5be3da0ded16fbc0 (patch)
treeb594deeda79c753fc3e7591dac4ad2712208ab8d
parentde2e8e3191eae37b91f672a03e028a35c8863c9d (diff)
downloadlibuca-a1ab005916ba3aa50923294c5be3da0ded16fbc0.tar.gz
libuca-a1ab005916ba3aa50923294c5be3da0ded16fbc0.tar.bz2
libuca-a1ab005916ba3aa50923294c5be3da0ded16fbc0.tar.xz
libuca-a1ab005916ba3aa50923294c5be3da0ded16fbc0.zip
Add download button and make dimax work
-rw-r--r--plugins/pco/uca-pco-camera.c3
-rw-r--r--src/uca-camera.c5
-rw-r--r--src/uca-camera.h3
-rw-r--r--tools/gui/control.c48
-rw-r--r--tools/gui/control.glade12
5 files changed, 65 insertions, 6 deletions
diff --git a/plugins/pco/uca-pco-camera.c b/plugins/pco/uca-pco-camera.c
index 92f814e..d5f5593 100644
--- a/plugins/pco/uca-pco-camera.c
+++ b/plugins/pco/uca-pco-camera.c
@@ -554,7 +554,8 @@ uca_pco_camera_grab(UcaCamera *camera, gpointer *data, GError **error)
if (is_readout) {
if (priv->current_image == priv->num_recorded_images) {
- *data = NULL;
+ g_set_error (error, UCA_CAMERA_ERROR, UCA_CAMERA_ERROR_END_OF_STREAM,
+ "End of data stream");
return;
}
diff --git a/src/uca-camera.c b/src/uca-camera.c
index 8b08359..9210a05 100644
--- a/src/uca-camera.c
+++ b/src/uca-camera.c
@@ -47,6 +47,7 @@ G_DEFINE_TYPE(UcaCamera, uca_camera, G_TYPE_OBJECT)
* @UCA_CAMERA_ERROR_NOT_RECORDING: Camera is not recording
* @UCA_CAMERA_ERROR_NO_GRAB_FUNC: No grab callback was set
* @UCA_CAMERA_ERROR_NOT_IMPLEMENTED: Virtual function is not implemented
+ * @UCA_CAMERA_ERROR_END_OF_STREAM: Data stream has ended.
*/
GQuark uca_camera_error_quark()
{
@@ -602,6 +603,10 @@ uca_camera_trigger (UcaCamera *camera, GError **error)
*
* You must have called uca_camera_start_recording() before, otherwise you will
* get a #UCA_CAMERA_ERROR_NOT_RECORDING error.
+ *
+ * If *data is %NULL after returning from uca_camera_grab() and error is also
+ * %NULL, the data stream has ended. For example, with cameras that support
+ * in-camera memory, all frames have been transfered.
*/
void
uca_camera_grab (UcaCamera *camera, gpointer *data, GError **error)
diff --git a/src/uca-camera.h b/src/uca-camera.h
index d84b5f2..ef3bf14 100644
--- a/src/uca-camera.h
+++ b/src/uca-camera.h
@@ -40,7 +40,8 @@ typedef enum {
UCA_CAMERA_ERROR_RECORDING,
UCA_CAMERA_ERROR_NOT_RECORDING,
UCA_CAMERA_ERROR_NO_GRAB_FUNC,
- UCA_CAMERA_ERROR_NOT_IMPLEMENTED
+ UCA_CAMERA_ERROR_NOT_IMPLEMENTED,
+ UCA_CAMERA_ERROR_END_OF_STREAM
} UcaCameraError;
typedef enum {
diff --git a/tools/gui/control.c b/tools/gui/control.c
index c9fd2f6..930c4d0 100644
--- a/tools/gui/control.c
+++ b/tools/gui/control.c
@@ -41,6 +41,7 @@ typedef struct {
GtkWidget *start_button;
GtkWidget *stop_button;
GtkWidget *record_button;
+ GtkWidget *download_button;
GtkComboBox *zoom_box;
GtkWidget *histogram_view;
@@ -52,6 +53,7 @@ typedef struct {
gint display_width, display_height;
gdouble zoom_factor;
State state;
+ gboolean data_in_camram;
gint timestamp;
gint width, height;
@@ -88,7 +90,7 @@ convert_grayscale_to_rgb (ThreadData *data, gpointer buffer)
output[i++] = val;
output[i++] = val;
output[i++] = val;
- }
+ }
}
}
else if (data->pixel_size == 2) {
@@ -103,7 +105,7 @@ convert_grayscale_to_rgb (ThreadData *data, gpointer buffer)
output[i++] = val;
output[i++] = val;
output[i++] = val;
- }
+ }
}
}
}
@@ -204,6 +206,8 @@ set_tool_button_state (ThreadData *data)
data->state == RUNNING || data->state == RECORDING);
gtk_widget_set_sensitive (data->record_button,
data->state == IDLE);
+ gtk_widget_set_sensitive (data->download_button,
+ data->data_in_camram);
gtk_widget_set_sensitive (GTK_WIDGET (data->zoom_box),
data->state == IDLE);
}
@@ -254,12 +258,14 @@ on_stop_button_clicked (GtkWidget *widget, ThreadData *data)
{
GError *error = NULL;
+ g_object_get (data->camera, "has-camram-recording", &data->data_in_camram, NULL);
data->state = IDLE;
set_tool_button_state (data);
uca_camera_stop_recording (data->camera, &error);
if (error != NULL)
g_printerr ("Failed to stop: %s\n", error->message);
+
}
static void
@@ -285,6 +291,38 @@ on_record_button_clicked (GtkWidget *widget, ThreadData *data)
}
static void
+on_download_button_clicked (GtkWidget *widget, ThreadData *data)
+{
+ gpointer buffer;
+ GError *error = NULL;
+
+ uca_camera_start_readout (data->camera, &error);
+
+ if (error != NULL) {
+ g_printerr ("Failed to start read out of camera memory: %s\n", error->message);
+ return;
+ }
+
+ ring_buffer_reset (data->buffer);
+
+ while (error == NULL) {
+ buffer = ring_buffer_get_current_pointer (data->buffer);
+ uca_camera_grab (data->camera, &buffer, &error);
+ ring_buffer_proceed (data->buffer);
+ }
+
+ if (error->code != UCA_CAMERA_ERROR_END_OF_STREAM) {
+ guint n_frames = ring_buffer_get_num_blocks (data->buffer);
+
+ gtk_adjustment_set_upper (data->frame_slider, n_frames - 1);
+ gtk_adjustment_set_value (data->frame_slider, n_frames - 1);
+ }
+ else {
+ g_printerr ("Error while reading out frames: %s\n", error->message);
+ }
+}
+
+static void
on_histogram_changed (EggHistogramView *view, ThreadData *data)
{
if (data->state == IDLE)
@@ -359,6 +397,7 @@ create_main_window (GtkBuilder *builder, const gchar* camera_name)
td.start_button = GTK_WIDGET (gtk_builder_get_object (builder, "start-button"));
td.stop_button = GTK_WIDGET (gtk_builder_get_object (builder, "stop-button"));
td.record_button = GTK_WIDGET (gtk_builder_get_object (builder, "record-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.frame_slider = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "frames-adjustment"));
@@ -368,8 +407,6 @@ create_main_window (GtkBuilder *builder, const gchar* camera_name)
n_frames = mem_size * 1024 * 1024 / image_size;
ring_buffer = ring_buffer_new (image_size, n_frames);
- set_tool_button_state (&td);
-
egg_histogram_view_set_data (EGG_HISTOGRAM_VIEW (histogram_view),
ring_buffer_get_current_pointer (ring_buffer),
width * height, bits_per_sample, 256);
@@ -392,8 +429,10 @@ create_main_window (GtkBuilder *builder, const gchar* camera_name)
td.height = td.display_height = height;
td.zoom_factor = 1.0;
td.histogram_view = histogram_view;
+ td.data_in_camram = FALSE;
update_pixbuf_dimensions (&td);
+ set_tool_button_state (&td);
/* Hook up signals */
g_object_bind_property (gtk_builder_get_object (builder, "min-bin-value-adjustment"), "value",
@@ -408,6 +447,7 @@ create_main_window (GtkBuilder *builder, const gchar* camera_name)
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);
g_signal_connect (td.record_button, "clicked", G_CALLBACK (on_record_button_clicked), &td);
+ g_signal_connect (td.download_button, "clicked", G_CALLBACK (on_download_button_clicked), &td);
g_signal_connect (td.zoom_box, "changed", G_CALLBACK (on_zoom_changed), &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/tools/gui/control.glade b/tools/gui/control.glade
index 37f8150..2d2aaac 100644
--- a/tools/gui/control.glade
+++ b/tools/gui/control.glade
@@ -152,6 +152,18 @@
<property name="homogeneous">True</property>
</packing>
</child>
+ <child>
+ <object class="GtkToolButton" id="download-button">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Download</property>
+ <property name="use_underline">True</property>
+ <property name="icon_name">network-receive</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>