Commit 47d41bbcef603340c2d977800dde420bc382fa33
1 parent
588694e9
Exists in
ff_mask_improv
Better FFill dialog
Showing
2 changed files
with
61 additions
and
42 deletions
Show diff stats
invesalius/data/styles.py
| @@ -1839,8 +1839,7 @@ class FloodFillMaskInteractorStyle(DefaultInteractorStyle): | @@ -1839,8 +1839,7 @@ class FloodFillMaskInteractorStyle(DefaultInteractorStyle): | ||
| 1839 | bstruct = np.zeros((3, 3, 1), dtype='uint8') | 1839 | bstruct = np.zeros((3, 3, 1), dtype='uint8') |
| 1840 | bstruct[:, :, 0] = _bstruct | 1840 | bstruct[:, :, 0] = _bstruct |
| 1841 | 1841 | ||
| 1842 | - | ||
| 1843 | - | 1842 | + print bstruct |
| 1844 | if self.config.target == '2D': | 1843 | if self.config.target == '2D': |
| 1845 | floodfill.floodfill_threshold(mask, [[x, y, z]], self.t0, self.t1, self.fill_value, bstruct, mask) | 1844 | floodfill.floodfill_threshold(mask, [[x, y, z]], self.t0, self.t1, self.fill_value, bstruct, mask) |
| 1846 | b_mask = self.viewer.slice_.buffer_slices[self.orientation].mask | 1845 | b_mask = self.viewer.slice_.buffer_slices[self.orientation].mask |
| @@ -1857,7 +1856,7 @@ class FloodFillMaskInteractorStyle(DefaultInteractorStyle): | @@ -1857,7 +1856,7 @@ class FloodFillMaskInteractorStyle(DefaultInteractorStyle): | ||
| 1857 | else: | 1856 | else: |
| 1858 | with futures.ThreadPoolExecutor(max_workers=1) as executor: | 1857 | with futures.ThreadPoolExecutor(max_workers=1) as executor: |
| 1859 | future = executor.submit(floodfill.floodfill_threshold, mask, [[x, y, z]], self.t0, self.t1, self.fill_value, bstruct, mask) | 1858 | future = executor.submit(floodfill.floodfill_threshold, mask, [[x, y, z]], self.t0, self.t1, self.fill_value, bstruct, mask) |
| 1860 | - | 1859 | + |
| 1861 | dlg = wx.ProgressDialog("Filling ...", "Doido", parent=None, style=wx.PD_APP_MODAL) | 1860 | dlg = wx.ProgressDialog("Filling ...", "Doido", parent=None, style=wx.PD_APP_MODAL) |
| 1862 | while not future.done(): | 1861 | while not future.done(): |
| 1863 | dlg.Pulse() | 1862 | dlg.Pulse() |
invesalius/gui/dialogs.py
| @@ -1851,14 +1851,11 @@ class FFillOptionsDialog(wx.Dialog): | @@ -1851,14 +1851,11 @@ class FFillOptionsDialog(wx.Dialog): | ||
| 1851 | self._init_gui() | 1851 | self._init_gui() |
| 1852 | 1852 | ||
| 1853 | def _init_gui(self): | 1853 | def _init_gui(self): |
| 1854 | - sizer = wx.GridBagSizer(5, 6) | ||
| 1855 | - | ||
| 1856 | - flag_labels = wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | ||
| 1857 | - | ||
| 1858 | - # self.target = wx.RadioBox(self, -1, "", | ||
| 1859 | - # choices=[_(u"2D - Actual slice"), _(u"3D - Entire volume")], | ||
| 1860 | - # style=wx.NO_BORDER | wx.VERTICAL) | ||
| 1861 | - self.target_2d = wx.RadioButton(self, -1, _(u"2D - Actual slice")) | 1854 | + """ |
| 1855 | + Create the widgets. | ||
| 1856 | + """ | ||
| 1857 | + # Target | ||
| 1858 | + self.target_2d = wx.RadioButton(self, -1, _(u"2D - Actual slice"), style=wx.RB_GROUP) | ||
| 1862 | self.target_3d = wx.RadioButton(self, -1, _(u"3D - All slices")) | 1859 | self.target_3d = wx.RadioButton(self, -1, _(u"3D - All slices")) |
| 1863 | 1860 | ||
| 1864 | if self.config.target == "2D": | 1861 | if self.config.target == "2D": |
| @@ -1866,54 +1863,77 @@ class FFillOptionsDialog(wx.Dialog): | @@ -1866,54 +1863,77 @@ class FFillOptionsDialog(wx.Dialog): | ||
| 1866 | else: | 1863 | else: |
| 1867 | self.target_3d.SetValue(1) | 1864 | self.target_3d.SetValue(1) |
| 1868 | 1865 | ||
| 1869 | - choices2d = ["4", "8"] | ||
| 1870 | - choices3d = ["6", "18", "26"] | ||
| 1871 | - self.conect2D = wx.RadioBox(self, -1, _(u"2D Connectivity"), choices=choices2d, style=wx.NO_BORDER | wx.HORIZONTAL) | ||
| 1872 | - self.conect3D = wx.RadioBox(self, -1, _(u"3D Connectivity"), choices=choices3d, style=wx.NO_BORDER | wx.HORIZONTAL) | 1866 | + # Connectivity 2D |
| 1867 | + self.conect2D_4 = wx.RadioButton(self, -1, "4", style=wx.RB_GROUP) | ||
| 1868 | + self.conect2D_8 = wx.RadioButton(self, -1, "8") | ||
| 1873 | 1869 | ||
| 1874 | - try: | ||
| 1875 | - self.conect2D.SetSelection(choices2d.index(str(self.config.con_2d))) | ||
| 1876 | - except ValueError: | ||
| 1877 | - print "ERROR 2D" | ||
| 1878 | - self.conect2D.SetSelection(0) | 1870 | + if self.config.con_2d == 8: |
| 1871 | + self.conect2D_8.SetValue(1) | ||
| 1872 | + else: | ||
| 1873 | + self.conect2D_4.SetValue(1) | ||
| 1879 | self.config.con_2d = 4 | 1874 | self.config.con_2d = 4 |
| 1880 | 1875 | ||
| 1881 | - try: | ||
| 1882 | - self.conect3D.SetSelection(choices3d.index(str(self.config.con_3d))) | ||
| 1883 | - except ValueError: | ||
| 1884 | - print "ERROR 3D" | ||
| 1885 | - self.conect3D.SetSelection(0) | ||
| 1886 | - self.config.con_3d = 6 | 1876 | + # Connectivity 3D |
| 1877 | + self.conect3D_6 = wx.RadioButton(self, -1, "6", style=wx.RB_GROUP) | ||
| 1878 | + self.conect3D_18 = wx.RadioButton(self, -1, "18") | ||
| 1879 | + self.conect3D_26 = wx.RadioButton(self, -1, "26") | ||
| 1880 | + | ||
| 1881 | + if self.config.con_3d == 18: | ||
| 1882 | + self.conect3D_18.SetValue(1) | ||
| 1883 | + elif self.config.con_3d == 26: | ||
| 1884 | + self.conect3D_26.SetValue(1) | ||
| 1885 | + else: | ||
| 1886 | + self.conect3D_6.SetValue(1) | ||
| 1887 | + | ||
| 1888 | + # Sizer | ||
| 1889 | + sizer = wx.GridBagSizer(11, 6) | ||
| 1890 | + sizer.AddStretchSpacer((0, 0)) | ||
| 1891 | + | ||
| 1892 | + sizer.Add(wx.StaticText(self, -1, _(u"Parameters")), (1, 0), (1, 6), flag=wx.LEFT, border=7) | ||
| 1893 | + sizer.Add(self.target_2d, (2, 0), (1, 6), flag=wx.LEFT, border=9) | ||
| 1894 | + sizer.Add(self.target_3d, (3, 0), (1, 6), flag=wx.LEFT, border=9) | ||
| 1895 | + | ||
| 1896 | + sizer.AddStretchSpacer((4, 0)) | ||
| 1887 | 1897 | ||
| 1888 | - sizer.Add(wx.StaticText(self, -1, _(u"Parameters")), (0, 0), flag=wx.TOP|wx.LEFT|wx.RIGHT, border=7) | ||
| 1889 | - sizer.AddStretchSpacer((0, 5)) | ||
| 1890 | - sizer.Add(self.target_2d, (1, 0), (1, 3), flag=wx.LEFT|wx.RIGHT, border=9) | ||
| 1891 | - sizer.Add(self.target_3d, (2, 0), (1, 3), flag=wx.LEFT|wx.RIGHT, border=9) | ||
| 1892 | - sizer.Add(self.conect2D, (3, 0), flag=wx.TOP|wx.LEFT|wx.RIGHT, border=9) | ||
| 1893 | - sizer.Add(self.conect3D, (4, 0), flag=wx.ALL, border=9) | 1898 | + sizer.Add(wx.StaticText(self, -1, _(u"2D Connectivity")), (5, 0), (1, 6), flag=wx.LEFT, border=9) |
| 1899 | + sizer.Add(self.conect2D_4, (6, 0), flag=wx.LEFT, border=9) | ||
| 1900 | + sizer.Add(self.conect2D_8, (6, 1), flag=wx.LEFT, border=9) | ||
| 1901 | + | ||
| 1902 | + sizer.AddStretchSpacer((7, 0)) | ||
| 1903 | + | ||
| 1904 | + sizer.Add(wx.StaticText(self, -1, _(u"3D Connectivity")), (8, 0), (1, 6), flag=wx.LEFT, border=9) | ||
| 1905 | + sizer.Add(self.conect3D_6, (9, 0), flag=wx.LEFT, border=9) | ||
| 1906 | + sizer.Add(self.conect3D_18, (9, 1), flag=wx.LEFT, border=9) | ||
| 1907 | + sizer.Add(self.conect3D_26, (9, 2), flag=wx.LEFT, border=9) | ||
| 1908 | + sizer.AddStretchSpacer((10, 0)) | ||
| 1894 | 1909 | ||
| 1895 | self.SetSizer(sizer) | 1910 | self.SetSizer(sizer) |
| 1896 | sizer.Fit(self) | 1911 | sizer.Fit(self) |
| 1897 | self.Layout() | 1912 | self.Layout() |
| 1898 | 1913 | ||
| 1899 | - self.Bind(wx.EVT_RADIOBUTTON, self.OnSetTarget) | ||
| 1900 | - self.conect2D.Bind(wx.EVT_RADIOBOX, self.OnSetCon2D) | ||
| 1901 | - self.conect3D.Bind(wx.EVT_RADIOBOX, self.OnSetCon3D) | 1914 | + self.Bind(wx.EVT_RADIOBUTTON, self.OnSetRadio) |
| 1902 | self.Bind(wx.EVT_CLOSE, self.OnClose) | 1915 | self.Bind(wx.EVT_CLOSE, self.OnClose) |
| 1903 | 1916 | ||
| 1904 | - def OnSetTarget(self, evt): | 1917 | + def OnSetRadio(self, evt): |
| 1918 | + # Target | ||
| 1905 | if self.target_2d.GetValue(): | 1919 | if self.target_2d.GetValue(): |
| 1906 | self.config.target = "2D" | 1920 | self.config.target = "2D" |
| 1907 | else: | 1921 | else: |
| 1908 | self.config.target = "3D" | 1922 | self.config.target = "3D" |
| 1909 | 1923 | ||
| 1910 | - def OnSetCon2D(self, evt): | ||
| 1911 | - self.config.con_2d = int(self.conect2D.GetStringSelection()) | ||
| 1912 | - print self.config.con_2d | 1924 | + # 2D |
| 1925 | + if self.conect2D_4.GetValue(): | ||
| 1926 | + self.config.con_2d = 4 | ||
| 1927 | + elif self.conect2D_8.GetValue(): | ||
| 1928 | + self.config.con_2d = 8 | ||
| 1913 | 1929 | ||
| 1914 | - def OnSetCon3D(self, evt): | ||
| 1915 | - self.config.con_3d = int(self.conect3D.GetStringSelection()) | ||
| 1916 | - print self.config.con_3d | 1930 | + # 3D |
| 1931 | + if self.conect3D_6.GetValue(): | ||
| 1932 | + self.config.con_3d = 6 | ||
| 1933 | + elif self.conect3D_18.GetValue(): | ||
| 1934 | + self.config.con_3d = 18 | ||
| 1935 | + elif self.conect3D_26.GetValue(): | ||
| 1936 | + self.config.con_3d = 26 | ||
| 1917 | 1937 | ||
| 1918 | def OnClose(self, evt): | 1938 | def OnClose(self, evt): |
| 1919 | if self.config.dlg_visible: | 1939 | if self.config.dlg_visible: |