Skip to content

Commit 11b64fc

Browse files
committed
add Group, Real, Vector
1 parent 395b0f0 commit 11b64fc

File tree

13 files changed

+638
-43
lines changed

13 files changed

+638
-43
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- add "Group selected" to column menu
1111
- toolkitgroupview is more compact
1212
- add vips_header_get builtin
13+
- add Real, Group, Vector graphic classes
1314

1415
## 9.0.11 2025/07/21
1516

TODO

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
- get judder with rotate and images smaller than the window
32

43
draw on update, then draw again on relayout

src/group.c

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
/* an input group ... put/get methods
2+
*/
3+
4+
/*
5+
6+
Copyright (C) 1991-2003 The National Gallery
7+
8+
This program is free software; you can redistribute it and/or modify
9+
it under the terms of the GNU General Public License as published by
10+
the Free Software Foundation; either version 2 of the License, or
11+
(at your option) any later version.
12+
13+
This program is distributed in the hope that it will be useful,
14+
but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
GNU General Public License for more details.
17+
18+
You should have received a copy of the GNU General Public License along
19+
with this program; if not, write to the Free Software Foundation, Inc.,
20+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21+
22+
*/
23+
24+
/*
25+
26+
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
27+
28+
*/
29+
30+
/*
31+
#define DEBUG
32+
*/
33+
34+
#include "nip4.h"
35+
36+
G_DEFINE_TYPE(Group, group, VALUE_TYPE)
37+
38+
static gboolean group_save_list(PElement *list, char *filename);
39+
40+
/* Exported, since main.c uses this to save 'main' to a file. @filename is
41+
* incremented.
42+
*/
43+
gboolean
44+
group_save_item(PElement *item, char *filename)
45+
{
46+
gboolean result;
47+
Imageinfo *ii;
48+
char buf[FILENAME_MAX];
49+
50+
/* We don't want $VAR etc. in the filename we pass down to the file
51+
* ops.
52+
*/
53+
g_strlcpy(buf, filename, FILENAME_MAX);
54+
path_expand(buf);
55+
56+
if (!heap_is_instanceof(CLASS_GROUP, item, &result))
57+
return FALSE;
58+
if (result) {
59+
PElement value;
60+
61+
if (!class_get_member(item, MEMBER_VALUE, NULL, &value) ||
62+
!group_save_list(&value, filename))
63+
return FALSE;
64+
}
65+
66+
if (!heap_is_instanceof(CLASS_IMAGE, item, &result))
67+
return FALSE;
68+
if (result) {
69+
PElement value;
70+
71+
if (!class_get_member(item, MEMBER_VALUE, NULL, &value) ||
72+
!heap_get_image(&value, &ii))
73+
return FALSE;
74+
if (vips_image_write_to_file(ii->image, buf, NULL)) {
75+
error_vips_all();
76+
return FALSE;
77+
}
78+
79+
increment_filename(filename);
80+
}
81+
82+
if (PEISIMAGE(item)) {
83+
if (!heap_get_image(item, &ii))
84+
return FALSE;
85+
if (vips_image_write_to_file(ii->image, buf, NULL)) {
86+
error_vips_all();
87+
return FALSE;
88+
}
89+
90+
increment_filename(filename);
91+
}
92+
93+
if (PEISLIST(item)) {
94+
if (!group_save_list(item, filename))
95+
return FALSE;
96+
}
97+
98+
return TRUE;
99+
}
100+
101+
static gboolean
102+
group_save_list(PElement *list, char *filename)
103+
{
104+
int i;
105+
int length;
106+
107+
if ((length = heap_list_length(list)) < 0)
108+
return FALSE;
109+
110+
for(i = 0; i < length; i++) {
111+
PElement item;
112+
113+
if (!heap_list_index(list, i, &item) ||
114+
!group_save_item(&item, filename))
115+
return FALSE;
116+
}
117+
118+
return TRUE;
119+
}
120+
121+
static gboolean
122+
group_graphic_save(Classmodel *classmodel,
123+
GtkWindow *parent, const char *filename)
124+
{
125+
Group *group = GROUP(classmodel);
126+
Row *row = HEAPMODEL(group)->row;
127+
PElement *root = &row->expr->root;
128+
char buf[FILENAME_MAX];
129+
130+
/* We are going to increment the filename ... make sure there's some
131+
* space at the end of the string.
132+
*/
133+
g_strlcpy(buf, filename, FILENAME_MAX - 5);
134+
135+
if (!group_save_item(root, buf))
136+
return FALSE;
137+
138+
return TRUE;
139+
}
140+
141+
static void
142+
group_class_init(GroupClass *class)
143+
{
144+
ClassmodelClass *classmodel_class = (ClassmodelClass *) class;
145+
146+
/* Create signals.
147+
*/
148+
149+
classmodel_class->graphic_save = group_graphic_save;
150+
151+
model_register_loadable(MODEL_CLASS(class));
152+
}
153+
154+
static void
155+
group_init(Group *group)
156+
{
157+
iobject_set(IOBJECT(group), CLASS_GROUP, NULL);
158+
}
159+

