def reposition_depth_canvas(self): #display_coords = self._get_depth_canvas_display_coords() # UIM = UIManager() parent_controller_uid = UIM._getparentuid(self.tc._controller_uid) granpa_controller_uid = UIM._getparentuid(parent_controller_uid) granpa_controller = UIM.get(granpa_controller_uid) # xmin, xmax = self.tc.get_xlim() depth_min, depth_max = granpa_controller.shown_ylim # top_px = self.tc._get_ypixel_from_depth(depth_min) bottom_px = self.tc._get_ypixel_from_depth(depth_max) # transaxes = self.tc.get_transaxes() # # xmin_px, _ = transaxes.transform((0.0, 0.0)) xmin_px, top_px_ax = transaxes.transform((0.0, 0.0)) # xmax_px, _ = transaxes.transform((1.0, 1.0)) xmax_px, bottom_px_ax = transaxes.transform((1.0, 1.0)) # # print ('\nMin Max Y:', top_px, top_px_ax, bottom_px, bottom_px_ax) # self.d1_canvas.SetSize(int(xmin_px), int(top_px), xmax_px - xmin_px, self.canvas_height) # self.d2_canvas.SetSize(int(xmin_px), int(bottom_px) - self.canvas_height, xmax_px - xmin_px, self.canvas_height)
def PreDelete(self): UIM = UIManager() parent_controller_uid = UIM._getparentuid(self._controller_uid) # parent_controller = UIM.get(parent_controller_uid) granpa_controller_uid = UIM._getparentuid(parent_controller_uid) granpa_controller = UIM.get(granpa_controller_uid) # granpa_controller.view._detach_top_window(self)
def draw(self): if self._mplot_objects: self.clear() UIM = UIManager() controller = UIM.get(self._controller_uid) toc = self.get_parent_controller() xdata = toc.get_filtered_data(dimensions_desired=1) if xdata is None: return # ydata = toc.get_last_dimension_index_data() xdata_valid_idxs = ~np.isnan(xdata) xdata = xdata[xdata_valid_idxs] ydata = ydata[xdata_valid_idxs] # booldata, codes = toc.get_int_from_log(xdata) # canvas = self.get_canvas() toc_uid = UIM._getparentuid(self._controller_uid) track_controller_uid = UIM._getparentuid(toc_uid) track_controller = UIM.get(track_controller_uid) # for i, code in enumerate(codes): vec = [] start = None end = None for idx in range(len(ydata)): d = booldata[i, idx] if d and start is None: start = ydata[idx] elif not d and start is not None: end = ydata[idx] vec.append((start, end)) start = None patches = [] for start, end in vec: patch = track_controller.append_artist('Rectangle', (0.0, start), 160.0, end - start) patches.append(patch) collection = track_controller.append_artist( 'PatchCollection', patches, color=COLOR_CYCLE_NAMES[i]) print(COLOR_CYCLE_NAMES[i]) self._set_picking(collection, 0) self._mplot_objects[('part', code)] = collection self.draw_canvas()
def PreDelete(self): UIM = UIManager() parent_controller_uid = UIM._getparentuid(self._controller_uid) parent_controller = UIM.get(parent_controller_uid) granpa_controller_uid = UIM._getparentuid(parent_controller_uid) granpa_controller = UIM.get(granpa_controller_uid) if parent_controller.overview: try: granpa_controller._pre_delete_overview_track() except: pass else: granpa_controller.view._detach_bottom_window(self) # self.destroy_depth_canvas()
def PostInit(self): log.debug('{}.AfterInit started'.format(self.name)) UIM = UIManager() main_window = wx.App.Get().GetTopWindow() # DetachPane if granpa object has a AuiManager... parent_uid = UIM._getparentuid(self.uid) grampa_uid = UIM._getparentuid(parent_uid) parent = UIM.get(parent_uid) grampa = UIM.get(grampa_uid) if isinstance(grampa, MainWindowController): mgr = wx.aui.AuiManager.GetManager(main_window) if mgr is not None: mgr.DetachPane(parent.view) if self.pos == -1: # Appending - Not needed to declare pos self.pos = parent.view.GetToolsCount() if self.pos > parent.view.GetToolsCount(): # If pos was setted out of range for inserting in parent Menu msg = 'Invalid tool position for ToolBarTool with text={}. Position will be setting to {}'.format( self.label, parent.view.GetToolsCount()) logging.warning(msg) self.pos = parent.view.GetToolsCount() bitmap = GripyBitmap(self.bitmap) # TODO: Rever isso try: tool = parent.view.InsertTool(self.pos, self.id, self.label, bitmap, wx.NullBitmap, self.kind, self.help, self.long_help, None) except Exception as e: msg = 'Error in creating ToolBarTool: ' + e logging.exception(msg) print('\n\n', msg) raise if self.callback and tool: main_window.Bind(wx.EVT_TOOL, self.callback, tool) parent.view.Realize() # AtachPane again if granpa object had it detached... if isinstance(grampa, MainWindowController): mgr.AddPane(parent.view, parent.view.paneinfo) mgr.Update() logging.debug('{}.AfterInit ended'.format(self.name))
def __init__(self, controller_uid): UIViewObject.__init__(self, controller_uid) _UIM = UIManager() parent_controller_uid = _UIM._getparentuid(self._controller_uid) parent_controller = _UIM.get(parent_controller_uid) wx.StatusBar.__init__(self, parent_controller.view) parent_controller.view.SetStatusBar(self)
def __init__(self, controller_uid): """ """ # # Basic WorkPage interface structure # ================================== # Top: ToolBar # Center: A (main) panel where the 'things happens' ;-) # Bottom: StatusBar # UIViewObject.__init__(self, controller_uid) UIM = UIManager() controller = UIM.get(controller_uid) parent_uid = UIM._getparentuid(controller.uid) parent_controller = UIM.get(parent_uid) parent_view = parent_controller.view.main_area_panel wx.Panel.__init__(self, parent_view) if controller.pos == -1: controller.pos = parent_controller.view.get_notebook_page_count() # result = parent_controller.insert_notebook_page( controller.pos, self, controller.title, True) # if not result: log.error('Page could not be inserted in MainWindow notebook.') # controller.subscribe(self._set_title, 'change.title') controller.subscribe(self._set_pos, 'change.pos') controller.subscribe(self._set_float_mode, 'change.float_mode') # Set notebook page name self._set_own_name()
def __init__(self, controller_uid): UIViewObject.__init__(self, controller_uid) UIM = UIManager() # controller = UIM.get(self._controller_uid) parent_controller_uid = UIM._getparentuid(self._controller_uid) parent_controller = UIM.get(parent_controller_uid) wx.TreeCtrl.__init__(self, parent_controller.view, -1, wx.Point(0, 0), wx.Size(200, 250), wx.TR_DEFAULT_STYLE | wx.NO_BORDER) self._rootid = self.AddRoot(wx.EmptyString) self._set_project_name() # self.SetItemData(self._rootid, (controller._PSEUDOROOTUID, None)) self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.on_rightclick) ''' imglist = wx.ImageList(16, 16, True, 2) imglist.Add(wx.ArtProvider_GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, wx.Size(16,16))) tree.AssignImageList(imglist) items.append(tree.AppendItem(root, "Item 1", 0)) ''' parent_controller.view._mgr.AddPane(self, wx.aui.AuiPaneInfo().Name("tree"). Caption("Object Manager").Left().Layer(1).Position(1). PinButton(True).MinimizeButton(True). CloseButton(False).MaximizeButton(True) ) parent_controller.view._mgr.Update() self.Bind(wx.EVT_TREE_BEGIN_DRAG, self._on_begin_drag)
def __init__(self, controller_uid): TopLevel.__init__(self, controller_uid) UIM = UIManager() controller = UIM.get(self._controller_uid) # parent_uid = UIM._getparentuid(self._controller_uid) parent_obj = UIM.get(parent_uid) if not parent_obj: wx_parent = None else: wx_parent = parent_obj.view # wx.Frame.__init__(self, wx_parent, wx.ID_ANY, controller.title, pos=controller.pos, size=controller.size, style=controller.style) if controller.icon: self.icon = GripyIcon(controller.icon, wx.BITMAP_TYPE_ICO) self.SetIcon(self.icon) if controller.maximized: self.Maximize() # TODO: Bind para a super class??? self.Bind(wx.EVT_MAXIMIZE, self.on_maximize) self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.EVT_MOVE, self.on_move) self.Bind(wx.EVT_CLOSE, self.on_close)
def insert_notebook_page(self, *args, **kwargs): try: page = None if kwargs: page = kwargs.get('page') if not page: page = args[1] UIM = UIManager() page_ctrl_parent_uid = UIM._getparentuid(page._controller_uid) if self._controller_uid == page_ctrl_parent_uid: # print ('b4 insert page') ret_val = self._notebook.InsertPage(*args, **kwargs) # print ('after insert page') self.adjust_background_panel() # if not self._notebook.IsShown(): # print ('SETTING show_main_area_panel(False)') # self.show_main_area_panel(False) return ret_val except Exception as e: print('ERROR:', e) return False
def _on_track_move(self, event): axes = event.inaxes if axes is None: return OM = ObjectManager() UIM = UIManager() parent_controller_uid = UIM._getparentuid(self._controller_uid) parent_controller = UIM.get(parent_controller_uid) info = parent_controller.index_type + ': {:0.2f}'.format(event.ydata) for toc in UIM.list('track_object_controller', self._controller_uid): data = toc.get_data_info(event) if data is None: continue if isinstance(data, float): str_x = '{:0.2f}'.format(data) else: str_x = str(data) obj = OM.get(toc.data_obj_uid) info += ', {}: {}'.format(obj.name, str_x) # print ('on_track_move:', event.xdata, event.ydata) parent_controller.show_status_message(info)
def _set_title(self, new_value, old_value): UIM = UIManager() controller = UIM.get(self._controller_uid) main_window_uid = UIM._getparentuid(controller.uid) main_window = UIM.get(main_window_uid) my_pos = main_window.view.get_notebook_page_index(self) controller.set_value_from_event('pos', my_pos) main_window.view.set_notebook_page_text(controller.pos, new_value)
def get_canvas(self): try: first_mpl_object = list(self._mplot_objects.values())[0] canvas = first_mpl_object.figure.canvas return canvas except: # TODO: Rever linhas abaixo # Getting from TrackController try: UIM = UIManager() toc_uid = UIM._getparentuid(self._controller_uid) track_controller_uid = UIM._getparentuid(toc_uid) track_controller = UIM.get(track_controller_uid) tcc = track_controller._get_canvas_controller() return tcc.view except: raise
def on_change_width(self, new_value, old_value): UIM = UIManager() parent_uid = UIM._getparentuid(self.uid) parent_ctrl = UIM.get(parent_uid) parent_ctrl.view._do_change_width(self.get_position(False), self.width) if not self.selected: return parent_ctrl._change_width_for_selected_tracks(self.uid)
def _change_position(self, new_value, old_value): UIM = UIManager() parent_controller_uid = UIM._getparentuid(self._controller_uid) parent_controller = UIM.get(parent_controller_uid) print('\nTrackView._change_position:', self._controller_uid, old_value, new_value) parent_controller.change_track_position(self._controller_uid, old_value, new_value) self.update_title()
def __init__(self, controller_uid): UIViewObject.__init__(self, controller_uid) wx.MenuBar.__init__(self) # UIM = UIManager() parent_controller_uid = UIM._getparentuid(controller_uid) parent_controller = UIM.get(parent_controller_uid) wx_parent = parent_controller._get_wx_parent() wx_parent.SetMenuBar(self)
def depth_to_wx_position(self, depth): UIM = UIManager() parent_controller_uid = UIM._getparentuid(self._controller_uid) parent_controller = UIM.get(parent_controller_uid) if depth <= parent_controller.wellplot_ylim[0]: return 0 elif depth >= parent_controller.wellplot_ylim[1]: return self.track.GetClientSize().height return self.track.get_ypixel_from_depth(depth)
def _set_float_mode(self, new_value, old_value): UIM = UIManager() controller = UIM.get(self._controller_uid) parent_uid = UIM._getparentuid(controller.uid) if new_value: controller.unsubscribe(self._set_title, 'change.title') controller.unsubscribe(self._set_pos, 'change.pos') fc = UIM.create('frame_controller', parent_uid, title=controller.title) UIM.reparent(self._controller_uid, fc.uid) fc.view.Show() else: mwc_uid = UIM._getparentuid(parent_uid) mwc = UIM.get(mwc_uid) UIM.reparent(self._controller_uid, mwc.uid) UIM.remove(parent_uid) controller.subscribe(self._set_title, 'change.title') controller.subscribe(self._set_pos, 'change.pos')
def get_track_on_position(self, pos, relative_position=True): if pos == -1: return self.get_overview_track() b_splitter = self._tracks_panel.bottom_splitter if relative_position: pos = b_splitter.get_windows_indexes_shown()[pos] bottom_window = b_splitter.GetWindow(pos) UIM = UIManager() for tcc in UIM.list('track_canvas_controller'): if tcc.view == bottom_window: track_ctrl_uid = UIM._getparentuid(tcc.uid) return UIM.get(track_ctrl_uid) raise Exception('Informed position [{}] is invalid.'.format(pos))
def __init__(self, controller_uid): UIViewObject.__init__(self, controller_uid) _UIM = UIManager() controller = _UIM.get(self._controller_uid) parent_controller_uid = _UIM._getparentuid(self._controller_uid) parent_controller = _UIM.get(parent_controller_uid) #wx.SystemOptions.SetOption("msw.remap", '0') wx.ToolBar.__init__(self, parent_controller.view, controller.id, controller.pos, controller.size, controller.style) self.Realize() if isinstance(parent_controller, MainWindowController): mgr = wx.aui.AuiManager.GetManager(parent_controller.view) mgr.AddPane(self, self.paneinfo) mgr.Update()
def _set_pos(self, new_value, old_value): UIM = UIManager() controller = UIM.get(self._controller_uid) main_window_uid = UIM._getparentuid(controller.uid) main_window = UIM.get(main_window_uid) # Check event if new_value < 0 or new_value > main_window.view.get_notebook_page_count() - 1: # Undo wrong event controller.set_value_from_event('pos', old_value) return # Broadcasting position change to other pages for mw_child in UIM.list(tidfilter='workpage_controller', parentuidfilter=main_window_uid): pos = main_window.view.get_notebook_page_index(mw_child.view) mw_child.set_value_from_event('pos', pos)
def PostInit(self): log.debug('{}.PostInit started'.format(self.name)) _UIM = UIManager() controller = _UIM.get(self._controller_uid) parent_controller_uid = _UIM._getparentuid(self._controller_uid) parent_controller = _UIM.get(parent_controller_uid) if controller.pos == -1: # Appending - Not needed to declare pos controller.pos = parent_controller.view.GetMenuItemCount() if controller.pos > parent_controller.view.GetMenuItemCount(): # If pos was setted out of range for inserting in parent Menu msg = 'Invalid menu position for MenuItem with text={}. Position will be setting to {}'.format( controller.label, parent_controller.view.GetMenuItemCount()) log.warning(msg) controller.pos = parent_controller.view.GetMenuItemCount() log.debug('{}.PostInit ended'.format(self.name))
def __init__(self, controller_uid): UIViewObject.__init__(self, controller_uid) UIM = UIManager() parent_uid = UIM._getparentuid(self._controller_uid) parent_controller = UIM.get(parent_uid) wx_parent = parent_controller._get_wx_parent(self.tid) wx.Panel.__init__(self, wx_parent) # self.track_view_object = wx_parent self._visual_objects = [] self.SetBackgroundColour('white') self.SetSizer(wx.BoxSizer(wx.VERTICAL)) # self.Bind(wx.EVT_LEFT_DOWN, self._on_button_press) self.Bind(wx.EVT_MIDDLE_DOWN, self._on_button_press) self.Bind(wx.EVT_RIGHT_DOWN, self._on_button_press)
def end_dragging(self, canvas): if self._drag_mode != SASH_DRAG_DRAGGING: return self._drag_mode = SASH_DRAG_NONE self._old_y = None if self.track.HasCapture(): self.track.ReleaseMouse() # print 'mouse solto' y1 = self.d1_canvas.GetPosition()[1] y2 = self.d2_canvas.GetPosition()[1] #print 'y12:', y1, y2 if y1 <= y2: d1 = self.track.get_depth_from_ypixel(y1) d2 = self.track.get_depth_from_ypixel(y2 + self.canvas_width) # print 'considerando y12:', y1, y2 + self.canvas_width else: d1 = self.track.get_depth_from_ypixel(y2) d2 = self.track.get_depth_from_ypixel(y1 + self.canvas_width) # print 'considerando y12:', y2, y1 + self.canvas_width #print 'd12:', d1, d2 # UIM = UIManager() parent_controller_uid = UIM._getparentuid(self._controller_uid) parent_controller = UIM.get(parent_controller_uid) # #parent_controller.wellplot_ylim = (d1, d2) # parent_controller.set_value_from_event('shown_ylim', (d1, d2)) parent_controller._reload_ylim() # # #self._reload_depths_from_canvas_positions() #if self._callback: # self._callback(self.get_depth()) #print 'Send ' + str(self.get_depth()) + ' to callback...' canvas.SetBackgroundColour(self.canvas_color) canvas.Refresh() # #d1, d2 = self.get_depth() self.track.SetToolTip(wx.ToolTip('{0:.2f} - {1:.2f}'.format(d1, d2)))
def PreDelete(self): try: UIM = UIManager() controller = UIM.get(self._controller_uid) parent_controller_uid = UIM._getparentuid(self._controller_uid) parent_controller = UIM.get(parent_controller_uid) # TODO: disconect ctc.view.mpl_connect('motion_notify_event', self.on_track_move) ???? if not controller.overview: pos = controller.pos parent_controller._adjust_positions_after_track_deletion(pos) except Exception as e: print('TRACK PreDelete:', e) raise
def get_track_position(self, track_uid, relative_position=True): UIM = UIManager() if UIM._getparentuid(track_uid) != self._controller_uid: raise Exception() track = UIM.get(track_uid) if track.overview: return -1 tcc = track._get_canvas_controller() #if relative_position: # return self._tracks_panel.bottom_splitter.GetVisibleIndexOf(bottom) #return self._tracks_panel.bottom_splitter.IndexOf(bottom) if relative_position: ret = self._tracks_panel.bottom_splitter.GetVisibleIndexOf( tcc.view) else: ret = self._tracks_panel.bottom_splitter.IndexOf(tcc.view) #print 'get_track_position({}, {}): {}'.format(track_uid, relative_position, ret) return ret
def remove_properties(self, obj_uid): # print('\n\n\nRemoving ALL properties for:', obj_uid) UIM = UIManager() parent_controller_uid = UIM._getparentuid(self.uid) parent_controller = UIM.get(parent_controller_uid) # TODO: Retirar isso daqui... if parent_controller.view.splitter.IsSplit(): parent_controller.view.splitter.Unsplit(self.view) # # if self._properties: obj = self._get_object(obj_uid) # print('self.view.GetPropertyValues():', self.view.GetPropertyValues()) for key, value in self._properties.items(): obj.unsubscribe(self.refresh_property, 'change.' + key) # self._properties.clear() self.view.Clear()
def __init__(self, controller_uid): try: UIViewObject.__init__(self, controller_uid) UIM = UIManager() parent_controller_uid = UIM._getparentuid(self._controller_uid) parent_controller = UIM.get(parent_controller_uid) wx_parent = parent_controller._get_wx_parent(self.tid) pg.PropertyGrid.__init__( self, wx_parent, style=pg.PG_SPLITTER_AUTO_CENTER # |\ # pg.PG_HIDE_MARGIN ) self.SetMarginColour('white') self.SetCaptionBackgroundColour(BLUE_COLORS_SCALE[2]) self.SetCaptionTextColour('white') except Exception as e: print('ERRO PropertyGridView.__init__:', e)
def on_change_plottype(self, new_value, old_value): UIM = UIManager() repr_ctrl = self.get_representation() label = self.get_label() # if repr_ctrl: UIM.remove(repr_ctrl.uid) if label: label.destroy() # if new_value is not None: repr_tid = _PLOTTYPES_REPRESENTATIONS.get(new_value) try: # track_ctrl_uid = UIM._getparentuid(self.uid) track_ctrl = UIM.get(track_ctrl_uid) # if not track_ctrl.overview: label = track_ctrl._append_track_label( toc_uid=track_ctrl_uid ) # data_obj = self.get_data_object() label.set_title(data_obj.name) label.set_subtitle(data_obj.datatype) # self._label = label # else: self._label = None # # TODO: rever linha abaixo state = self._get_log_state() repr_ctrl = UIM.create(repr_tid, self.uid, **state) repr_ctrl.draw() # except Exception as e: print ('ERROR on_change_plottype', e) self.plottype = None raise
def _on_button_press(self, event): return UIM = UIManager() track_controller_uid = UIM._getparentuid(self._controller_uid) track_controller = UIM.get(track_controller_uid) track_controller._on_button_press(event) # self.track_view_object.process_event(event) """ if isinstance(event, wx.MouseEvent): gui_evt = event else: gui_evt = event.guiEvent print (gui_evt) if gui_evt.GetEventObject() and gui_evt.GetEventObject().HasCapture(): gui_evt.GetEventObject().ReleaseMouse() # """ """