示例#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)
示例#2
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)
示例#3
0
    def _open_model(self, model_uid):
        OM = ObjectManager()
        model = OM.get(model_uid)

        UIM = UIManager()
        mwc = wx.GetApp().get_main_window_controller()
        cc = UIM.create('modelplot_controller', mwc.uid)

        #xlim_max, ylim_max = model.data.shape
        # (left, right, bottom, top)
        extent = (0, model.nx, model.ny, 0)

        print("\n\n")
        print(extent)
        print("\n\n")

        image = cc._main_panel.append_artist("AxesImage",
                                             cmap="binary",
                                             extent=extent)

        image.set_data(model.data)

        cpc = UIM.list('canvas_plotter_controller', cc.uid)[0]
        cpc.figure_titletext = model.name

        xlim = (0, model.nx)
        cpc.xlim = xlim
        cpc.set_plot_lim("x", xlim)
        ylim = (model.ny, 0)
        cpc.ylim = ylim
        cpc.set_plot_lim("y", ylim)

        print(model.nx, model.ny)
示例#4
0
    def _get_log_state(self):
        # TODO: Rever necessidade de obj.name - ParametersManager
        state = {}
        OM = ObjectManager()
        obj = OM.get(self.data_obj_uid)

        if obj.tid == 'log':
            # TODO: Rever isso
            PM = ParametersManager.get()
            parms = PM.get_datatypes_visual_props(obj.datatype)
            if parms is not None:
                state['left_scale'] = parms.get('LeftScale')
                state['right_scale'] = parms.get('RightScale')
                state['thickness'] = parms.get('LineWidth')
                state['color'] = parms.get('Color', 'Black')
                loglin = parms.get('LogLin')
                if loglin == 'Lin':
                    state['x_scale'] = 0
                elif loglin == 'Log':
                    state['x_scale'] = 1
                else:
                    raise ValueError('Unknown LogLin: [{}]'.format(loglin))
            else:
                if obj.name == 'LOG_TESTE_CURVE':
                    state['x_scale'] = 1
                    ls, rs = (0.01, 100000.0)
                else:
                    state['x_scale'] = 0
                    ls, rs = calculate_extremes(obj)
                state['left_scale'] = ls
                state['right_scale'] = rs

        return state
示例#5
0
 def get_data_info(self, event):
     """
     Retorna a string com informações do dado exibido em tela, 
     de acordo com a posicao do mouse no momento.
     """
     image = self._mplot_objects.get('density')
     if image:
         value = image.get_cursor_data(event)
         #
         #            UIM = UIManager()
         #            controller = UIM.get(self._controller_uid)
         toc = self.get_parent_controller()
         x_di_uid, x_index_data = toc.get_index_for_dimension(-2)
         y_di_uid, y_index_data = toc.get_index_for_dimension(-1)
         canvas = self.get_canvas()
         xvalue = canvas.inverse_transform(event.xdata, x_index_data[0],
                                           x_index_data[-1])
         #
         OM = ObjectManager()
         x_data_index = OM.get(x_di_uid)
         y_data_index = OM.get(y_di_uid)
         #
         if event.ydata < y_index_data[0] or event.ydata > y_index_data[-1]:
             return None
         #
         msg = x_data_index.name + ': {:0.2f}'.format(xvalue) + ', ' \
               + y_data_index.name + ': {:0.2f}'.format(event.ydata)
         msg += ', Value: {:0.2f}'.format(value)
         return '[' + msg + ']'
     else:
         msg = ''
         return '[' + msg + ']'
示例#6
0
 def _init_data(self):
     try:
         OM = ObjectManager()
         data_obj = OM.get(self.data_obj_uid)
         # No need to get unit from data_obj if it not changed.
         self._data_name = data_obj.name
         self._data_unit = data_obj.unit
         self._data_type = data_obj.datatype
         #
         data_indexes = data_obj.get_data_indexes()
         for dim_idx in range(len(data_indexes)):
             indexes_per_dim_uid = data_indexes[dim_idx]
             di_uid = indexes_per_dim_uid[0]  # Chosing the first one!
             di = OM.get(di_uid)
             if (len(data_indexes) - dim_idx) <= 2:
                 # Sempre exibe as 2 ultimas dimensoes do dado.
                 # Ex: sismica 3-d stacked (iline, xline, tempo) serah exibido
                 # xline e tempo, em principio.
                 # (di_uid, is_ranged, start, stop)
                 self._data.append([di_uid, True, 0, len(di.data)])
             else:
                 self._data.append([di_uid, False, 0, len(di.data)])
                 #
     except Exception as e:
         print('ERROR _init_data:', e)
         raise
