Exemplo n.º 1
0
    def OnRenameObject(self, event):
        (node_type, node_main_info, node_extra_info) = self.popup_obj
        OM = ObjectManager()
        obj = OM.get(node_main_info)

        UIM = UIManager()
        dlg = UIM.create('dialog_controller', title='Rename object')
        #
        try:
            ctn_details = dlg.view.AddCreateContainer('StaticBox',
                                                      label='Object details',
                                                      orient=wx.VERTICAL,
                                                      proportion=0,
                                                      flag=wx.EXPAND | wx.TOP,
                                                      border=5)
            dlg.view.AddStaticText(ctn_details,
                                   proportion=0,
                                   flag=wx.EXPAND | wx.TOP,
                                   border=5,
                                   label='Name: ' + obj.name)
            #
            dlg.view.AddStaticText(ctn_details,
                                   proportion=0,
                                   flag=wx.EXPAND | wx.TOP,
                                   border=5,
                                   label='Type id: ' + obj.tid)
            dlg.view.AddStaticText(ctn_details,
                                   proportion=0,
                                   flag=wx.EXPAND | wx.TOP,
                                   border=5,
                                   label='Object id: ' + str(obj.oid))
            #
            ctn_new_name = dlg.view.AddCreateContainer('StaticBox',
                                                       label='New name',
                                                       orient=wx.VERTICAL,
                                                       proportion=0,
                                                       flag=wx.EXPAND | wx.TOP,
                                                       border=5)
            dlg.view.AddTextCtrl(ctn_new_name,
                                 proportion=0,
                                 flag=wx.EXPAND | wx.TOP,
                                 border=5,
                                 widget_name='new_name',
                                 initial=obj.name)
            #
            dlg.view.SetSize((300, 330))
            answer = dlg.view.ShowModal()
            #
            if answer == wx.ID_OK:
                results = dlg.get_results()
                new_name = results.get('new_name')
                obj.name = new_name
                UIM = UIManager()
                controller = UIM.get(self._controller_uid)
                controller.reload_object_node(obj.uid)
        except Exception as e:
            print('\nERROR OnRenameObject:', e)
            raise
        finally:
            UIM.remove(dlg.uid)
Exemplo n.º 2
0
 def _OnResetZAxis(self, event):
     """
     Reset based on controller.wellplot_ylim, not on a new DataIndex inclusion.
     """
     UIM = UIManager()
     controller = UIM.get(self._controller_uid)
     controller.shown_ylim = controller.wellplot_ylim
Exemplo n.º 3
0
 def PostInit(self):
     OM = ObjectManager()
     UIM = UIManager()
     controller = UIM.get(self._controller_uid)
     controller.subscribe(self.set_fit, 'change.fit')
     controller.subscribe(self.set_multicursor, 'change.multicursor')
     #
     well = OM.get(controller.obj_uid)
     controller.attach(well.uid)
     # Populate index type Choice
     for z_axis_dt in well.get_z_axis_datatypes().keys():
         self._tool_bar.choice_IT.Append(z_axis_dt)
     # Setting index type Choice
     idx_index_type = self._tool_bar.choice_IT.GetItems().index(
         controller.index_type)
     self._tool_bar.choice_IT.SetSelection(idx_index_type)
     #
     self._tool_bar.choice_IT.Bind(wx.EVT_CHOICE, self._on_index_type)
     # Setting min and max Z axis TextCtrls
     self._reload_z_axis_textctrls()
     # Create Overview Track
     UIM.create('track_controller',
                self._controller_uid,
                overview=True,
                plotgrid=False)
Exemplo n.º 4
0
 def _reload_tracks_titles(self, pos, exclude_track_uid=None):
     """
     From position on, reload Tracks titles.
     
     When a new :class:`~GRIPy-3.ui.mvc_classes.TrackController` object is
     created, others Tracks with position equal or greater must have their 
     titles updates.
     
     Parameters
     ----------
     pos: int
         First position to have title updated.
     exclude_track_uid: :class:`~GRIPy-3.ui.mvc_classes.TrackController` 
                         uid, optional.    
         If given, exclude the Track to have title updated.
     """
     UIM = UIManager()
     tracks_affected = UIM.exec_query('track_controller',
                                      self._controller_uid,
                                      'pos>=' + str(pos))
     if exclude_track_uid:
         exclude_track = UIM.get(exclude_track_uid)
         tracks_affected.remove(exclude_track)
     for track in tracks_affected:
         track.reload_track_title()
