File: gwygraph.c

package info (click to toggle)
gwyddion 2.62-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 51,952 kB
  • sloc: ansic: 398,486; python: 7,877; sh: 5,492; makefile: 4,723; xml: 3,883; cpp: 1,969; pascal: 418; perl: 154; ruby: 130
file content (626 lines) | stat: -rw-r--r-- 19,713 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
/*
 *  $Id: gwygraph.c 20678 2017-12-18 18:26:55Z yeti-dn $
 *  Copyright (C) 2003 David Necas (Yeti), Petr Klapetek.
 *  E-mail: yeti@gwyddion.net, klapetek@gwyddion.net.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor,
 *  Boston, MA 02110-1301, USA.
 */

#include "config.h"
#include <string.h>
#include <gtk/gtk.h>

#include <libgwyddion/gwymacros.h>
#include <libgwyddion/gwymath.h>
#include <libgwydgets/gwygraph.h>
#include <libgwydgets/gwygraphmodel.h>

enum {
    PROP_0,
    PROP_MODEL,
    PROP_LAST
};

static void gwy_graph_finalize          (GObject *object);
static void gwy_graph_set_property      (GObject *object,
                                         guint prop_id,
                                         const GValue *value,
                                         GParamSpec *pspec);
static void gwy_graph_get_property      (GObject *object,
                                         guint prop_id,
                                         GValue *value,
                                         GParamSpec *pspec);
static void gwy_graph_refresh_all       (GwyGraph *graph);
static void gwy_graph_model_notify      (GwyGraph *graph,
                                         GParamSpec *pspec,
                                         GwyGraphModel *gmodel);
static void gwy_graph_curve_data_changed(GwyGraph *graph,
                                         gint i);
static void gwy_graph_refresh_ranges    (GwyGraph *graph);
static void gwy_graph_axis_rescaled     (GwyAxis *axis,
                                         GwyGraph *graph);
static void gwy_graph_zoomed            (GwyGraph *graph);
static void gwy_graph_label_updated     (GwyAxis *axis,
                                         GParamSpec *pspec,
                                         GwyGraph *graph);

G_DEFINE_TYPE(GwyGraph, gwy_graph, GTK_TYPE_TABLE)

static void
gwy_graph_class_init(GwyGraphClass *klass)
{
    GObjectClass *gobject_class = G_OBJECT_CLASS(klass);

    gobject_class->finalize = gwy_graph_finalize;
    gobject_class->set_property = gwy_graph_set_property;
    gobject_class->get_property = gwy_graph_get_property;

    /**
     * GwyGraph:model:
     *
     * The graph model of the graph.
     *
     * Since: 2.7
     **/
    g_object_class_install_property
        (gobject_class,
         PROP_MODEL,
         g_param_spec_object("model",
                             "Model",
                             "The graph model of the graph.",
                             GWY_TYPE_GRAPH_MODEL,
                             G_PARAM_READWRITE));

}

static void
gwy_graph_init(G_GNUC_UNUSED GwyGraph *graph)
{
    gwy_debug("");
}

static void
gwy_graph_finalize(GObject *object)
{
    GwyGraph *graph = GWY_GRAPH(object);

    GWY_SIGNAL_HANDLER_DISCONNECT(graph->zoom_selection,
                                  graph->zoom_finished_id);
    GWY_SIGNAL_HANDLER_DISCONNECT(graph->graph_model, graph->model_notify_id);
    GWY_SIGNAL_HANDLER_DISCONNECT(graph->graph_model,
                                  graph->curve_data_changed_id);
    GWY_OBJECT_UNREF(graph->graph_model);
    GWY_OBJECT_UNREF(graph->zoom_selection);

    G_OBJECT_CLASS(gwy_graph_parent_class)->finalize(object);
}

static void
gwy_graph_set_property(GObject *object,
                       guint prop_id,
                       const GValue *value,
                       GParamSpec *pspec)
{
    GwyGraph *graph = GWY_GRAPH(object);

    switch (prop_id) {
        case PROP_MODEL:
        gwy_graph_set_model(graph, g_value_get_object(value));
        break;

        default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
        break;
    }
}

static void
gwy_graph_get_property(GObject*object,
                       guint prop_id,
                       GValue *value,
                       GParamSpec *pspec)
{
    GwyGraph *graph = GWY_GRAPH(object);

    switch (prop_id) {
        case PROP_MODEL:
        g_value_set_object(value, graph->graph_model);
        break;

        default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
        break;
    }
}

/**
 * gwy_graph_new:
 * @gmodel: A graph model.
 *
 * Creates graph widget based on information in model.
 *
 * Returns: new graph widget.
 **/