示例#7
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)
示例#8
0
 def PostInit(self):
     toc = self._get_track_object_controller()
     OM = ObjectManager()
     for (di_uid, display, first, last) in toc._data:
         di = OM.get(di_uid)
         print('\n', di.name, display, first, last)
         self.view.add_panel(di_uid, display, first, last)
     self.view.add_bottom_panel()
示例#9
0
 def PreExit(self):
     msg = "Application is preparing to terminate...."
     logging.debug(msg)
     #
     OM = ObjectManager()
     UIM = UIManager()
     UIM.PreExit()
     OM._reset()
示例#10
0
 def get_friendly_name(self):
     """
     Metodo duplicado em Log e DataIndex
     """
     OM = ObjectManager()
     parent_well_uid = OM._getparentuid(self.uid)
     parent_well = OM.get(parent_well_uid)
     return self.name + '@' + parent_well.name
示例#11
0
    def PreExit(self):
        msg = 'GriPy Application is preparing to terminate....'
        log.info(msg)

        OM = ObjectManager()
        UIM = UIManager()
        UIM.PreExit()
        OM._reset()
示例#12
0
 def get_data_indexes(self):
     OM = ObjectManager()
     curve_sets = OM.list('curve_set', self.uid)
     ret = OrderedDict()
     for curve_set in curve_sets:
         dis = OM.list('data_index', curve_set.uid)
         ret[curve_set.uid] = dis
     return ret
示例#13
0
def on_save_image(*args, **kwargs):
    
    OM = ObjectManager()
    UIM = UIManager()
    #
    images_od = OrderedDict()
    images = OM.list('image')
    for image in images:
        images_od[image.name] = image.uid    

    #
    dlg = UIM.create('dialog_controller', title='Save image file')
    ctn_image = dlg.view.AddCreateContainer('StaticBox', label='Select Image', 
                                            orient=wx.VERTICAL, proportion=0, 
                                            flag=wx.EXPAND|wx.TOP, border=5)


    dlg.view.AddChoice(ctn_image, proportion=0, flag=wx.EXPAND|wx.TOP, 
                       border=5, widget_name='images_choice', options=images_od,
                       initial=0) 
    #
    
    dlg.view.SetSize((300, 180))
    result = dlg.view.ShowModal()

  
    
    if result == wx.ID_OK:
        results = dlg.get_results()  
            
        print(results)    
    
        image_uid = results.get("images_choice")
    
    
        wildcard = "Save image file (*.png, *.tif)|*.png;*.tif"
    
        fdlg = wx.FileDialog(wx.App.Get().GetTopWindow(), 
                             "Save file", 
                             wildcard=wildcard, 
                             style=wx.FD_SAVE
        )
        
        if fdlg.ShowModal() == wx.ID_OK:
            file_name = fdlg.GetFilename()
            dir_name = fdlg.GetDirectory()
            fdlg.Destroy()
        else:
            fdlg.Destroy()
            return
        
        fullfilename = os.path.join(dir_name, file_name)        
        
        print("fullfilename: ", fullfilename)

        image = OM.get(image_uid)
        img = Image.fromarray(image.data)
        img.save(fullfilename)
示例#14
0
 def get_friendly_name(self):
     UIM = UIManager()
     controller = UIM.get(self._controller_uid)
     OM = ObjectManager()
     well = OM.get(controller.obj_uid)
     idx = self._get_sequence_number()
     name = self._get_tid_friendly_name() \
                            + ': ' + well.name + ' ['+ str(idx) + ']'
     return name
