Exemplo n.º 1
0
 def _set_setting(self, settings, setting_keys, setting_names, default,
                  save=True, auto_type=None):
     """
     helper method for ``reapply_settings``
     """
     set_name = setting_names[0]
     value = get_setting(settings, setting_keys, setting_names, default,
                         auto_type=auto_type)
     if save:
         setattr(self, set_name, value)
     return value
Exemplo n.º 2
0
 def _set_setting(self, settings, setting_keys: List[str],
                  setting_names: List[str], default: Any,
                  save: bool=True, auto_type=None) -> Any:
     """
     helper method for ``reapply_settings``
     """
     set_name = setting_names[0]
     value = get_setting(settings, setting_keys, setting_names, default,
                         auto_type=auto_type)
     if save:
         setattr(self, set_name, value)
     return value
Exemplo n.º 3
0
    def load(self, settings):
        """helper method for ``setup_gui``"""
        #red = (1.0, 0.0, 0.0)
        screen_shape_default = (1100, 700)

        setting_keys = [str(key) for key in settings.childKeys()]

        # sets the window size/position
        main_window_geometry = get_setting(
            settings, setting_keys,
            ['main_window_geometry', 'mainWindowGeometry'], None)
        if main_window_geometry is not None:
            self.parent.restoreGeometry(main_window_geometry)

        # this is the gui font
        self._set_setting(settings,
                          setting_keys, ['font_size'],
                          self.font_size,
                          auto_type=int)

        # the info/debug/gui/command preferences
        self._set_setting(settings,
                          setting_keys, ['show_info'],
                          self.show_info,
                          True,
                          auto_type=bool)
        self._set_setting(settings,
                          setting_keys, ['show_debug'],
                          self.show_debug,
                          True,
                          auto_type=bool)
        self._set_setting(settings,
                          setting_keys, ['show_command'],
                          self.show_command,
                          True,
                          auto_type=bool)
        self._set_setting(settings,
                          setting_keys, ['show_warning'],
                          self.show_warning,
                          True,
                          auto_type=bool)
        self._set_setting(settings,
                          setting_keys, ['show_error'],
                          self.show_error,
                          True,
                          auto_type=bool)

        # the vtk panel background color
        self._set_setting(settings,
                          setting_keys, ['use_gradient_background'],
                          False,
                          auto_type=bool)
        self._set_setting(settings,
                          setting_keys,
                          ['background_color', 'backgroundColor'],
                          GREY,
                          auto_type=float)
        self._set_setting(settings,
                          setting_keys, ['background_color2'],
                          GREY,
                          auto_type=float)

        # scales the coordinate systems
        self._set_setting(settings,
                          setting_keys, ['coord_scale'],
                          self.coord_scale,
                          auto_type=float)
        self._set_setting(settings,
                          setting_keys, ['coord_text_scale'],
                          self.coord_text_scale,
                          auto_type=float)

        # this is for the 3d annotation
        self._set_setting(settings,
                          setting_keys, ['annotation_color', 'labelColor'],
                          BLACK,
                          auto_type=float)
        self._set_setting(settings,
                          setting_keys, ['annotation_size'],
                          18,
                          auto_type=int)  # int
        if isinstance(self.annotation_size, float):
            # throw the float in the trash as it's from an old version of vtk
            self.annotation_size = 18
        elif isinstance(self.annotation_size, int):
            pass
        else:
            print('annotation_size = ', self.annotation_size)

        self._set_setting(settings,
                          setting_keys, ['magnify'],
                          self.magnify,
                          auto_type=int)

        # this is the text in the lower left corner
        self._set_setting(settings,
                          setting_keys, ['text_color', 'textColor'],
                          BLACK,
                          auto_type=float)
        self._set_setting(settings,
                          setting_keys, ['text_size'],
                          14,
                          auto_type=int)

        # highlight
        self._set_setting(settings,
                          setting_keys, ['highlight_color'],
                          ORANGE,
                          auto_type=float)
        self._set_setting(settings,
                          setting_keys, ['highlight_opacity'],
                          HIGHLIGHT_OPACITY,
                          auto_type=float)
        self._set_setting(settings,
                          setting_keys, ['highlight_point_size'],
                          HIGHLIGHT_POINT_SIZE,
                          auto_type=float)
        self._set_setting(settings,
                          setting_keys, ['highlight_line_thickness'],
                          HIGHLIGHT_LINE_THICKNESS,
                          auto_type=float)
        #self._set_setting(settings, setting_keys, ['highlight_style'],
        #HIGHLIGHT_OPACITY, auto_type=float)

        # default colormap for legend
        self._set_setting(settings, setting_keys, ['colormap'], 'jet')

        # general gui sizing
        screen_shape = self._set_setting(settings,
                                         setting_keys, ['screen_shape'],
                                         screen_shape_default,
                                         save=False,
                                         auto_type=int)

        #try:
        #screen_shape = settings.value("screen_shape", screen_shape_default)
        #except (TypeError, AttributeError):
        #screen_shape = screen_shape_default

        #if 'recent_files' in setting_keys:
        try:
            self.parent.recent_files = settings.value("recent_files",
                                                      self.recent_files)
        except (TypeError, AttributeError):
            pass

        self._set_setting(settings,
                          setting_keys, ['nastran_is_element_quality'],
                          self.nastran_is_element_quality,
                          True,
                          auto_type=bool)
        self._set_setting(settings,
                          setting_keys, ['nastran_is_properties'],
                          self.nastran_is_properties,
                          True,
                          auto_type=bool)
        self._set_setting(settings,
                          setting_keys, ['nastran_is_3d_bars'],
                          self.nastran_is_3d_bars,
                          True,
                          auto_type=bool)
        self._set_setting(settings,
                          setting_keys, ['nastran_is_3d_bars_update'],
                          self.nastran_is_3d_bars_update,
                          True,
                          auto_type=bool)
        self._set_setting(settings,
                          setting_keys, ['nastran_create_coords'],
                          self.nastran_create_coords,
                          True,
                          auto_type=bool)
        self._set_setting(settings,
                          setting_keys, ['nastran_is_bar_axes'],
                          self.nastran_is_bar_axes,
                          True,
                          auto_type=bool)

        #w = screen_shape.width()
        #h = screen_shape.height()
        #try:
        if screen_shape:
            self.parent.resize(screen_shape[0], screen_shape[1])
            #width, height = screen_shape

        font = QtGui.QFont()
        font.setPointSize(self.font_size)
        self.parent.setFont(font)
