using key to change histogram scale setting value

master
Steffen Pohle 3 years ago
parent 7046b2edc9
commit 59c59e557a

@ -1,3 +1,6 @@
2022-11-26:
- adding histogram
2022-11-10:
- support for DNG file export

@ -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.

@ -23,6 +23,8 @@ private:
public:
char *debugpath;
char *readdumppath;
int histogram_log = 1; // logarithmic or linear scale
Configuration();
~Configuration();

@ -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);

@ -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;
}
};

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<!-- Generated with glade 3.40.0 -->
<interface>
<requires lib="gtk+" version="3.18"/>
<object class="GtkAdjustment" id="detect-pos-adjbright">
@ -22,18 +22,6 @@
<property name="orientation">vertical</property>
<property name="spacing">3</property>
<property name="baseline-position">top</property>
<child>
<object class="GtkDrawingArea" id="temp-da">
<property name="visible">True</property>
<property name="can-focus">False</property>
<signal name="draw" handler="cb_imagetempda_draw" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
@ -224,7 +212,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
<property name="position">0</property>
</packing>
</child>
<child>
@ -442,6 +430,18 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkDrawingArea" id="temp-da">
<property name="visible">True</property>
<property name="can-focus">False</property>
<signal name="draw" handler="cb_imagetempda_draw" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
@ -454,11 +454,12 @@
<child>
<object class="GtkDrawingArea" id="histogram-da">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="events">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</property>
<property name="can-focus">True</property>
<property name="events">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</property>
<signal name="button-press-event" handler="cb_histogramda_btnpress" swapped="no"/>
<signal name="button-release-event" handler="cb_histogramda_btnrelease" swapped="no"/>
<signal name="draw" handler="cb_histogramda_draw" swapped="no"/>
<signal name="key-press-event" handler="cb_histogramda_keypress" swapped="no"/>
<signal name="motion-notify-event" handler="cb_histogramda_motion" swapped="no"/>
</object>
</child>

Loading…
Cancel
Save