time | Calls | line |
---|
| | 1 | function todists = convertDistances(viewport, tounits, fromunits, distances)
|
| | 2 | % This is an undocumented function and may be removed in a future release.
|
| | 3 |
|
| | 4 | % Use the matlab.graphics.general.UnitPosition object "viewport" to convert
|
| | 5 | % the units of "distances" from "fromunits" to "tounits".
|
| | 6 | %
|
| | 7 | % "distances" are [left bottom right top]. Unlike positions, pixel based
|
| | 8 | % distances are not 1-based. In order to do the conversion correctly,
|
| | 9 | % perform two conversions: once for left/bottom, and once for right/top.
|
| | 10 |
|
| | 11 | % Copyright 2018 The MathWorks, Inc.
|
| | 12 |
|
| | 13 | % Set the 'Units' and 'Position' to the starting units and position.
|
0.004 | 46 | 14 | viewport.Units = fromunits;
|
0.002 | 46 | 15 | viewport.Position = [0, 0, distances(1:2)];
|
| | 16 |
|
| | 17 | % Set the 'Units' to the new units, this will trigger a unit conversion.
|
< 0.001 | 46 | 18 | viewport.Units = tounits;
|
| | 19 |
|
| | 20 | % Read back the new position in the new units.
|
< 0.001 | 46 | 21 | leftbottom = viewport.Position;
|
| | 22 |
|
| | 23 | % Set the 'Units' and 'Position' to the starting units and position.
|
< 0.001 | 46 | 24 | viewport.Units = fromunits;
|
0.001 | 46 | 25 | viewport.Position = [0, 0, distances(3:4)];
|
| | 26 |
|
| | 27 | % Set the 'Units' to the new units, this will trigger a unit conversion.
|
< 0.001 | 46 | 28 | viewport.Units = tounits;
|
| | 29 |
|
| | 30 | % Read back the new position in the new units.
|
< 0.001 | 46 | 31 | righttop = viewport.Position;
|
| | 32 |
|
| | 33 | % Merge the outputs
|
< 0.001 | 46 | 34 | todists = [leftbottom(3:4), righttop(3:4)];
|
| | 35 |
|
< 0.001 | 46 | 36 | end
|
Other subfunctions in this file are not included in this listing.