| 1839 | } |
| 1840 | |
| 1841 | void |
| 1842 | LayoutViewFunctions::cm_align_cell_origin () |
| 1843 | { |
| 1844 | int cv_index = view ()->active_cellview_index (); |
| 1845 | if (cv_index >= 0) { |
| 1846 | |
| 1847 | const db::Cell *cell = view ()->cellview (cv_index).cell (); |
| 1848 | if (! cell) { |
| 1849 | return; |
| 1850 | } |
| 1851 | if (cell->is_proxy ()) { |
| 1852 | throw tl::Exception (tl::to_string (tr ("Cannot use this function on a PCell or library cell"))); |
| 1853 | } |
| 1854 | |
| 1855 | lay::AlignCellOptionsDialog dialog (parent_widget ()); |
| 1856 | if (dialog.exec_dialog (m_align_cell_options)) { |
| 1857 | |
| 1858 | view ()->clear_selection (); |
| 1859 | |
| 1860 | view ()->transaction (tl::to_string (tr ("Align cell origin"))); |
| 1861 | |
| 1862 | db::Box bbox; |
| 1863 | |
| 1864 | if (m_align_cell_options.visible_only) { |
| 1865 | for (lay::LayerPropertiesConstIterator l = view ()->begin_layers (); !l.at_end (); ++l) { |
| 1866 | if (! l->has_children () && l->layer_index () >= 0 && l->cellview_index () == cv_index && l->visible (true /*real*/)) { |
| 1867 | bbox += cell->bbox (l->layer_index ()); |
| 1868 | } |
| 1869 | } |
| 1870 | } else { |
| 1871 | bbox = cell->bbox (); |
| 1872 | } |
| 1873 | |
| 1874 | db::Coord refx, refy; |
| 1875 | switch (m_align_cell_options.mode_x) { |
| 1876 | case -1: |
| 1877 | refx = bbox.left (); |
| 1878 | break; |
| 1879 | case 1: |
| 1880 | refx = bbox.right (); |
| 1881 | break; |
| 1882 | default: |
| 1883 | refx = bbox.center ().x (); |
| 1884 | break; |
| 1885 | } |
| 1886 | switch (m_align_cell_options.mode_y) { |
| 1887 | case -1: |
| 1888 | refy = bbox.bottom (); |
| 1889 | break; |
| 1890 | case 1: |
| 1891 | refy = bbox.top (); |
| 1892 | break; |
| 1893 | default: |
| 1894 | refy = bbox.center ().y (); |
| 1895 | break; |
| 1896 | } |
| 1897 | |
| 1898 | db::Layout &layout = view ()->cellview (cv_index)->layout (); |
nothing calls this directly
no test coverage detected