Commit 937b7ca31abcd24bb6d29bce5cc93d82ca511314
1 parent
e83c555b
Exists in
mask_boolean_op_bkp
Added Intesection and XOR
Showing
3 changed files
with
18 additions
and
4 deletions
Show diff stats
invesalius/constants.py
invesalius/data/slice_.py
... | ... | @@ -1222,7 +1222,9 @@ class Slice(object): |
1222 | 1222 | |
1223 | 1223 | def do_boolean_op(self, op, m1, m2): |
1224 | 1224 | name_ops = {const.BOOLEAN_UNION: _(u"Union"), |
1225 | - const.BOOLEAN_DIFF: _(u"Diff")} | |
1225 | + const.BOOLEAN_DIFF: _(u"Diff"), | |
1226 | + const.BOOLEAN_AND: _(u"Intersection"), | |
1227 | + const.BOOLEAN_XOR: _(u"XOR")} | |
1226 | 1228 | |
1227 | 1229 | |
1228 | 1230 | name = u"%s_%s_%s" % (name_ops[op], m1.name, m2.name) |
... | ... | @@ -1250,6 +1252,12 @@ class Slice(object): |
1250 | 1252 | elif op == const.BOOLEAN_DIFF: |
1251 | 1253 | m[:] = ((m1 > 2) - (m2 > 2)) * 255 |
1252 | 1254 | |
1255 | + elif op == const.BOOLEAN_AND: | |
1256 | + m[:] = ((m1 > 2) & (m2 > 2)) * 255 | |
1257 | + | |
1258 | + elif op == const.BOOLEAN_XOR: | |
1259 | + m[:] = numpy.logical_xor((m1 > 2), (m2 > 2)) * 255 | |
1260 | + | |
1253 | 1261 | future_mask.was_edited = True |
1254 | 1262 | self._add_mask_into_proj(future_mask) |
1255 | 1263 | ... | ... |
invesalius/gui/dialogs.py
... | ... | @@ -1492,7 +1492,9 @@ class MaskBooleanDialog(wx.Dialog): |
1492 | 1492 | self.mask2.SetSelection(0) |
1493 | 1493 | |
1494 | 1494 | op_choices = ((u"Union", const.BOOLEAN_UNION), |
1495 | - (u"Difference", const.BOOLEAN_DIFF)) | |
1495 | + (u"Difference", const.BOOLEAN_DIFF), | |
1496 | + (u"Intersection", const.BOOLEAN_AND), | |
1497 | + (u"XOR", const.BOOLEAN_XOR)) | |
1496 | 1498 | self.op_boolean = wx.ComboBox(self, -1, op_choices[0][0], choices=[]) |
1497 | 1499 | |
1498 | 1500 | for n, i in op_choices: |
... | ... | @@ -1528,6 +1530,8 @@ class MaskBooleanDialog(wx.Dialog): |
1528 | 1530 | m1 = self.mask1.GetClientData(self.mask1.GetSelection()) |
1529 | 1531 | m2 = self.mask2.GetClientData(self.mask2.GetSelection()) |
1530 | 1532 | |
1531 | - print op, m1.name, m2.name | |
1532 | - | |
1533 | 1533 | Publisher.sendMessage('Do boolean operation', (op, m1, m2)) |
1534 | + Publisher.sendMessage('Reload actual slice') | |
1535 | + | |
1536 | + self.Close() | |
1537 | + self.Destroy() | ... | ... |