GtkWidget*
gwy_graph_new(GwyGraphModel *gmodel)
{
    GwyGraph *graph;
    guint i;

    gwy_debug("");

    graph = GWY_GRAPH(g_object_new(GWY_TYPE_GRAPH, NULL));

    graph->area = GWY_GRAPH_AREA(gwy_graph_area_new());
    graph->area->status = GWY_GRAPH_STATUS_PLAIN;
    graph->enable_user_input = TRUE;

    gtk_table_resize(GTK_TABLE(graph), 3, 3);
    gtk_table_set_homogeneous(GTK_TABLE(graph), FALSE);
    gtk_table_set_row_spacings(GTK_TABLE(graph), 0);
    gtk_table_set_col_spacings(GTK_TABLE(graph), 0);

    for (i = GTK_POS_LEFT; i <= GTK_POS_BOTTOM; i++)
        graph->axis[i] = GWY_AXIS(gwy_axis_new(i));

    gwy_graph_set_axis_visible(graph, GTK_POS_RIGHT, FALSE);
    gwy_graph_set_axis_visible(graph, GTK_POS_TOP, FALSE);

    /* XXX: Is there any reason why we never connect to "rescaled" of top and
     * right axes? */
    /* Axis signals never disconnected, we assume axes are not reparented
     * elsewhere */
    graph->rescaled_id[GTK_POS_LEFT]
        = g_signal_connect(graph->axis[GTK_POS_LEFT], "rescaled",
                           G_CALLBACK(gwy_graph_axis_rescaled), graph);
    graph->rescaled_id[GTK_POS_BOTTOM]
        = g_signal_connect(graph->axis[GTK_POS_BOTTOM], "rescaled",
                           G_CALLBACK(gwy_graph_axis_rescaled), graph);

    gtk_table_attach(GTK_TABLE(graph), GTK_WIDGET(graph->axis[GTK_POS_LEFT]),
                     0, 1, 1, 2,
                     GTK_FILL, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0);
    gtk_table_attach(GTK_TABLE(graph), GTK_WIDGET(graph->axis[GTK_POS_RIGHT]),
                     2, 3, 1, 2,
                     GTK_FILL, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0);
    gtk_table_attach(GTK_TABLE(graph), GTK_WIDGET(graph->axis[GTK_POS_TOP]),
                     1, 2, 0, 1,
                     GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL, 0, 0);
    gtk_table_attach(GTK_TABLE(graph), GTK_WIDGET(graph->axis[GTK_POS_BOTTOM]),
                     1, 2, 2, 3,
                     GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL, 0, 0);

    for (i = GTK_POS_LEFT; i <= GTK_POS_BOTTOM; i++) {
        g_signal_connect(graph->axis[i], "notify::label",
                         G_CALLBACK(gwy_graph_label_updated), graph);
        gtk_widget_show(GTK_WIDGET(graph->axis[i]));
    }

    for (i = 0; i < 4; i++) {
        graph->corner[i] = GWY_GRAPH_CORNER(gwy_graph_corner_new());
        gtk_table_attach(GTK_TABLE(graph), GTK_WIDGET(graph->corner[i]),
                         2*(i/2), 2*(i/2) + 1, 2*(i%2), 2*(i%2) + 1,
                         GTK_FILL, GTK_FILL, 0, 0);
        gtk_widget_show(GTK_WIDGET(graph->corner[i]));
    }

    graph->zoom_selection = gwy_graph_area_get_selection(graph->area,
                                                         GWY_GRAPH_STATUS_ZOOM);
    g_object_ref(graph->zoom_selection);
    graph->zoom_finished_id
        = g_signal_connect_swapped(graph->zoom_selection, "finished",
                                   G_CALLBACK(gwy_graph_zoomed), graph);

    gtk_table_attach(GTK_TABLE(graph), GTK_WIDGET(graph->area), 1, 2, 1, 2,
                     GTK_FILL | GTK_EXPAND | GTK_SHRINK,
                     GTK_FILL | GTK_EXPAND | GTK_SHRINK,
                     0, 0);

    gtk_widget_show_all(GTK_WIDGET(graph->area));

    if (gmodel)
        gwy_graph_set_model(GWY_GRAPH(graph), gmodel);

    return GTK_WIDGET(graph);
}

