Introduced a Locator callback and associated usage of this callback to provide interactive updating of the volume bounds
This commit is contained in:
@@ -25,6 +25,8 @@ void Locator::setTransformAsExtents(double minX, double minY, double maxX, doubl
|
||||
minX, minY, minZ, 1.0);
|
||||
|
||||
_inverse.invert(_transform);
|
||||
|
||||
locatorModified();
|
||||
}
|
||||
|
||||
bool Locator::convertLocalToModel(const osg::Vec3d& local, osg::Vec3d& world) const
|
||||
@@ -165,3 +167,45 @@ bool Locator::computeLocalBounds(osg::Vec3d& bottomLeft, osg::Vec3d& topRight) c
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Locator::addCallback(LocatorCallback* callback)
|
||||
{
|
||||
// check if callback is already attached, if so just return early
|
||||
for(LocatorCallbacks::iterator itr = _locatorCallbacks.begin();
|
||||
itr != _locatorCallbacks.end();
|
||||
++itr)
|
||||
{
|
||||
if (*itr == callback)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// callback is not attached so now attach it.
|
||||
_locatorCallbacks.push_back(callback);
|
||||
}
|
||||
|
||||
void Locator::removeCallback(LocatorCallback* callback)
|
||||
{
|
||||
// checl if callback is attached, if so erase it.
|
||||
for(LocatorCallbacks::iterator itr = _locatorCallbacks.begin();
|
||||
itr != _locatorCallbacks.end();
|
||||
++itr)
|
||||
{
|
||||
if (*itr == callback)
|
||||
{
|
||||
_locatorCallbacks.erase(itr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Locator::locatorModified()
|
||||
{
|
||||
for(LocatorCallbacks::iterator itr = _locatorCallbacks.begin();
|
||||
itr != _locatorCallbacks.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->locatorModified(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user