MCPcopy Create free account
hub / github.com/KLayout/klayout / icon_for_layer

Method icon_for_layer

src/laybasic/laybasic/layLayoutViewBase.cc:1722–1888  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1720}
1721
1722tl::PixelBuffer
1723LayoutViewBase::icon_for_layer (const LayerPropertiesConstIterator &iter, unsigned int w, unsigned int h, double dpr, unsigned int di_off, bool no_state)
1724{
1725 if (dpr < 0.0) {
1726 dpr = canvas () ? canvas ()->dpr () : 1.0;
1727 }
1728
1729 double gamma = canvas () ? canvas ()->gamma () : 2.0;
1730 double dpr_drawing = canvas () ? 1.0 / canvas ()->resolution () : 1.0;
1731 unsigned int oversampling = canvas () ? canvas ()->oversampling () : 1;
1732
1733 h = std::max ((unsigned int) 16, h) * oversampling * dpr + 0.5;
1734 w = std::max ((unsigned int) 16, w) * oversampling * dpr + 0.5;
1735
1736 tl::color_t def_color = 0x808080;
1737 tl::color_t fill_color = iter->has_fill_color (true) ? iter->eff_fill_color (true) : def_color;
1738 tl::color_t frame_color = iter->has_frame_color (true) ? iter->eff_frame_color (true) : def_color;
1739
1740 tl::PixelBuffer image (w, h);
1741 image.set_transparent (true);
1742 image.fill (background_color ().rgb ());
1743
1744 // upper scanline is a dummy one
1745 tl::color_t *sl0 = (uint32_t *) image.scan_line (0);
1746 for (size_t i = 0; i < w; ++i) {
1747 *sl0++ = 0;
1748 }
1749
1750 lay::Bitmap fill (w, h, 1.0, 1.0);
1751 lay::Bitmap frame (w, h, 1.0, 1.0);
1752 lay::Bitmap text (w, h, 1.0, 1.0);
1753 lay::Bitmap vertex (w, h, 1.0, 1.0);
1754
1755 unsigned int wp = w - 1;
1756
1757 if (! no_state && ! iter->visible (true)) {
1758
1759 wp = w / 4;
1760
1761 // Show the arrow if it is invisible also locally.
1762 if (! iter->visible (false)) {
1763
1764 unsigned int aw = h / 4;
1765 unsigned int ap = w / 2 - 1;
1766 for (unsigned int i = 0; i <= aw; ++i) {
1767 text.fill (h / 2 - 1 - i, ap, ap + aw - i + 1);
1768 text.fill (h / 2 - 1 + i, ap, ap + aw - i + 1);
1769 }
1770
1771 }
1772
1773 }
1774
1775 if (! no_state && no_stipples ()) {
1776 // Show a partial stipple pattern only for "no stipple" mode
1777 for (unsigned int i = 1; i < h - 2; ++i) {
1778 fill.fill (i, w - 1 - w / 4, w);
1779 }

Callers

nothing calls this directly

Calls 15

canvasFunction · 0.85
maxFunction · 0.85
no_stipplesFunction · 0.85
minFunction · 0.85
single_bitmap_to_imageFunction · 0.85
dither_patternFunction · 0.85
dprMethod · 0.80
eff_fill_colorMethod · 0.80
eff_frame_colorMethod · 0.80
scan_lineMethod · 0.80
visibleMethod · 0.80
validMethod · 0.80

Tested by

no test coverage detected