}
//----------------------------------------------------------------------------
- void Canvas::addDependentCanvas(const CanvasWeakPtr& canvas)
+ void Canvas::addParentCanvas(const CanvasWeakPtr& canvas)
{
if( canvas.expired() )
{
(
SG_GENERAL,
SG_WARN,
- "Canvas::addDependentCanvas: got an expired Canvas dependent on "
- << _node->getPath()
+ "Canvas::addParentCanvas: got an expired parent: " << _node->getPath()
);
return;
}
- _dependent_canvases.insert(canvas);
+ _parent_canvases.insert(canvas);
}
//----------------------------------------------------------------------------
- void Canvas::removeDependentCanvas(const CanvasWeakPtr& canvas)
+ void Canvas::addChildCanvas(const CanvasWeakPtr& canvas)
{
- _dependent_canvases.erase(canvas);
+ if( canvas.expired() )
+ {
+ SG_LOG
+ (
+ SG_GENERAL,
+ SG_WARN,
+ "Canvas::addChildCanvas: got an expired child: " << _node->getPath()
+ );
+ return;
+ }
+
+ _child_canvases.insert(canvas);
+ }
+
+ //----------------------------------------------------------------------------
+ void Canvas::removeParentCanvas(const CanvasWeakPtr& canvas)
+ {
+ _parent_canvases.erase(canvas);
+ }
+
+ //----------------------------------------------------------------------------
+ void Canvas::removeChildCanvas(const CanvasWeakPtr& canvas)
+ {
+ _child_canvases.erase(canvas);
}
//----------------------------------------------------------------------------
if( _visible || _render_always )
{
+ BOOST_FOREACH(CanvasWeakPtr canvas, _child_canvases)
+ {
+ // TODO should we check if the image the child canvas is displayed
+ // within is really visible?
+ if( !canvas.expired() )
+ canvas.lock()->_visible = true;
+ }
+
if( _render_dirty )
{
- // Also mark all dependent (eg. recursively used) canvases as dirty
- BOOST_FOREACH(CanvasWeakPtr canvas, _dependent_canvases)
+ // Also mark all canvases this canvas is displayed within as dirty
+ BOOST_FOREACH(CanvasWeakPtr canvas, _parent_canvases)
{
if( !canvas.expired() )
canvas.lock()->_render_dirty = true;
//----------------------------------------------------------------------------
int Canvas::getViewWidth() const
{
- return _view_width;
+ return _texture.getViewSize().x();
}
//----------------------------------------------------------------------------
int Canvas::getViewHeight() const
{
- return _view_height;
+ return _texture.getViewSize().y();
}
//----------------------------------------------------------------------------
CanvasMgr* getCanvasMgr() const;
/**
- * Add a canvas which should be mared as dirty upon any change to this
+ * Add a canvas which should be marked as dirty upon any change to this
* canvas.
*
* This mechanism is used to eg. redraw a canvas if it's displaying
* another canvas (recursive canvases)
*/
- void addDependentCanvas(const CanvasWeakPtr& canvas);
+ void addParentCanvas(const CanvasWeakPtr& canvas);
+
+ /**
+ * Add a canvas which should be marked visible if this canvas is visible.
+ */
+ void addChildCanvas(const CanvasWeakPtr& canvas);
/**
* Stop notifying the given canvas upon changes
*/
- void removeDependentCanvas(const CanvasWeakPtr& canvas);
+ void removeParentCanvas(const CanvasWeakPtr& canvas);
+ void removeChildCanvas(const CanvasWeakPtr& canvas);
GroupPtr createGroup(const std::string& name = "");
std::vector<SGPropertyNode*> _dirty_placements;
std::vector<Placements> _placements;
- std::set<CanvasWeakPtr> _dependent_canvases; //<! Canvases which use this
- // canvas and should be
- // notified about changes
+ std::set<CanvasWeakPtr> _parent_canvases, //<! Canvases showing this canvas
+ _child_canvases; //<! Canvases displayed within
+ // this canvas
typedef std::map<std::string, PlacementFactory> PlacementFactoryMap;
static PlacementFactoryMap _placement_factories;
updateCoordinateFrame();
}
+ //----------------------------------------------------------------------------
+ osg::Vec2s ODGauge::getViewSize() const
+ {
+ return osg::Vec2s(_view_width, _view_height);
+ }
+
//----------------------------------------------------------------------------
void ODGauge::useImageCoords(bool use)
{
*/
void setViewSize(int width, int height = -1);
+ osg::Vec2s getViewSize() const;
+
/**
* DEPRECATED
*
void Image::setSrcCanvas(CanvasPtr canvas)
{
if( !_src_canvas.expired() )
- _src_canvas.lock()->removeDependentCanvas(_canvas);
+ _src_canvas.lock()->removeParentCanvas(_canvas);
+ if( !_canvas.expired() )
+ _canvas.lock()->removeChildCanvas(_src_canvas);
_src_canvas = canvas;
_geom->getOrCreateStateSet()
if( !_src_canvas.expired() )
{
setupDefaultDimensions();
- _src_canvas.lock()->addDependentCanvas(_canvas);
+ _src_canvas.lock()->addParentCanvas(_canvas);
+
+ if( !_canvas.expired() )
+ _canvas.lock()->addChildCanvas(_src_canvas);
}
}