Beispiel #1
0
	def close(self):

		if self._roicircle == 1: ROImanager.draw_circle(self)
		elif self._roirect == 1: ROImanager.draw_rectangle(self)

		try: ROIdisplay.noshow_roi(self)
		except AttributeError: pass

		self.rt_Window.destroy()
		self._menucheckROI.set(0)
Beispiel #2
0
	def clearall_roiList(self):

		MainDisplay.show_overlay(self)
		ROIdisplay.noshow_roi(self)

		del self._roipath
		del self._roilabel

		self.roiListbox.delete(0, 'end')

		self._canvas.draw()
Beispiel #3
0
	def keepdelall_roi(self, keep):

		self.roiListbox.selection_clear(0, 'end')
		self.roiListbox.selection_set(0, 'end')

		if keep == 0: ROImanager.deldata_inroi(self)
		elif keep == 1: ROImanager.keepdata_inroi(self)

		ROIdisplay.noshow_roi(self)

		del self._roipath; del self._roilabel

		self.roiListbox.delete(0, 'end')

		MainDisplay.show_overlay(self)
Beispiel #4
0
	def apply(self):
		self._overedge['size'].set(self.ove_szSpinbox.get())
		self._overedge['ecolor'].set(self.ove_ecCombobox.get())
		self._overedge['fcolor'].set(self.ove_fcCombobox.get())
		self._overskel['size'].set(self.ovs_szSpinbox.get())
		self._overskel['ecolor'].set(self.ovs_ecCombobox.get())
		self._overskel['fcolor'].set(self.ovs_fcCombobox.get())
		self._overlabel['size'].set(self.ovl_szSpinbox.get())
		self._overlabel['ecolor'].set(self.ovl_ecCombobox.get())
		self._overfit['lwidth'].set(self.ovf_lwSpinbox.get())
		self._overfit['color'].set(self.ovf_lcCombobox.get())

		MainDisplay.show_overlay(self)
		try: ROIdisplay.show_roi(self)
		except AttributeError: pass
		ImageOverlay.setstate_cpanel(self)
Beispiel #5
0
	def keepdelsel_roi(self, keep):

		if keep == 0:
			ROImanager.deldata_inroi(self)
			list_del = self.roiListbox.curselection()
		elif keep == 1:
			ROImanager.keepdata_inroi(self)
			list_del = [item for item in np.arange(self.roiListbox.size())
						if item not in self.roiListbox.curselection()]

		ROIdisplay.noshow_roi(self)

		for item in sorted(list_del, reverse=True):
			del self._roipath[item]
			del self._roilabel[item]

		for n, item in enumerate(self._roilabel):
			item.set_text(str(n+1))

		MainDisplay.show_overlay(self)

		ROIdisplay.show_roi(self)
		ROImanager.update_roiList(self)
Beispiel #6
0
	def selectall_roiList(self):

		self.roiListbox.selection_clear(0, 'end')
		self.roiListbox.selection_set(0, 'end')

		ROIdisplay.draw_selec(self, '<Button-1>')
