atomes 1.1.15
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
w_curve.c
Go to the documentation of this file.
1/* This file is part of the 'atomes' software
2
3'atomes' is free software: you can redistribute it and/or modify it under the terms
4of the GNU Affero General Public License as published by the Free Software Foundation,
5either version 3 of the License, or (at your option) any later version.
6
7'atomes' is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
8without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9See the GNU General Public License for more details.
10
11You should have received a copy of the GNU Affero General Public License along with 'atomes'.
12If not, see <https://www.gnu.org/licenses/>
13
14Copyright (C) 2022-2024 by CNRS and University of Strasbourg */
15
22/*
23* This file: 'w_curve.c'
24*
25* Contains:
26*
27
28 - The functions to create the graph/curve window
29
30*
31* List of functions:
32
33 int get_curve_shift (project * this_proj, int b, int c);
34
35 G_MODULE_EXPORT gboolean view_curve_popup (GtkWidget * widget, gpointer data);
36 G_MODULE_EXPORT gboolean on_motion_notify_event (GtkWidget * widget, GdkEventMotion * event, gpointer data);
37 G_MODULE_EXPORT gboolean on_curve_button_event (GtkWidget * widget, GdkEvent * event, gpointer data);
38 G_MODULE_EXPORT gboolean on_curve_key_pressed (GtkWidget * widg, GdkEventKey * event, gpointer data);
39 G_MODULE_EXPORT gboolean on_curve_key_pressed (GtkEventControllerKey * self, guint keyval, guint keycode, GdkModifierType state, gpointer data);
40
41 void curve_zoom_in_out (gboolean state, gdouble event_x, gdouble event_y, gpointer data);
42 void curve_button_event (double event_x, double event_y, guint event_button, guint event_type, guint32 event_time, gpointer data);
43 void curve_button_event (GdkEvent * event, double event_x, double event_y, guint event_button, guint event_type, guint32 event_time, gpointer data);
44 void curve_key_pressed (guint keyval, GdkModifierType state, gpointer data);
45
46 static void on_curve_pointer_motion (GtkEventControllerMotion * motion, gdouble x, gdouble y, gpointer data);
47
48 G_MODULE_EXPORT void on_curve_button_pressed (GtkGesture * gesture, int n_press, double x, double y, gpointer data);
49 G_MODULE_EXPORT void on_curve_button_released (GtkGesture * gesture, int n_press, double x, double y, gpointer data);
50 G_MODULE_EXPORT void on_curve_realize (GtkWidget * widg, gpointer data);
51
52 GtkWidget * create_curve (tint * data);
53
54*/
55
56#include <stdlib.h>
57#include <math.h>
58#include <gtk/gtk.h>
59#include <gdk/gdk.h>
60#include <cairo.h>
61
62#include "global.h"
63#include "callbacks.h"
64#include "curve.h"
65#include "cedit.h"
66#include "datab.h"
67
68extern void autoscale (gpointer data);
69extern void curve_menu_bar_action (GSimpleAction * action, GVariant * parameter, gpointer data);
70
72int activeg = 0;
73int activec = 0;
74int activer = 0;
75
76#ifdef GTK3
85G_MODULE_EXPORT gboolean view_curve_popup (GtkWidget * widget, gpointer data)
86{
88 return TRUE;
89}
90#endif
91
102void curve_zoom_in_out (gboolean state, gdouble event_x, gdouble event_y, gpointer data)
103{
104 int a, b, c;
105 int x, y;
106 double r, g, d;
107 double tmp, xp, yp;
108 gchar * str;
109 gint width, height;
110 CurveState * cstate = (CurveState *)data;
111 a = cstate -> id -> a;
112 b = cstate -> id -> b;
113 c = cstate -> id -> c;
114 project * this_proj = get_project_by_id(a);
115 int curve_shift = get_curve_shift (this_proj,b,c);
116#ifdef GTK4
117 event_y -= (double) curve_shift;
118#endif
119 if (state && cstate -> mouseState.MouseIsDown)
120 {
121 cairo_t * rec;
122 cairo_region_t * reg;
123#ifdef GTK3
124 GdkWindow * win = gtk_widget_get_window (this_proj -> curves[b][c] -> plot);
125 reg = gdk_window_get_visible_region (win);
126 GdkDrawingContext * curve_context = gdk_window_begin_draw_frame (win, reg);
127 if (gdk_drawing_context_is_valid (curve_context))
128 {
129 rec = gdk_drawing_context_get_cairo_context (curve_context);
130 if (event_x >= x_min && event_x <= x_max && event_y <= y_min && event_y >= y_max)
131#else
132 GtkNative * native = gtk_widget_get_native (this_proj -> curves[b][c] -> plot);
133 GdkSurface * surf = gtk_native_get_surface (native);
134 cairo_surface_t * csurf = cairo_surface_create_for_rectangle (this_proj -> curves[b][c] -> surface, 0.0, (double)curve_shift,
135 (double)gtk_widget_get_width(this_proj -> curves[b][c] -> plot),
136 (double)gtk_widget_get_height(this_proj -> curves[b][c] -> plot));
137 reg = gdk_cairo_region_create_from_surface (csurf);
138 GdkDrawContext * curve_context = (GdkDrawContext *) gdk_surface_create_cairo_context (surf);
139 gdk_draw_context_begin_frame (curve_context, reg);
140 if (gdk_draw_context_is_in_frame (curve_context))
141 {
142 rec = gdk_cairo_context_cairo_create ((GdkCairoContext *)curve_context);
143 if (event_x >= x_min && event_x <= x_max && event_y <= y_min+(double)curve_shift && event_y >= y_max)
144#endif
145 {
146 width = event_x - cstate -> mouseState.start_x;
147 height = event_y - cstate -> mouseState.start_y;
148#ifdef GTK3
149 cairo_set_source_surface (rec, this_proj -> curves[b][c] -> surface, 0, -curve_shift);
150#else
151 height += (double) curve_shift;
152 cairo_set_source_surface (rec, this_proj -> curves[b][c] -> surface, 0, +curve_shift);
153#endif
154 cairo_paint (rec);
155 if (event_x < cstate -> mouseState.start_x)
156 {
157 r=0.0;
158 x = cstate -> mouseState.start_x + 2;
159 if (event_y < cstate -> mouseState.start_y)
160 {
161 g=0.0;
162 d=1.0;
163 y = cstate -> mouseState.start_y + 8;
164 str = g_strdup_printf ("zoom: out (x) / in (y)");
165 }
166 else
167 {
168 g=1.0;
169 d=0.0;
170 y = cstate -> mouseState.start_y - 4;
171 str = g_strdup_printf ("zoom: out (x) / out (y)");
172 }
173 }
174 else
175 {
176 r=1.0;
177 x = cstate -> mouseState.start_x - 100;
178 if (event_y < cstate -> mouseState.start_y)
179 {
180 g=0.0;
181 d=0.0;
182 y = cstate -> mouseState.start_y + 8;
183 str = g_strdup_printf ("zoom: in (x) / in (y)");
184 }
185 else
186 {
187 g=0.0;
188 d=1.0;
189 y = cstate -> mouseState.start_y - 4;
190 str = g_strdup_printf ("zoom: in (x) / out (y)");
191 }
192 }
193 cairo_set_source_rgba (rec, r, g, d, 0.05);
194 cairo_rectangle (rec, cstate -> mouseState.start_x, cstate -> mouseState.start_y, width, height);
195 cairo_fill (rec);
196 cairo_set_source_rgba (rec, r, g, d, 1.0);
197 cairo_set_line_width (rec, 1.0);
198 cairo_move_to (rec, cstate -> mouseState.start_x, cstate -> mouseState.start_y);
199#ifdef GTK4
200 event_y += (double) curve_shift;
201#endif
202 cairo_line_to (rec, cstate -> mouseState.start_x, event_y);
203 cairo_line_to (rec, event_x, event_y);
204 cairo_line_to (rec, event_x, cstate -> mouseState.start_y);
205 cairo_line_to (rec, cstate -> mouseState.start_x, cstate -> mouseState.start_y);
206 cairo_stroke (rec);
207 if (abs(width) > 10 && abs(height) > 5)
208 {
209 cairo_move_to (rec, x, y);
210 cairo_show_text (rec, str);
211 }
212 g_free (str);
213 width = event_x - x_min;
214 tmp = this_proj -> curves[b][c] -> axmax[0] - this_proj -> curves[b][c] -> axmin[0];
215 xp = this_proj -> curves[b][c] -> axmin[0] + width * tmp / XDRAW;
216#ifdef GTK4
217 event_y -= (double) curve_shift;
218#endif
219 height = event_y - y_max;
220 tmp = this_proj -> curves[b][c] -> axmax[1] - this_proj -> curves[b][c] -> axmin[1];
221 yp = this_proj -> curves[b][c] -> axmax[1] + height * tmp / YDRAW;
222 str = g_strdup_printf ("(x= %f, y= %f)", xp, yp);
223 }
224 else
225 {
226 str = g_strdup_printf ("(Not in plot)");
227 }
228 gtk_label_set_text (GTK_LABEL(this_proj -> curves[b][c] -> pos), str);
229 g_free (str);
230 }
231#ifdef GTK3
232 gdk_window_end_draw_frame (win, curve_context);
233#else
234 gdk_draw_context_end_frame (curve_context);
235#endif
236 }
237 else if (! cstate -> mouseState.MouseIsDown)
238 {
239#ifdef GTK3
240 // gtk_widget_get_size_request (this_proj -> curves[b][c] -> plot, & this_proj -> curves[b][c] -> wsize[0], & this_proj -> curves[b][c] -> wsize[1]);
241 gtk_window_get_size (GTK_WINDOW(this_proj -> curves[b][c] -> window),
242 & this_proj -> curves[b][c] -> wsize[0],
243 & y);
244 this_proj -> curves[b][c] -> wsize[1] = y - curve_shift;
245#else
246 this_proj -> curves[b][c] -> wsize[0] = gtk_widget_get_width (this_proj -> curves[b][c] -> plot);
247 this_proj -> curves[b][c] -> wsize[1] = gtk_widget_get_height (this_proj -> curves[b][c] -> plot);
248#endif
249 prep_plot (this_proj, b, c);
250#ifdef GTK4
251 if (event_x >= x_min && event_x <= x_max && event_y <= y_min+(double)curve_shift && event_y >= y_max)
252#else
253 if (event_x >= x_min && event_x <= x_max && event_y <= y_min && event_y >= y_max)
254#endif
255 {
256 width = event_x - x_min;
257 tmp = this_proj -> curves[b][c] -> axmax[0] - this_proj -> curves[b][c] -> axmin[0];
258 xp = this_proj -> curves[b][c] -> axmin[0] + width * tmp / XDRAW;
259 height = event_y - y_max;
260 tmp = this_proj -> curves[b][c] -> axmax[1] - this_proj -> curves[b][c] -> axmin[1];
261 yp = this_proj -> curves[b][c] -> axmax[1] + height * tmp / YDRAW;
262 str = g_strdup_printf ("(x= %f, y= %f)", xp, yp);
263 }
264 else
265 {
266 str = g_strdup_printf ("Not in plot");
267 }
268 gtk_label_set_text (GTK_LABEL(this_proj -> curves[b][c] -> pos), str);
269 g_free (str);
270 }
271}
272
273#ifdef GTK3
283G_MODULE_EXPORT gboolean on_motion_notify_event (GtkWidget * widget, GdkEventMotion * event, gpointer data)
284{
285 curve_zoom_in_out ((event -> state & GDK_BUTTON1_MASK) ? TRUE : FALSE, event -> x, event -> y, data);
286 return TRUE;
287}
288#else
299static void on_curve_pointer_motion (GtkEventControllerMotion * motion, gdouble x, gdouble y, gpointer data)
300{
301 curve_zoom_in_out (((CurveState *)data) -> mouseState.MouseIsDown, x, y, data);
302}
303#endif
304
305#ifdef GTK4
318void curve_button_event (double event_x, double event_y, guint event_button, guint event_type, guint32 event_time, gpointer data)
319#else
333void curve_button_event (GdkEvent * event, double event_x, double event_y, guint event_button, guint event_type, guint32 event_time, gpointer data)
334#endif
335{
336 int x1, x2, y1, y2;
337 double tmp;
338 int a, b, c;
339 CurveState * cstate = (CurveState *)data;
340 a = activeg = cstate -> id -> a;
341 b = activer = cstate -> id -> b;
342 c = activec = cstate -> id -> c;
343 project * this_proj = get_project_by_id(a);
344#ifdef GTK4
345 int curve_shift = get_curve_shift (this_proj, b, c);
346#endif
347 if (event_type == GDK_BUTTON_PRESS)
348 {
349 if (event_button == 1)
350 {
351#ifdef GTK3
352 /*
353 The following is not working:
354 gtk_widget_get_size_request (this_proj -> curves[b][c] -> plot, & this_proj -> curves[b][c] -> wsize[0], & this_proj -> curves[b][c] -> wsize[1]);
355 */
356 gtk_window_get_size (GTK_WINDOW(this_proj -> curves[b][c] -> window),
357 & this_proj -> curves[b][c] -> wsize[0],
358 & y1);
359 this_proj -> curves[b][c] -> wsize[1] = y1 - get_curve_shift (this_proj, b, c);
360#else
361 this_proj -> curves[b][c] -> wsize[0] = gtk_widget_get_width (this_proj -> curves[b][c] -> plot);
362 this_proj -> curves[b][c] -> wsize[1] = gtk_widget_get_height (this_proj -> curves[b][c] -> plot);
363#endif
364 prep_plot (this_proj, b, c);
365#ifdef GTK4
366 if (event_x >= x_min && event_x <= x_max && event_y <= y_min+(double)curve_shift && event_y >= y_max)
367#else
368 if (event_x >= x_min && event_x <= x_max && event_y <= y_min && event_y >= y_max)
369#endif
370 {
371 cstate -> mouseState.start_x = event_x;
372 cstate -> mouseState.start_y = event_y;
373 cstate -> mouseState.time = event_time;
374 cstate -> mouseState.MouseIsDown = TRUE;
375 }
376 }
377 else if (event_button == 3)
378 {
379#ifdef GTK4
380 pop_menu_at_pointer (curve_popup_menu(data), event_x, event_y);
381#else
383#endif
384 }
385 }
386 else if (event_type == GDK_BUTTON_RELEASE)
387 {
388 cstate -> mouseState.MouseIsDown = FALSE;
389 if (event_button == 1)
390 {
391 etime = event_time - cstate -> mouseState.time;
392 if (event_x >= x_min && event_x <= x_max && event_y <= y_min && event_y >= y_max)
393 {
394 if (event_x != cstate -> mouseState.start_x && event_y != cstate -> mouseState.start_y)
395 {
396 if (etime > 500 && etime < 50000)
397 {
398 x1 = cstate -> mouseState.start_x - x_min;
399 y1 = cstate -> mouseState.start_y - y_max;
400 x2 = event_x - x_min;
401 y2 = event_y - y_max;
402#ifdef GTK4
403 y1 -= curve_shift;
404 y2 -= curve_shift;
405#endif
406 tmp = this_proj -> curves[b][c] -> axmax[0] - this_proj -> curves[b][c] -> axmin[0];
407 if (x2 > x1)
408 {
409 // zoom-in on X
410 this_proj -> curves[b][c] -> axmax[0] = this_proj -> curves[b][c] -> axmin[0] + x2 * tmp / XDRAW;
411 this_proj -> curves[b][c] -> axmin[0] = this_proj -> curves[b][c] -> axmin[0] + x1 * tmp / XDRAW;
412 }
413 else
414 {
415 // zoom-out on X
416 this_proj -> curves[b][c] -> axmin[0] = this_proj -> curves[b][c] -> axmin[0] - (x1 - x2) * tmp / XDRAW;
417 this_proj -> curves[b][c] -> axmax[0] = this_proj -> curves[b][c] -> axmax[0] + (x1 - x2) * tmp / XDRAW;
418 }
419 tmp = this_proj -> curves[b][c] -> axmax[1] - this_proj -> curves[b][c] -> axmin[1];
420 if (y1 > y2)
421 {
422 // zoom-in on Y
423 this_proj -> curves[b][c] -> axmin[1] = this_proj -> curves[b][c] -> axmax[1] + y1 * tmp / YDRAW;
424 this_proj -> curves[b][c] -> axmax[1] = this_proj -> curves[b][c] -> axmax[1] + y2 * tmp / YDRAW;
425 }
426 else
427 {
428 // zoom-out on Y
429 this_proj -> curves[b][c] -> axmin[1] = this_proj -> curves[b][c] -> axmin[1] + (y2 - y1) * tmp / YDRAW;
430 this_proj -> curves[b][c] -> axmax[1] = this_proj -> curves[b][c] -> axmax[1] - (y2 - y1) * tmp / YDRAW;
431 }
432 }
433 }
434 }
435 tint id;
436 id.a = a;
437 id.b = b;
438 id.c = c;
439 update_curve ((gpointer)& id);
440 }
441 }
442}
443
444#ifdef GTK4
456G_MODULE_EXPORT void on_curve_button_pressed (GtkGesture * gesture, int n_press, double x, double y, gpointer data)
457{
458 curve_button_event (x, y, gtk_gesture_single_get_current_button ((GtkGestureSingle * )gesture), GDK_BUTTON_PRESS, gtk_event_controller_get_current_event_time((GtkEventController *)gesture), data);
459}
460
472G_MODULE_EXPORT void on_curve_button_released (GtkGesture * gesture, int n_press, double x, double y, gpointer data)
473{
474 curve_button_event (x, y, gtk_gesture_single_get_current_button ((GtkGestureSingle * )gesture), GDK_BUTTON_RELEASE, gtk_event_controller_get_current_event_time((GtkEventController *)gesture), data);
475}
476#else
486G_MODULE_EXPORT gboolean on_curve_button_event (GtkWidget * widget, GdkEvent * event, gpointer data)
487{
488 GdkEventButton * bevent = (GdkEventButton *)event;
489 curve_button_event (event, bevent -> x, bevent -> y, bevent -> button, bevent -> type, bevent -> time, data);
490 return TRUE;
491}
492#endif
493
503void curve_key_pressed (guint keyval, GdkModifierType state, gpointer data)
504{
505 if (state & GDK_CONTROL_MASK)
506 {
507 switch (keyval)
508 {
509 case GDK_KEY_a:
510 autoscale (data);
511 break;
512 case GDK_KEY_c:
513 hide_curve (data);
514 break;
515 case GDK_KEY_e:
516 edit_curve (data);
517 break;
518 case GDK_KEY_i:
519 save_image (data);
520 break;
521 case GDK_KEY_s:
522 write_curve (data);
523 break;
524 }
525 }
526}
527
528#ifdef GTK3
538G_MODULE_EXPORT gboolean on_curve_key_pressed (GtkWidget * widg, GdkEventKey * event, gpointer data)
539{
540 if (event -> type == GDK_KEY_PRESS)
541 {
542 //GdkModifierType accel_mask = gtk_accelerator_get_default_mod_mask ();
543 // if ((event -> state & accel_mask) == GDK_CONTROL_MASK)
544 curve_key_pressed (event -> keyval, event -> state, data);
545 }
546 return FALSE;
547}
548#else
560G_MODULE_EXPORT gboolean on_curve_key_pressed (GtkEventControllerKey * self, guint keyval, guint keycode, GdkModifierType state, gpointer data)
561{
562 curve_key_pressed (keyval, state, data);
563 return TRUE;
564}
565#endif
566
576int get_curve_shift (project * this_proj, int b, int c)
577{
578 return get_widget_height (this_proj -> curves[b][c] -> window) - get_widget_height (this_proj -> curves[b][c] -> plot);
579}
580
589G_MODULE_EXPORT void on_curve_realize (GtkWidget * widg, gpointer data)
590{
591 tint * id = (tint *)data;
592 project * this_proj = get_project_by_id(id -> a);
593 resize_this_window (this_proj -> curves[id -> b][id -> c] -> window,
594 this_proj -> curves[id -> b][id -> c] -> wsize[0],
595 this_proj -> curves[id -> b][id -> c] -> wsize[1]+get_curve_shift (this_proj, id -> b, id -> c));
596}
597
605GtkWidget * create_curve (tint * data)
606{
607 GtkWidget * Curve, * vbox;
608
609 activec = data -> c;
610 project * this_proj = get_project_by_id(data -> a);
611 gchar * str = g_strdup_printf ("%s - %s", prepare_for_title (this_proj -> name), this_proj -> curves[data -> b][data -> c] -> name);
612 Curve = create_win (str, MainWindow, FALSE, TRUE);
613 activer = data -> b;
614 g_free (str);
617 this_proj -> curves[data -> b][data -> c] -> curve_vbox = create_vbox (BSEP);
618 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, this_proj -> curves[data -> b][data -> c] -> curve_vbox, FALSE, FALSE, 0);
619
621 this_proj -> curves[data -> b][data -> c] -> action_id = curve_action_id;
622 this_proj -> curves[data -> b][data -> c] -> action_group = g_simple_action_group_new ();
623 GSimpleAction * curve_action[5];
624 curve_action[0] = g_simple_action_new ("save.data", NULL);
625 curve_action[1] = g_simple_action_new ("close.curve", NULL);
626 curve_action[2] = g_simple_action_new ("edit.curve", NULL);
627 curve_action[3] = g_simple_action_new ("save.image", NULL);
628 curve_action[4] = g_simple_action_new ("shortcuts.curve", NULL);
629 int i;
630 for (i=0; i<5; i++)
631 {
632 g_action_map_add_action (G_ACTION_MAP(this_proj -> curves[data -> b][data -> c] -> action_group), G_ACTION(curve_action[i]));
633 g_signal_connect (curve_action[i], "activate", G_CALLBACK(curve_menu_bar_action), data);
634 }
635 str = g_strdup_printf ("c-%d", this_proj -> curves[data -> b][data -> c] -> action_id);
636 gtk_widget_insert_action_group (Curve, str, G_ACTION_GROUP(this_proj -> curves[data -> b][data -> c] -> action_group));
637 g_free (str);
639
640 this_proj -> curves[data -> b][data -> c] -> datatree = NULL;
641 this_proj -> curves[data -> b][data -> c] -> state.id = data;
642 this_proj -> curves[data -> b][data -> c] -> plot = gtk_drawing_area_new ();
643 gtk_widget_set_size_request (this_proj -> curves[data -> b][data -> c] -> plot, 100, 100);
644 gtk_widget_set_hexpand (this_proj -> curves[data -> b][data -> c] -> plot, TRUE);
645 gtk_widget_set_vexpand (this_proj -> curves[data -> b][data -> c] -> plot, TRUE);
646#ifdef GTK3
647 gtk_widget_add_events (GTK_WIDGET (this_proj -> curves[data -> b][data -> c] -> plot),
648 GDK_EXPOSURE_MASK | GDK_SMOOTH_SCROLL_MASK |
649 GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
650 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
651 g_signal_connect (G_OBJECT(this_proj -> curves[data -> b][data -> c] -> plot), "motion_notify_event", G_CALLBACK(on_motion_notify_event), & this_proj -> curves[data -> b][data -> c] -> state);
652 g_signal_connect (G_OBJECT(this_proj -> curves[data -> b][data -> c] -> plot), "button_press_event", G_CALLBACK(on_curve_button_event), & this_proj -> curves[data -> b][data -> c] -> state);
653 g_signal_connect (G_OBJECT(this_proj -> curves[data -> b][data -> c] -> plot), "button_release_event", G_CALLBACK(on_curve_button_event),& this_proj -> curves[data -> b][data -> c] -> state);
654 g_signal_connect (G_OBJECT(this_proj -> curves[data -> b][data -> c] -> plot), "popup-menu", G_CALLBACK(view_curve_popup), & this_proj -> curves[data -> b][data -> c] -> state);
655#else
656 add_widget_gesture_and_key_action (Curve, "curve-button-pressed", G_CALLBACK(on_curve_button_pressed), & this_proj -> curves[data -> b][data -> c] -> state,
657 "curve-button-released", G_CALLBACK(on_curve_button_released), & this_proj -> curves[data -> b][data -> c] -> state,
658 "curve-key-pressed", G_CALLBACK(on_curve_key_pressed), data,
659 "curve-pointer-motion", G_CALLBACK(on_curve_pointer_motion), & this_proj -> curves[data -> b][data -> c] -> state,
660 NULL, NULL, NULL);
661#endif
662
663 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, this_proj -> curves[data -> b][data -> c] -> plot, FALSE, TRUE, 0);
664
665#ifdef GTK3
666 g_signal_connect (G_OBJECT(this_proj -> curves[data -> b][data -> c] -> plot), "draw", G_CALLBACK(show_curve), data);
667 g_signal_connect (G_OBJECT(Curve), "key-press-event", G_CALLBACK(on_curve_key_pressed), data);
668#else
669 gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA(this_proj -> curves[data -> b][data -> c] -> plot), (GtkDrawingAreaDrawFunc)show_curve, data, NULL);
670#endif
671 g_signal_connect (G_OBJECT(Curve), "realize", G_CALLBACK(on_curve_realize), data);
672 add_gtk_close_event (Curve, G_CALLBACK(to_hide_curve), data);
673 return Curve;
674}
Callback declarations for main window.
void edit_curve(gpointer data)
create the curve edition dialog
Definition cedit.c:347
Variable declarations for the curve layout edition window.
gint32 etime
Definition curve.c:63
void prep_plot(project *this_proj, int rid, int cid)
prepare curve plot (setting up variables for the plot)
Definition curve.c:315
double YDRAW
Definition curve.c:65
double XDRAW
Definition curve.c:65
double y_max
Definition curve.c:69
double x_max
Definition curve.c:68
void update_curve(gpointer data)
update curve rendering
Definition curve.c:589
double y_min
Definition curve.c:69
double x_min
Definition curve.c:68
Variable declarations for the curve widget Functions for interactions with the curve widget.
GtkWidget * curve_popup_menu(gpointer data)
create curve popup menu
Definition m_curve.c:706
G_MODULE_EXPORT gboolean to_hide_curve(GtkWindow *thecurve, gpointer data)
void hide_curve(gpointer data)
hide curve
Definition show.c:312
void save_image(gpointer cdata)
export curve window plot to image - creating the dialog
Definition w_img.c:326
void curve_window_add_menu_bar(tint *data)
add menu bar to the curve window
Definition m_curve.c:612
void show_curve(GtkDrawingArea *area, cairo_t *cr, int width, int height, gpointer curve)
show curve callback GTK3
Definition show.c:77
void write_curve(gpointer idata)
save curve data - creating the dialog
Definition w_data.c:164
Variable declarations for the curve data edition window.
GtkWidget * MainWindow
Definition global.c:201
Global variable declarations Global convenience function declarations Global data structure defin...
void resize_this_window(GtkWidget *window, int x, int y)
resize this GtkWindow
Definition gtk-misc.c:581
GtkWidget * create_win(gchar *str, GtkWidget *parent, gboolean modal, gboolean resiz)
create a new GtkWindow
Definition gtk-misc.c:445
int get_widget_height(GtkWidget *widg)
retrive GtkWidget height
Definition gtk-misc.c:2419
#define BSEP
Definition global.h:245
void pop_menu_at_pointer(GtkWidget *widg, GdkEvent *event)
popup a menu at pointer location
Definition gtk-misc.c:2301
struct Curve Curve
curve data structure
Definition global.h:606
void add_gtk_close_event(GtkWidget *widg, GCallback handler, gpointer data)
add a close event signal and callback to a GtkWidget
Definition gtk-misc.c:2387
@ CONTAINER_WIN
Definition global.h:250
void add_box_child_start(int orientation, GtkWidget *widg, GtkWidget *child, gboolean expand, gboolean fill, int padding)
Add a GtkWidget in a GtkBox at the initial position.
Definition gtk-misc.c:299
gchar * prepare_for_title(gchar *init)
prepare a string for a window title, getting rid of all markup
Definition tools.c:71
void add_container_child(int type, GtkWidget *widg, GtkWidget *child)
Add a GtkWidget into another GtkWidget.
Definition gtk-misc.c:226
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:801
project * get_project_by_id(int p)
get project pointer using id number
Definition project.c:120
void motion(glwin *view, gint x, gint y, GdkModifierType state)
mouse motion in the OpenGL window
Definition glview.c:626
image * plot
Definition ogl_draw.c:66
action
Definition glview.h:189
double y
Definition ogl_draw.c:57
double x
Definition ogl_draw.c:57
int id
Definition global.h:941
Definition global.h:104
int b
Definition tab-1.c:95
int c
Definition tab-1.c:95
int d
Definition tab-1.c:95
int a
Definition tab-1.c:95
void curve_key_pressed(guint keyval, GdkModifierType state, gpointer data)
the keyboard shortcut actions for the curve window
Definition w_curve.c:503
int activer
Definition w_curve.c:74
void autoscale(gpointer data)
autoscale callback
Definition m_curve.c:100
int get_curve_shift(project *this_proj, int b, int c)
get cruve window size shift
Definition w_curve.c:576
void curve_button_event(GdkEvent *event, double event_x, double event_y, guint event_button, guint event_type, guint32 event_time, gpointer data)
handle mouse button event on the curve window GTK3
Definition w_curve.c:333
G_MODULE_EXPORT gboolean on_curve_key_pressed(GtkEventControllerKey *self, guint keyval, guint keycode, GdkModifierType state, gpointer data)
keyboard key press event for the curve window GTK4
Definition w_curve.c:560
int activec
Definition w_curve.c:73
void curve_zoom_in_out(gboolean state, gdouble event_x, gdouble event_y, gpointer data)
curve zoom in or out
Definition w_curve.c:102
G_MODULE_EXPORT gboolean on_curve_button_event(GtkWidget *widget, GdkEvent *event, gpointer data)
mouse button event on the curve window
Definition w_curve.c:486
int curve_action_id
Definition w_curve.c:71
int activeg
Definition w_curve.c:72
G_MODULE_EXPORT void on_curve_realize(GtkWidget *widg, gpointer data)
curve window realize callback
Definition w_curve.c:589
void curve_menu_bar_action(GSimpleAction *action, GVariant *parameter, gpointer data)
curve menu action callback
Definition m_curve.c:297
GtkWidget * create_curve(tint *data)
create the curve data plot window
Definition w_curve.c:605
GtkWidget * vbox
Definition workspace.c:72