src/group.h

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/* a group in a workspace
2+
*/
3+
4+
/*
5+
6+
Copyright (C) 1991-2003 The National Gallery
7+
8+
This program is free software; you can redistribute it and/or modify
9+
it under the terms of the GNU General Public License as published by
10+
the Free Software Foundation; either version 2 of the License, or
11+
(at your option) any later version.
12+
13+
This program is distributed in the hope that it will be useful,
14+
but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
GNU General Public License for more details.
17+
18+
You should have received a copy of the GNU General Public License along
19+
with this program; if not, write to the Free Software Foundation, Inc.,
20+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21+
22+
*/
23+
24+
/*
25+
26+
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
27+
28+
*/
29+
30+
#define GROUP_TYPE (group_get_type())
31+
#define GROUP(obj) \
32+
(G_TYPE_CHECK_INSTANCE_CAST((obj), GROUP_TYPE, Group))
33+
#define GROUP_CLASS(klass) \
34+
(G_TYPE_CHECK_CLASS_CAST((klass), GROUP_TYPE, GroupClass))
35+
#define IS_GROUP(obj) \
36+
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GROUP_TYPE))
37+
#define IS_GROUP_CLASS(klass) \
38+
(G_TYPE_CHECK_CLASS_TYPE((klass), GROUP_TYPE))
39+
#define GROUP_GET_CLASS(obj) \
40+
(G_TYPE_INSTANCE_GET_CLASS((obj), GROUP_TYPE, GroupClass))
41+
42+
typedef struct _Group {
43+
Value parent_object;
44+
45+
} Group;
46+
47+
typedef struct _GroupClass {
48+
ValueClass parent_class;
49+
50+
/* My methods.
51+
*/
52+
} GroupClass;
53+
54+
GType group_get_type(void);
55+
gboolean group_save_item(PElement *item, char *filename);