Beispiel #7
0
	def create_window(self):

		try: self.rt_Window.destroy()
		except AttributeError: pass

		self.rt_Window = tk.Toplevel(self)
		self.rt_Window.title('ROI Manager Tracking')
		#self.rt_Window.geometry('240x350-80+50')
		self.rt_Window.resizable(0,1)
		self.rt_Window.protocol('WM_DELETE_WINDOW',
								lambda: ROImanager.close(self))

		self.rt_Window.columnconfigure(0, weight = 1)
		self.rt_Window.rowconfigure(1, weight = 1)

		self.rt_drawFrame = ttk.Frame(self.rt_Window)
		self.roicircleButton = ttk.Button(self.rt_drawFrame,
										text = 'Circle',
										style = 'SunkableButton.TButton',
										command = lambda: ROImanager.draw_circle(self))
		self.roirectButton = ttk.Button(self.rt_drawFrame,
										text = 'Rectangle',
										style = 'SunkableButton.TButton',
										command = lambda: ROImanager.draw_rectangle(self))
		self.roipolyButton = ttk.Button(self.rt_drawFrame,
										text = 'Polygon')

		self.rt_middleFrame = ttk.Frame(self.rt_Window)
		self.rt_middleFrame.rowconfigure(0, weight = 1)
		self.rt_middleFrame.columnconfigure([0,1], weight = 1)
		self.roilistFrame = ttk.LabelFrame(self.rt_middleFrame,
									text = 'ROIs')
		self.roilistFrame.rowconfigure(0, weight = 1)

		self.roiListbox = tk.Listbox(self.roilistFrame,
									width = 15, selectmode = 'extended')
		self.roiListbox.bind('<<ListboxSelect>>',
										lambda event, arg = self:
													ROIdisplay.draw_selec(self, event))
		self.roilistScrollbar = ttk.Scrollbar(self.roilistFrame)
		self.roilistScrollbar.config(command = self.roiListbox.yview)
		self.roiListbox.config(yscrollcommand = self.roilistScrollbar.set)

		self.rt_manageFrame = ttk.Frame(self.rt_middleFrame)
		self.roiselectallButton = ttk.Button(self.rt_manageFrame,
											text = 'Select All',
											command = lambda: ROImanager.selectall_roiList(self))
		self.roiclearallButton = ttk.Button(self.rt_manageFrame,
											text = 'Clear All',
											command = lambda: ROImanager.clearall_roiList(self))
		self.roideleteallButton = ttk.Button(self.rt_manageFrame,
											text = 'Delete All',
											command = lambda: ROImanager.keepdelall_roi(self, 0))
		self.roikeepallButton = ttk.Button(self.rt_manageFrame,
											text = 'Keep All',
											command = lambda: ROImanager.keepdelall_roi(self, 1))
		self.roideleteselecButton = ttk.Button(self.rt_manageFrame,
											text = 'Delete Selection',
											command = lambda: ROImanager.keepdelsel_roi(self, 0))
		self.roikeepselecButton = ttk.Button(self.rt_manageFrame,
											text = 'Keep Selection',
											command = lambda: ROImanager.keepdelsel_roi(self,1))

		self.rt_bottomFrame = ttk.Frame(self.rt_Window)
		self.rt_bottomFrame.columnconfigure([0,1], weight = 1)
		self.roioptionsButton = ttk.Button(self.rt_bottomFrame,
										text = 'Options',
										command = lambda: ROImanager.create_options(self))
		self.roicloseButton = ttk.Button(self.rt_bottomFrame,
										text = 'Close',
										command = lambda: ROImanager.close(self))


		self.rt_drawFrame.grid(row = 0, column = 0,
										sticky = 'nsew')
		self.roicircleButton.grid(row = 0, column = 0,
										sticky = 'nsew', padx = 2, pady = 10)
		self.roirectButton.grid(row = 0, column = 1,
										sticky = 'nsew', padx = 2, pady = 10)
		self.roipolyButton.grid(row = 0, column = 2,
										sticky = 'nsew', padx = 2, pady = 10)

		self.rt_middleFrame.grid(row = 1, column = 0, sticky = 'nsew')

		self.roilistFrame.grid(row = 0, column = 0,
									sticky = 'ns')
		self.roiListbox.grid(row = 0, column = 0, sticky = 'ns')
		self.roilistScrollbar.grid(row = 0, column = 1, sticky = 'ns')

		self.rt_manageFrame.grid(row = 0, column = 1,
										sticky = 'nsew')
		self.roiselectallButton.grid(row = 0, column = 0, sticky = 'nsew',
										pady = 2, padx = 2)
		self.roiclearallButton.grid(row = 1, column = 0, sticky = 'nsew',
										pady = 2, padx = 2)
		self.roideleteallButton.grid(row = 2, column = 0, sticky = 'nsew',
										pady = 2, padx = 2)
		self.roikeepallButton.grid(row = 3, column = 0, sticky = 'nsew',
										pady = 2, padx = 2)
		self.roideleteselecButton.grid(row = 4, column = 0, sticky = 'nsew',
										pady = 2, padx = 2)
		self.roikeepselecButton.grid(row = 5, column = 0, sticky = 'nsew',
										pady = 2, padx = 2)

		self.rt_bottomFrame.grid(row = 2, column = 0,
										sticky = 'nsew')
		self.roioptionsButton.grid(row = 0, column = 0,
										sticky = 'nsew', padx = 10, pady = 10)
		self.roicloseButton.grid(row = 0, column = 1,
										sticky = 'nsew', padx = 10, pady = 10)

		try:
			self._roipath[-1]
			ROImanager.setstate_roi(self)
			ROIdisplay.show_roi(self)
			ROImanager.update_roiList(self)
		except AttributeError:
			ROImanager.setstate_noroi(self)
Beispiel #8
0
	def connect_mpl(self):
		self._cid_press = self._canvas.mpl_connect('button_press_event', lambda event, arg = self: ROIdisplay.on_mousepress(arg, event))
		self._cid_drag = self._canvas.mpl_connect('motion_notify_event', lambda event, arg = self: ROIdisplay.on_mousedrag(arg, event))
		self._cid_up = self._canvas.mpl_connect('button_release_event', lambda event, arg = self: ROIdisplay.on_mouseup(arg, event))