示例#15
0
    def _create_data_index_map(self, *args):
        """
        args: List of lists of DataIndex uids. 
              
        Examples:
            
            1-D data: [index.uid, owt_index.uid, twt_index.uid]
            
            5-D data: [i_line_index.uid],
                      [x_line_index.uid],
                      [offset_index.uid],
                      [freq_index.uid],
                      [time_index.uid, prof_index.uid]
        """
        max_dims = self._get_max_dimensions()
        if len(args) > max_dims:
            msg = 'Exceed number of dimensions [{}] - {}.'.format(
                max_dims, args)
            print('\n' + msg)
            raise Exception(msg)

        OM = ObjectManager()
        data = []

        for di_objs in args:
            if not isinstance(di_objs, list):
                # arg should be a object uid.
                di_objs = [di_objs]
            for di_obj in di_objs:
                try:
                    # Then, test if object exist this is a valid object uid.
                    obj = OM.get(di_obj)
                    if not obj.tid == 'data_index':
                        raise Exception()
                except:
                    print('\n\nDEU RUIM:', di_obj)
                    msg = 'Error in objects informed as ' + \
                                            'Data Indexes: {}.'.format(args)
                    raise Exception(msg)

            data.append(di_objs)

        try:
            di_map = OM.new('data_index_map', data)
        except Exception as e:
            msg = 'ERROR DataObject._create_data_index_map: {} - data: {}'.format(
                e, data)
            print('\n' + msg)
            raise

        if not OM.add(di_map, self.uid):
            msg = 'Cannot add {} to {}.'.format(di_map, self.uid)
            print('\n' + msg)
            raise Exception(msg)

        msg = 'Criado {} com sucesso.'.format(di_map)
示例#16
0
    def __init__(self, rocktableuid):
        super(RockTable, self).__init__()

        self.OM = ObjectManager()
        self.rocktypeuid = []
        self.rocktableuid = rocktableuid

        self.rocktypemap = [rocktype.uid for rocktype in self.OM.list('rocktype', self.rocktableuid)]
        self.N_COLS = 4
        self.N_ROWS = 0
示例#17
0
    def __init__(self, *args, **kwargs):
        if 'size' not in kwargs:
            kwargs['size'] = (640, 480)

        super(Dialog, self).__init__(*args, **kwargs)

        self.OM = ObjectManager()

        self.currentwellindex = 0
        self.currentrocktableindex = 0

        self.tables = []

        self.rocktablemap = [
            rocktable.uid for rocktable in self.OM.list('rocktable')
        ]
        work_table = []
        for rocktable in self.OM.list('rocktable'):
            work_table.append(RockTable(rocktable.uid))
        self.tables.append(work_table)
        self.grid = wx.grid.Grid(self)
        self.grid.SetDefaultColSize(100)

        #        else:
        self.grid.SetTable(
            self.tables[self.currentwellindex][self.currentrocktableindex])
        self.grid.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.on_cell_dlclick)
        self.grid.Bind(wx.grid.EVT_GRID_LABEL_LEFT_DCLICK,
                       self.on_label_dlclick)

        toolbar_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.rocktable_choice = wx.Choice(self)
        self.rocktable_choice.AppendItems([
            self.OM.get(rocktableuid).name
            for rocktableuid in self.rocktablemap
        ])
        self.rocktable_choice.SetSelection(self.currentrocktableindex)
        self.rocktable_choice.Bind(wx.EVT_CHOICE, self.on_rocktable_choice)

        add_rocktype_button = wx.Button(self, label='ADD ROCK TYPE')
        add_rocktype_button.Bind(wx.EVT_BUTTON, self.on_add_rocktype)

        remove_rocktype_button = wx.Button(self, label='REM ROCK TYPE')
        remove_rocktype_button.Bind(wx.EVT_BUTTON, self.on_remove_rocktype)

        toolbar_sizer.Add(self.rocktable_choice, 1, wx.ALIGN_LEFT)
        toolbar_sizer.Add(add_rocktype_button, 0, wx.ALIGN_LEFT)
        toolbar_sizer.Add(remove_rocktype_button, 0, wx.ALIGN_LEFT)

        main_sizer = wx.BoxSizer(wx.VERTICAL)
        main_sizer.Add(toolbar_sizer, proportion=0, flag=wx.EXPAND)
        main_sizer.Add(self.grid, proportion=1, flag=wx.EXPAND)

        self.SetSizer(main_sizer)