Exemplo n.º 5
0
 def insert_track(self):
     """
     Insert new tracks.
     
     If there is any selected track, create a new 
     :class:`~GRIPy-3.ui.mvc_classes.TrackController` at last position.
     Instead, for every selected track creates a new
     :class:`~GRIPy-3.ui.mvc_classes.TrackController` object one position
     before.
     
     Returns
     -------
     new_tracks_uids : list       
         A list containing :class:`~GRIPy-3.ui.mvc_classes.TrackController` 
         objects uids.
     """
     UIM = UIManager()
     selected_tracks = UIM.exec_query('track_controller',
                                      self.uid,
                                      'selected=True',
                                      orderby='pos',
                                      reverse=True)
     # There isn't any track selected
     if not selected_tracks:
         new_track = UIM.create('track_controller', self.uid, pos=len(self))
         return [new_track.uid]
     # Instead, insert new tracks before every selected track
     new_tracks_uids = []
     for track in selected_tracks:
         new_track = UIM.create('track_controller', self.uid, pos=track.pos)
         new_tracks_uids.append(new_track.uid)
     return new_tracks_uids
Exemplo n.º 6
0
 def __init__(self, controller_uid):
     UIViewObject.__init__(self, controller_uid)
     UIM = UIManager()
     controller = UIM.get(self._controller_uid)
     if controller.id == wx.ID_ANY:
         controller.id = UIM.new_wx_id()
     wx.Menu.__init__(self)
Exemplo n.º 7
0
 def set_multicursor(self, new_value, old_value):
     UIM = UIManager()
     tracks = UIM.list('track_controller', self._controller_uid)
     if not tracks:
         return
     for track in tracks:
         track.view.track.update_multicursor(new_value)
Exemplo n.º 8
0
 def reposition_depth_canvas(self):
     UIM = UIManager()
     controller = UIM.get(self._controller_uid)
     if not controller.overview:
         return
     tcc = UIM.list('track_canvas_controller', self._controller_uid)[0]
     tcc.reposition_depth_canvas()
Exemplo n.º 9
0
 def _doApply(self):
     results = []
     for panel in self.panels:
         results.append(panel.get_result())
     UIM = UIManager()
     controller = UIM.get(self._controller_uid)
     controller.Set(results)
Exemplo n.º 10
0
 def PreDelete(self):
     UIM = UIManager()
     controller = UIM.get(self._controller_uid)
     if controller.float_mode:
         raise Exception('TRATAR DELETE ON FLOAT MODE')
     mwc = interface.get_main_window_controller()
     mwc.remove_notebook_page(self)
Exemplo n.º 11
0
    def activatePlugin(self):
        if self.is_activated:
            return
        if self.plugin_object._parent_menu:
            menu_name = self.plugin_object._parent_menu
        else:
            menu_name = GripyPlugin._DEFAULT_PARENT_MENU
        found = None
        _UIM = UIManager()
        menus = _UIM.list('menu_controller')
        for menu in menus:
            testing_name = menu.label
            if testing_name.startswith('&'):
                testing_name = testing_name[1:]
            if testing_name == menu_name:
                found = menu
        if found:
            msg = 'Plugin {} will try insert itself to Menu {}'.format(
                self.name, found.label)
            log.debug(msg)

            menu_item = _UIM.create('menu_item_controller',
                                    found.uid,
                                    label=self.name,
                                    help=self.description,
                                    callback=self.plugin_object.event_run)

            if menu_item:
                self._menu_item_uid = menu_item.uid
            log.debug('Plugin {} was inserted to Menu {}'.format(
                self.name, found.label))
        self.plugin_object.activate()
        log.debug('Activated plugin: {}'.format(self.name))
Exemplo n.º 12
0
 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)
Exemplo n.º 13
0
 def on_page_changed(self, event):
     UIM = UIManager()
     for idx in range(self._notebook.GetPageCount()):
         page = self._notebook.GetPage(idx)
         controller = UIM.get(page._controller_uid)
         controller.set_value_from_event('pos', idx)
     event.Skip()
Exemplo n.º 14
0
    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)
Exemplo n.º 15
0
 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()
Exemplo n.º 16
0
 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)
Exemplo n.º 17
0
 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)
Exemplo n.º 18
0
    def set_ylim(self, ymin, ymax):
        tcc = self._get_canvas_controller()
        tcc.ylim = (ymax, ymin)
        UIM = UIManager()
        for toc in UIM.list('track_object_controller', self._controller_uid):

            toc.redraw()