static void
gwy_graph_refresh_all(GwyGraph *graph)
{
    GwyGraphModel *gmodel;
    GwySIUnit *siunit;
    guint i;

    if (!graph->graph_model)
        return;

    gmodel = GWY_GRAPH_MODEL(graph->graph_model);

    g_object_get(gmodel, "si-unit-x", &siunit, NULL);
    gwy_axis_set_si_unit(graph->axis[GTK_POS_BOTTOM], siunit);
    gwy_axis_set_si_unit(graph->axis[GTK_POS_TOP], siunit);
    g_object_unref(siunit);

    g_object_get(gmodel, "si-unit-y", &siunit, NULL);
    gwy_axis_set_si_unit(graph->axis[GTK_POS_LEFT], siunit);
    gwy_axis_set_si_unit(graph->axis[GTK_POS_RIGHT], siunit);
    g_object_unref(siunit);

    for (i = GTK_POS_LEFT; i <= GTK_POS_BOTTOM; i++) {
        const gchar *label;

        label = gmodel ? gwy_graph_model_get_axis_label(gmodel, i) : NULL;
        gwy_axis_set_label(graph->axis[i], label);
    }

    gwy_graph_refresh_ranges(graph);
}

/**
 * gwy_graph_set_model:
 * @graph: A graph widget.
 * @gmodel: New graph model
 *
 * Changes the model a graph displays.
 *
 * Everything in graph widgets will be reset to reflect the new data.
 **/
void
gwy_graph_set_model(GwyGraph *graph, GwyGraphModel *gmodel)
{
    g_return_if_fail(GWY_IS_GRAPH(graph));
    g_return_if_fail(!gmodel || GWY_IS_GRAPH_MODEL(gmodel));

    if (graph->graph_model == gmodel)
        return;

    GWY_SIGNAL_HANDLER_DISCONNECT(graph->graph_model, graph->model_notify_id);
    GWY_SIGNAL_HANDLER_DISCONNECT(graph->graph_model,
                                  graph->curve_data_changed_id);

    if (gmodel)
        g_object_ref(gmodel);
    GWY_OBJECT_UNREF(graph->graph_model);
    graph->graph_model = gmodel;

    if (gmodel) {
        graph->model_notify_id
            = g_signal_connect_swapped(gmodel, "notify",
                                       G_CALLBACK(gwy_graph_model_notify),
                                       graph);
        graph->curve_data_changed_id
            = g_signal_connect_swapped(gmodel, "curve-data-changed",
                                       G_CALLBACK(gwy_graph_curve_data_changed),
                                       graph);
    }

    gwy_graph_area_set_model(graph->area, gmodel);
    gwy_graph_refresh_all(graph);
    g_object_notify(G_OBJECT(graph), "model");
}

/**
 * gwy_graph_get_model:
 * @graph: A graph widget.
 *
 * Gets the model of a graph.
 *
 * Returns: The graph model this graph widget displays.
 **/
GwyGraphModel*
gwy_graph_get_model(GwyGraph *graph)
{
    g_return_val_if_fail(GWY_IS_GRAPH(graph), NULL);

    return graph->graph_model;
}

static void
gwy_graph_model_notify(GwyGraph *graph,
                       GParamSpec *pspec,
                       GwyGraphModel *gmodel)
{
    /* Axis labels */
    if (g_str_has_prefix(pspec->name, "axis-label-")) {
        const gchar *name = pspec->name + strlen("axis-label-");
        gchar *label = NULL;

        g_object_get(gmodel, pspec->name, &label, NULL);
        if (gwy_strequal(name, "left"))
            gwy_axis_set_label(graph->axis[GTK_POS_LEFT], label);
        else if (gwy_strequal(name, "bottom"))
            gwy_axis_set_label(graph->axis[GTK_POS_BOTTOM], label);
        else if (gwy_strequal(name, "right"))
            gwy_axis_set_label(graph->axis[GTK_POS_RIGHT], label);
        else if (gwy_strequal(name, "top"))
            gwy_axis_set_label(graph->axis[GTK_POS_TOP], label);
        g_free(label);

        return;
    }

    /* Units */
    if (g_str_has_prefix(pspec->name, "si-unit-")) {
        const gchar *name = pspec->name + strlen("si-unit-");
        GwySIUnit *unit = NULL;

        /* Both model and axis assign units by value so this is correct */
        g_object_get(gmodel, pspec->name, &unit, NULL);
        if (gwy_strequal(name, "x")) {
            gwy_axis_set_si_unit(graph->axis[GTK_POS_BOTTOM], unit);
            gwy_axis_set_si_unit(graph->axis[GTK_POS_TOP], unit);
        }
        else if (gwy_strequal(name, "y")) {
            gwy_axis_set_si_unit(graph->axis[GTK_POS_LEFT], unit);
            gwy_axis_set_si_unit(graph->axis[GTK_POS_RIGHT], unit);
        }
        g_object_unref(unit);

        return;
    }

    /* Ranges */
    if (g_str_has_prefix(pspec->name, "x-")
        || g_str_has_prefix(pspec->name, "y-")) {
        gwy_graph_refresh_ranges(graph);
        return;
    }

    /* Number of curves */
    if (gwy_strequal(pspec->name, "n-curves")) {
        gwy_graph_curve_data_changed(graph, -1);
        return;
    }

    gwy_debug("ignoring changed model property <%s>", pspec->name);
}

