Skip to content

Commit

Permalink
Output SVG groups that work as layers in Inkscape
Browse files Browse the repository at this point in the history
  • Loading branch information
Willem3141 committed Oct 4, 2024
1 parent 2be8220 commit 55f6ce6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion cartocrow/renderer/svg_renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ void SvgRenderer::save(const std::filesystem::path& file) {
m_out << "<defs><circle id=\"vertex\" cx=\"0\" cy=\"0\" r=\"4\"/></defs>\n";

for (auto painting : m_paintings) {
m_out << "<g>\n";
m_out << "<g inkscape:groupmode=\"layer\"";
if (painting.name) {
m_out << " inkscape:label=\"" << *painting.name << "\"";
}
m_out << ">\n";
pushStyle();
painting.m_painting->paint(*this);
popStyle();
Expand Down
6 changes: 5 additions & 1 deletion cartocrow/renderer/svg_renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ class SvgRenderer : public GeometryRenderer {
struct DrawnPainting {
/// The painting itself.
std::shared_ptr<GeometryPainting> m_painting;
/// The name of the painting displayed as a layer name in ipe.
/// The name of the painting displayed as a layer name in Inkscape.
///
/// The SVG standard does not have a concept of layers, however Inkscape
/// does support them by means of groups with the custom inkscape:label
/// attribute.
std::optional<std::string> name;
};

Expand Down

0 comments on commit 55f6ce6

Please sign in to comment.