示例#18
0
 def get_curve_set(self):
     """
     Metodo de conveniencia.
     
     Se o objeto possui curve_set, o retorna. Senão retorna None.
     
     Metodo duplicado em DataIndex e Log.
     """
     OM = ObjectManager()
     curve_set_uid = OM._getparentuid(self.uid)
     return OM.get(curve_set_uid)
示例#19
0
 def get_friendly_indexes_dict(self):
     """Used by menu_functions
     """
     OM = ObjectManager()
     ret_od = OrderedDict()
     indexes_set = self.get_data_indexes()
     for curve_set_uid, data_indexes in indexes_set.items():
         curve_set = OM.get(curve_set_uid)
         for data_index in data_indexes:
             di_friendly_name = data_index.name + '@' + curve_set.name
             ret_od[di_friendly_name] = data_index.uid
     return ret_od
示例#20
0
 def get_data_indexes(self, dimension=None):
     """
     """
     OM = ObjectManager()
     data_index_maps = OM.list('data_index_map', self.uid)
     if not data_index_maps:
         raise Exception('Object without DataIndexMap: {}'.format(self.uid))
     data_index_map = data_index_maps[0]
     data_indexes = data_index_map._get_data_indexes()
     if dimension is None:
         return data_indexes
     return data_indexes[dimension]
示例#21
0
文件: tree.py 项目: giruenf/GRIPy
 def OnUnitConvert(self, event):
     (node_type, node_main_info, node_extra_info) = self.popup_obj
     OM = ObjectManager()
     obj = OM.get(node_main_info)
     try:
         unit = uom.get_unit(obj.unit)
         dim = uom.get_unit_dimension(unit.dimension)
         qc = uom.get_quantity_class(dim.name)
         UNITS_OPTIONS = OrderedDict()
         for mu in qc.memberUnit:
             UNITS_OPTIONS[mu] = mu
     except:
         msg = 'Unit ' + obj.unit + ' cannot be converted.'
         wx.MessageBox(msg, 'Warning', wx.OK | wx.ICON_WARNING)
         return
         #
     UIM = UIManager()
     dlg = UIM.create('dialog_controller', title='Unit conversion')
     #
     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))
         dlg.view.AddStaticText(ctn_details, proportion=0, flag=wx.EXPAND | wx.TOP, border=5,
                                label='Current unit: ' + obj.unit)
         #
         ctn_new_unit = dlg.view.AddCreateContainer('StaticBox', label='New unit', orient=wx.VERTICAL, proportion=0,
                                                    flag=wx.EXPAND | wx.TOP, border=5)
         dlg.view.AddChoice(ctn_new_unit, proportion=0, flag=wx.EXPAND | wx.TOP, border=5, widget_name='new_unit',
                            options=UNITS_OPTIONS)
         #    
         dlg.view.SetSize((300, 330))
         answer = dlg.view.ShowModal()
         #
         if answer == wx.ID_OK:
             results = dlg.get_results()
             new_unit_name = results.get('new_unit')
             new_data = uom.convert(obj.data, obj.unit, new_unit_name)
             obj._data = new_data
             obj.unit = new_unit_name
         #                UIM = UIManager()
     #                controller = UIM.get(self._controller_uid)
     #                controller.reload_object(obj.uid)
     except Exception:
         pass
     finally:
         UIM.remove(dlg.uid)
示例#22
0
 def get_index_for_dimension(self, dim_idx=-1):
     """
     For some data dimension, returns the DataIndex uid and 
     its data filtered by mask values.
     """
     OM = ObjectManager()
     dim_data = self._data[dim_idx]
     dim_di_uid = dim_data[0]
     di = OM.get(dim_di_uid)
     slicer = self._get_slicer()
     dim_di_data = di.data[slicer[dim_idx]]
     return dim_di_uid, dim_di_data
示例#23
0
 def _reload_ylims_from_index_type(self):
     """
     Given a y axis datatype (e.g. MD), reload its limits.
     """
     OM = ObjectManager()
     try:
         well = OM.get(self.obj_uid)
     except:
         raise
     ylim = well.get_z_axis_datatype_range(self.index_type)
     self.wellplot_ylim = ylim
     self.shown_ylim = ylim