Exemplo n.º 4
0
    def load(self, settings):
        """helper method for ``setup_gui``"""
        #red = (1.0, 0.0, 0.0)
        screen_shape_default = (1100, 700)

        setting_keys = [str(key) for key in settings.childKeys()]

        # sets the window size/position
        main_window_geometry = get_setting(
            settings, setting_keys, ['main_window_geometry', 'mainWindowGeometry'], None)
        if main_window_geometry is not None:
            self.parent.restoreGeometry(main_window_geometry)

        # this is the gui font
        self._set_setting(settings, setting_keys, ['font_size'], self.font_size, auto_type=int)

        # the info/debug/gui/command preferences
        self._set_setting(settings, setting_keys, ['show_info'], self.show_info,
                          True, auto_type=bool)
        self._set_setting(settings, setting_keys, ['show_debug'], self.show_debug,
                          True, auto_type=bool)
        self._set_setting(settings, setting_keys, ['show_command'], self.show_command,
                          True, auto_type=bool)
        self._set_setting(settings, setting_keys, ['show_warning'], self.show_warning,
                          True, auto_type=bool)
        self._set_setting(settings, setting_keys, ['show_error'], self.show_error,
                          True, auto_type=bool)

        # the vtk panel background color
        self._set_setting(settings, setting_keys, ['use_gradient_background'],
                          False, auto_type=bool)
        self._set_setting(settings, setting_keys, ['background_color', 'backgroundColor'],
                          GREY, auto_type=float)
        self._set_setting(settings, setting_keys, ['background_color2'], GREY, auto_type=float)

        # scales the coordinate systems
        self._set_setting(settings, setting_keys, ['coord_scale'], COORD_SCALE, auto_type=float)
        self._set_setting(settings, setting_keys, ['coord_text_scale'], COORD_TEXT_SCALE, auto_type=float)

        # this is for the 3d annotation
        self._set_setting(settings, setting_keys, ['annotation_color', 'labelColor'],
                          BLACK, auto_type=float)
        self._set_setting(settings, setting_keys, ['annotation_size'], ANNOTATION_SIZE, auto_type=int) # int
        if isinstance(self.annotation_size, float):
            # throw the float in the trash as it's from an old version of vtk
            self.annotation_size = ANNOTATION_SIZE
        elif isinstance(self.annotation_size, int):
            pass
        else:
            print('annotation_size = ', self.annotation_size)

        self._set_setting(settings, setting_keys, ['magnify'], self.magnify, auto_type=int)

        # this is the text in the lower left corner
        self._set_setting(settings, setting_keys, ['text_color', 'textColor'],
                          BLACK, auto_type=float)
        self._set_setting(settings, setting_keys, ['text_size'], TEXT_SIZE, auto_type=int)

        # highlight
        self._set_setting(settings, setting_keys, ['highlight_color'],
                          ORANGE, auto_type=float)
        self._set_setting(settings, setting_keys, ['highlight_opacity'],
                          HIGHLIGHT_OPACITY, auto_type=float)
        self._set_setting(settings, setting_keys, ['highlight_point_size'],
                          HIGHLIGHT_POINT_SIZE, auto_type=float)
        self._set_setting(settings, setting_keys, ['highlight_line_thickness'],
                          HIGHLIGHT_LINE_THICKNESS, auto_type=float)
        #self._set_setting(settings, setting_keys, ['highlight_style'],
                          #HIGHLIGHT_OPACITY, auto_type=float)

        # default colormap for legend
        self._set_setting(settings, setting_keys, ['colormap'],
                          'jet')


        # general gui sizing
        screen_shape = self._set_setting(settings, setting_keys, ['screen_shape'],
                                         screen_shape_default, save=False, auto_type=int)

        #try:
            #screen_shape = settings.value("screen_shape", screen_shape_default)
        #except (TypeError, AttributeError):
            #screen_shape = screen_shape_default

        #if 'recent_files' in setting_keys:
        try:
            self.parent.recent_files = settings.value("recent_files", self.recent_files)
        except (TypeError, AttributeError):
            pass

        for key in NASTRAN_BOOL_KEYS:
            default = getattr(self, key)
            self._set_setting(settings, setting_keys, [key],
                              default, save=True, auto_type=bool)

        #w = screen_shape.width()
        #h = screen_shape.height()
        #try:
        if screen_shape:
            self.parent.resize(screen_shape[0], screen_shape[1])
            #width, height = screen_shape

        font = QtGui.QFont()
        font.setPointSize(self.font_size)
        self.parent.setFont(font)

        #if 0:
            #pos_default = 0, 0
            #pos = settings.value("pos", pos_default)
            #x_pos, y_pos = pos
            #print(pos)
            #self.mapToGlobal(QtCore.QPoint(pos[0], pos[1]))
            #y_pos = pos_default[0]
            #self.parent.setGeometry(x_pos, y_pos, width, height)
        #except TypeError:
            #self.resize(1100, 700)
        is_loaded = True
        return is_loaded