static void
gwy_graph_curve_data_changed(GwyGraph *graph,
                             G_GNUC_UNUSED gint i)
{
    gwy_graph_refresh_ranges(graph);
}

static void
gwy_graph_refresh_ranges(GwyGraph *graph)
{
    GwyGraphModel *gmodel = graph->graph_model;
    gdouble xmin, xmax, ymin, ymax;
    gboolean xlg, ylg;

    g_object_get(gmodel,
                 "x-logarithmic", &xlg,
                 "y-logarithmic", &ylg,
                 NULL);
    gwy_axis_set_logarithmic(graph->axis[GTK_POS_BOTTOM], xlg);
    gwy_axis_set_logarithmic(graph->axis[GTK_POS_TOP], xlg);
    gwy_axis_set_logarithmic(graph->axis[GTK_POS_LEFT], ylg);
    gwy_axis_set_logarithmic(graph->axis[GTK_POS_RIGHT], ylg);

    /* Request range */
    if (!gwy_graph_model_get_ranges(gmodel, xlg, ylg,
                                    &xmin, &xmax, &ymin, &ymax)) {
        xmin = xlg ? 0.1 : 0.0;
        ymin = ylg ? 0.1 : 0.0;
        xmax = ymax = 1.0;
    }

    gwy_debug("%p: req x:(%g,%g) y:(%g,%g)", graph, xmin, xmax, ymin, ymax);

    gwy_axis_request_range(graph->axis[GTK_POS_BOTTOM], xmin, xmax);
    gwy_axis_request_range(graph->axis[GTK_POS_TOP], xmin, xmax);  /* XXX */
    gwy_axis_request_range(graph->axis[GTK_POS_LEFT], ymin, ymax);
    gwy_axis_request_range(graph->axis[GTK_POS_RIGHT], ymin, ymax);  /* XXX */
    /* The range propagation happens in "rescaled" handler. */
}

static void
gwy_graph_axis_rescaled(GwyAxis *axis, GwyGraph *graph)
{
    GwyGraphGridType grid_type;
    gdouble min, max;

    if (graph->graph_model == NULL)
        return;

    gwy_debug("%p: axis %p", graph, axis);

    gwy_axis_get_range(axis, &min, &max);
    if (axis == graph->axis[GTK_POS_BOTTOM])
        gwy_graph_area_set_x_range(graph->area, min, max);
    if (axis == graph->axis[GTK_POS_LEFT])
        gwy_graph_area_set_y_range(graph->area, min, max);

    g_object_get(graph->graph_model, "grid-type", &grid_type, NULL);
    if (grid_type == GWY_GRAPH_GRID_AUTO) {
        const gdouble *ticks;
        guint nticks;

        ticks = gwy_axis_get_major_ticks(axis, &nticks);
        if (axis == graph->axis[GTK_POS_BOTTOM])
            gwy_graph_area_set_x_grid_data(graph->area, nticks, ticks);
        if (axis == graph->axis[GTK_POS_LEFT])
            gwy_graph_area_set_y_grid_data(graph->area, nticks, ticks);
    }
}

/**
 * gwy_graph_get_axis:
 * @graph: A graph widget.
 * @type: Axis orientation
 *
 * Gets a graph axis.
 *
 * Returns: The axis (of given orientation) within the graph widget.
 **/
GwyAxis*
gwy_graph_get_axis(GwyGraph *graph, GtkPositionType type)
{
    g_return_val_if_fail(GWY_IS_GRAPH(graph), NULL);
    g_return_val_if_fail(type <= GTK_POS_BOTTOM, NULL);

    return graph->axis[type];
}

/**
 * gwy_graph_set_axis_visible:
 * @graph: A graph widget.
 * @type: Axis orientation
 * @is_visible: set/unset axis visibility within graph widget
 *
 * Sets the visibility of graph axis of given orientation. Visibility
 * can be set also directly using GwyAxis API.
 **/
