summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2013-07-16 10:38:04 +0200
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2013-07-16 10:38:04 +0200
commita819e61b6dec46260505af1e957a4a8cda716b43 (patch)
tree7fcb0839ec0b7ab7ed04af7240a65f2453edc1b4
parent895c77c7705f172e8a132baa27daa0bae4ae830f (diff)
downloadlibuca-a819e61b6dec46260505af1e957a4a8cda716b43.tar.gz
libuca-a819e61b6dec46260505af1e957a4a8cda716b43.tar.bz2
libuca-a819e61b6dec46260505af1e957a4a8cda716b43.tar.xz
libuca-a819e61b6dec46260505af1e957a4a8cda716b43.zip
Add some acquisition control
-rw-r--r--bin/gui/control.c58
-rw-r--r--bin/gui/control.glade203
2 files changed, 237 insertions, 24 deletions
diff --git a/bin/gui/control.c b/bin/gui/control.c
index 5fa82df..76b1345 100644
--- a/bin/gui/control.c
+++ b/bin/gui/control.c
@@ -49,6 +49,7 @@ typedef struct {
GtkProgressBar *download_progressbar;
GtkWidget *download_close_button;
GtkAdjustment *download_adjustment;
+ GtkAdjustment *count;
GtkWidget *histogram_view;
GtkToggleButton *histogram_button;
@@ -207,6 +208,21 @@ print_and_free_error (GError **error)
*error = NULL;
}
+static void
+set_tool_button_state (ThreadData *data)
+{
+ gtk_widget_set_sensitive (data->start_button,
+ data->state == IDLE);
+ gtk_widget_set_sensitive (data->stop_button,
+ 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);
+}
+
static gpointer
preview_frames (void *args)
{
@@ -241,13 +257,22 @@ record_frames (gpointer args)
{
ThreadData *data;
gpointer buffer;
+ guint n_max;
guint n_frames = 0;
GError *error = NULL;
data = (ThreadData *) args;
ring_buffer_reset (data->buffer);
- while (data->state == RECORDING) {
+ n_max = (guint) gtk_adjustment_get_value (data->count);
+
+ while (1) {
+ if (data->state != RECORDING)
+ break;
+
+ if (n_max > 0 && n_frames >= n_max)
+ break;
+
buffer = ring_buffer_get_current_pointer (data->buffer);
uca_camera_grab (data->camera, buffer, NULL);
@@ -259,6 +284,9 @@ record_frames (gpointer args)
print_and_free_error (&error);
}
+ data->state = IDLE;
+ set_tool_button_state (data);
+
n_frames = ring_buffer_get_num_blocks (data->buffer);
gdk_threads_enter ();
@@ -286,21 +314,6 @@ on_destroy (GtkWidget *widget, ThreadData *data)
}
static void
-set_tool_button_state (ThreadData *data)
-{
- gtk_widget_set_sensitive (data->start_button,
- data->state == IDLE);
- gtk_widget_set_sensitive (data->stop_button,
- 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);
-}
-
-static void
update_current_frame (ThreadData *data)
{
gpointer buffer;
@@ -504,7 +517,6 @@ create_main_window (GtkBuilder *builder, const gchar* camera_name)
GtkWidget *property_tree_view;
GdkPixbuf *pixbuf;
GtkBox *histogram_box;
- GtkContainer *property_window;
GtkAdjustment *max_bin_adjustment;
RingBuffer *ring_buffer;
gsize image_size;
@@ -532,7 +544,6 @@ create_main_window (GtkBuilder *builder, const gchar* camera_name)
histogram_view = egg_histogram_view_new ();
property_tree_view = egg_property_tree_view_new (G_OBJECT (camera));
- property_window = GTK_CONTAINER (gtk_builder_get_object (builder, "property-window"));
image = GTK_WIDGET (gtk_builder_get_object (builder, "image"));
histogram_box = GTK_BOX (gtk_builder_get_object (builder, "histogram-box"));
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
@@ -545,6 +556,7 @@ create_main_window (GtkBuilder *builder, const gchar* camera_name)
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"));
+ td.count = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "acquisitions-adjustment"));
td.download_dialog = GTK_DIALOG (gtk_builder_get_object (builder, "download-dialog"));
td.download_adjustment = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "download-adjustment"));
@@ -593,6 +605,13 @@ create_main_window (GtkBuilder *builder, const gchar* camera_name)
td.histogram_view, "maximum-bin-value",
G_BINDING_DEFAULT);
+ g_object_bind_property (gtk_builder_get_object (builder, "repeat-checkbutton"), "active",
+ gtk_builder_get_object (builder, "repeat-box"), "sensitive", 0);
+
+ g_object_bind_property (camera, "exposure-time",
+ gtk_builder_get_object (builder, "exposure-adjustment"), "value",
+ G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
+
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);
@@ -603,7 +622,8 @@ create_main_window (GtkBuilder *builder, const gchar* camera_name)
g_signal_connect (window, "destroy", G_CALLBACK (on_destroy), &td);
/* Layout */
- gtk_container_add (property_window, property_tree_view);
+ gtk_container_add (GTK_CONTAINER (gtk_builder_get_object (builder, "property-window")),
+ property_tree_view);
gtk_box_pack_start (histogram_box, td.histogram_view, TRUE, TRUE, 6);
gtk_widget_show_all (window);
diff --git a/bin/gui/control.glade b/bin/gui/control.glade
index 3f64802..5cf339d 100644
--- a/bin/gui/control.glade
+++ b/bin/gui/control.glade
@@ -210,6 +210,185 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
+ <object class="GtkTable" id="table3">
+ <property name="visible">True</property>
+ <property name="border_width">12</property>
+ <property name="n_rows">4</property>
+ <property name="n_columns">2</property>
+ <child>
+ <object class="GtkLabel" id="label9">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Exposure time:</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ <property name="x_padding">6</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label10">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Count:</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ <property name="x_padding">6</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="spinbutton4">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">•</property>
+ <property name="adjustment">acquisitions-adjustment</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="y_options"></property>
+ <property name="x_padding">6</property>
+ <property name="y_padding">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="checkbutton1">
+ <property name="label" translatable="yes">Integrate</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ <property name="x_padding">6</property>
+ <property name="y_padding">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="repeat-checkbutton">
+ <property name="label" translatable="yes">Repeat</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ <property name="x_padding">6</property>
+ <property name="y_padding">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label11">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="repeat-box">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkSpinButton" id="spinbutton5">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">•</property>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label12">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">times</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="y_options"></property>
+ <property name="x_padding">6</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox2">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkSpinButton" id="spinbutton3">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">•</property>
+ <property name="adjustment">exposure-adjustment</property>
+ <property name="digits">6</property>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label13">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">seconds</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="y_options"></property>
+ <property name="x_padding">6</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label8">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Acquisition</property>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkHBox" id="histogram-box">
<property name="visible">True</property>
<property name="border_width">10</property>
@@ -312,6 +491,9 @@
</packing>
</child>
</object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
</child>
<child type="tab">
<object class="GtkLabel" id="label1">
@@ -319,13 +501,14 @@
<property name="label" translatable="yes">Histogram</property>
</object>
<packing>
+ <property name="position">1</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<object class="GtkTable" id="table2">
<property name="visible">True</property>
- <property name="border_width">10</property>
+ <property name="border_width">12</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<property name="column_spacing">6</property>
@@ -348,7 +531,7 @@
<child>
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
- <property name="xalign">1</property>
+ <property name="xalign">0</property>
<property name="label" translatable="yes">Frame:</property>
</object>
<packing>
@@ -361,7 +544,7 @@
<child>
<object class="GtkLabel" id="label6">
<property name="visible">True</property>
- <property name="xalign">1</property>
+ <property name="xalign">0</property>
<property name="label" translatable="yes">Zoom:</property>
</object>
<packing>
@@ -389,7 +572,7 @@
</child>
</object>
<packing>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
<child type="tab">
@@ -398,7 +581,7 @@
<property name="label" translatable="yes">Preview</property>
</object>
<packing>
- <property name="position">1</property>
+ <property name="position">2</property>
<property name="tab_fill">False</property>
</packing>
</child>
@@ -640,4 +823,14 @@
<property name="page_increment">10</property>
<property name="page_size">10</property>
</object>
+ <object class="GtkAdjustment" id="exposure-adjustment">
+ <property name="upper">100</property>
+ <property name="step_increment">0.01</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="acquisitions-adjustment">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
</interface>