Hi,
I have an issue related to High DPI display and I don’t find a solution in the guide.
I have a getter derived from CRhinoGetPoint
in which I dynamically draw a filled circle of a fixed real distance. For that I use CRhinoDisplayPipeline::DrawPoint
as there’s no function to draw a filled circle from ON_Circle
.
I also draw a non-filled circle of the same radius, with CRhinoDisplayPipeline::DrawCircle
.
In this picture I draw the inner part in grey and the outer part in black with the same center (note, this is just an example as actually I have to draw different filled/non-filled circles with different centers but same radius):
The problem is that in High DPI displays there’s a mismatch of radius: the filled circle (whose radius is defined in pixels in the SDK) is way bigger than the non-filled circle. I’ve been reported this by a customer using a 4K monitor; unfortunately I don’t have such a monitor but I know there’s a problem there.
Please take a look on how to fix this, here’s the sample:
cmdSampleGetPointPixelCircle.cpp (2.7 KB)
The getter:
class GetPointPixelCircle : public CRhinoGetPoint
{
public:
GetPointPixelCircle(double circleRadius);
void DynamicDraw(CRhinoDisplayPipeline& dp, const ON_3dPoint& pt);
private:
double m_circleRadius;
ON_Color m_innerColor, m_outerColor;
int m_thickness;
};
GetPointPixelCircle::GetPointPixelCircle(double circleRadius)
{
m_circleRadius = circleRadius;
m_innerColor = ON_Color::Gray230;
m_outerColor = ON_Color::Black;
m_thickness = 10;
}
void GetPointPixelCircle::DynamicDraw(CRhinoDisplayPipeline& dp, const ON_3dPoint& pt)
{
int circlePixelRadius;
const CRhinoViewport* vp = dp.GetRhinoVP();
if (nullptr != vp)
{
double pixelsPerUnit = 0.0;
if (vp->View().m_vp.GetWorldToScreenScale(vp->View().TargetPoint(), &pixelsPerUnit))
{
// Draw inner part
circlePixelRadius = (int)(m_circleRadius * pixelsPerUnit);
dp.DrawPoint(pt, circlePixelRadius, ERhinoPointStyle::RPS_CIRCLE, m_innerColor);
// Draw outer part
const ON_Plane& plane = vp->ConstructionPlane().m_plane;
ON_Circle circle(plane, pt, m_circleRadius);
dp.DrawCircle(circle, m_outerColor, m_thickness);
}
}
CRhinoGetPoint::DynamicDraw(dp, pt);
}
I think the issue is about the conversion of the real radius to screen pixel radius through ON_Viewport::GetWorldToScreenScale
. I took that part of code from @dale’s SampleMarker.
Thank you,
Pablo