src/meson.build

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -31,42 +31,63 @@ sources = files(
3131
'builtin.c',
3232
'class.c',
3333
'classmodel.c',
34+
'colour.c',
35+
'colourview.c',
3436
'column.c',
3537
'columnview.c',
3638
'compile.c',
3739
'displaybar.c',
3840
'dump.c',
39-
'expr.c',
4041
'editview.c',
42+
'expr.c',
43+
'expression.c',
44+
'expressionview.c',
4145
'filemodel.c',
46+
'fontname.c',
47+
'fontnameview.c',
4248
'formula.c',
4349
'fuzzy.c',
4450
'graphicview.c',
51+
'group.c',
4552
'gtkutil.c',
4653
'heap.c',
4754
'heapmodel.c',
55+
'iarrow.c',
4856
'icontainer.c',
57+
'ientry.c',
4958
'iimage.c',
50-
'colour.c',
51-
'colourview.c',
5259
'iimageview.c',
53-
'iarrow.c',
54-
'iregion.c',
55-
'iregiongroup.c',
56-
'iregiongroupview.c',
57-
'iregionview.c',
5860
'imagedisplay.c',
59-
'regionview.c',
60-
'valueview.c',
6161
'imageinfo.c',
6262
'imageui.c',
6363
'imagewindow.c',
6464
'infobar.c',
6565
'iobject.c',
66+
'iregion.c',
67+
'iregiongroup.c',
68+
'iregiongroupview.c',
69+
'iregionview.c',
6670
'itext.c',
6771
'itextview.c',
6872
'itextview.c',
69-
'ientry.c',
73+
'kplot/array.c',
74+
'kplot/border.c',
75+
'kplot/bucket.c',
76+
'kplot/buffer.c',
77+
'kplot/colours.c',
78+
'kplot/draw.c',
79+
'kplot/grid.c',
80+
'kplot/hist.c',
81+
'kplot/kdata.c',
82+
'kplot/kplot.c',
83+
'kplot/label.c',
84+
'kplot/margin.c',
85+
'kplot/mean.c',
86+
'kplot/plotctx.c',
87+
'kplot/reallocarray.c',
88+
'kplot/stddev.c',
89+
'kplot/tic.c',
90+
'kplot/vector.c',
7091
'link.c',
7192
'log.c',
7293
'main.c',
@@ -81,18 +102,10 @@ sources = files(
81102
'number.c',
82103
'numberview.c',
83104
'option.c',
84-
'expression.c',
85-
'expressionview.c',
86105
'optionview.c',
106+
'path.c',
87107
'pathname.c',
88108
'pathnameview.c',
89-
'fontname.c',
90-
'fontnameview.c',
91-
'slider.c',
92-
'sliderview.c',
93-
'toggle.c',
94-
'toggleview.c',
95-
'path.c',
96109
'plot.c',
97110
'plotdisplay.c',
98111
'plotview.c',
@@ -104,14 +117,18 @@ sources = files(
104117
'program.c',
105118
'progress.c',
106119
'properties.c',
120+
'real.c',
121+
'recover.c',
107122
'reduce.c',
123+
'regionview.c',
108124
'rhs.c',
109125
'rhsview.c',
110126
'row.c',
111127
'rowview.c',
112128
'saveoptions.c',
113-
'recover.c',
114129
'secret.c',
130+
'slider.c',
131+
'sliderview.c',
115132
'spin.c',
116133
'string.c',
117134
'stringview.c',
@@ -121,6 +138,8 @@ sources = files(
121138
'tile.c',
122139
'tilecache.c',
123140
'tilesource.c',
141+
'toggle.c',
142+
'toggleview.c',
124143
'tool.c',
125144
'toolkit.c',
126145
'toolkitgroup.c',
@@ -131,6 +150,9 @@ sources = files(
131150
'tree.c',
132151
'tslider.c',
133152
'util.c',
153+
'value.c',
154+
'valueview.c',
155+
'vector.c',
134156
'view.c',
135157
'vipsobject.c',
136158
'vobject.c',
@@ -141,24 +163,6 @@ sources = files(
141163
'workspaceroot.c',
142164
'workspaceview.c',
143165
'workspaceviewlabel.c',
144-
'kplot/array.c',
145-
'kplot/border.c',
146-
'kplot/bucket.c',
147-
'kplot/buffer.c',
148-
'kplot/colours.c',
149-
'kplot/draw.c',
150-
'kplot/grid.c',
151-
'kplot/hist.c',
152-
'kplot/kdata.c',
153-
'kplot/kplot.c',
154-
'kplot/label.c',
155-
'kplot/margin.c',
156-
'kplot/mean.c',
157-
'kplot/plotctx.c',
158-
'kplot/reallocarray.c',
159-
'kplot/stddev.c',
160-
'kplot/tic.c',
161-
'kplot/vector.c',
162166
)
163167

164168
parse_c = custom_target('parse.c',

src/nip4.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,10 @@ typedef struct _Workspace Workspace;
273273
#include "plot.h"
274274
#include "toggle.h"
275275
#include "iimage.h"
276+
#include "value.h"
277+
#include "real.h"
278+
#include "group.h"
279+
#include "vector.h"
276280
#include "colour.h"
277281
#include "iregiongroup.h"
278282
#include "iregion.h"

0 commit comments

Comments
 (0)