diff --git a/ChangeLog b/ChangeLog index 0df678a..8d1b16a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2022-11-26: +- adding histogram + 2022-11-10: - support for DNG file export diff --git a/configuration.cc b/configuration.cc index 0b93220..f67e6e7 100644 --- a/configuration.cc +++ b/configuration.cc @@ -76,6 +76,12 @@ void Configuration::SaveConfig(std::string filename) { cbe = gtk_bin_get_child(GTK_BIN(cb)); jp.AddObject("device", (string) gtk_entry_get_text(GTK_ENTRY(cbe))); + + // + // histogram settings + jp.AddObject("histogram_log", histogram_log); + + // // save button config for (i = 0; i < BTN_PRESET_MAX; i++) { @@ -137,6 +143,7 @@ void Configuration::LoadConfig(std::string filename) { gtk_entry_set_text(GTK_ENTRY(cbdevice), vstr.c_str()); } + jp.GetValueInt("histogram_log", &histogram_log); // // start streaming if a device was selected. diff --git a/configuration.h b/configuration.h index 67485e3..7154b62 100644 --- a/configuration.h +++ b/configuration.h @@ -23,6 +23,8 @@ private: public: char *debugpath; char *readdumppath; + int histogram_log = 1; // logarithmic or linear scale + Configuration(); ~Configuration(); diff --git a/gui.h b/gui.h index e8530ba..ce54796 100644 --- a/gui.h +++ b/gui.h @@ -105,6 +105,7 @@ G_MODULE_EXPORT void cb_histogramda_draw(GtkWidget *area, cairo_t *cr, int w, in G_MODULE_EXPORT void cb_histogramda_motion (GtkWidget *widget, GdkEvent *event, gpointer data); G_MODULE_EXPORT void cb_histogramda_btnpress (GtkWidget *widget, gpointer data); G_MODULE_EXPORT void cb_histogramda_btnrelease (GtkWidget *widget, gpointer data); +G_MODULE_EXPORT void cb_histogramda_keypress (GtkWidget *widget, GdkEventKey *event, gpointer data); diff --git a/histogram.cc b/histogram.cc index 2378ed8..a38cfeb 100644 --- a/histogram.cc +++ b/histogram.cc @@ -25,7 +25,6 @@ int histogram_pressed_x; // window x-coordinate when pressing a b int histogram_released_x; // window x-coordinate when releasing a button int histogram_pressed = 0; // indicates button pressed or not int histogram_zoomed = 0; // indicates zoom -int histogram_log = 1; // logarithmic or linear scale extern GtkBuilder *_builder_; // work around for threads @@ -73,7 +72,7 @@ void cb_histogramda_draw(GtkWidget *area, cairo_t *cr, int w, int h, gpointer da int histogram_scale = histogram_width - 1 > 0 ? histogram_width - 1 : 1; for (int i = 0; i < histogram_width; i++) { px = HISTOGRAM_MARGIN + ((clientw-HISTOGRAM_MARGIN*2) * i) / histogram_scale; - if (histogram_log) + if (config.histogram_log) py2 = (clienth-HISTOGRAM_MARGIN) - ((clienth-HISTOGRAM_MARGIN*2) * log10(histogram[chan][histogram_zoom_start+i]+1) / log10(histogram_max)); else py2 = (clienth-HISTOGRAM_MARGIN) - ((clienth-HISTOGRAM_MARGIN*2) * histogram[chan][histogram_zoom_start+i] / histogram_max); @@ -99,7 +98,8 @@ void cb_histogramda_draw(GtkWidget *area, cairo_t *cr, int w, int h, gpointer da } // draw some text - snprintf (txt, 255, "%d", histogram_max); + if (config.histogram_log) snprintf (txt, 255, "%d - Log", histogram_max); + else snprintf (txt, 255, "%d - Lin", histogram_max); for (int i = 0; i < 5; i++) { int dx, dy; @@ -224,3 +224,17 @@ void cb_histogramda_btnrelease (GtkWidget *widget, gpointer data) { } } }; + + +void cb_histogramda_keypress (GtkWidget *widget, GdkEventKey *event, gpointer data) { + + printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__); + + if (event == NULL) return; + + else if (event->keyval == 'l') { + if (config.histogram_log == 0) config.histogram_log = 1; + else config.histogram_log = 0; + } +}; + diff --git a/simpleskycam.ui b/simpleskycam.ui index 172e65c..08f4a45 100644 --- a/simpleskycam.ui +++ b/simpleskycam.ui @@ -1,5 +1,5 @@ - + @@ -22,18 +22,6 @@ vertical 3 top - - - True - False - - - - True - True - 0 - - True @@ -224,7 +212,7 @@ False False - 1 + 0 @@ -442,6 +430,18 @@ False False + 1 + + + + + True + False + + + + True + True 2 @@ -454,11 +454,12 @@ True - False - GDK_POINTER_MOTION_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON2_MOTION_MASK | GDK_BUTTON3_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK + True + GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON2_MOTION_MASK | GDK_BUTTON3_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_FOCUS_CHANGE_MASK | GDK_STRUCTURE_MASK | GDK_PROPERTY_CHANGE_MASK | GDK_VISIBILITY_NOTIFY_MASK | GDK_PROXIMITY_IN_MASK | GDK_PROXIMITY_OUT_MASK | GDK_SUBSTRUCTURE_MASK | GDK_SCROLL_MASK | GDK_TOUCH_MASK | GDK_SMOOTH_SCROLL_MASK | GDK_TOUCHPAD_GESTURE_MASK | GDK_TABLET_PAD_MASK +