def __init__(self, parent): LogWindowGUI.LogWindowGUI.__init__(self, parent) stockicons = StockItems.StockIconFactory() self.m_toolBar2.GetToolByPos(1).SetNormalBitmap( stockicons.getToolbarBitmap("scissors9")) self.m_toolBar2.Realize() self.Layout()
def __init__(self, *args, **kw): wx.lib.stattext.GenStaticText.__init__(self, *args, **kw) # load static icon self.up_down_bitmap = StockItems.StockIconFactory().getBitmap( 'up-down-arrows') self.full_rect = None
def __init__(self, parent): self._Panes = [] self._WindowLevelModes = [ vtkEVS.GEWindowLevelInteractionMode.GEWindowLevelInteractionMode(), ] self._SectionIndex = [ 0, ] # stock item manager self._stockicons = StockItems.StockIconFactory() wx.lib.agw.aui.AuiToolBar.__init__(self, parent, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.lib.agw.aui.AUI_TB_HORZ_LAYOUT) self._ids = [wx.NewId() for i in range(7)] self.AddTool(self._ids[0], u"tool", self._stockicons.getBitmap('rotate'), wx.NullBitmap, wx.ITEM_RADIO, wx.EmptyString, u"Rotate Image", None) self.AddTool(self._ids[1], u"tool", self._stockicons.getBitmap('winlev'), wx.NullBitmap, wx.ITEM_RADIO, wx.EmptyString, u"Adjust window/level", None) self.AddTool(self._ids[2], u"tool", self._stockicons.getBitmap('zoom'), wx.NullBitmap, wx.ITEM_RADIO, wx.EmptyString, u"Adjust image zoom", None) self.AddTool(self._ids[3], u"tool", self._stockicons.getBitmap('pan'), wx.NullBitmap, wx.ITEM_RADIO, wx.EmptyString, u"Pan image", None) self.AddTool(self._ids[4], u"tool", self._stockicons.getBitmap('slice'), wx.NullBitmap, wx.ITEM_RADIO, wx.EmptyString, u"Adjust image slice position", None) # self.AddTool(self._ids[5], u"tool", self._stockicons.getBitmap( # 'roi'), wx.NullBitmap, wx.ITEM_RADIO, wx.EmptyString, u"Draw ROIs", None) # self.AddTool(self._ids[6], u"tool", self._stockicons.getBitmap( # 'line_draw'), wx.NullBitmap, wx.ITEM_RADIO, wx.EmptyString, u"Draw Line Propfile", None) self.Realize() # Connect Events self.Bind(wx.EVT_TOOL, self.onButtonRotate, id=self._ids[0]) self.Bind(wx.EVT_TOOL, self.onButtonWinLevel, id=self._ids[1]) self.Bind(wx.EVT_TOOL, self.onButtonZoom, id=self._ids[2]) self.Bind(wx.EVT_TOOL, self.onButtonPan, id=self._ids[3]) self.Bind(wx.EVT_TOOL, self.onButtonSlice, id=self._ids[4])
def __init__(self, parent): StatisticsGUI.StatisticsGUI.__init__(self, parent) stockicons = StockItems.StockIconFactory() self.m_toolBar1.GetToolByPos(1).SetNormalBitmap( stockicons.getToolbarBitmap("scissors9")) self.m_toolBar1.Realize() self.Layout() # keep track of row insertion point self.current_row = 0 # a dictionary of labels self._field_index = collections.OrderedDict() # map header label to column number for n in xrange(self.m_gridStatistics.GetNumberCols()): val = self.m_gridStatistics.GetColLabelValue(n) self._field_index[val] = n
def __init__(self, parent=None, **kw): wx.Panel.__init__(self, parent, id=-1) # determine directory of installed software self._installdir = os.path.abspath(sys.path[0]) # get an icon factory self._stockicons = StockItems.StockIconFactory() # determine default plugin directory self._plugindir = os.path.join(self._installdir, "Plugins") directories = [os.path.abspath( self._plugindir), os.path.join(appdirs.user_data_dir("MicroView", "Parallax Innovations"), "Plugins")] logging.info("System plugin directory: {0}".format(directories[0])) logging.info("User plugin directory: {0}".format(directories[1])) PluginHelper.SetupPlugins(directories) # some plugins need to be passed ROI key events self._standard_roi_plugins = [] # we'll modify the splash screen splashlogger = logging.getLogger("splash") splashlogger.info("Loading plugins...") # create a list that holds the registered plugins self._pluginWeakReferenceList = [] self._activeROIPluginWeakRef = {} self._activeROIManager = None self._TabName2PluginName = {"Tools & Apps": "Tools & Apps"} self._pluginCount = 0 self._menubar = None # create a notebook and pack it into the default frame widget self.CreateNoteBook() # listen to certain zope events component.provideHandler(self.onActionEvent)
def __init__(self, parent, **kw): RenderPane.RenderPane.__init__(self, parent, **kw) self._index = 0 if 'index' in kw: self._index = kw['index'] else: logging.error("MicroViewRenderPane requires an image index!") # The 'tracked' sliceplane is what gets displayed in the lower right of # each self._tracked_sliceplane_index = 2 # viewport self._pane_name = kw['name'] # keep reference to parent object self._parent = parent # what style of coordinate system? self._coordinate_system = CoordinateSystem.CoordinateSystem.vtk_coords # create an VTK event object self._eventObject = vtk.vtkObject() # keep a reference to OrthoPlanes self.__orthoPlanes = None self._lastActorFactory = None # keep track of whether mouse moved during right click events self._right_click_x = None self._right_click_y = None self._stockicons = StockItems.StockIconFactory() # button-1 action binding self._B1Action = 'rotate' # create some default cursors self._cursors = { 'winlev': wx.StockCursor(wx.CURSOR_ARROW), 'rotate': wx.StockCursor(wx.CURSOR_ARROW), 'zoom': wx.StockCursor(wx.CURSOR_MAGNIFIER), 'pan': wx.StockCursor(wx.CURSOR_HAND), 'slice': wx.StockCursor(wx.CURSOR_ARROW), 'spin': wx.StockCursor(wx.CURSOR_ARROW), } # override some of the default with cursor if we find them on disk for action in ('pan', 'winlev', 'zoom', 'slice', 'spin'): filename = os.path.join('Cursors', '%s.gif' % action) if os.path.exists(filename): try: image = wx.Image(filename) image.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_X, 1) image.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_Y, 1) self._cursors[action] = wx.CursorFromImage(image) except: logging.exception("MicroViewRenderPane") self._use_dicom_coordinates = False # ------------------------------------------------------------------------------------ # Set up some zope event handlers # --------------------------------------------------------------------- component.provideHandler(self.OnConfigModified)
def __init__(self, parent, *args, **kw): VTKPlotWindowGUI.VTKPlotWindowGUI.__init__(self, parent) # ------------------------------------------------------------------------------------ # Set up some zope event handlers # ------------------------------------------------------------------------------------ component.provideHandler(self.OnImageChangeEvent) self._voxel_volume_set = False self._voxel_volume = 1.0 if ('bar' in kw): self._usebar = True else: self._usebar = False self._scale = 1.0 self._unit = kw.get('units', 'pixels') self._dragging = 0 # is this needed? self._x0 = None self._y0 = None self._x1 = None self._y1 = None self._select_x0 = None self._select_x1 = None self._select_i0 = None self._select_i1 = None self.xdata = [] self.ydata = [] self._line = [None, None] self._liney = None self._title = "This is the title" self.filename = '' self._xlabel = "" self._ylabel = "" self._usesymbols = False # indicates whether nearest data point should be highlighted or not self._use_highlight_data = True self._isROI = False self._linelength = None self._inputname = "" self._highlight_visible = False self.__shortname__ = 'VTKPlot' self._otsu_threshold = None self._otsu_marker = None self._unit_scalings = {'pixels': 1.0, 'mm': 1.0, 'wavelength': 1.0} self.plot_data = None self.legend = None if ('scale' in kw): self._scale = float(kw['scale']) if ('title' in kw): self._title = kw['title'] if ('xlabel' in kw): self._xlabel = kw['xlabel'] if ('ylabel' in kw): self._ylabel = kw['ylabel'] # get icon factory self._stockicons = StockItems.StockIconFactory() # create info panel - it'll depend on whether this is a line plot or # histogram window self.lower_panel = self.CreateLowerPanel() self.GetSizer().Add(self.lower_panel, 0, wx.EXPAND, 5) # create a matplotlib panel self.dpi = 100 self.fig = Figure((3.0, 3.0), dpi=self.dpi) # self.fig.subplots_adjust(left=0.07, right=0.97, bottom=0.08, top=0.95) self.fig.subplots_adjust(left=0.0, right=1, bottom=0.0, top=1) self.axes = self.fig.add_subplot(111) # default labels self.axes.set_title(self._title, size=10) self.axes.set_ylabel(self._ylabel, size=8) self.line_tool = None # A red, horizontal line tool self.end_markers = None # Markers that go at the end of each line self.data_markers = None # Marks that indicate nearest data point pylab.setp(self.axes.get_xticklabels(), fontsize=8) pylab.setp(self.axes.get_yticklabels(), fontsize=8) sizer = wx.BoxSizer(wx.VERTICAL) # create canvas for plot widget self.canvas = FigCanvas(self.m_panelMatplotPanel, -1, self.fig) self.m_panelMatplotPanel.SetSizer(sizer) self.m_panelMatplotPanel.Fit() # activate interactive navigation self.toolbar = MicroViewNavigationToolbar(self.canvas) self.toolbar.Realize() tw, th = self.toolbar.GetSizeTuple() fw, fh = self.canvas.GetSizeTuple() self.toolbar.SetSize(wx.Size(fw, th)) sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND) sizer.Add(self.canvas, 1, wx.EXPAND) self.toolbar.update() # adjust toolbar self.EnableToolbar() # wire up events self.canvas.mpl_connect('motion_notify_event', self.MouseMoveEvent) self.canvas.mpl_connect('key_press_event', self.KeyPressEvent) self.canvas.mpl_connect('figure_leave_event', self.LeaveCanvasEvent) # wire up events here self.toolbar.Bind( wx.EVT_TOOL, self.SaveData, id=self.toolbar.SAVE_DATA) self.toolbar.Bind( wx.EVT_TOOL, self.SaveSnapShot, id=self.toolbar.SAVE_SNAPSHOT) self.toolbar.Bind( wx.EVT_TOOL, self.symbolsOnOff, id=self.toolbar.VIEW_SYMBOLS) # self.toolbar.Bind(wx.EVT_TOOL, self.Reset, id=self.toolbar.RESET_VIEW) self.toolbar.Bind( wx.EVT_TOOL, self.AutoThreshold, id=self.toolbar.AUTO_THRESHOLD) self.toolbar.Bind( wx.EVT_TOOL, self.onCopyHighlightToolbarButton, id=self.toolbar.COPY_HIGHLIGHT) self.toolbar.Bind( wx.EVT_TOOL, self.onShowHighlightToolbarToogle, id=self.toolbar.SHOW_HIGHLIGHT) self.toolbar.Bind( wx.EVT_TOOL, self.NearestDataSymbolsOnOff, id=self.toolbar.VIEW_NEARESTDATA) self.toolbar.Bind( wx.EVT_TOOL, self.select_roi, id=self.toolbar.SELECT_ROI) # listen to size events self.Bind(wx.EVT_PAINT, self.OnPaint) self._plotData = None # This table is used to make the input invisible self._wlTableInvisible = vtk.vtkWindowLevelLookupTable() self._wlTableInvisible.SetSaturationRange(0, 0) self._wlTableInvisible.SetHueRange(0, 0) self._wlTableInvisible.SetValueRange(0, 1) self._wlTableInvisible.SetNumberOfColors(2) self._wlTableInvisible.SetTableValue(0, 0.0, 0.0, 0.0, 0.0) self._wlTableInvisible.SetTableValue(1, 0.0, 0.0, 0.0, 0.0) self._wlTableInvisible.Build() # Invoke an event to react to currently loaded image mv = component.getUtility(IMicroViewMainFrame) current_image = mv.GetCurrentImageIndex() number_images_displayed = mv.GetNumberOfImagesCurrentlyLoaded() title = mv.GetCurrentImageTitle() self.OnImageChangeEvent(CurrentImageChangeEvent( current_image, number_images_displayed, title))
def _init_toolbar(self): self._parent = self.canvas.GetParent() self.wx_ids = {} _NTB2_HOME = wx.NewId() self._NTB2_BACK = wx.NewId() self._NTB2_FORWARD = wx.NewId() self._NTB2_PAN = wx.NewId() self._NTB2_ZOOM = wx.NewId() _NTB2_SUBPLOT = wx.NewId() self.wx_ids['Back'] = self._NTB2_BACK self.wx_ids['Forward'] = self._NTB2_FORWARD self.wx_ids['Pan'] = self._NTB2_PAN self.wx_ids['Zoom'] = self._NTB2_ZOOM # Add MicroView-specific tools stockicons = StockItems.StockIconFactory() self.SAVE_DATA = wx.NewId() self.SAVE_SNAPSHOT = wx.NewId() self.VIEW_SYMBOLS = wx.NewId() self.VIEW_NEARESTDATA = wx.NewId() self.AUTO_THRESHOLD = wx.NewId() self.SHOW_HIGHLIGHT = wx.NewId() self.COPY_HIGHLIGHT = wx.NewId() self.SELECT_ROI = wx.NewId() dummy_bitmap = wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE_AS) icon_size = dummy_bitmap.GetWidth() self.SetToolBitmapSize(wx.Size(icon_size, icon_size)) self.AddSimpleTool(self.SAVE_DATA, stockicons.getToolbarBitmap( wx.ART_FILE_SAVE_AS), 'Save data', 'Save data to file') self.AddSimpleTool(self.SAVE_SNAPSHOT, stockicons.getToolbarBitmap( 'glyphicons_011_camera'), 'Save snapshot', 'Save snapshot') self.AddCheckTool(self.VIEW_SYMBOLS, stockicons.getToolbarBitmap( 'office-chart-line-stacked-with-symbols'), shortHelp='Show symbols', longHelp='Show symbols') self.AddCheckTool(self.VIEW_NEARESTDATA, stockicons.getToolbarBitmap( 'office-chart-line-stacked-with-nearest-data'), shortHelp='View nearest datapoint', longHelp='View nearest datapoint') self.AddSimpleTool( self.AUTO_THRESHOLD, stockicons.getToolbarBitmap( 'autothreshold-wizard-24'), 'Automatically select threshold from histogram', 'Automatically select threshold from histogram') self.AddCheckTool(self.SHOW_HIGHLIGHT, stockicons.getToolbarBitmap( 'highlight'), shortHelp='Show Highlight', longHelp='Show Highlight') self.AddSimpleTool(self.COPY_HIGHLIGHT, stockicons.getToolbarBitmap( 'copy'), 'Copy Highlight', 'Copy Highlight') # The following tools are copied from the original matplotlib code self.AddSimpleTool(_NTB2_HOME, stockicons.getToolbarBitmap('glyphicons_020_home'), 'Home', 'Reset original view') self.AddSimpleTool(self._NTB2_BACK, stockicons.getToolbarBitmap('glyphicons_170_step_backward'), 'Back', 'Back navigation view') self.AddSimpleTool(self._NTB2_FORWARD, stockicons.getToolbarBitmap('glyphicons_178_step_forward'), 'Forward', 'Forward navigation view') # todo: get new bitmap self.AddCheckTool(self._NTB2_PAN, stockicons.getToolbarBitmap('glyphicons_186_move'), shortHelp='Pan', longHelp='Pan with left, zoom with right') self.AddCheckTool(self._NTB2_ZOOM, stockicons.getToolbarBitmap('glyphicons_093_crop'), shortHelp='Zoom', longHelp='Zoom to rectangle') self.AddCheckTool(self.SELECT_ROI, stockicons.getToolbarBitmap( 'select_histogram_region'), longHelp='Select Histogram Region', shortHelp='Select Region') bind(self, wx.EVT_TOOL, self.home, id=_NTB2_HOME) bind(self, wx.EVT_TOOL, self.forward, id=self._NTB2_FORWARD) bind(self, wx.EVT_TOOL, self.back, id=self._NTB2_BACK) bind(self, wx.EVT_TOOL, self.zoom, id=self._NTB2_ZOOM) bind(self, wx.EVT_TOOL, self.pan, id=self._NTB2_PAN) self.Realize()