Hey all,
I need some help on an issue I am facing. I am trying to have a temporary circle follow my mouse, but I am finding after some point there is a distance between the circle and my mouse. After all my investigation, all I can find is that the converted point seems to be wrong.
Here’s what my code looks like.
void OnMouseMove( UINT nFlags, CPoint point )
{
SetTempPinPos( point );
}
void SetTempPinPos( CPoint const& tempPinPos )
{
PixelToWorld( tempPinPos, tempPinPosInWorld );
DrawPin( tempPinPosInWorld ); //Draws a circle with the center being at that point, not adding that in
}
bool PixelToWorld( CPoint const& point, PointDataType<double> & convertedPoint ) const
{
HPS::Point pointInPixel( point.x, point.y, 0 );
auto res { Convert( HPS::Coordinate::Space::Pixel, HPS::Coordinate::Space::World, pointInPixel, convertedPoint ) };
if( res )
{
convertedPoint = RestorePoint( PointDataType<double>( convertedPoint.x, convertedPoint.y, convertedPoint.z ) );
}
return res;
}
bool Convert( HPS::Coordinate::Space spaceIn,
HPS::Coordinate::Space spaceOut,
HPS::Point const& point,
PointDataType<double>& convertedPoint ) const
{
HPS::Point transformedPoint {};
auto sprkPath { HPS::SprocketPath( m_canvas,
m_canvas.GetAttachedLayout(),
m_canvas.GetAttachedLayout().GetAttachedView(),
m_model ) };
auto res { sprkPath.GetKeyPath().ConvertCoordinate( spaceIn, point, spaceOut, transformedPoint ) };
convertedPoint.x = transformedPoint.x;
convertedPoint.y = transformedPoint.y;
convertedPoint.z = transformedPoint.z;
return res;
}
PointDataType<double> RestorePoint( PointDataType<double> const& point ) const
{
return PointDataType<double>( point.x + m_origin.x,
point.y + m_origin.y,
point.z + m_origin.z );
// We use a origin to reduce the value of these points, we use geomatic coordinates so they can get quite big
}
Any help is greatly appreciated on why the circle we draw seems to be offset from the mouse.