KJB
|
class used to render a PixPath as an SVG polygonal path picture More...
#include <svgwrap.h>
Public Member Functions | |
SvgWrap (const PixPath &pp=PixPath::reserve()) | |
ctor take a path and sets fields to sensible default values More... | |
SvgWrap & | set_segs (bool seg=true) |
can opt in/out of showing line segments between points of path More... | |
SvgWrap & | set_xml (bool xml=true) |
can opt in/out of emitting XML tag at start of output More... | |
SvgWrap & | set_svg (bool svg=true) |
can opt in/out of emitting opening SVG tag at start of output More... | |
SvgWrap & | set_svg (bool svg_open, bool svg_close) |
can opt in/out of emitting SVG open, close tags (you pick which) More... | |
SvgWrap & | set_text (bool txt=true) |
can opt in/out of showing point sequence index More... | |
SvgWrap & | set_color (const std::string &color) |
set the color of the path and text More... | |
SvgWrap & | set_color (const kjb_c::Pixel &color) |
see overload of same name, but this takes a struct kjb_c::Pixel. More... | |
SvgWrap & | set_fill (bool fill=false) |
can opt in/out of making this a filled polygon More... | |
SvgWrap & | set_fill_color (const std::string &color) |
set the color used for filling the polygon interior (if any). More... | |
SvgWrap & | set_fill_color (const kjb_c::Pixel &color) |
see overload of same name, but this takes a struct kjb_c::Pixel. More... | |
SvgWrap & | set_id (const std::string &) |
try to set the id string for the path More... | |
const std::string & | get_id () const |
retrieve the identifier for this rendering More... | |
SvgWrap & | set_path_extra (const std::string &) |
set an extra attribute to add to each path node in SVG More... | |
const std::string & | get_path_extra () const |
retrieve the optional extra-path-attribute string. More... | |
std::string | operator() () const |
render the path in a rectangular box using SVG 1.1 More... | |
Static Public Member Functions | |
static std::string | xml_header () |
string for top of a standalone XML file More... | |
Public Attributes | |
bool | m_show_segments |
show line segments between points? More... | |
bool | m_show_text |
show numbered sequence of points? More... | |
bool | m_gen_xml_header |
print the special XML header tag? More... | |
bool | m_open_svg |
print an opening SVG tag? More... | |
bool | m_close_svg |
print the close tag of the SVG node? More... | |
bool | m_fill_path |
should the path be filled? More... | |
unsigned | m_width |
width in world units of the SVG image More... | |
unsigned | m_height |
height in world units of SVG image More... | |
unsigned | m_magnify |
magnification from world to image More... | |
std::string | m_color |
color, as text string, of objects More... | |
std::string | m_fill_color |
color of fill, can override default More... | |
bool | m_totally_omit_stroke_attribute |
no mention of stroke at all More... | |
bool | m_totally_omit_fill_attribute |
no mention of fill at all More... | |
class used to render a PixPath as an SVG polygonal path picture
The many "set_xxx" functions all return a reference to *this, so that they can be chained.
Expert users might want to avoid the automated logic that controls how the stroke and fill attributes are computed, perhaps because the path will be placed within a group tag. The "m_totally_omit_*" booleans will turn off those attributes, irrespective of any other flags. Under some circumstances that is the only way to get the desired output; however, because they are specialty settings and they trump other state settings, we don't provide set functions for them and the user has to write out their deliberately long and clumsy names, to make clear that they are for experts only.
|
inline |
ctor take a path and sets fields to sensible default values
|
inline |
retrieve the identifier for this rendering
|
inline |
retrieve the optional extra-path-attribute string.
std::string kjb::qd::SvgWrap::operator() | ( | ) | const |
render the path in a rectangular box using SVG 1.1
|
inline |
set the color of the path and text
color | is a string specifying output color. See http://www.w3.org/Graphics/SVG/IG/resources/svgprimer.html#colors for a presentation of valid color. In brief, you can use standard named colors like "red," hex values like "#cbacca," or other things. |
We call this the "default color" because it controls the color of lines, text, and polygon fill unless the user provides an overriding value for polygon fill color.
|
inline |
see overload of same name, but this takes a struct kjb_c::Pixel.
|
inline |
can opt in/out of making this a filled polygon
|
inline |
set the color used for filling the polygon interior (if any).
The ctor-time default value is the empty string, which has the semantics of "use the default color."
The value here controls the color used to fill the interior points of the polygon defined by the path vertices. It does not affect stroke color or text color, both of which are set by the default color. If you want the polygons filled, you must turn on the fill flag; if you also want the interior color different from the outline, you must also set the fill color to the name/description of your desired color.
Technical points:
|
inline |
see overload of same name, but this takes a struct kjb_c::Pixel.
SvgWrap & kjb::qd::SvgWrap::set_id | ( | const std::string & | id | ) |
try to set the id string for the path
kjb::Illegal_argument | if the ID string contains a bad character. |
Disallowed characters include nonprintable characters and the characters in the string "<&>" – no support (yet) for escape sequences like "&" Also the double-quote character and backslash are disallowed.
SvgWrap & kjb::qd::SvgWrap::set_path_extra | ( | const std::string & | e | ) |
set an extra attribute to add to each path node in SVG
kjb::Illegal_argument | if the string contains a bad character. |
The purpose is to set one or more attributes to be applied to each path node to support the many SVG features that we don't want to explicitly add to the API. Use as many attributes as you like, just obey XML syntax. Some sample attributes that you might want to use are below.
The attribute must not, accidentally or on purpose, close a tag or break XML syntax, so we do not allow the characters '<' '>' '\' or '&' which all require special treatment. The above restriction is neither totally necessary nor sufficient to preserve the XML rules, so, apologies for the crudeness but be careful anyway. You can mess up your XML easily with this method!
|
inline |
can opt in/out of showing line segments between points of path
|
inline |
can opt in/out of emitting opening SVG tag at start of output
|
inline |
can opt in/out of emitting SVG open, close tags (you pick which)
|
inline |
can opt in/out of showing point sequence index
|
inline |
can opt in/out of emitting XML tag at start of output
|
inlinestatic |
string for top of a standalone XML file
bool kjb::qd::SvgWrap::m_close_svg |
print the close tag of the SVG node?
std::string kjb::qd::SvgWrap::m_color |
color, as text string, of objects
std::string kjb::qd::SvgWrap::m_fill_color |
color of fill, can override default
bool kjb::qd::SvgWrap::m_fill_path |
should the path be filled?
bool kjb::qd::SvgWrap::m_gen_xml_header |
print the special XML header tag?
unsigned kjb::qd::SvgWrap::m_height |
height in world units of SVG image
unsigned kjb::qd::SvgWrap::m_magnify |
magnification from world to image
bool kjb::qd::SvgWrap::m_open_svg |
print an opening SVG tag?
bool kjb::qd::SvgWrap::m_show_segments |
show line segments between points?
bool kjb::qd::SvgWrap::m_show_text |
show numbered sequence of points?
bool kjb::qd::SvgWrap::m_totally_omit_fill_attribute |
no mention of fill at all
bool kjb::qd::SvgWrap::m_totally_omit_stroke_attribute |
no mention of stroke at all
unsigned kjb::qd::SvgWrap::m_width |
width in world units of the SVG image