本文整理汇总了C++中BaseRenderer::GetCurrentWorldGeometry2D方法的典型用法代码示例。如果您正苦于以下问题:C++ BaseRenderer::GetCurrentWorldGeometry2D方法的具体用法?C++ BaseRenderer::GetCurrentWorldGeometry2D怎么用?C++ BaseRenderer::GetCurrentWorldGeometry2D使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseRenderer
的用法示例。
在下文中一共展示了BaseRenderer::GetCurrentWorldGeometry2D方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: timeStep
bool
mitk::PlanarFigureInteractor::IsMousePositionAcceptableAsNewControlPoint(
mitk::StateEvent const * stateEvent,
const PlanarFigure* planarFigure )
{
assert(stateEvent && planarFigure);
BaseRenderer* renderer = stateEvent->GetEvent()->GetSender();
assert(renderer);
// Get the timestep to support 3D+t
int timeStep( renderer->GetTimeStep( planarFigure ) );
// Get current display position of the mouse
//Point2D currentDisplayPosition = positionEvent->GetDisplayPosition();
// Check if a previous point has been set
bool tooClose = false;
const Geometry2D *renderingPlane = renderer->GetCurrentWorldGeometry2D();
mitk::Geometry2D *planarFigureGeometry =
dynamic_cast< mitk::Geometry2D * >( planarFigure->GetGeometry( timeStep ) );
Point2D point2D, correctedPoint;
// Get the point2D from the positionEvent
if ( !this->TransformPositionEventToPoint2D( stateEvent, point2D,
planarFigureGeometry ) )
{
return false;
}
// apply the controlPoint constraints of the planarFigure to get the
// coordinates that would actually be used.
correctedPoint = const_cast<PlanarFigure*>( planarFigure )->ApplyControlPointConstraints( 0, point2D );
// map the 2D coordinates of the new point to world-coordinates
// and transform those to display-coordinates
mitk::Point3D newPoint3D;
planarFigureGeometry->Map( correctedPoint, newPoint3D );
mitk::Point2D newDisplayPosition;
renderingPlane->Map( newPoint3D, newDisplayPosition );
renderer->GetDisplayGeometry()->WorldToDisplay( newDisplayPosition, newDisplayPosition );
for( int i=0; i < (int)planarFigure->GetNumberOfControlPoints(); i++ )
{
if ( i != planarFigure->GetSelectedControlPoint() )
{
// Try to convert previous point to current display coordinates
mitk::Point3D previousPoint3D;
// map the 2D coordinates of the control-point to world-coordinates
planarFigureGeometry->Map( planarFigure->GetControlPoint( i ), previousPoint3D );
if ( renderer->GetDisplayGeometry()->Distance( previousPoint3D ) < 0.1 ) // ugly, but assert makes this work
{
mitk::Point2D previousDisplayPosition;
// transform the world-coordinates into display-coordinates
renderingPlane->Map( previousPoint3D, previousDisplayPosition );
renderer->GetDisplayGeometry()->WorldToDisplay( previousDisplayPosition, previousDisplayPosition );
//Calculate the distance. We use display-coordinates here to make
// the check independent of the zoom-level of the rendering scene.
double a = newDisplayPosition[0] - previousDisplayPosition[0];
double b = newDisplayPosition[1] - previousDisplayPosition[1];
// If point is to close, do not set a new point
tooClose = (a * a + b * b < m_MinimumPointDistance );
}
if ( tooClose )
return false; // abort loop early
}
}
return !tooClose; // default
}