A Linkage document file contains coordinates based on there being 96.0 pixels per inch. If the software is rendering onto an old monitor then the document units are scaled based on the amount of zoom in effect and then they are translated to different coordinates if the document has been panned in the window. If there is an adjustment needed because the DPI is not 96.0, that happens last. The effect is that the software treats the display, or even the printer device as if it has 96.0 DPI and then makes a final adjustment to “zoom” things to adjust for the DPI difference. There is one odd thing that happens while rendering to the device; Some elements are drawn un-zoomed. All the text and the circles for connectors are drawn at a certain “inch” size in the output regardless of any zoom factor.

The Windows Linkage software has some functions, such as Scale(), that take a point and return a scaled point. It is assumed that the scaling should be done to convert document units of 96.0 per inch to screen (or printer, etc.) units. The scaling also adjusts for panning and also makes an adjustment because the center of the window needs to be the 0,0 origin point of the document. To handle elements that are drawn to a fixed size regardless of the zoom, there is a function called unscaledUnits() that converts a measurement of 96.0 units per inch to units appropriate for the device. The Windows software actually uses this only for DXF output and it is otherwise only ever set to 1.0. That seems weird but the renderer code actually adjusts for the DPI difference, not the code that calls the rendering functions.

In the Mac Linkage software, I decided to create a separate Scale object that will keep track of the zoom, pan, DPI scaling, etc. and now I’m in trouble. It’s not trouble due to complexity or my inability to solve a problem, it’s trouble with giving names to functions that do scaling. I opted to use toRender() and toDocument() functions to convert between the two sets of coordinates. Since the Scale object will have the pan and zoom set in it, as well as the 96.0 units to screen coordinates, the renderer will do nothing to adjust for DPI. Interestingly, there is one more level of scaling done by the operating system since the actual physical pixels on the screen are never addressed by the rendering code – those are sort of off-limits to my code. But since the Mac still has virtual pixels that are not at 96.0 per inch, I need to do additional scaling of some values when I draw elements on the screen. I have no idea what to call the translation since it’s not really related to physical pixels-per-inch. I just need to be able to have 1 unit on the Mac be the same as 1 unit on the PC so my hard-coded adjustments to align things that don’t zoom are the same in both sets of software.

Maybe I just call the scaling function dpiAdjust( from: Double ) and be done with it. the virtual pixels do count as “dots” so “dots-per-inch” would work. I’d just rather have something a little more generic sounding. Maybe that’s just me being a bit pedantic. After all, the function in the Windows Linkage code is called “unscalledUnits().”