void
gwy_graph_set_axis_visible(GwyGraph *graph,
                           GtkPositionType type,
                           gboolean is_visible)
{
    g_return_if_fail(GWY_IS_GRAPH(graph));
    g_return_if_fail(type <= GTK_POS_BOTTOM);

    gwy_axis_set_visible(graph->axis[type], is_visible);
}

/**
 * gwy_graph_get_area:
 * @graph: A graph widget.
 *
 * Gets the area widget of a graph.
 *
 * Returns: The graph area widget within the graph.
 **/
GtkWidget*
gwy_graph_get_area(GwyGraph *graph)
{
    g_return_val_if_fail(GWY_IS_GRAPH(graph), NULL);

    return GTK_WIDGET(graph->area);
}

/**
 * gwy_graph_set_status:
 * @graph: A graph widget.
 * @status: graph status
 *
 * Sets the status of a graph widget.
 *
 * The status determines how the graph reacts on mouse events.
 * This includes point or area selection and zooming.
 **/
void
gwy_graph_set_status(GwyGraph *graph, GwyGraphStatusType status)
{
    gwy_graph_area_set_status(GWY_GRAPH_AREA(graph->area), status);
}

/**
 * gwy_graph_get_status:
 * @graph: A graph widget.
 *
 * Get the status of a graph widget.
 *
 * See gwy_graph_set_status() for more.
 *
 * Returns: The current graph status.
 **/
GwyGraphStatusType
gwy_graph_get_status(GwyGraph *graph)
{
    return graph->area->status;
}

/**
 * gwy_graph_enable_user_input:
 * @graph: A graph widget.
 * @enable: whether to enable user input
 *
 * Enables/disables all the graph/curve settings dialogs to be invoked by
 * mouse clicks.
 **/
void
gwy_graph_enable_user_input(GwyGraph *graph, gboolean enable)
{
    guint i;

    graph->enable_user_input = enable;
    gwy_graph_area_enable_user_input(graph->area, enable);

    for (i = GTK_POS_LEFT; i <= GTK_POS_BOTTOM; i++)
        gwy_axis_enable_label_edit(graph->axis[i], enable);
}

static void
gwy_graph_zoomed(GwyGraph *graph)
{
    gdouble x_reqmin, x_reqmax, y_reqmin, y_reqmax;
    GwySelection *selection;
    gdouble zoomdata[4];

    selection = graph->zoom_selection;
    if (graph->area->status != GWY_GRAPH_STATUS_ZOOM ||
        gwy_selection_get_data(selection, NULL) != 1)
        return;

    gwy_selection_get_object(selection, 0, zoomdata);
    x_reqmin = MIN(zoomdata[0], zoomdata[0] + zoomdata[2]);
    x_reqmax = MAX(zoomdata[0], zoomdata[0] + zoomdata[2]);
    y_reqmin = MIN(zoomdata[1], zoomdata[1] + zoomdata[3]);
    y_reqmax = MAX(zoomdata[1], zoomdata[1] + zoomdata[3]);
    /* This in turn causes graph refresh including axes rescale */
    g_object_set(graph->graph_model,
                 "x-min", x_reqmin, "x-min-set", TRUE,
                 "x-max", x_reqmax, "x-max-set", TRUE,
                 "y-min", y_reqmin, "y-min-set", TRUE,
                 "y-max", y_reqmax, "y-max-set", TRUE,
                 NULL);

    gwy_graph_set_status(graph, GWY_GRAPH_STATUS_PLAIN);
}

static void
gwy_graph_label_updated(GwyAxis *axis,
                        G_GNUC_UNUSED GParamSpec *pspec,
                        GwyGraph *graph)
{
    if (graph->graph_model)
        gwy_graph_model_set_axis_label(graph->graph_model,
                                       gwy_axis_get_orientation(axis),
                                       gwy_axis_get_label(axis));
}

/************************** Documentation ****************************/

/**
 * SECTION:gwygraph
 * @title: GwyGraph
 * @short_description: Widget for displaying graphs
 *
 * #GwyGraph is a basic widget for displaying graphs.
 * It consists of several widgets that can also be used separately (at least
 * in principle):
 * #GwyGraphArea forms the main part of the graph,
 * #GwyAxis is used for the axes,
 * #GwyGraphLabel represents the key
 * and #GwyGraphCorner is a dummy widget (at this moment) used for graph
 * corners.
 *
 * Persisent graph properties and data are represented with #GwyGraphModel.
 * Changes to the model are automatically reflected in the graph.
 **/

/* vim: set cin et ts=4 sw=4 cino=>1s,e0,n0,f0,{0,}0,^0,\:1s,=0,g1s,h0,t0,+1s,c3,(0,u0 : */