Change 'Zoom to Fit' margins and add 'Zoom to Objects'
CHANGED: The margin used in 'Zoom to Fit' is now 2% instead of 10%. ADDED: Added 'Zoom to Objects' to Eeschema which does not include the page and border in the bbox calculations. CHANGED: Removed pre-existing code that tweaked the center to account for the scrollbars. It actually made the view off center. Removing it results in perfectly centered zooms. Fixes https://gitlab.com/kicad/code/kicad/issues/5145
This commit is contained in:
parent
43ab963650
commit
abdd1906c2
|
@ -58,7 +58,7 @@ option( MAINTAIN_PNGS
|
|||
# SMALL - for menus - 16 x 16
|
||||
# MID - for toolbars - 26 x 26
|
||||
# BIG - for program icons - 48 x 48
|
||||
# which are given on three basename lists: BMAPS_SMALL, BMAPS_MID,a nd BMAPS_BIG
|
||||
# which are given on three basename lists: BMAPS_SMALL, BMAPS_MID,and BMAPS_BIG
|
||||
# respectively. The basename is without file extension and without path.
|
||||
# A corresponding ${basename}.svg file must exist in 'sources' dir below here.
|
||||
|
||||
|
@ -508,6 +508,7 @@ set( BMAPS_MID
|
|||
zoom_area
|
||||
zoom_auto_fit_in_page
|
||||
zoom_fit_in_page
|
||||
zoom_fit_to_objects
|
||||
zoom_center_on_screen
|
||||
zoom_in
|
||||
zoom_out
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
|
||||
/* Do not modify this file, it was automatically generated by the
|
||||
* PNG2cpp CMake script, using a *.png file as input.
|
||||
*/
|
||||
|
||||
#include <bitmaps_png/bitmaps_list.h>
|
||||
|
||||
static const unsigned char png[] = {
|
||||
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
|
||||
0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x1a, 0x08, 0x04, 0x00, 0x00, 0x00, 0x03, 0x43, 0x84,
|
||||
0x45, 0x00, 0x00, 0x02, 0x29, 0x49, 0x44, 0x41, 0x54, 0x38, 0xcb, 0xd5, 0x94, 0xc1, 0x6f, 0x12,
|
||||
0x41, 0x14, 0xc6, 0x37, 0x31, 0x5e, 0xb4, 0xa5, 0x5e, 0xf8, 0x17, 0x5a, 0xef, 0x93, 0x62, 0x04,
|
||||
0x8c, 0x97, 0x26, 0xa4, 0x91, 0x84, 0x80, 0xb1, 0x37, 0x7a, 0x72, 0x5d, 0xbd, 0x78, 0x20, 0x31,
|
||||
0x1e, 0x5c, 0xf4, 0xd6, 0xea, 0x6d, 0x6d, 0x57, 0x84, 0x26, 0x55, 0xd3, 0x78, 0x28, 0x85, 0xb6,
|
||||
0x1a, 0x96, 0x18, 0x12, 0x83, 0x46, 0x4c, 0x49, 0x04, 0xd3, 0x66, 0xb9, 0x40, 0xcf, 0xd6, 0xad,
|
||||
0x3d, 0x58, 0x20, 0xa1, 0x97, 0x4d, 0xe7, 0x73, 0x66, 0xa1, 0x48, 0xcb, 0x56, 0xf1, 0xe8, 0x7e,
|
||||
0x97, 0xdd, 0xc9, 0xfc, 0xf6, 0xbd, 0xf7, 0xbd, 0x37, 0x23, 0x08, 0xff, 0xe3, 0x83, 0x21, 0x5c,
|
||||
0x64, 0x3a, 0x3f, 0xe8, 0xf6, 0x91, 0xd4, 0xaa, 0xb2, 0x1b, 0x35, 0x45, 0x88, 0x88, 0x9a, 0x8a,
|
||||
0xb1, 0x92, 0x86, 0xe3, 0x2f, 0xc8, 0xdb, 0x47, 0x33, 0x07, 0x6e, 0x10, 0x78, 0x70, 0x9d, 0xa9,
|
||||
0xfd, 0x36, 0xdb, 0x5a, 0x97, 0xff, 0x80, 0x24, 0x5f, 0x87, 0x29, 0xc1, 0x1d, 0x1a, 0xaf, 0x66,
|
||||
0x55, 0x3d, 0xa0, 0x07, 0xb4, 0x58, 0xa2, 0x2a, 0xb1, 0x95, 0x30, 0x5d, 0x5e, 0x3a, 0x35, 0x4a,
|
||||
0x98, 0xba, 0xf0, 0x6c, 0xbf, 0x38, 0xd1, 0xbb, 0xba, 0xe1, 0x53, 0xeb, 0x2e, 0x4c, 0x53, 0xdb,
|
||||
0x68, 0x18, 0x99, 0x39, 0x20, 0x50, 0xf7, 0xe5, 0xdc, 0xbd, 0x9f, 0xc7, 0x25, 0xe7, 0xd4, 0x3a,
|
||||
0x61, 0x49, 0xda, 0xd4, 0xb6, 0xb2, 0xea, 0xc6, 0x6d, 0x5a, 0x9c, 0x88, 0x34, 0x34, 0x94, 0x90,
|
||||
0x67, 0xfa, 0x88, 0x32, 0x93, 0x86, 0x48, 0xa3, 0x38, 0x29, 0x51, 0x0f, 0x52, 0xa9, 0x3e, 0x48,
|
||||
0xd9, 0x25, 0x88, 0x57, 0x05, 0x21, 0xd2, 0xd8, 0xc2, 0x37, 0x66, 0x00, 0xc1, 0x15, 0x34, 0x99,
|
||||
0xb6, 0x18, 0x24, 0x08, 0x89, 0x1a, 0xc1, 0x53, 0xe3, 0x64, 0x72, 0xc3, 0xb2, 0xe9, 0x45, 0x66,
|
||||
0xbe, 0x0d, 0xed, 0xe0, 0x2a, 0xbc, 0xb8, 0x86, 0x6d, 0xac, 0xe1, 0xbd, 0x05, 0x65, 0x62, 0x1e,
|
||||
0xd6, 0x80, 0x13, 0x7d, 0xc3, 0x98, 0x48, 0x43, 0xd0, 0x03, 0x6d, 0xa8, 0xd9, 0xd1, 0x1a, 0x8b,
|
||||
0x17, 0xb7, 0xa0, 0x4a, 0x28, 0x88, 0x5b, 0x14, 0xa3, 0xc7, 0xa1, 0x51, 0x91, 0x06, 0x51, 0x09,
|
||||
0x72, 0x68, 0x13, 0x85, 0x8e, 0xf4, 0x6e, 0xa4, 0xcd, 0x1b, 0x41, 0x88, 0x7d, 0xd0, 0x10, 0x4f,
|
||||
0x4f, 0xb3, 0xd2, 0x2b, 0x59, 0x15, 0x71, 0x95, 0xbb, 0x35, 0x65, 0x62, 0x6e, 0xc8, 0x66, 0x9f,
|
||||
0x7f, 0xdc, 0x88, 0x85, 0x1a, 0x87, 0xca, 0x18, 0xef, 0xe8, 0xeb, 0x6f, 0x23, 0xb6, 0x09, 0x14,
|
||||
0xa3, 0xdf, 0xf2, 0xb4, 0x07, 0x12, 0xdd, 0xf0, 0x71, 0xcb, 0xcb, 0x3d, 0xe2, 0x96, 0x17, 0xfc,
|
||||
0xd2, 0xa1, 0x17, 0xe9, 0x64, 0x7f, 0x73, 0x1d, 0xb3, 0x2d, 0x82, 0x79, 0x9b, 0xe6, 0x46, 0x73,
|
||||
0x73, 0x4d, 0x82, 0x27, 0x2d, 0x5c, 0xb0, 0x99, 0x89, 0x75, 0x99, 0x8f, 0x91, 0x5a, 0xff, 0x3c,
|
||||
0xd9, 0xbb, 0x5a, 0xf0, 0xcf, 0x35, 0x5d, 0xb8, 0x84, 0x6c, 0xe9, 0x94, 0xe9, 0x5b, 0x5e, 0x9a,
|
||||
0x66, 0xe3, 0x29, 0xd1, 0x44, 0x35, 0xfb, 0x5c, 0x0f, 0x54, 0x82, 0x5a, 0x7c, 0xa1, 0x26, 0x1d,
|
||||
0x12, 0x86, 0x10, 0x4c, 0x51, 0xed, 0xd3, 0x87, 0xfb, 0x38, 0x6b, 0x83, 0xbd, 0x79, 0xf0, 0xb8,
|
||||
0xe5, 0x61, 0x5b, 0xdc, 0x08, 0x31, 0xf1, 0xa3, 0xe1, 0x65, 0x89, 0xbd, 0xfb, 0x32, 0xc5, 0x7e,
|
||||
0x36, 0x0e, 0x1f, 0x5e, 0x7d, 0x37, 0x9c, 0x76, 0x83, 0xeb, 0x48, 0xa5, 0x14, 0xe3, 0xa1, 0x29,
|
||||
0xd2, 0x9b, 0x54, 0x66, 0x87, 0x30, 0x9d, 0xe4, 0xb5, 0x64, 0xf2, 0x97, 0xad, 0x26, 0xb8, 0xb0,
|
||||
0xb8, 0x67, 0x8b, 0x59, 0xe8, 0x39, 0x8c, 0xb1, 0xe3, 0x3e, 0x7c, 0xf4, 0x9d, 0xbf, 0xeb, 0xef,
|
||||
0xf4, 0x8e, 0x63, 0x83, 0x5e, 0x02, 0x67, 0x5e, 0xee, 0xb8, 0xba, 0xd8, 0xc0, 0x57, 0x8d, 0xe1,
|
||||
0x5c, 0xdc, 0x3b, 0xc2, 0xfe, 0xe1, 0x86, 0x32, 0x9c, 0x2f, 0x7e, 0xb4, 0xb1, 0x5f, 0xc5, 0xd8,
|
||||
0xb1, 0x0b, 0xd5, 0xd8, 0x0b, 0x57, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42,
|
||||
0x60, 0x82,
|
||||
};
|
||||
|
||||
const BITMAP_OPAQUE zoom_fit_to_objects_xpm[1] = {{ png, sizeof( png ), "zoom_fit_to_objects_xpm" }};
|
||||
|
||||
//EOF
|
|
@ -500,6 +500,7 @@ EXTERN_BITMAP( zoom_auto_fit_in_page_xpm )
|
|||
EXTERN_BITMAP( zoom_center_on_screen_xpm )
|
||||
EXTERN_BITMAP( zoom_redraw_xpm )
|
||||
EXTERN_BITMAP( zoom_fit_in_page_xpm )
|
||||
EXTERN_BITMAP( zoom_fit_to_objects_xpm )
|
||||
EXTERN_BITMAP( zoom_in_xpm )
|
||||
EXTERN_BITMAP( zoom_out_xpm )
|
||||
EXTERN_BITMAP( zoom_page_xpm )
|
||||
|
|
|
@ -0,0 +1,208 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="26"
|
||||
height="26"
|
||||
id="svg2"
|
||||
sodipodi:version="0.32"
|
||||
inkscape:version="1.0 (4035a4fb49, 2020-05-01)"
|
||||
version="1.0"
|
||||
sodipodi:docname="zoom_fit_to_objects.svg"
|
||||
inkscape:output_extension="org.inkscape.output.svg.inkscape">
|
||||
<defs
|
||||
id="defs4">
|
||||
<linearGradient
|
||||
id="StandardGradient"
|
||||
gradientTransform="scale(1.0003344,0.9996657)"
|
||||
x1="10.558969"
|
||||
y1="3.0148761"
|
||||
x2="10.558969"
|
||||
y2="19.285688"
|
||||
gradientUnits="userSpaceOnUse">
|
||||
<stop
|
||||
id="stop3309"
|
||||
offset="0"
|
||||
style="stop-color:#000000;stop-opacity:0.86274511;" />
|
||||
<stop
|
||||
style="stop-color:#000000;stop-opacity:0.47058824;"
|
||||
offset="1"
|
||||
id="stop3311" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#StandardGradient"
|
||||
id="linearGradient3031"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(1.2478294,0,0,1.18389,0.28239592,-4.4878088)"
|
||||
x1="10.558969"
|
||||
y1="3.0148761"
|
||||
x2="10.558969"
|
||||
y2="19.285688" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#9a9a9a"
|
||||
borderopacity="1"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="29.751908"
|
||||
inkscape:cx="16.152149"
|
||||
inkscape:cy="16.152149"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="g8133"
|
||||
showgrid="true"
|
||||
inkscape:showpageshadow="false"
|
||||
showguides="true"
|
||||
inkscape:guide-bbox="true"
|
||||
inkscape:window-width="1375"
|
||||
inkscape:window-height="967"
|
||||
inkscape:window-x="1932"
|
||||
inkscape:window-y="10"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:snap-to-guides="true"
|
||||
inkscape:snap-grids="true"
|
||||
inkscape:document-rotation="0">
|
||||
<sodipodi:guide
|
||||
orientation="0,1"
|
||||
position="26.278146,128"
|
||||
id="guide2385"
|
||||
inkscape:locked="false" />
|
||||
<sodipodi:guide
|
||||
orientation="1,0"
|
||||
position="128,54.082119"
|
||||
id="guide2387"
|
||||
inkscape:locked="false" />
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid3672"
|
||||
visible="true"
|
||||
enabled="true"
|
||||
empspacing="2"
|
||||
snapvisiblegridlinesonly="true" />
|
||||
<sodipodi:guide
|
||||
orientation="0.70710678,0.70710678"
|
||||
position="26,0"
|
||||
id="guide3780"
|
||||
inkscape:locked="false" />
|
||||
<sodipodi:guide
|
||||
orientation="-0.70710678,0.70710678"
|
||||
position="26,26"
|
||||
id="guide3824"
|
||||
inkscape:locked="false" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
<cc:license
|
||||
rdf:resource="http://creativecommons.org/licenses/by-sa/4.0/" />
|
||||
</cc:Work>
|
||||
<cc:License
|
||||
rdf:about="http://creativecommons.org/licenses/by-sa/4.0/">
|
||||
<cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#Reproduction" />
|
||||
<cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#Distribution" />
|
||||
<cc:requires
|
||||
rdf:resource="http://creativecommons.org/ns#Notice" />
|
||||
<cc:requires
|
||||
rdf:resource="http://creativecommons.org/ns#Attribution" />
|
||||
<cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
|
||||
<cc:requires
|
||||
rdf:resource="http://creativecommons.org/ns#ShareAlike" />
|
||||
</cc:License>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="layer3"
|
||||
inkscape:label="Cross"
|
||||
style="display:inline"
|
||||
transform="translate(0,4)">
|
||||
<rect
|
||||
style="fill:#f2f2f2;fill-opacity:1;stroke:#666666;stroke-width:0.94;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:3;stroke-opacity:1"
|
||||
id="rect3869"
|
||||
width="8.46"
|
||||
height="8.46"
|
||||
x="8.7700005"
|
||||
y="4.77" />
|
||||
<path
|
||||
sodipodi:type="arc"
|
||||
style="fill:none;stroke:#333333;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
id="path3766"
|
||||
sodipodi:cx="10"
|
||||
sodipodi:cy="10"
|
||||
sodipodi:rx="8"
|
||||
sodipodi:ry="8"
|
||||
d="m 18,10 a 8,8 0 0 1 -8,8 8,8 0 0 1 -8,-8 8,8 0 0 1 8,-8 8,8 0 0 1 8,8 z"
|
||||
transform="translate(3,-1)" />
|
||||
<path
|
||||
style="fill:none;stroke:#333333;stroke-width:2.4;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
d="m 19,19 3,3"
|
||||
id="path3782"
|
||||
inkscape:connector-curvature="0"
|
||||
transform="translate(0,-4)"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
transform="translate(0,-4)"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path3784"
|
||||
d="M 26,26 22,22"
|
||||
style="fill:none;stroke:#333333;stroke-width:4.4;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
sodipodi:nodetypes="cc" />
|
||||
</g>
|
||||
<g
|
||||
transform="translate(0,4)"
|
||||
style="display:inline"
|
||||
inkscape:label="Display"
|
||||
id="g8133"
|
||||
inkscape:groupmode="layer">
|
||||
<rect
|
||||
y="4.77"
|
||||
x="8.7700005"
|
||||
height="8.46"
|
||||
width="8.46"
|
||||
id="rect8125"
|
||||
style="fill:#f2f2f2;fill-opacity:1;stroke:#666666;stroke-width:0.94;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:3;stroke-opacity:1" />
|
||||
<path
|
||||
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#333333;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:0.4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
d="M 13 4 C 8.0412819 4 4 8.0412819 4 13 C 4 17.958718 8.0412819 22 13 22 C 15.04799 22 16.934285 21.303147 18.449219 20.144531 L 19.830078 21.525391 A 2.20022 2.20022 0 0 0 20.445312 23.554688 L 24.445312 27.554688 A 2.20022 2.20022 0 1 0 27.554688 24.445312 L 23.554688 20.445312 A 2.20022 2.20022 0 0 0 21.976562 19.777344 A 2.20022 2.20022 0 0 0 21.521484 19.826172 L 20.144531 18.449219 C 21.303147 16.934285 22 15.04799 22 13 C 22 8.0412819 17.958718 4 13 4 z M 13 6 C 16.877838 6 20 9.1221621 20 13 C 20 16.877838 16.877838 20 13 20 C 9.1221621 20 6 16.877838 6 13 C 6 9.1221621 9.1221621 6 13 6 z "
|
||||
transform="translate(0,-4)"
|
||||
id="path8127" />
|
||||
<rect
|
||||
style="fill:#333333;fill-opacity:1;stroke:#333333;stroke-opacity:1"
|
||||
id="rect1195"
|
||||
width="2"
|
||||
height="1"
|
||||
x="11.426549"
|
||||
y="6.4141593" />
|
||||
<rect
|
||||
y="8"
|
||||
x="15"
|
||||
height="1"
|
||||
width="1"
|
||||
id="rect1195-6"
|
||||
style="display:inline;fill:#333333;fill-opacity:1;stroke:#333333;stroke-width:0.707107;stroke-opacity:1" />
|
||||
<rect
|
||||
y="10.368141"
|
||||
x="10.585841"
|
||||
height="1"
|
||||
width="3"
|
||||
id="rect1195-4"
|
||||
style="display:inline;fill:#333333;fill-opacity:1;stroke:#333333;stroke-width:1.22474;stroke-opacity:1" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 8.4 KiB |
|
@ -259,6 +259,11 @@ TOOL_ACTION ACTIONS::zoomFitScreen( "common.Control.zoomFitScreen",
|
|||
_( "Zoom to Fit" ), _( "Zoom to Fit" ),
|
||||
zoom_fit_in_page_xpm );
|
||||
|
||||
TOOL_ACTION ACTIONS::zoomFitObjects( "common.Control.zoomFitObjects",
|
||||
AS_GLOBAL, MD_CTRL + WXK_HOME, "",
|
||||
_( "Zoom to Objects" ), _( "Zoom to Objects" ),
|
||||
zoom_fit_to_objects_xpm );
|
||||
|
||||
TOOL_ACTION ACTIONS::zoomIn( "common.Control.zoomIn",
|
||||
AS_GLOBAL,
|
||||
#if defined( __WXMAC__ )
|
||||
|
|
|
@ -250,7 +250,19 @@ int COMMON_TOOLS::ZoomCenter( const TOOL_EVENT& aEvent )
|
|||
|
||||
int COMMON_TOOLS::ZoomFitScreen( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
KIGFX::VIEW* view = getView();
|
||||
return doZoomFit( ZOOM_FIT_ALL );
|
||||
}
|
||||
|
||||
|
||||
int COMMON_TOOLS::ZoomFitObjects( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
return doZoomFit( ZOOM_FIT_OBJECTS );
|
||||
}
|
||||
|
||||
|
||||
int COMMON_TOOLS::doZoomFit( ZOOM_FIT_TYPE_T aFitType )
|
||||
{
|
||||
KIGFX::VIEW* view = getView();
|
||||
EDA_DRAW_PANEL_GAL* canvas = m_frame->GetCanvas();
|
||||
EDA_DRAW_FRAME* frame = getEditFrame<EDA_DRAW_FRAME>();
|
||||
|
||||
|
@ -258,11 +270,24 @@ int COMMON_TOOLS::ZoomFitScreen( const TOOL_EVENT& aEvent )
|
|||
BOX2I defaultBox = canvas->GetDefaultViewBBox();
|
||||
VECTOR2D scrollbarSize = VECTOR2D( canvas->GetSize() - canvas->GetClientSize() );
|
||||
|
||||
view->SetScale( 1.0 ); // the best scale will be fixed later, from this initial value
|
||||
// but this call ensure all view parameters are up to date
|
||||
// especially at init time
|
||||
view->SetScale( 1.0 ); // The best scale will be determined later, but this initial
|
||||
// value ensures all view parameters are up to date (especially
|
||||
// at init time)
|
||||
VECTOR2D screenSize = view->ToWorld( canvas->GetClientSize(), false );
|
||||
|
||||
// Currently "Zoom to Objects" is only supported on Eeschema. Support for other
|
||||
// programs in the suite can be added as needed.
|
||||
|
||||
if( aFitType == ZOOM_FIT_OBJECTS )
|
||||
{
|
||||
if( frame->IsType( FRAME_SCH ) )
|
||||
bBox = view->GetItemsExtents(); // Get a BBox of all items except page and border
|
||||
else
|
||||
aFitType = ZOOM_FIT_ALL; // Just do a "Zoom to Fit" for unsupported editors
|
||||
}
|
||||
|
||||
// If the screen is empty then use the default view bbox
|
||||
|
||||
if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 )
|
||||
bBox = defaultBox;
|
||||
|
||||
|
@ -270,27 +295,37 @@ int COMMON_TOOLS::ZoomFitScreen( const TOOL_EVENT& aEvent )
|
|||
double scale = view->GetScale() / std::max( fabs( vsize.x / screenSize.x ),
|
||||
fabs( vsize.y / screenSize.y ) );
|
||||
|
||||
// Reserve a 10% margin around component bounding box.
|
||||
double margin_scale_factor = 1.1;
|
||||
// Reserve a 2% margin around bounding boxes.
|
||||
double margin_scale_factor = 1.02;
|
||||
|
||||
// Leave a bigger margin for library editors & viewers
|
||||
if( frame->IsType( FRAME_FOOTPRINT_VIEWER ) || frame->IsType( FRAME_FOOTPRINT_VIEWER_MODAL )
|
||||
|| frame->IsType( FRAME_SCH_VIEWER ) || frame->IsType( FRAME_SCH_VIEWER_MODAL ) )
|
||||
switch( aFitType )
|
||||
{
|
||||
margin_scale_factor = 1.4;
|
||||
}
|
||||
else if( frame->IsType( FRAME_SCH_LIB_EDITOR ) || frame->IsType( FRAME_FOOTPRINT_EDITOR ) )
|
||||
{
|
||||
margin_scale_factor = 2;
|
||||
case ZOOM_FIT_ALL:
|
||||
// Leave a bigger margin for library editors & viewers
|
||||
|
||||
if( frame->IsType( FRAME_FOOTPRINT_VIEWER ) || frame->IsType( FRAME_FOOTPRINT_VIEWER_MODAL )
|
||||
|| frame->IsType( FRAME_SCH_VIEWER ) || frame->IsType( FRAME_SCH_VIEWER_MODAL ) )
|
||||
{
|
||||
margin_scale_factor = 1.4;
|
||||
}
|
||||
else if( frame->IsType( FRAME_SCH_LIB_EDITOR ) || frame->IsType( FRAME_FOOTPRINT_EDITOR ) )
|
||||
{
|
||||
margin_scale_factor = 2;
|
||||
}
|
||||
break;
|
||||
|
||||
// Currently the same value as "ZOOM_FIT_ALL" but allows easy expansion/change in the future.
|
||||
case ZOOM_FIT_OBJECTS:
|
||||
margin_scale_factor = 1.02; // Reserve a 2% margin around bounding box.
|
||||
break;
|
||||
|
||||
default:
|
||||
margin_scale_factor = 1.02;
|
||||
}
|
||||
|
||||
view->SetScale( scale / margin_scale_factor );
|
||||
view->SetCenter( bBox.Centre() );
|
||||
|
||||
// Take scrollbars into account
|
||||
VECTOR2D worldScrollbarSize = view->ToWorld( scrollbarSize, false );
|
||||
view->SetCenter( view->GetCenter() + worldScrollbarSize / 2.0 );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -565,6 +600,7 @@ void COMMON_TOOLS::setTransitions()
|
|||
Go( &COMMON_TOOLS::ZoomInOutCenter, ACTIONS::zoomOutCenter.MakeEvent() );
|
||||
Go( &COMMON_TOOLS::ZoomCenter, ACTIONS::zoomCenter.MakeEvent() );
|
||||
Go( &COMMON_TOOLS::ZoomFitScreen, ACTIONS::zoomFitScreen.MakeEvent() );
|
||||
Go( &COMMON_TOOLS::ZoomFitObjects, ACTIONS::zoomFitObjects.MakeEvent() );
|
||||
Go( &COMMON_TOOLS::ZoomPreset, ACTIONS::zoomPreset.MakeEvent() );
|
||||
Go( &COMMON_TOOLS::CenterContents, ACTIONS::centerContents.MakeEvent() );
|
||||
|
||||
|
|
|
@ -1591,4 +1591,10 @@ void VIEW::ShowPreview( bool aShow )
|
|||
|
||||
const int VIEW::TOP_LAYER_MODIFIER = -VIEW_MAX_LAYERS;
|
||||
|
||||
const BOX2I VIEW::GetItemsExtents() const
|
||||
{
|
||||
// To be implemented by subclasses.
|
||||
return BOX2I();
|
||||
}
|
||||
|
||||
} // namespace KIGFX
|
||||
|
|
|
@ -167,6 +167,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
|
|||
viewMenu->Add( ACTIONS::zoomInCenter );
|
||||
viewMenu->Add( ACTIONS::zoomOutCenter );
|
||||
viewMenu->Add( ACTIONS::zoomFitScreen );
|
||||
viewMenu->Add( ACTIONS::zoomFitObjects );
|
||||
viewMenu->Add( ACTIONS::zoomTool );
|
||||
viewMenu->Add( ACTIONS::zoomRedraw );
|
||||
|
||||
|
|
|
@ -80,6 +80,20 @@ void SCH_VIEW::SetScale( double aScale, VECTOR2D aAnchor )
|
|||
}
|
||||
|
||||
|
||||
const BOX2I SCH_VIEW::GetItemsExtents() const
|
||||
{
|
||||
// Calc the bounding box of all items on screen except the page border
|
||||
EDA_RECT bBoxItems;
|
||||
|
||||
for( EDA_ITEM* item : m_frame->GetScreen()->Items() )
|
||||
{
|
||||
if( item != m_worksheet.get() )
|
||||
bBoxItems.Merge( item->GetBoundingBox() );
|
||||
}
|
||||
|
||||
return bBoxItems;
|
||||
}
|
||||
|
||||
void SCH_VIEW::ResizeSheetWorkingArea( SCH_SCREEN* aScreen )
|
||||
{
|
||||
const PAGE_INFO& page_info = aScreen->GetPageSettings();
|
||||
|
|
|
@ -88,6 +88,12 @@ public:
|
|||
|
||||
void SetScale( double aScale, VECTOR2D aAnchor = { 0, 0 } ) override;
|
||||
|
||||
/**
|
||||
* Return BBox of all items on screen except page and border
|
||||
*/
|
||||
const BOX2I GetItemsExtents() const override;
|
||||
|
||||
|
||||
/**
|
||||
* Clear the hide flag of all items in the view
|
||||
*/
|
||||
|
|
|
@ -78,6 +78,7 @@ void SCH_EDIT_FRAME::ReCreateHToolbar()
|
|||
m_mainToolBar->Add( ACTIONS::zoomInCenter );
|
||||
m_mainToolBar->Add( ACTIONS::zoomOutCenter );
|
||||
m_mainToolBar->Add( ACTIONS::zoomFitScreen );
|
||||
m_mainToolBar->Add( ACTIONS::zoomFitObjects );
|
||||
m_mainToolBar->Add( ACTIONS::zoomTool, ACTION_TOOLBAR::TOGGLE, ACTION_TOOLBAR::CANCEL );
|
||||
|
||||
m_mainToolBar->AddScaledSeparator( this );
|
||||
|
|
|
@ -92,6 +92,7 @@ public:
|
|||
static TOOL_ACTION zoomOutCenter;
|
||||
static TOOL_ACTION zoomCenter;
|
||||
static TOOL_ACTION zoomFitScreen;
|
||||
static TOOL_ACTION zoomFitObjects; // Zooms to bbox of items on screen (except page border)
|
||||
static TOOL_ACTION zoomPreset;
|
||||
static TOOL_ACTION zoomTool;
|
||||
static TOOL_ACTION centerContents;
|
||||
|
|
|
@ -56,6 +56,7 @@ public:
|
|||
int ZoomInOutCenter( const TOOL_EVENT& aEvent );
|
||||
int ZoomCenter( const TOOL_EVENT& aEvent );
|
||||
int ZoomFitScreen( const TOOL_EVENT& aEvent );
|
||||
int ZoomFitObjects( const TOOL_EVENT& aEvent );
|
||||
int ZoomPreset( const TOOL_EVENT& aEvent );
|
||||
|
||||
int CenterContents( const TOOL_EVENT& aEvent );
|
||||
|
@ -88,6 +89,16 @@ public:
|
|||
int SwitchCanvas( const TOOL_EVENT& aEvent );
|
||||
|
||||
private:
|
||||
/**
|
||||
* Enum ZOOM_FIT_TYPE_T
|
||||
* is the set of "Zoom to Fit" types that can be performed
|
||||
*/
|
||||
enum ZOOM_FIT_TYPE_T
|
||||
{
|
||||
ZOOM_FIT_ALL, // Zoom to fall all items in view INCLUDING page and border
|
||||
ZOOM_FIT_OBJECTS, // Zoom to fit all items in view EXCLUDING page and border
|
||||
};
|
||||
|
||||
///> Sets up handlers for various events.
|
||||
void setTransitions() override;
|
||||
|
||||
|
@ -99,6 +110,8 @@ private:
|
|||
///> Note: idx == 0 is Auto; idx == 1 is first entry in zoomList
|
||||
int doZoomToPreset( int idx, bool aCenterOnCursor );
|
||||
|
||||
int doZoomFit( ZOOM_FIT_TYPE_T aFitType );
|
||||
|
||||
std::vector<VECTOR2I> m_grids; // grids from APP_SETTINGS converted to internal units
|
||||
// and with the user grid appended
|
||||
};
|
||||
|
|
|
@ -289,6 +289,11 @@ public:
|
|||
return m_boundary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return BBox of all items on screen except page and border
|
||||
*/
|
||||
virtual const BOX2I GetItemsExtents() const;
|
||||
|
||||
/**
|
||||
* Function SetScaleLimits()
|
||||
* Sets minimum and maximum values for scale.
|
||||
|
|
Loading…
Reference in New Issue