Exemplo n.º 19
0
    def PostInit(self):
        try:
            self.sizer = wx.BoxSizer(wx.VERTICAL)
            self._tool_bar = wx.aui.AuiToolBar(self)
            self.sizer.Add(self._tool_bar, 0, flag=wx.TOP | wx.EXPAND)
            #     
            UIM = UIManager()
            canvas_controller = UIM.create('canvas_plotter_controller',
                                           self._controller_uid
                                           )
            #

            self._main_panel = canvas_controller.view
            # TODO: Keep this conection? (must be disconected at PreDelete??)
            #            self._main_panel.mpl_connect('motion_notify_event', 
            #                                                     self.on_canvas_mouse_move)
            self.sizer.Add(self._main_panel, 1, flag=wx.EXPAND)
            #
            self._status_bar = PlotStatusBar(self)
            self.sizer.Add(self._status_bar, 0, flag=wx.BOTTOM | wx.EXPAND)
            self.SetSizer(self.sizer)
            #
            self._build_tool_bar()
            self.Layout()
        except Exception as e:
            print('ERROR IN CrossPlot.PostInit:', e)
            raise
Exemplo n.º 20
0
 def create_depth_canvas(self):
     self._in_canvas = -1
     self._drag_mode = SASH_DRAG_NONE
     self.canvas_color = 'blue'
     self.canvas_alt_color = 'red'
     self.canvas_width = 3
     #
     display_coords = self._get_depth_canvas_display_coords()
     #
     UIM = UIManager()
     tcc = UIM.list('track_canvas_controller', self._controller_uid)[0]
     #
     self.d1_canvas = wx.Panel(tcc.view, name='D1')
     self.d1_canvas.SetSize((display_coords['width'], self.canvas_width))
     self.d1_canvas.SetBackgroundColour(self.canvas_color)
     self.d1_canvas.SetPosition(
         (display_coords['xmin'], display_coords['ymin']))
     #
     self.d2_canvas = wx.Panel(tcc.view, name='D2')
     self.d2_canvas.SetSize((display_coords['width'], self.canvas_width))
     self.d2_canvas.SetBackgroundColour(self.canvas_color)
     self.d2_canvas.SetPosition(
         (display_coords['xmin'],
          display_coords['ymax'] - self.canvas_width))
     #
     self.d1_canvas.Bind(wx.EVT_MOUSE_EVENTS, self.on_canvas_mouse)
     self.d2_canvas.Bind(wx.EVT_MOUSE_EVENTS, self.on_canvas_mouse)
Exemplo n.º 21
0
    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)
Exemplo n.º 22
0
    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
Exemplo n.º 23
0
 def PostInit(self):
     self.create_title()
     UIM = UIManager()
     controller = UIM.get(self._controller_uid)
     controller.subscribe(self._on_change_title, 'change.title')
     controller.subscribe(self._on_change_title, 'change.title_bgcolor')
     controller.subscribe(self._on_change_title, 'change.title_fontsize')
Exemplo n.º 24
0
 def _set_project_name(self, name=wx.EmptyString):
     UIM = UIManager()
     controller = UIM.get(self._controller_uid)
     if name:
         self._root_name = controller._DEFAULT_ROOT_NAME + ' [' + name + ']'
     else:
         self._root_name = controller._DEFAULT_ROOT_NAME
     self.SetItemText(self._rootid, self._root_name)
Exemplo n.º 25
0
 def _get_label_controller(self):
     """
     """
     UIM = UIManager()
     controller = UIM.get(self._controller_uid)
     if controller.overview:
         return None
     return UIM.list('track_label_controller', self._controller_uid)[0]
Exemplo n.º 26
0
 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)
Exemplo n.º 27
0
    def PreExit(self):
        msg = 'GriPy Application is preparing to terminate....'
        log.info(msg)

        OM = ObjectManager()
        UIM = UIManager()
        UIM.PreExit()
        OM._reset()
Exemplo n.º 28
0
 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)
Exemplo n.º 29
0
 def _reload_z_axis_textctrls(self, *args):
     UIM = UIManager()
     controller = UIM.get(self._controller_uid)
     ymin, ymax = controller.shown_ylim
     z_start_str = "{0:.2f}".format(ymin)
     self._tool_bar.z_start.SetValue(z_start_str)
     z_end_str = "{0:.2f}".format(ymax)
     self._tool_bar.z_end.SetValue(z_end_str)
Exemplo n.º 30
0
 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)