Commit 5cc84dd2df654ff86432b3e142c4ab52fdedfcbb
1 parent
1e33187c
Exists in
ff_mask
Split the the fill and remove in 2 interaction styles
Showing
3 changed files
with
18 additions
and
11 deletions
Show diff stats
invesalius/constants.py
... | ... | @@ -501,6 +501,7 @@ SLICE_STATE_EDITOR = 3008 |
501 | 501 | SLICE_STATE_WATERSHED = 3009 |
502 | 502 | SLICE_STATE_REORIENT = 3010 |
503 | 503 | SLICE_STATE_MASK_FFILL = 3011 |
504 | +SLICE_STATE_REMOVE_MASK_PARTS = 3012 | |
504 | 505 | |
505 | 506 | VOLUME_STATE_SEED = 2001 |
506 | 507 | # STATE_LINEAR_MEASURE = 3001 |
... | ... | @@ -519,6 +520,7 @@ SLICE_STYLES.append(STATE_DEFAULT) |
519 | 520 | SLICE_STYLES.append(SLICE_STATE_EDITOR) |
520 | 521 | SLICE_STYLES.append(SLICE_STATE_WATERSHED) |
521 | 522 | SLICE_STYLES.append(SLICE_STATE_MASK_FFILL) |
523 | +SLICE_STYLES.append(SLICE_STATE_REMOVE_MASK_PARTS) | |
522 | 524 | |
523 | 525 | VOLUME_STYLES = TOOL_STATES + [VOLUME_STATE_SEED, STATE_MEASURE_DISTANCE, |
524 | 526 | STATE_MEASURE_ANGLE] |
... | ... | @@ -528,6 +530,7 @@ VOLUME_STYLES.append(STATE_DEFAULT) |
528 | 530 | STYLE_LEVEL = {SLICE_STATE_EDITOR: 1, |
529 | 531 | SLICE_STATE_WATERSHED: 1, |
530 | 532 | SLICE_STATE_MASK_FFILL: 2, |
533 | + SLICE_STATE_REMOVE_MASK_PARTS: 2, | |
531 | 534 | SLICE_STATE_CROSS: 2, |
532 | 535 | SLICE_STATE_SCROLL: 2, |
533 | 536 | SLICE_STATE_REORIENT: 2, | ... | ... |
invesalius/data/styles.py
... | ... | @@ -1774,6 +1774,10 @@ class FloodFillMaskInteractorStyle(DefaultInteractorStyle): |
1774 | 1774 | self.config = FFillConfig() |
1775 | 1775 | self.dlg_ffill = None |
1776 | 1776 | |
1777 | + self.t0 = 0 | |
1778 | + self.t1 = 1 | |
1779 | + self.fill_value = 254 | |
1780 | + | |
1777 | 1781 | self.AddObserver("LeftButtonPressEvent", self.OnFFClick) |
1778 | 1782 | |
1779 | 1783 | def SetUp(self): |
... | ... | @@ -1831,16 +1835,7 @@ class FloodFillMaskInteractorStyle(DefaultInteractorStyle): |
1831 | 1835 | mask = self.viewer.slice_.current_mask.matrix[1:, 1:, 1:] |
1832 | 1836 | cp_mask = mask |
1833 | 1837 | |
1834 | - if iren.GetControlKey(): | |
1835 | - t0 = 254 | |
1836 | - t1 = 255 | |
1837 | - fill = 1 | |
1838 | - else: | |
1839 | - t0 = 0 | |
1840 | - t1 = 1 | |
1841 | - fill = 254 | |
1842 | - | |
1843 | - floodfill.floodfill_threshold(cp_mask, [[x, y, z]], t0, t1, fill, bstruct, mask) | |
1838 | + floodfill.floodfill_threshold(cp_mask, [[x, y, z]], self.t0, self.t1, self.fill_value, bstruct, mask) | |
1844 | 1839 | |
1845 | 1840 | self.viewer.slice_.buffer_slices['AXIAL'].discard_mask() |
1846 | 1841 | self.viewer.slice_.buffer_slices['CORONAL'].discard_mask() |
... | ... | @@ -1891,6 +1886,14 @@ class FloodFillMaskInteractorStyle(DefaultInteractorStyle): |
1891 | 1886 | return sagital, coronal, axial |
1892 | 1887 | |
1893 | 1888 | |
1889 | +class RemoveMaskPartsInteractorStyle(FloodFillMaskInteractorStyle): | |
1890 | + def __init__(self, viewer): | |
1891 | + FloodFillMaskInteractorStyle.__init__(self, viewer) | |
1892 | + self.t0 = 254 | |
1893 | + self.t1 = 255 | |
1894 | + self.fill_value = 1 | |
1895 | + | |
1896 | + | |
1894 | 1897 | def get_style(style): |
1895 | 1898 | STYLES = { |
1896 | 1899 | const.STATE_DEFAULT: DefaultInteractorStyle, |
... | ... | @@ -1907,6 +1910,7 @@ def get_style(style): |
1907 | 1910 | const.SLICE_STATE_WATERSHED: WaterShedInteractorStyle, |
1908 | 1911 | const.SLICE_STATE_REORIENT: ReorientImageInteractorStyle, |
1909 | 1912 | const.SLICE_STATE_MASK_FFILL: FloodFillMaskInteractorStyle, |
1913 | + const.SLICE_STATE_REMOVE_MASK_PARTS: RemoveMaskPartsInteractorStyle, | |
1910 | 1914 | } |
1911 | 1915 | return STYLES[style] |
1912 | 1916 | ... | ... |
invesalius/gui/frame.py
... | ... | @@ -569,7 +569,7 @@ class Frame(wx.Frame): |
569 | 569 | Publisher.sendMessage('Enable style', const.SLICE_STATE_MASK_FFILL) |
570 | 570 | |
571 | 571 | def OnRemoveMaskParts(self): |
572 | - Publisher.sendMessage('Enable style', const.SLICE_STATE_MASK_FFILL) | |
572 | + Publisher.sendMessage('Enable style', const.SLICE_STATE_REMOVE_MASK_PARTS) | |
573 | 573 | |
574 | 574 | # ------------------------------------------------------------------ |
575 | 575 | # ------------------------------------------------------------------ | ... | ... |