canvas: Refactor with C++11
This commit is contained in:
@@ -22,8 +22,10 @@
|
|||||||
#include "CanvasEventManager.hxx"
|
#include "CanvasEventManager.hxx"
|
||||||
#include "CanvasEventVisitor.hxx"
|
#include "CanvasEventVisitor.hxx"
|
||||||
#include "CanvasPlacement.hxx"
|
#include "CanvasPlacement.hxx"
|
||||||
|
|
||||||
#include <simgear/canvas/events/KeyboardEvent.hxx>
|
#include <simgear/canvas/events/KeyboardEvent.hxx>
|
||||||
#include <simgear/canvas/events/MouseEvent.hxx>
|
#include <simgear/canvas/events/MouseEvent.hxx>
|
||||||
|
#include <simgear/misc/strutils.hxx>
|
||||||
#include <simgear/scene/util/parse_color.hxx>
|
#include <simgear/scene/util/parse_color.hxx>
|
||||||
#include <simgear/scene/util/RenderConstants.hxx>
|
#include <simgear/scene/util/RenderConstants.hxx>
|
||||||
|
|
||||||
@@ -32,9 +34,6 @@
|
|||||||
#include <osgText/Text>
|
#include <osgText/Text>
|
||||||
#include <osgViewer/Viewer>
|
#include <osgViewer/Viewer>
|
||||||
|
|
||||||
#include <boost/algorithm/string/predicate.hpp>
|
|
||||||
#include <boost/foreach.hpp>
|
|
||||||
|
|
||||||
namespace simgear
|
namespace simgear
|
||||||
{
|
{
|
||||||
namespace canvas
|
namespace canvas
|
||||||
@@ -64,18 +63,9 @@ namespace canvas
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
Canvas::Canvas(SGPropertyNode* node):
|
Canvas::Canvas(SGPropertyNode* node):
|
||||||
PropertyBasedElement(node),
|
PropertyBasedElement(node),
|
||||||
_canvas_mgr(0),
|
|
||||||
_event_manager(new EventManager),
|
_event_manager(new EventManager),
|
||||||
_size_x(-1),
|
|
||||||
_size_y(-1),
|
|
||||||
_view_width(-1),
|
|
||||||
_view_height(-1),
|
|
||||||
_status(node, "status"),
|
_status(node, "status"),
|
||||||
_status_msg(node, "status-msg"),
|
_status_msg(node, "status-msg")
|
||||||
_sampling_dirty(false),
|
|
||||||
_render_dirty(true),
|
|
||||||
_visible(true),
|
|
||||||
_render_always(false)
|
|
||||||
{
|
{
|
||||||
_status = 0;
|
_status = 0;
|
||||||
setStatusFlags(MISSING_SIZE_X | MISSING_SIZE_Y);
|
setStatusFlags(MISSING_SIZE_X | MISSING_SIZE_Y);
|
||||||
@@ -281,7 +271,7 @@ namespace canvas
|
|||||||
|
|
||||||
if( _visible || _render_always )
|
if( _visible || _render_always )
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(CanvasWeakPtr canvas_weak, _child_canvases)
|
for(auto& canvas_weak: _child_canvases)
|
||||||
{
|
{
|
||||||
// TODO should we check if the image the child canvas is displayed
|
// TODO should we check if the image the child canvas is displayed
|
||||||
// within is really visible?
|
// within is really visible?
|
||||||
@@ -293,7 +283,7 @@ namespace canvas
|
|||||||
if( _render_dirty )
|
if( _render_dirty )
|
||||||
{
|
{
|
||||||
// Also mark all canvases this canvas is displayed within as dirty
|
// Also mark all canvases this canvas is displayed within as dirty
|
||||||
BOOST_FOREACH(CanvasWeakPtr canvas_weak, _parent_canvases)
|
for(auto& canvas_weak: _parent_canvases)
|
||||||
{
|
{
|
||||||
CanvasPtr canvas = canvas_weak.lock();
|
CanvasPtr canvas = canvas_weak.lock();
|
||||||
if( canvas )
|
if( canvas )
|
||||||
@@ -522,8 +512,8 @@ namespace canvas
|
|||||||
{
|
{
|
||||||
const std::string& name = node->getNameString();
|
const std::string& name = node->getNameString();
|
||||||
|
|
||||||
if( boost::starts_with(name, "status")
|
if( strutils::starts_with(name, "status")
|
||||||
|| boost::starts_with(name, "data-") )
|
|| strutils::starts_with(name, "data-") )
|
||||||
return;
|
return;
|
||||||
_render_dirty = true;
|
_render_dirty = true;
|
||||||
|
|
||||||
@@ -538,7 +528,7 @@ namespace canvas
|
|||||||
if( !placements.empty() )
|
if( !placements.empty() )
|
||||||
{
|
{
|
||||||
bool placement_dirty = false;
|
bool placement_dirty = false;
|
||||||
BOOST_FOREACH(PlacementPtr& placement, placements)
|
for(auto& placement: placements)
|
||||||
{
|
{
|
||||||
// check if change can be directly handled by placement
|
// check if change can be directly handled by placement
|
||||||
if( placement->getProps() == node->getParent()
|
if( placement->getProps() == node->getParent()
|
||||||
|
|||||||
+13
-11
@@ -33,7 +33,7 @@
|
|||||||
#include <osg/NodeCallback>
|
#include <osg/NodeCallback>
|
||||||
#include <osg/observer_ptr>
|
#include <osg/observer_ptr>
|
||||||
|
|
||||||
#include <boost/scoped_ptr.hpp>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace simgear
|
namespace simgear
|
||||||
@@ -211,21 +211,21 @@ namespace canvas
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
CanvasMgr *_canvas_mgr;
|
CanvasMgr *_canvas_mgr {nullptr};
|
||||||
|
|
||||||
boost::scoped_ptr<EventManager> _event_manager;
|
std::unique_ptr<EventManager> _event_manager;
|
||||||
|
|
||||||
int _size_x,
|
int _size_x {-1},
|
||||||
_size_y,
|
_size_y {-1},
|
||||||
_view_width,
|
_view_width {-1},
|
||||||
_view_height;
|
_view_height {-1};
|
||||||
|
|
||||||
PropertyObject<int> _status;
|
PropertyObject<int> _status;
|
||||||
PropertyObject<std::string> _status_msg;
|
PropertyObject<std::string> _status_msg;
|
||||||
|
|
||||||
bool _sampling_dirty,
|
bool _sampling_dirty {false},
|
||||||
_render_dirty,
|
_render_dirty {true},
|
||||||
_visible;
|
_visible {true};
|
||||||
|
|
||||||
ODGauge _texture;
|
ODGauge _texture;
|
||||||
|
|
||||||
@@ -235,7 +235,9 @@ namespace canvas
|
|||||||
ElementWeakPtr _focus_element;
|
ElementWeakPtr _focus_element;
|
||||||
|
|
||||||
CullCallbackPtr _cull_callback;
|
CullCallbackPtr _cull_callback;
|
||||||
bool _render_always; //!< Used to disable automatic lazy rendering (culling)
|
|
||||||
|
/** Used to disable automatic lazy rendering (culling) */
|
||||||
|
bool _render_always {false};
|
||||||
|
|
||||||
std::vector<SGPropertyNode*> _dirty_placements;
|
std::vector<SGPropertyNode*> _dirty_placements;
|
||||||
std::vector<Placements> _placements;
|
std::vector<Placements> _placements;
|
||||||
|
|||||||
@@ -22,13 +22,11 @@
|
|||||||
#include "CanvasWindow.hxx"
|
#include "CanvasWindow.hxx"
|
||||||
|
|
||||||
#include <simgear/canvas/Canvas.hxx>
|
#include <simgear/canvas/Canvas.hxx>
|
||||||
|
#include <simgear/misc/strutils.hxx>
|
||||||
#include <simgear/scene/util/OsgMath.hxx>
|
#include <simgear/scene/util/OsgMath.hxx>
|
||||||
|
|
||||||
#include <osgGA/GUIEventHandler>
|
#include <osgGA/GUIEventHandler>
|
||||||
|
|
||||||
#include <boost/algorithm/string/predicate.hpp>
|
|
||||||
#include <boost/foreach.hpp>
|
|
||||||
|
|
||||||
namespace simgear
|
namespace simgear
|
||||||
{
|
{
|
||||||
namespace canvas
|
namespace canvas
|
||||||
@@ -43,9 +41,6 @@ namespace canvas
|
|||||||
const Style& parent_style,
|
const Style& parent_style,
|
||||||
Element* parent ):
|
Element* parent ):
|
||||||
Image(canvas, node, parent_style, parent),
|
Image(canvas, node, parent_style, parent),
|
||||||
_attributes_dirty(0),
|
|
||||||
_resizable(false),
|
|
||||||
_capture_events(true),
|
|
||||||
_resize_top(node, "resize-top"),
|
_resize_top(node, "resize-top"),
|
||||||
_resize_right(node, "resize-right"),
|
_resize_right(node, "resize-right"),
|
||||||
_resize_bottom(node, "resize-bottom"),
|
_resize_bottom(node, "resize-bottom"),
|
||||||
@@ -92,7 +87,7 @@ namespace canvas
|
|||||||
_capture_events = node->getBoolValue();
|
_capture_events = node->getBoolValue();
|
||||||
else if( name == "decoration-border" )
|
else if( name == "decoration-border" )
|
||||||
parseDecorationBorder(node->getStringValue());
|
parseDecorationBorder(node->getStringValue());
|
||||||
else if( boost::starts_with(name, "shadow-")
|
else if( strutils::starts_with(name, "shadow-")
|
||||||
|| name == "content-size" )
|
|| name == "content-size" )
|
||||||
_attributes_dirty |= DECORATION;
|
_attributes_dirty |= DECORATION;
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ namespace canvas
|
|||||||
DECORATION = 1
|
DECORATION = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32_t _attributes_dirty;
|
uint32_t _attributes_dirty {0};
|
||||||
|
|
||||||
CanvasPtr _canvas_decoration;
|
CanvasPtr _canvas_decoration;
|
||||||
CanvasWeakPtr _canvas_content;
|
CanvasWeakPtr _canvas_content;
|
||||||
@@ -113,8 +113,8 @@ namespace canvas
|
|||||||
ImagePtr _image_content,
|
ImagePtr _image_content,
|
||||||
_image_shadow;
|
_image_shadow;
|
||||||
|
|
||||||
bool _resizable,
|
bool _resizable {false},
|
||||||
_capture_events;
|
_capture_events {true};
|
||||||
|
|
||||||
PropertyObject<int> _resize_top,
|
PropertyObject<int> _resize_top,
|
||||||
_resize_right,
|
_resize_right,
|
||||||
|
|||||||
@@ -31,10 +31,6 @@
|
|||||||
#include <osg/StateAttribute>
|
#include <osg/StateAttribute>
|
||||||
#include <osg/Version>
|
#include <osg/Version>
|
||||||
|
|
||||||
#include <boost/algorithm/string/predicate.hpp>
|
|
||||||
#include <boost/foreach.hpp>
|
|
||||||
#include <boost/make_shared.hpp>
|
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@@ -219,7 +215,7 @@ namespace canvas
|
|||||||
|
|
||||||
// The transform node keeps a reference on this element, so ensure it is
|
// The transform node keeps a reference on this element, so ensure it is
|
||||||
// deleted.
|
// deleted.
|
||||||
BOOST_FOREACH(osg::Group* parent, _transform->getParents())
|
for(osg::Group* parent: group->getParents())
|
||||||
{
|
{
|
||||||
parent->removeChild(_transform.get());
|
parent->removeChild(_transform.get());
|
||||||
}
|
}
|
||||||
@@ -228,8 +224,8 @@ namespace canvas
|
|||||||
setVisible(false);
|
setVisible(false);
|
||||||
removeListener();
|
removeListener();
|
||||||
|
|
||||||
_parent = 0;
|
_parent = nullptr;
|
||||||
_transform = 0;
|
_transform = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@@ -341,7 +337,8 @@ namespace canvas
|
|||||||
if( listeners == _listener.end() )
|
if( listeners == _listener.end() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
BOOST_FOREACH(EventListener const& listener, listeners->second)
|
for(auto const& listener: listeners->second)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
listener(event);
|
listener(event);
|
||||||
@@ -354,6 +351,7 @@ namespace canvas
|
|||||||
"canvas::Element: event handler error: '" << ex.what() << "'"
|
"canvas::Element: event handler error: '" << ex.what() << "'"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -526,7 +524,7 @@ namespace canvas
|
|||||||
if( parent == _node )
|
if( parent == _node )
|
||||||
{
|
{
|
||||||
const std::string& name = child->getNameString();
|
const std::string& name = child->getNameString();
|
||||||
if( boost::starts_with(name, "data-") )
|
if( strutils::starts_with(name, "data-") )
|
||||||
return;
|
return;
|
||||||
else if( StyleInfo const* style_info = getStyleInfo(name) )
|
else if( StyleInfo const* style_info = getStyleInfo(name) )
|
||||||
{
|
{
|
||||||
@@ -541,7 +539,7 @@ namespace canvas
|
|||||||
}
|
}
|
||||||
else if( name == "update" )
|
else if( name == "update" )
|
||||||
return update(0);
|
return update(0);
|
||||||
else if( boost::starts_with(name, "blend-") )
|
else if( strutils::starts_with(name, "blend-") )
|
||||||
return (void)(_attributes_dirty |= BLEND_FUNC);
|
return (void)(_attributes_dirty |= BLEND_FUNC);
|
||||||
}
|
}
|
||||||
else if( parent
|
else if( parent
|
||||||
@@ -578,8 +576,8 @@ namespace canvas
|
|||||||
|
|
||||||
// TODO generalize CSS property parsing
|
// TODO generalize CSS property parsing
|
||||||
const std::string RECT("rect(");
|
const std::string RECT("rect(");
|
||||||
if( !boost::ends_with(clip, ")")
|
if( !strutils::ends_with(clip, ")")
|
||||||
|| !boost::starts_with(clip, RECT) )
|
|| !strutils::starts_with(clip, RECT) )
|
||||||
{
|
{
|
||||||
SG_LOG(SG_GENERAL, SG_WARN, "Canvas: invalid clip: " << clip);
|
SG_LOG(SG_GENERAL, SG_WARN, "Canvas: invalid clip: " << clip);
|
||||||
return;
|
return;
|
||||||
@@ -791,11 +789,8 @@ namespace canvas
|
|||||||
PropertyBasedElement(node),
|
PropertyBasedElement(node),
|
||||||
_canvas( canvas ),
|
_canvas( canvas ),
|
||||||
_parent( parent ),
|
_parent( parent ),
|
||||||
_attributes_dirty( 0 ),
|
|
||||||
_transform( new osg::MatrixTransform ),
|
_transform( new osg::MatrixTransform ),
|
||||||
_style( parent_style ),
|
_style( parent_style )
|
||||||
_scissor( 0 ),
|
|
||||||
_drawable( 0 )
|
|
||||||
{
|
{
|
||||||
staticInit();
|
staticInit();
|
||||||
|
|
||||||
@@ -924,7 +919,7 @@ namespace canvas
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void Element::setupStyle()
|
void Element::setupStyle()
|
||||||
{
|
{
|
||||||
BOOST_FOREACH( Style::value_type style, _style )
|
for(auto const& style: _style)
|
||||||
setStyle(style.second);
|
setStyle(style.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,13 +24,13 @@
|
|||||||
#include <simgear/canvas/CanvasEvent.hxx>
|
#include <simgear/canvas/CanvasEvent.hxx>
|
||||||
#include <simgear/props/PropertyBasedElement.hxx>
|
#include <simgear/props/PropertyBasedElement.hxx>
|
||||||
#include <simgear/misc/stdint.hxx> // for uint32_t
|
#include <simgear/misc/stdint.hxx> // for uint32_t
|
||||||
|
#include <simgear/std/type_traits.hxx>
|
||||||
|
|
||||||
#include <osg/BoundingBox>
|
#include <osg/BoundingBox>
|
||||||
#include <osg/MatrixTransform>
|
#include <osg/MatrixTransform>
|
||||||
|
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
#include <boost/function.hpp>
|
#include <boost/function.hpp>
|
||||||
#include <boost/type_traits/is_base_of.hpp>
|
|
||||||
|
|
||||||
namespace osg
|
namespace osg
|
||||||
{
|
{
|
||||||
@@ -217,13 +217,14 @@ namespace canvas
|
|||||||
*/
|
*/
|
||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
static
|
static
|
||||||
typename boost::enable_if<
|
std::enable_if_t<
|
||||||
boost::is_base_of<Element, Derived>,
|
std::is_base_of<Element, Derived>::value,
|
||||||
ElementPtr
|
ElementPtr
|
||||||
>::type create( const CanvasWeakPtr& canvas,
|
>
|
||||||
const SGPropertyNode_ptr& node,
|
create( const CanvasWeakPtr& canvas,
|
||||||
const Style& style = Style(),
|
const SGPropertyNode_ptr& node,
|
||||||
Element* parent = NULL )
|
const Style& style = Style(),
|
||||||
|
Element* parent = NULL )
|
||||||
{
|
{
|
||||||
return ElementPtr( new Derived(canvas, node, style, parent) );
|
return ElementPtr( new Derived(canvas, node, style, parent) );
|
||||||
}
|
}
|
||||||
@@ -251,13 +252,13 @@ namespace canvas
|
|||||||
CanvasWeakPtr _canvas;
|
CanvasWeakPtr _canvas;
|
||||||
ElementWeakPtr _parent;
|
ElementWeakPtr _parent;
|
||||||
|
|
||||||
mutable uint32_t _attributes_dirty;
|
mutable uint32_t _attributes_dirty = 0;
|
||||||
|
|
||||||
osg::observer_ptr<osg::MatrixTransform> _transform;
|
osg::observer_ptr<osg::MatrixTransform> _transform;
|
||||||
std::vector<TransformType> _transform_types;
|
std::vector<TransformType> _transform_types;
|
||||||
|
|
||||||
Style _style;
|
Style _style;
|
||||||
RelativeScissor *_scissor;
|
RelativeScissor *_scissor = nullptr;
|
||||||
|
|
||||||
typedef std::vector<EventListener> Listener;
|
typedef std::vector<EventListener> Listener;
|
||||||
typedef std::map<int, Listener> ListenerMap;
|
typedef std::map<int, Listener> ListenerMap;
|
||||||
|
|||||||
@@ -23,13 +23,10 @@
|
|||||||
#include "CanvasMap.hxx"
|
#include "CanvasMap.hxx"
|
||||||
#include "CanvasPath.hxx"
|
#include "CanvasPath.hxx"
|
||||||
#include "CanvasText.hxx"
|
#include "CanvasText.hxx"
|
||||||
|
|
||||||
#include <simgear/canvas/CanvasEventVisitor.hxx>
|
#include <simgear/canvas/CanvasEventVisitor.hxx>
|
||||||
#include <simgear/canvas/events/MouseEvent.hxx>
|
#include <simgear/canvas/events/MouseEvent.hxx>
|
||||||
|
|
||||||
#include <boost/bind.hpp>
|
|
||||||
#include <boost/foreach.hpp>
|
|
||||||
#include <boost/lambda/core.hpp>
|
|
||||||
|
|
||||||
namespace simgear
|
namespace simgear
|
||||||
{
|
{
|
||||||
namespace canvas
|
namespace canvas
|
||||||
@@ -138,7 +135,7 @@ namespace canvas
|
|||||||
if( !_transform.valid() )
|
if( !_transform.valid() )
|
||||||
{
|
{
|
||||||
warnTransformExpired("getElementById");
|
warnTransformExpired("getElementById");
|
||||||
return ElementPtr();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<GroupPtr> groups;
|
std::vector<GroupPtr> groups;
|
||||||
@@ -153,14 +150,14 @@ namespace canvas
|
|||||||
groups.push_back(group);
|
groups.push_back(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FOREACH( GroupPtr group, groups )
|
for(auto group: groups)
|
||||||
{
|
{
|
||||||
ElementPtr el = group->getElementById(id);
|
ElementPtr el = group->getElementById(id);
|
||||||
if( el )
|
if( el )
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ElementPtr();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@@ -323,7 +320,7 @@ namespace canvas
|
|||||||
void Group::childChanged(SGPropertyNode* node)
|
void Group::childChanged(SGPropertyNode* node)
|
||||||
{
|
{
|
||||||
SGPropertyNode* parent = node->getParent();
|
SGPropertyNode* parent = node->getParent();
|
||||||
SGPropertyNode* grand_parent = parent ? parent->getParent() : NULL;
|
SGPropertyNode* grand_parent = parent ? parent->getParent() : nullptr;
|
||||||
|
|
||||||
if( grand_parent == _node
|
if( grand_parent == _node
|
||||||
&& node->getNameString() == "z-index" )
|
&& node->getNameString() == "z-index" )
|
||||||
@@ -399,7 +396,7 @@ namespace canvas
|
|||||||
if( !_transform.valid() )
|
if( !_transform.valid() )
|
||||||
{
|
{
|
||||||
warnTransformExpired("findChild");
|
warnTransformExpired("findChild");
|
||||||
return ElementPtr();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
for(size_t i = 0; i < _transform->getNumChildren(); ++i)
|
for(size_t i = 0; i < _transform->getNumChildren(); ++i)
|
||||||
@@ -418,7 +415,7 @@ namespace canvas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ElementPtr();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace canvas
|
} // namespace canvas
|
||||||
|
|||||||
@@ -117,9 +117,7 @@ namespace canvas
|
|||||||
ElementWeakPtr parent ):
|
ElementWeakPtr parent ):
|
||||||
Element(canvas, node, parent_style, parent),
|
Element(canvas, node, parent_style, parent),
|
||||||
_texture(new osg::Texture2D),
|
_texture(new osg::Texture2D),
|
||||||
_node_src_rect( node->getNode("source", 0, true) ),
|
_node_src_rect( node->getNode("source", 0, true) )
|
||||||
_src_rect(0,0),
|
|
||||||
_region(0,0)
|
|
||||||
{
|
{
|
||||||
staticInit();
|
staticInit();
|
||||||
|
|
||||||
@@ -634,7 +632,9 @@ namespace canvas
|
|||||||
// Abort pending request
|
// Abort pending request
|
||||||
if( _http_request )
|
if( _http_request )
|
||||||
{
|
{
|
||||||
Canvas::getSystemAdapter()->getHTTPClient()->cancelRequest(_http_request, "setting new image");
|
Canvas::getSystemAdapter()
|
||||||
|
->getHTTPClient()
|
||||||
|
->cancelRequest(_http_request, "setting new image");
|
||||||
_http_request.reset();
|
_http_request.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -100,8 +100,8 @@ namespace canvas
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void setSourceRect(const SGRect<float>& sourceRect);
|
void setSourceRect(const SGRect<float>& sourceRect);
|
||||||
protected:
|
|
||||||
|
|
||||||
|
protected:
|
||||||
enum ImageAttributes
|
enum ImageAttributes
|
||||||
{
|
{
|
||||||
SRC_RECT = LAST_ATTRIBUTE << 1, // Source image rectangle
|
SRC_RECT = LAST_ATTRIBUTE << 1, // Source image rectangle
|
||||||
@@ -134,9 +134,9 @@ namespace canvas
|
|||||||
osg::ref_ptr<osg::Vec2Array> _texCoords;
|
osg::ref_ptr<osg::Vec2Array> _texCoords;
|
||||||
osg::ref_ptr<osg::Vec4Array> _colors;
|
osg::ref_ptr<osg::Vec4Array> _colors;
|
||||||
|
|
||||||
SGPropertyNode *_node_src_rect;
|
SGPropertyNode *_node_src_rect = nullptr;
|
||||||
SGRect<float> _src_rect,
|
SGRect<float> _src_rect {0, 0},
|
||||||
_region;
|
_region {0, 0};
|
||||||
|
|
||||||
SVGpreserveAspectRatio _preserve_aspect_ratio;
|
SVGpreserveAspectRatio _preserve_aspect_ratio;
|
||||||
|
|
||||||
|
|||||||
@@ -18,13 +18,14 @@
|
|||||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
|
||||||
#include <simgear_config.h>
|
#include <simgear_config.h>
|
||||||
|
|
||||||
#include "CanvasMap.hxx"
|
#include "CanvasMap.hxx"
|
||||||
#include "map/geo_node_pair.hxx"
|
#include "map/geo_node_pair.hxx"
|
||||||
#include "map/projection.hxx"
|
#include "map/projection.hxx"
|
||||||
|
|
||||||
#include <cmath>
|
#include <simgear/misc/strutils.hxx>
|
||||||
|
|
||||||
#include <boost/algorithm/string/predicate.hpp>
|
#include <cmath>
|
||||||
|
|
||||||
#define LOG_GEO_RET(msg) \
|
#define LOG_GEO_RET(msg) \
|
||||||
{\
|
{\
|
||||||
@@ -73,13 +74,8 @@ namespace canvas
|
|||||||
Group(canvas, node, parent_style, parent)
|
Group(canvas, node, parent_style, parent)
|
||||||
{
|
{
|
||||||
staticInit();
|
staticInit();
|
||||||
if (node->getChild(PROJECTION) &&
|
|
||||||
(node->getChild(PROJECTION)->getStringValue() == WEB_MERCATOR)) {
|
projectionNodeChanged(node->getChild(PROJECTION));
|
||||||
_projection = (boost::shared_ptr<HorizontalProjection>) new WebMercatorProjection();
|
|
||||||
} else {
|
|
||||||
_projection = (boost::shared_ptr<HorizontalProjection>) new SansonFlamsteedProjection();
|
|
||||||
}
|
|
||||||
_projection_dirty = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@@ -124,7 +120,7 @@ namespace canvas
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void Map::childAdded(SGPropertyNode* parent, SGPropertyNode* child)
|
void Map::childAdded(SGPropertyNode* parent, SGPropertyNode* child)
|
||||||
{
|
{
|
||||||
if( boost::ends_with(child->getNameString(), GEO) )
|
if( strutils::ends_with(child->getNameString(), GEO) )
|
||||||
_geo_nodes[child].reset(new GeoNodePair());
|
_geo_nodes[child].reset(new GeoNodePair());
|
||||||
else if( parent != _node && child->getNameString() == HDG )
|
else if( parent != _node && child->getNameString() == HDG )
|
||||||
_hdg_nodes.insert(child);
|
_hdg_nodes.insert(child);
|
||||||
@@ -135,7 +131,7 @@ namespace canvas
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void Map::childRemoved(SGPropertyNode* parent, SGPropertyNode* child)
|
void Map::childRemoved(SGPropertyNode* parent, SGPropertyNode* child)
|
||||||
{
|
{
|
||||||
if( boost::ends_with(child->getNameString(), GEO) )
|
if( strutils::ends_with(child->getNameString(), GEO) )
|
||||||
// TODO remove from other node
|
// TODO remove from other node
|
||||||
_geo_nodes.erase(child);
|
_geo_nodes.erase(child);
|
||||||
else if( parent != _node && child->getName() == HDG )
|
else if( parent != _node && child->getName() == HDG )
|
||||||
@@ -157,7 +153,7 @@ namespace canvas
|
|||||||
{
|
{
|
||||||
const std::string& name = child->getNameString();
|
const std::string& name = child->getNameString();
|
||||||
|
|
||||||
if( boost::ends_with(name, GEO) )
|
if( strutils::ends_with(name, GEO) )
|
||||||
return geoNodeChanged(child);
|
return geoNodeChanged(child);
|
||||||
else if( name == HDG )
|
else if( name == HDG )
|
||||||
return hdgNodeChanged(child);
|
return hdgNodeChanged(child);
|
||||||
@@ -188,24 +184,31 @@ namespace canvas
|
|||||||
_projection->setRange(child->getDoubleValue());
|
_projection->setRange(child->getDoubleValue());
|
||||||
else if( child->getNameString() == SCREEN_RANGE )
|
else if( child->getNameString() == SCREEN_RANGE )
|
||||||
_projection->setScreenRange(child->getDoubleValue());
|
_projection->setScreenRange(child->getDoubleValue());
|
||||||
else if( child->getNameString() == PROJECTION ) {
|
else if( child->getNameString() == PROJECTION )
|
||||||
if (child->getStringValue() == WEB_MERCATOR) {
|
projectionNodeChanged(child);
|
||||||
_projection = (boost::shared_ptr<HorizontalProjection>) new WebMercatorProjection();
|
else
|
||||||
} else {
|
|
||||||
_projection = (boost::shared_ptr<HorizontalProjection>) new SansonFlamsteedProjection();
|
|
||||||
}
|
|
||||||
_projection->setWorldPosition(_node->getDoubleValue(REF_LAT),
|
|
||||||
_node->getDoubleValue(REF_LON) );
|
|
||||||
_projection->setOrientation(_node->getFloatValue(HDG));
|
|
||||||
_projection->setScreenRange(_node->getDoubleValue(SCREEN_RANGE));
|
|
||||||
_projection->setRange(_node->getDoubleValue(RANGE));
|
|
||||||
_projection_dirty = true;
|
|
||||||
} else
|
|
||||||
return Group::childChanged(child);
|
return Group::childChanged(child);
|
||||||
|
|
||||||
_projection_dirty = true;
|
_projection_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void Map::projectionNodeChanged(SGPropertyNode* child)
|
||||||
|
{
|
||||||
|
if(child && child->getStringValue() == WEB_MERCATOR)
|
||||||
|
_projection = std::make_shared<WebMercatorProjection>();
|
||||||
|
else
|
||||||
|
_projection = std::make_shared<SansonFlamsteedProjection>();
|
||||||
|
|
||||||
|
_projection->setWorldPosition(_node->getDoubleValue(REF_LAT),
|
||||||
|
_node->getDoubleValue(REF_LON) );
|
||||||
|
_projection->setOrientation(_node->getFloatValue(HDG));
|
||||||
|
_projection->setScreenRange(_node->getDoubleValue(SCREEN_RANGE));
|
||||||
|
_projection->setRange(_node->getDoubleValue(RANGE));
|
||||||
|
|
||||||
|
_projection_dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void Map::geoNodeChanged(SGPropertyNode* child)
|
void Map::geoNodeChanged(SGPropertyNode* child)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,9 +22,9 @@
|
|||||||
|
|
||||||
#include "CanvasGroup.hxx"
|
#include "CanvasGroup.hxx"
|
||||||
|
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <memory>
|
||||||
#include <boost/unordered_map.hpp>
|
#include <unordered_map>
|
||||||
#include <boost/unordered_set.hpp>
|
#include <unordered_set>
|
||||||
|
|
||||||
namespace simgear
|
namespace simgear
|
||||||
{
|
{
|
||||||
@@ -57,33 +57,29 @@ namespace canvas
|
|||||||
|
|
||||||
virtual void childChanged(SGPropertyNode * child);
|
virtual void childChanged(SGPropertyNode * child);
|
||||||
|
|
||||||
typedef boost::unordered_map< SGPropertyNode*,
|
using GeoNodes =
|
||||||
boost::shared_ptr<GeoNodePair>
|
std::unordered_map<SGPropertyNode*, std::shared_ptr<GeoNodePair>>;
|
||||||
> GeoNodes;
|
using NodeSet = std::unordered_set<SGPropertyNode*>;
|
||||||
typedef boost::unordered_set<SGPropertyNode*> NodeSet;
|
|
||||||
|
|
||||||
GeoNodes _geo_nodes;
|
GeoNodes _geo_nodes;
|
||||||
NodeSet _hdg_nodes;
|
NodeSet _hdg_nodes;
|
||||||
boost::shared_ptr<HorizontalProjection> _projection;
|
std::shared_ptr<HorizontalProjection> _projection;
|
||||||
bool _projection_dirty;
|
bool _projection_dirty = false;
|
||||||
|
|
||||||
struct GeoCoord
|
struct GeoCoord
|
||||||
{
|
{
|
||||||
GeoCoord():
|
|
||||||
type(INVALID),
|
|
||||||
value(0)
|
|
||||||
{}
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
INVALID,
|
INVALID,
|
||||||
LATITUDE,
|
LATITUDE,
|
||||||
LONGITUDE
|
LONGITUDE
|
||||||
} type;
|
} type = INVALID;
|
||||||
double value;
|
double value = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
void geoNodeChanged(SGPropertyNode * child);
|
void projectionNodeChanged(SGPropertyNode* child);
|
||||||
void hdgNodeChanged(SGPropertyNode * child);
|
void geoNodeChanged(SGPropertyNode* child);
|
||||||
|
void hdgNodeChanged(SGPropertyNode* child);
|
||||||
|
|
||||||
GeoCoord parseGeoCoord(const std::string& val) const;
|
GeoCoord parseGeoCoord(const std::string& val) const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -206,23 +206,13 @@ namespace canvas
|
|||||||
return SGVec2f(-1.0f, -1.0f);
|
return SGVec2f(-1.0f, -1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
class Path::PathDrawable:
|
class Path::PathDrawable:
|
||||||
public osg::Drawable
|
public osg::Drawable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PathDrawable(Path* path):
|
PathDrawable(Path* path):
|
||||||
_path_element(path),
|
_path_element(path)
|
||||||
_path(VG_INVALID_HANDLE),
|
|
||||||
_paint(VG_INVALID_HANDLE),
|
|
||||||
_paint_fill(VG_INVALID_HANDLE),
|
|
||||||
_attributes_dirty(~0),
|
|
||||||
_mode(0),
|
|
||||||
_fill_rule(VG_EVEN_ODD),
|
|
||||||
_stroke_width(1),
|
|
||||||
_stroke_linecap(VG_CAP_BUTT),
|
|
||||||
_stroke_linejoin(VG_JOIN_MITER)
|
|
||||||
{
|
{
|
||||||
setSupportsDisplayList(false);
|
setSupportsDisplayList(false);
|
||||||
setDataVariance(Object::DYNAMIC);
|
setDataVariance(Object::DYNAMIC);
|
||||||
@@ -579,22 +569,22 @@ namespace canvas
|
|||||||
|
|
||||||
Path *_path_element;
|
Path *_path_element;
|
||||||
|
|
||||||
mutable VGPath _path;
|
mutable VGPath _path {VG_INVALID_HANDLE};
|
||||||
mutable VGPaint _paint;
|
mutable VGPaint _paint {VG_INVALID_HANDLE};
|
||||||
mutable VGPaint _paint_fill;
|
mutable VGPaint _paint_fill {VG_INVALID_HANDLE};
|
||||||
mutable uint32_t _attributes_dirty;
|
mutable uint32_t _attributes_dirty {~0u};
|
||||||
|
|
||||||
CmdList _cmds;
|
CmdList _cmds;
|
||||||
CoordList _coords;
|
CoordList _coords;
|
||||||
|
|
||||||
VGbitfield _mode;
|
VGbitfield _mode {0};
|
||||||
osg::Vec4f _fill_color;
|
osg::Vec4f _fill_color;
|
||||||
VGFillRule _fill_rule;
|
VGFillRule _fill_rule {VG_EVEN_ODD};
|
||||||
osg::Vec4f _stroke_color;
|
osg::Vec4f _stroke_color;
|
||||||
VGfloat _stroke_width;
|
VGfloat _stroke_width {1};
|
||||||
std::vector<VGfloat> _stroke_dash;
|
std::vector<VGfloat> _stroke_dash;
|
||||||
VGCapStyle _stroke_linecap;
|
VGCapStyle _stroke_linecap {VG_CAP_BUTT};
|
||||||
VGJoinStyle _stroke_linejoin;
|
VGJoinStyle _stroke_linejoin {VG_JOIN_MITER};
|
||||||
|
|
||||||
osg::Vec3f transformPoint( const osg::Matrix& m,
|
osg::Vec3f transformPoint( const osg::Matrix& m,
|
||||||
osg::Vec2f pos ) const
|
osg::Vec2f pos ) const
|
||||||
@@ -842,33 +832,34 @@ namespace canvas
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void Path::childChanged(SGPropertyNode* child)
|
void Path::childChanged(SGPropertyNode* child)
|
||||||
{
|
{
|
||||||
const std::string& name = child->getNameString();
|
const std::string& name = child->getNameString();
|
||||||
const std::string &prName = child->getParent()->getNameString();
|
const std::string &prName = child->getParent()->getNameString();
|
||||||
|
|
||||||
if (simgear::strutils::starts_with(name, "border-"))
|
if( strutils::starts_with(name, "border-") )
|
||||||
{
|
{
|
||||||
_attributes_dirty |= RECT;
|
_attributes_dirty |= RECT;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prName == "rect") {
|
if (prName == "rect")
|
||||||
_hasRect = true;
|
{
|
||||||
if (name == "left") {
|
_hasRect = true;
|
||||||
_rect.setLeft(child->getDoubleValue());
|
if (name == "left") {
|
||||||
} else if (name == "top") {
|
_rect.setLeft(child->getDoubleValue());
|
||||||
_rect.setTop(child->getDoubleValue());
|
} else if (name == "top") {
|
||||||
} else if (name == "right") {
|
_rect.setTop(child->getDoubleValue());
|
||||||
_rect.setRight(child->getDoubleValue());
|
} else if (name == "right") {
|
||||||
} else if (name == "bottom") {
|
_rect.setRight(child->getDoubleValue());
|
||||||
_rect.setBottom(child->getDoubleValue());
|
} else if (name == "bottom") {
|
||||||
} else if (name == "width") {
|
_rect.setBottom(child->getDoubleValue());
|
||||||
_rect.setWidth(child->getDoubleValue());
|
} else if (name == "width") {
|
||||||
} else if (name == "height") {
|
_rect.setWidth(child->getDoubleValue());
|
||||||
_rect.setHeight(child->getDoubleValue());
|
} else if (name == "height") {
|
||||||
}
|
_rect.setHeight(child->getDoubleValue());
|
||||||
_attributes_dirty |= RECT;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
_attributes_dirty |= RECT;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if( child->getParent() != _node )
|
if( child->getParent() != _node )
|
||||||
return;
|
return;
|
||||||
@@ -904,67 +895,68 @@ namespace canvas
|
|||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
void operator+=(CoordList& base, const std::initializer_list<VGfloat>& other)
|
||||||
|
{
|
||||||
|
base.insert(base.end(), other.begin(), other.end());
|
||||||
|
}
|
||||||
|
|
||||||
void operator+=(CoordList& base, const std::initializer_list<VGfloat>& other)
|
//----------------------------------------------------------------------------
|
||||||
{
|
void Path::parseRectToVGPath()
|
||||||
base.insert(base.end(), other.begin(), other.end());
|
{
|
||||||
|
CmdList commands;
|
||||||
|
CoordList coords;
|
||||||
|
commands.reserve(4);
|
||||||
|
coords.reserve(8);
|
||||||
|
|
||||||
|
bool haveCorner = false;
|
||||||
|
SGVec2f topLeft = parseRectCornerRadius(_node, "left", "top", haveCorner);
|
||||||
|
if (haveCorner) {
|
||||||
|
commands.push_back(VG_MOVE_TO_ABS);
|
||||||
|
coords += {_rect.l(), _rect.t() + topLeft.y()};
|
||||||
|
commands.push_back(VG_SCCWARC_TO_REL);
|
||||||
|
coords += {topLeft.x(), topLeft.y(), 0.0, topLeft.x(), -topLeft.y()};
|
||||||
|
} else {
|
||||||
|
commands.push_back(VG_MOVE_TO_ABS);
|
||||||
|
coords += {_rect.l(), _rect.t()};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Path::parseRectToVGPath()
|
SGVec2f topRight = parseRectCornerRadius(_node, "right", "top", haveCorner);
|
||||||
{
|
if (haveCorner) {
|
||||||
CmdList commands;
|
commands.push_back(VG_HLINE_TO_ABS);
|
||||||
CoordList coords;
|
coords += {_rect.r() - topRight.x()};
|
||||||
commands.reserve(4);
|
commands.push_back(VG_SCCWARC_TO_REL);
|
||||||
coords.reserve(8);
|
coords += {topRight.x(), topRight.y(), 0.0, topRight.x(), topRight.y()};
|
||||||
|
} else {
|
||||||
bool haveCorner = false;
|
commands.push_back(VG_HLINE_TO_ABS);
|
||||||
SGVec2f topLeft = parseRectCornerRadius(_node, "left", "top", haveCorner);
|
coords += {_rect.r()};
|
||||||
if (haveCorner) {
|
|
||||||
commands.push_back(VG_MOVE_TO_ABS);
|
|
||||||
coords += {_rect.l(), _rect.t() + topLeft.y()};
|
|
||||||
commands.push_back(VG_SCCWARC_TO_REL);
|
|
||||||
coords += {topLeft.x(), topLeft.y(), 0.0, topLeft.x(), -topLeft.y()};
|
|
||||||
} else {
|
|
||||||
commands.push_back(VG_MOVE_TO_ABS);
|
|
||||||
coords += {_rect.l(), _rect.t()};
|
|
||||||
}
|
|
||||||
|
|
||||||
SGVec2f topRight = parseRectCornerRadius(_node, "right", "top", haveCorner);
|
|
||||||
if (haveCorner) {
|
|
||||||
commands.push_back(VG_HLINE_TO_ABS);
|
|
||||||
coords += {_rect.r() - topRight.x()};
|
|
||||||
commands.push_back(VG_SCCWARC_TO_REL);
|
|
||||||
coords += {topRight.x(), topRight.y(), 0.0, topRight.x(), topRight.y()};
|
|
||||||
} else {
|
|
||||||
commands.push_back(VG_HLINE_TO_ABS);
|
|
||||||
coords += {_rect.r()};
|
|
||||||
}
|
|
||||||
|
|
||||||
SGVec2f bottomRight = parseRectCornerRadius(_node, "right", "bottom", haveCorner);
|
|
||||||
if (haveCorner) {
|
|
||||||
commands.push_back(VG_VLINE_TO_ABS);
|
|
||||||
coords += {_rect.b() - bottomRight.y()};
|
|
||||||
commands.push_back(VG_SCCWARC_TO_REL);
|
|
||||||
coords += {bottomRight.x(), bottomRight.y(), 0.0, -bottomRight.x(), bottomRight.y()};
|
|
||||||
} else {
|
|
||||||
commands.push_back(VG_VLINE_TO_ABS);
|
|
||||||
coords += {_rect.b()};
|
|
||||||
}
|
|
||||||
|
|
||||||
SGVec2f bottomLeft = parseRectCornerRadius(_node, "left", "bottom", haveCorner);
|
|
||||||
if (haveCorner) {
|
|
||||||
commands.push_back(VG_HLINE_TO_ABS);
|
|
||||||
coords += {_rect.l() + bottomLeft.x()};
|
|
||||||
commands.push_back(VG_SCCWARC_TO_REL);
|
|
||||||
coords += {bottomLeft.x(), bottomLeft.y(), 0.0, -bottomLeft.x(), -bottomLeft.y()};
|
|
||||||
} else {
|
|
||||||
commands.push_back(VG_HLINE_TO_ABS);
|
|
||||||
coords += {_rect.l()};
|
|
||||||
}
|
|
||||||
|
|
||||||
commands.push_back(VG_CLOSE_PATH);
|
|
||||||
_path->setSegments(commands, coords);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SGVec2f bottomRight = parseRectCornerRadius(_node, "right", "bottom", haveCorner);
|
||||||
|
if (haveCorner) {
|
||||||
|
commands.push_back(VG_VLINE_TO_ABS);
|
||||||
|
coords += {_rect.b() - bottomRight.y()};
|
||||||
|
commands.push_back(VG_SCCWARC_TO_REL);
|
||||||
|
coords += {bottomRight.x(), bottomRight.y(), 0.0, -bottomRight.x(), bottomRight.y()};
|
||||||
|
} else {
|
||||||
|
commands.push_back(VG_VLINE_TO_ABS);
|
||||||
|
coords += {_rect.b()};
|
||||||
|
}
|
||||||
|
|
||||||
|
SGVec2f bottomLeft = parseRectCornerRadius(_node, "left", "bottom", haveCorner);
|
||||||
|
if (haveCorner) {
|
||||||
|
commands.push_back(VG_HLINE_TO_ABS);
|
||||||
|
coords += {_rect.l() + bottomLeft.x()};
|
||||||
|
commands.push_back(VG_SCCWARC_TO_REL);
|
||||||
|
coords += {bottomLeft.x(), bottomLeft.y(), 0.0, -bottomLeft.x(), -bottomLeft.y()};
|
||||||
|
} else {
|
||||||
|
commands.push_back(VG_HLINE_TO_ABS);
|
||||||
|
coords += {_rect.l()};
|
||||||
|
}
|
||||||
|
|
||||||
|
commands.push_back(VG_CLOSE_PATH);
|
||||||
|
_path->setSegments(commands, coords);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace canvas
|
} // namespace canvas
|
||||||
} // namespace simgear
|
} // namespace simgear
|
||||||
|
|||||||
@@ -68,10 +68,10 @@ namespace canvas
|
|||||||
|
|
||||||
void setSVGPath(const std::string& svgPath);
|
void setSVGPath(const std::string& svgPath);
|
||||||
|
|
||||||
void setRect(const SGRect<float>& r);
|
void setRect(const SGRectf& r);
|
||||||
void setRoundRect(const SGRect<float>& r, float radiusX, float radiusY = -1.0);
|
void setRoundRect(const SGRectf& r, float radiusX, float radiusY = -1.0);
|
||||||
protected:
|
|
||||||
|
|
||||||
|
protected:
|
||||||
enum PathAttributes
|
enum PathAttributes
|
||||||
{
|
{
|
||||||
CMDS = LAST_ATTRIBUTE << 1,
|
CMDS = LAST_ATTRIBUTE << 1,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#include <simgear_config.h>
|
#include <simgear_config.h>
|
||||||
#include "PropertyBasedElement.hxx"
|
#include "PropertyBasedElement.hxx"
|
||||||
#include <boost/algorithm/string/predicate.hpp>
|
#include <simgear/misc/strutils.hxx>
|
||||||
|
|
||||||
namespace simgear
|
namespace simgear
|
||||||
{
|
{
|
||||||
@@ -130,7 +130,7 @@ namespace simgear
|
|||||||
// character that followed it by the same character converted to ASCII
|
// character that followed it by the same character converted to ASCII
|
||||||
// uppercase.
|
// uppercase.
|
||||||
|
|
||||||
if( !boost::starts_with(name, DATA_PREFIX) )
|
if( !strutils::starts_with(name, DATA_PREFIX) )
|
||||||
return std::string();
|
return std::string();
|
||||||
|
|
||||||
std::string data_name;
|
std::string data_name;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#define SG_PROPERTY_BASED_ELEMENT_HXX_
|
#define SG_PROPERTY_BASED_ELEMENT_HXX_
|
||||||
|
|
||||||
#include <simgear/props/props.hxx>
|
#include <simgear/props/props.hxx>
|
||||||
|
#include <simgear/std/type_traits.hxx>
|
||||||
#include <simgear/structure/SGWeakReferenced.hxx>
|
#include <simgear/structure/SGWeakReferenced.hxx>
|
||||||
|
|
||||||
namespace simgear
|
namespace simgear
|
||||||
@@ -120,11 +121,9 @@ namespace simgear
|
|||||||
* @see setDataProp
|
* @see setDataProp
|
||||||
*/
|
*/
|
||||||
template<class T>
|
template<class T>
|
||||||
typename boost::disable_if<
|
std::enable_if_t<!std::is_same<T, SGPropertyNode*>::value, T>
|
||||||
boost::is_same<T, SGPropertyNode*>,
|
getDataProp( const std::string& name,
|
||||||
T
|
const T& def = {} ) const
|
||||||
>::type getDataProp( const std::string& name,
|
|
||||||
const T& def = T() ) const
|
|
||||||
{
|
{
|
||||||
SGPropertyNode* node = getDataProp<SGPropertyNode*>(name);
|
SGPropertyNode* node = getDataProp<SGPropertyNode*>(name);
|
||||||
if( node )
|
if( node )
|
||||||
@@ -140,11 +139,9 @@ namespace simgear
|
|||||||
* @see setDataProp
|
* @see setDataProp
|
||||||
*/
|
*/
|
||||||
template<class T>
|
template<class T>
|
||||||
typename boost::enable_if<
|
std::enable_if_t<std::is_same<T, SGPropertyNode*>::value, T>
|
||||||
boost::is_same<T, SGPropertyNode*>,
|
getDataProp( const std::string& name,
|
||||||
T
|
SGPropertyNode* = nullptr ) const
|
||||||
>::type getDataProp( const std::string& name,
|
|
||||||
SGPropertyNode* = NULL ) const
|
|
||||||
{
|
{
|
||||||
const std::string& attr = dataPropToAttrName(name);
|
const std::string& attr = dataPropToAttrName(name);
|
||||||
if( attr.empty() )
|
if( attr.empty() )
|
||||||
|
|||||||
Reference in New Issue
Block a user