示例#24
0
 def __init__(self, data_index_uid, display, is_range, min_idx, max_idx,
              *args, **kwargs):
     super(DimensionPanel, self).__init__(*args, **kwargs)
     self.SetSize(300, 50)
     #
     self.data_index_uid = data_index_uid
     OM = ObjectManager()
     obj = OM.get(data_index_uid)
     #
     main_sizer = wx.StaticBoxSizer(wx.VERTICAL, self, obj.name)
     #
     self.top_panel = wx.Panel(self)
     self.top_sizer = wx.BoxSizer(wx.HORIZONTAL)
     #
     self.check_display = wx.CheckBox(self.top_panel, -1, label='Display')
     self.check_display.Bind(wx.EVT_CHECKBOX, self._on_check_display)
     self.top_sizer.Add(self.check_display, 1, wx.ALIGN_CENTER | wx.LEFT,
                        30)
     #
     self.check_range = wx.CheckBox(self.top_panel, -1, label='Range')
     self.check_range.Bind(wx.EVT_CHECKBOX, self._on_check_range)
     self.top_sizer.Add(self.check_range, 1, wx.ALIGN_CENTER | wx.RIGHT, 30)
     self.top_panel.SetSizer(self.top_sizer)
     #
     main_sizer.Add(self.top_panel, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 3)
     #
     self.label = obj.name
     self.vec = obj.data
     self.display = display
     self.is_range = is_range
     #
     self.bottom_panel = wx.Panel(self)
     self.bottom_sizer = wx.BoxSizer(wx.VERTICAL)
     self.slider = RangeSlider(self.bottom_panel)
     self.bottom_sizer.Add(self.slider, 0, wx.EXPAND)
     self.text_value = wx.StaticText(self.bottom_panel, -1)
     self.bottom_sizer.Add(self.text_value, 0, wx.ALIGN_CENTER)
     self.bottom_panel.SetSizer(self.bottom_sizer)
     #
     main_sizer.Add(self.bottom_panel, 0, wx.EXPAND)
     #
     self.slider.SetRange(0, len(self.vec) - 1)
     self.min_idx = min_idx
     self.max_idx = max_idx
     #
     if self.display:
         self.set_check_display(1)
     else:
         self.set_check_display(0)
     #
     self.Bind(wx.EVT_PAINT, self._on_paint)
     self.SetSizer(main_sizer)
     main_sizer.Layout()
示例#25
0
 def load_project_data(self, fullfilename):
     OM = ObjectManager()
     UIM = UIManager()
     self.OM_file = fullfilename
     ret = OM.load(self.OM_file)
     if not ret:
         msg = 'GRIPy project cannot be opened.'
         wx.MessageBox(msg, 'Error', wx.OK | wx.ICON_ERROR)
         return
     mwc = UIM.list('main_window_controller')[0]
     tree_ctrl = UIM.list('tree_controller', mwc.uid)[0]
     if tree_ctrl:
         tree_ctrl.set_project_name(self.OM_file)
示例#26
0
    def _add_tree_node(self, objuid, parentuid=None):

        logging.debug("_add_tree_node " + str(objuid) + " - " + str(parentuid))

        OM = ObjectManager()
        obj = OM.get(objuid)

        node_props = obj._get_tree_object_node_properties()
        if node_props is None:
            return

        if obj._is_tree_tid_node_needed():

            obj_parent_node = self.get_object_tree_item(
                ID_TYPE_TID, objuid[0], parentuid)
            if obj_parent_node is None:

                if parentuid is None:
                    # Create tid node as a root child
                    tid_parent_node = self.GetRootItem()
                else:
                    # Create tid node as another object child
                    tid_parent_node = self.get_object_tree_item(
                        ID_TYPE_OBJECT, parentuid)

                # Create tid node
                class_ = OM._gettype(objuid[0])
                tid_label = class_._get_tid_friendly_name()

                obj_parent_node = self.AppendItem(tid_parent_node, tid_label)
                self.SetItemData(obj_parent_node,
                                 (ID_TYPE_TID, objuid[0], parentuid))
                self.Expand(tid_parent_node)
        else:
            obj_parent_node = self.get_object_tree_item(
                ID_TYPE_OBJECT, parentuid)

        obj_repr = node_props.pop('name')
        obj_node = self.AppendItem(obj_parent_node, obj_repr)
        self.SetItemData(obj_node, (ID_TYPE_OBJECT, objuid, 'name'))

        self.Expand(obj_parent_node)

        for attr, attr_label in node_props.items():
            logging.debug('Creating attr_node: {} - {} - {}'.format(
                ID_TYPE_ATTRIBUTE, objuid, attr))
            attr_node = self.AppendItem(obj_node, attr_label)
            self.SetItemData(attr_node, (ID_TYPE_ATTRIBUTE, objuid, attr))
            #print ('Creating attr_node:',  (ID_TYPE_ATTRIBUTE, objuid, attr))

        self.Expand(obj_node)
