#include <simgear/scene/util/parse_color.hxx>
#include <osg/Drawable>
-#include <osg/BlendFunc>
#include <vg/openvg.h>
#include <cassert>
*/
void setFill(const std::string& fill)
{
- if( fill == "none" )
+ if( fill.empty() || fill == "none" )
{
_mode &= ~VG_FILL_PATH;
}
*/
void setStroke(const std::string& stroke)
{
- if( stroke == "none" )
+ if( stroke.empty() || stroke == "none" )
{
_mode &= ~VG_STROKE_PATH;
}
{
osg::BoundingBox bb;
- osg::Vec2f cur; // VG "Current point" (in local coordinates)
+ osg::Vec2f cur(0, 0), // VG "Current point" (in local coordinates)
+ sub(0, 0); // beginning of current sub path
VGubyte cmd_index = 0;
for( size_t i = 0, ci = 0;
i < _cmds.size() && ci < _coords.size();
switch( cmd )
{
case VG_CLOSE_PATH:
+ cur = sub;
break;
case VG_MOVE_TO:
case VG_LINE_TO:
}
if( num_coords > 0 )
+ {
cur = points[ num_coords - 1 ];
+
+ if( cmd == VG_MOVE_TO )
+ sub = cur;
+ }
}
return bb;
};
};
+ //----------------------------------------------------------------------------
+ const std::string Path::TYPE_NAME = "path";
+
+ //----------------------------------------------------------------------------
+ void Path::staticInit()
+ {
+ if( isInit<Path>() )
+ return;
+
+ PathDrawableRef Path::*path = &Path::_path;
+
+ addStyle("fill", "color", &PathDrawable::setFill, path);
+ addStyle("fill-rule", "", &PathDrawable::setFillRule, path);
+ addStyle("stroke", "color", &PathDrawable::setStroke, path);
+ addStyle("stroke-width", "numeric", &PathDrawable::setStrokeWidth, path);
+ addStyle("stroke-dasharray", "", &PathDrawable::setStrokeDashArray, path);
+ addStyle("stroke-linecap", "", &PathDrawable::setStrokeLinecap, path);
+ }
+
//----------------------------------------------------------------------------
Path::Path( const CanvasWeakPtr& canvas,
const SGPropertyNode_ptr& node,
Element(canvas, node, parent_style, parent),
_path( new PathDrawable(this) )
{
- setDrawable(_path);
-
- if( !isInit<Path>() )
- {
- PathDrawableRef Path::*path = &Path::_path;
-
- addStyle("fill", "color", &PathDrawable::setFill, path);
- addStyle("fill-rule", "", &PathDrawable::setFillRule, path);
- addStyle("stroke", "color", &PathDrawable::setStroke, path);
- addStyle("stroke-width", "numeric", &PathDrawable::setStrokeWidth, path);
- addStyle("stroke-dasharray", "", &PathDrawable::setStrokeDashArray, path);
- addStyle("stroke-linecap", "", &PathDrawable::setStrokeLinecap, path);
- }
+ staticInit();
+ setDrawable(_path);
setupStyle();
}