Skip to content

Commit

Permalink
add func: delete box
Browse files Browse the repository at this point in the history
  • Loading branch information
nachifur committed Jun 27, 2021
1 parent e31136e commit 41cb631
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 45 deletions.
28 changes: 21 additions & 7 deletions mulimg_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def __init__(self, parent, UpdateUI, get_type):
(wx.ACCEL_NORMAL, wx.WXK_RIGHT,
self.menu_right.GetId()),
(wx.ACCEL_NORMAL, wx.WXK_LEFT,
self.menu_left.GetId())
self.menu_left.GetId()),
(wx.ACCEL_NORMAL, wx.WXK_DELETE,
self.menu_delete_box.GetId())
])
self.SetAcceleratorTable(acceltbl)
# self.img_Sizer = self.scrolledWindow_img.GetSizer()
Expand Down Expand Up @@ -277,8 +279,20 @@ def background_alpha(self, event):
def foreground_alpha(self, event):
self.ImgManager.img_alpha = self.foreground_slider.GetValue()

def delete_box(self, event):
if self.select_img_box.Value:
if self.box_id != -1:
self.xy_magnifier.pop(self.box_id)
self.refresh(event)
self.SetStatusText_(
["delete "+str(self.box_id)+"-th box", "-1", "-1", "-1"])
else:
self.xy_magnifier = []
self.refresh(event)
self.SetStatusText_(["delete all box", "-1", "-1", "-1"])

def up_img(self, event):
if self.move_img_box.Value:
if self.select_img_box.Value:
if self.box_id != -1:
box_point = self.xy_magnifier[self.box_id][0:4]
show_scale = self.xy_magnifier[self.box_id][4:6]
Expand All @@ -301,7 +315,7 @@ def up_img(self, event):
self.SetStatusText_(["up", "-1", "-1", "-1"])

def down_img(self, event):
if self.move_img_box.Value:
if self.select_img_box.Value:
if self.box_id != -1:
box_point = self.xy_magnifier[self.box_id][0:4]
show_scale = self.xy_magnifier[self.box_id][4:6]
Expand All @@ -327,7 +341,7 @@ def down_img(self, event):
self.SetStatusText_(["down", "-1", "-1", "-1"])

def right_img(self, event):
if self.move_img_box.Value:
if self.select_img_box.Value:
if self.box_id != -1:
box_point = self.xy_magnifier[self.box_id][0:4]
show_scale = self.xy_magnifier[self.box_id][4:6]
Expand All @@ -353,7 +367,7 @@ def right_img(self, event):
self.SetStatusText_(["right", "-1", "-1", "-1"])

def left_img(self, event):
if self.move_img_box.Value:
if self.select_img_box.Value:
if self.box_id != -1:
box_point = self.xy_magnifier[self.box_id][0:4]
show_scale = self.xy_magnifier[self.box_id][4:6]
Expand Down Expand Up @@ -389,7 +403,7 @@ def img_left_click(self, event):
self.x = x_0
self.y = y_0

if self.move_img_box.Value:
if self.select_img_box.Value:
# select box
x, y = event.GetPosition()
id = self.get_img_id_from_point([x, y])
Expand Down Expand Up @@ -421,7 +435,7 @@ def img_left_click(self, event):
self.refresh(event)

def img_left_dclick(self, event):
if self.move_img_box.Value:
if self.select_img_box.Value:
pass
else:
self.start_flag = 0
Expand Down
17 changes: 12 additions & 5 deletions mulimg_viewer_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,13 +359,13 @@ def __init__( self, parent ):

bSizer25 = wx.BoxSizer( wx.HORIZONTAL )

self.m_staticText30 = wx.StaticText( self.scrolledWindow_set, wx.ID_ANY, u"Move box", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText30 = wx.StaticText( self.scrolledWindow_set, wx.ID_ANY, u"Select box", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText30.Wrap( -1 )

bSizer25.Add( self.m_staticText30, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )

self.move_img_box = wx.CheckBox( self.scrolledWindow_set, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
bSizer25.Add( self.move_img_box, 0, wx.ALL, 5 )
self.select_img_box = wx.CheckBox( self.scrolledWindow_set, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
bSizer25.Add( self.select_img_box, 0, wx.ALL, 5 )


fgSizer3.Add( bSizer25, 1, wx.EXPAND, 5 )
Expand Down Expand Up @@ -567,6 +567,9 @@ def __init__( self, parent ):
self.menu_left = wx.MenuItem( self.m_menu2, wx.ID_ANY, u"left", wx.EmptyString, wx.ITEM_NORMAL )
self.m_menu2.Append( self.menu_left )

self.menu_delete_box = wx.MenuItem( self.m_menu2, wx.ID_ANY, u"delete_box", wx.EmptyString, wx.ITEM_NORMAL )
self.m_menu2.Append( self.menu_delete_box )

self.m_menubar1.Append( self.m_menu2, u"Edit" )

self.m_menu3 = wx.Menu()
Expand Down Expand Up @@ -596,7 +599,7 @@ def __init__( self, parent ):
self.magnifier.Bind( wx.EVT_TOGGLEBUTTON, self.magnifier_fc )
self.rotation.Bind( wx.EVT_TOGGLEBUTTON, self.rotation_fc )
self.choice_normalized_size.Bind( wx.EVT_CHOICE, self.change_img_stitch_mode )
self.move_img_box.Bind( wx.EVT_CHECKBOX, self.move_img_box_func )
self.select_img_box.Bind( wx.EVT_CHECKBOX, self.select_img_box_func )
self.colourPicker_gap.Bind( wx.EVT_COLOURPICKER_CHANGED, self.colour_change )
self.background_slider.Bind( wx.EVT_SCROLL, self.background_alpha )
self.foreground_slider.Bind( wx.EVT_SCROLL, self.foreground_alpha )
Expand All @@ -615,6 +618,7 @@ def __init__( self, parent ):
self.Bind( wx.EVT_MENU, self.down_img, id = self.menu_down.GetId() )
self.Bind( wx.EVT_MENU, self.right_img, id = self.menu_right.GetId() )
self.Bind( wx.EVT_MENU, self.left_img, id = self.menu_left.GetId() )
self.Bind( wx.EVT_MENU, self.delete_box, id = self.menu_delete_box.GetId() )
self.Bind( wx.EVT_MENU, self.index_table_gui, id = self.index_table.GetId() )
self.Bind( wx.EVT_MENU, self.about_gui, id = self.menu_about.GetId() )

Expand Down Expand Up @@ -659,7 +663,7 @@ def rotation_fc( self, event ):
def change_img_stitch_mode( self, event ):
event.Skip()

def move_img_box_func( self, event ):
def select_img_box_func( self, event ):
event.Skip()

def colour_change( self, event ):
Expand Down Expand Up @@ -706,6 +710,9 @@ def right_img( self, event ):
def left_img( self, event ):
event.Skip()

def delete_box( self, event ):
event.Skip()

def index_table_gui( self, event ):
event.Skip()

Expand Down
Loading

0 comments on commit 41cb631

Please sign in to comment.