示例#27
0
 def get_z_axis_datatype_range(self, datatype):
     """Given a Well index datatype (e.g. `MD`), returns a tuple with its 
     minimal and maximum values, considering all occurences.
     """
     min_ = 100000
     max_ = -1
     OM = ObjectManager()
     data_indexes = OM.list('data_index', self.uid, True)
     for data_index in data_indexes:
         if data_index.datatype == datatype:
             if data_index.start < min_:
                 min_ = data_index.start
             if data_index.end > max_:
                 max_ = data_index.end
     return (min_, max_)
示例#28
0
文件: objects.py 项目: giruenf/GRIPy
 def detach(self):
     """Detach a object vinculated to a ObjectManager object 
     by attach function.
     
     Called automatic from UIManager.remove function.
     """
     if self._attached_to is None:
         return
     #        print ('DETACHING...')
     try:
         OM = ObjectManager()
         OM.unsubscribe(self._check_OM_removals, 'pre_remove')
         #            print ('DETACHED {} FROM {}! \n'.format(self.uid, self._attached_to))
         self._attached_to = None
     except Exception as e:
         print('ERROR WHILE DETACHING:', e)
示例#29
0
    def reload_tree(self, *args):

        print()

        logging.debug("reload_tree " + str(args))

        self.DeleteChildren(self._rootid)
        OM = ObjectManager()

        lista = OM.list()
        print(lista)

        print()

        for obj in OM.list():
            self._add_tree_node(obj.uid, OM._getparentuid(obj.uid))
示例#30
0
    def set_dimension(self, dim_idx=-1, **kwargs):
        """
        dim_idx here refers to object actual data indexes.
        """
        # TODO: make dimensions changeable with np.transpose.
        #"""
        #dim_idx here refers to DataMask current dimension, not object
        #data indexes.
        #"""
        datatype = kwargs.pop('datatype', None)
        name = kwargs.pop('name', None)
        di_uid = kwargs.pop('di_uid', None)
        #
        if datatype is None and name is None and di_uid is None:
            raise Exception(
                'Either di_uid, datatype or name must be informed.')
        #
        OM = ObjectManager()
        data_obj = OM.get(self.data_obj_uid)
        data_indexes = data_obj.get_data_indexes()
        dim_dis_uids = data_indexes[dim_idx]
        #        print('dim_dis_uids:', dim_dis_uids)
        ret_datatypes = []
        #
        for dim_di_uid in dim_dis_uids:
            if dim_di_uid == di_uid:
                self._data[dim_idx][0] = di_uid
                #                print('self._data[dim_idx] 2.1:', self._data[dim_idx])
                return True
            dim_di = OM.get(dim_di_uid)
            #            print(dim_di.datatype, datatype)
            if dim_di.name == name:
                self._data[dim_idx][0] = dim_di_uid
                #                print('self._data[dim_idx] 2.2:', self._data[dim_idx])
                return True
            elif dim_di.datatype == datatype:
                ret_datatypes.append(dim_di_uid)
        if ret_datatypes:
            self._data[dim_idx][0] = ret_datatypes[
                0]  # Sets with the first one
            #            print('self._data[dim_idx] 2.3:', self._data[dim_idx])
            return True


#        print('set_dimension DEU FALSE')
        return False