1 /*
2     Gri - A language for scientific graphics programming
3     Copyright (C) 2008 Daniel Kelley
4 
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; version 3 of the License, or
8     (at your option) any later version.
9 
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14 
15     You should have received a copy of the GNU General Public License along
16     with this program; if not, write to the Free Software Foundation, Inc.,
17     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 
20 #include	"extern.hh"
21 extern FILE *_grSVG;
22 static std::vector<std::string> group_name;
23 
24 bool
groupCmd()25 groupCmd()
26 {
27 	printf("DEBUG: in 'group'\n");
28 	return group_start();
29 }
30 bool
end_groupCmd()31 end_groupCmd()
32 {
33 	printf("DEBUG: in 'end group'\n");
34 	return group_end();
35 }
36 bool
group_start(const char * id)37 group_start(const char *id)
38 {
39 	if (_output_file_type == svg) {
40 		std::string name = id;
41 		if (strlen(id) > 0)
42 			fprintf(_grSVG, "<g> <!-- %s -->\n", id);
43 		else
44 			fprintf(_grSVG, "<g> <!-- anonymous group -->\n");
45 		group_name.push_back(name);
46 	}
47 	return true;
48 }
49 bool
group_end()50 group_end()
51 {
52 	if (_output_file_type == svg) {
53 		if (group_name.size() > 0) {
54 			fprintf(_grSVG, "</g> <!-- end of %s -->\n", group_name.back().c_str());
55 			group_name.pop_back();
56 		} else {
57 			fprintf(_grSVG, "</g> <!-- end of anonymous group -->\n");
58 		}
59 	}
60 	return true;
61 }
62