Example #1
0
    def test_bdf_utils_01(self):
        msg = '1:10  14:20:2  50:40:-1'
        output = parse_patran_syntax(msg, pound=None)
        expected = np.array(
            [1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
             14, 16, 18, 20,
             40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]
        )
        error_msg = 'expected equal; A-B=%s; B-A=%s' % (
            np.setdiff1d(output, expected), np.setdiff1d(expected, output))
        assert np.array_equal(output, expected), error_msg

        msg = '1:#'
        output = parse_patran_syntax(msg, pound=5)
        assert np.array_equal(output, [1, 2, 3, 4, 5])

        msg = '#:1'
        with self.assertRaises(ValueError):
            output = parse_patran_syntax(msg, pound=None)
        #assert array_equal(output, [1, 2, 3, 4, 5])

        msg = '1:#'
        output = parse_patran_syntax(msg, pound='5')
        assert np.array_equal(output, [1, 2, 3, 4, 5])

        # should this raise an error?
        msg = '#:1'
        #with self.assertRaises(ValueError):
        output = parse_patran_syntax(msg, pound='5')
Example #2
0
    def test_bdf_utils_01(self):
        """tests parse_patran_syntax"""
        msg = '1:10  14:20:2  50:40:-1'
        output = parse_patran_syntax(msg, pound=None)
        expected = np.array([
            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 14, 16, 18, 20, 40, 41, 42, 43, 44,
            45, 46, 47, 48, 49, 50
        ])
        error_msg = 'expected equal; A-B=%s; B-A=%s' % (np.setdiff1d(
            output, expected), np.setdiff1d(expected, output))
        assert np.array_equal(output, expected), error_msg

        msg = '1:#'
        output = parse_patran_syntax(msg, pound=5)
        assert np.array_equal(output, [1, 2, 3, 4, 5])

        msg = '#:1'
        with self.assertRaises(ValueError):
            output = parse_patran_syntax(msg, pound=None)
        #assert array_equal(output, [1, 2, 3, 4, 5])

        msg = '1:#'
        output = parse_patran_syntax(msg, pound='5')
        assert np.array_equal(output, [1, 2, 3, 4, 5])

        # should this raise an error?
        msg = '#:1'
        #with self.assertRaises(ValueError):
        output = parse_patran_syntax(msg, pound='5')
Example #3
0
    def create_widgets(self):
        # Name
        self.pid = QtGui.QLabel("New Property ID:")
        self.pid_edit = QtGui.QLineEdit(str(self._default_pid).strip())
        self.pid_button = QtGui.QPushButton("Default")

        # Name
        self.elements = QtGui.QLabel("Element ID:")
        self.elements_edit = QtGui.QLineEdit(str(self._default_elements).strip())
        self.elements_button = QtGui.QPushButton("Default")


        # elements
        self.theta = QtGui.QLabel("Theta Neighbor Max:")
        self.theta_edit = QtGui.QLineEdit(str(self._default_theta).strip())
        self.theta_button = QtGui.QPushButton("Default")

        # applies a unique implicitly
        self.eids = parse_patran_syntax(str(self._default_elements), pound=self.elements_pound)
        self.cids = parse_patran_syntax(str(self._default_coords), pound=self.coords_pound)

        # continuous / discrete
        #self.checkbox_continuous = QtGui.QCheckBox("Continuous")
        #self.checkbox_discrete = QtGui.QCheckBox("Discrete")
        #self.checkbox_discrete.setChecked(self._default_is_discrete)

        # put these in a group
        #checkboxs2 = QtGui.QButtonGroup(self)
        #checkboxs2.addButton(self.checkbox_continuous)
        #checkboxs2.addButton(self.checkbox_discrete)

        # closing
        self.apply_button = QtGui.QPushButton("Apply")
        self.ok_button = QtGui.QPushButton("OK")
        self.cancel_button = QtGui.QPushButton("Cancel")
Example #4
0
    def create_widgets(self):
        # Name
        self.name = QtGui.QLabel("Name:")
        self.name_edit = QtGui.QLineEdit(str(self._default_name).strip())
        self.name_button = QtGui.QPushButton("Default")

        # Name
        self.coords = QtGui.QLabel("Coord IDs:")
        self.coords_edit = QtGui.QLineEdit(str(self._default_coords).strip())
        self.coords_button = QtGui.QPushButton("Default")


        # elements
        self.elements = QtGui.QLabel("Element IDs:")
        self.elements_edit = QtGui.QLineEdit(str(self._default_elements).strip())
        self.elements_button = QtGui.QPushButton("Default")

        # add
        self.add = QtGui.QLabel("Add:")
        self.add_edit = QtGui.QLineEdit(str(''))
        self.add_button = QtGui.QPushButton("Add")

        # remove
        self.remove = QtGui.QLabel("Remove:")
        self.remove_edit = QtGui.QLineEdit(str(''))
        self.remove_button = QtGui.QPushButton("Remove")

        # color
        self.color = QtGui.QLabel("Color:")
        #self.color_edit = QtGui.QPushButton()
        #self.color_edit.setColor(self._default_color)
        self.color_edit = ColorDisplay(self, self._default_color)
        self.color_button = QtGui.QPushButton("Default")

        # applies a unique implicitly
        self.eids = parse_patran_syntax(str(self._default_elements), pound=self.elements_pound)
        self.cids = parse_patran_syntax(str(self._default_coords), pound=self.coords_pound)

        # continuous / discrete
        #self.checkbox_continuous = QtGui.QCheckBox("Continuous")
        #self.checkbox_discrete = QtGui.QCheckBox("Discrete")
        #self.checkbox_discrete.setChecked(self._default_is_discrete)

        # put these in a group
        #checkboxs2 = QtGui.QButtonGroup(self)
        #checkboxs2.addButton(self.checkbox_continuous)
        #checkboxs2.addButton(self.checkbox_discrete)

        # closing
        self.apply_button = QtGui.QPushButton("Apply")
        self.ok_button = QtGui.QPushButton("OK")
        self.cancel_button = QtGui.QPushButton("Cancel")
Example #5
0
    def create_widgets(self):
        # Name
        self.pid = QLabel("New Property ID:")
        self.pid_edit = QLineEdit(str(self._default_property).strip())
        self.pid_button = QPushButton("Default")

        # Name
        self.elements = QLabel("Element IDs:")
        self.elements_edit = QLineEdit(str(self._default_elements).strip())
        self.elements_button = QPushButton("Default")

        # elements
        self.theta = QLabel("Theta Neighbor Max:")
        self.theta_edit = QLineEdit(str(self._default_theta).strip())
        self.theta_button = QPushButton("Default")

        # applies a unique implicitly
        self.eids = parse_patran_syntax(str(self._default_elements),
                                        pound=self.elements_pound)
        #self.cids = parse_patran_syntax(str(self._default_coords), pound=self.coords_pound)

        # continuous / discrete
        #self.checkbox_continuous = QCheckBox("Continuous")
        #self.checkbox_discrete = QCheckBox("Discrete")
        #self.checkbox_discrete.setChecked(self._default_is_discrete)

        # put these in a group
        #checkboxs2 = QButtonGroup(self)
        #checkboxs2.addButton(self.checkbox_continuous)
        #checkboxs2.addButton(self.checkbox_discrete)

        # closing
        self.apply_button = QPushButton("Apply")
        self.ok_button = QPushButton("OK")
        self.cancel_button = QPushButton("Cancel")
Example #6
0
 def check_patran_syntax(cell, pound=None):
     text = str(cell.text())
     try:
         values = parse_patran_syntax(text, pound=pound)
         cell.setStyleSheet("QLineEdit{background: white;}")
         return values, True
     except ValueError as e:
         cell.setStyleSheet("QLineEdit{background: red;}")
         cell.setToolTip(str(e))
         return None, False
Example #7
0
 def check_patran_syntax(self, cell, pound=None):
     text = str(cell.text())
     try:
         value = parse_patran_syntax(text, pound=pound)
         cell.setStyleSheet("QLineEdit{background: white;}")
         return value, True
     except ValueError as e:
         cell.setStyleSheet("QLineEdit{background: red;}")
         cell.setToolTip(str(e))
         return None, False
Example #8
0
    def _update_active_key_by_name(self, name):
        if name in self.keys:
            self.active_key = self.keys.index(name)
        else:
            # we (hopefully) just removed a row
            #self.active_key = self.keys[self.active_key]
            pass

        self.name_edit.setText(name)
        obj = self.out_data[self.active_key]

        self.eids = parse_patran_syntax(obj.element_str,
                                        pound=obj.elements_pound)
        self._default_elements = obj.element_str
        self._default_name = name
        self._apply_cids_eids()

        self.set_as_main_button.setEnabled(True)
        if name in ['main', 'anti-main']:
            self.name.setEnabled(False)
            self.name_set.setEnabled(False)
            self.name_edit.setEnabled(False)
            self.name_button.setEnabled(False)
            self.elements.setEnabled(False)
            self.elements_button.setEnabled(False)
            self.elements_edit.setEnabled(False)
            self.add.setEnabled(False)
            self.add_button.setEnabled(False)
            self.add_edit.setEnabled(False)
            self.remove.setEnabled(False)
            self.remove_button.setEnabled(False)
            self.remove_edit.setEnabled(False)
            self.delete_group_button.setEnabled(False)
            if name == 'anti-main':
                self.set_as_main_button.setEnabled(False)
            #self.apply_button.setEnabled(False)
            #self.ok_button.setEnabled(False)
        else:
            self.name.setEnabled(True)
            self.name_set.setEnabled(True)
            self.name_edit.setEnabled(True)
            self.name_button.setEnabled(True)
            self.elements.setEnabled(True)
            self.elements_button.setEnabled(True)

            self.add.setEnabled(True)
            self.add_button.setEnabled(True)
            self.add_edit.setEnabled(True)
            self.remove.setEnabled(True)
            self.remove_button.setEnabled(True)
            self.remove_edit.setEnabled(True)
            self.delete_group_button.setEnabled(True)
Example #9
0
    def _update_active_key_by_name(self, name):
        if name in self.keys:
            self.active_key = self.keys.index(name)
        else:
            # we (hopefully) just removed a row
            #self.active_key = self.keys[self.active_key]
            pass

        self.name_edit.setText(name)
        obj = self.out_data[self.active_key]

        self.eids = parse_patran_syntax(obj.element_str, pound=obj.elements_pound)
        self._default_elements = obj.element_str
        self._default_name = name
        self._apply_cids_eids()

        self.set_as_main_button.setEnabled(True)
        if name in ['main', 'anti-main']:
            self.name.setEnabled(False)
            self.name_set.setEnabled(False)
            self.name_edit.setEnabled(False)
            self.name_button.setEnabled(False)
            self.elements.setEnabled(False)
            self.elements_button.setEnabled(False)
            self.elements_edit.setEnabled(False)
            self.add.setEnabled(False)
            self.add_button.setEnabled(False)
            self.add_edit.setEnabled(False)
            self.remove.setEnabled(False)
            self.remove_button.setEnabled(False)
            self.remove_edit.setEnabled(False)
            self.delete_group_button.setEnabled(False)
            if name == 'anti-main':
                self.set_as_main_button.setEnabled(False)
            #self.apply_button.setEnabled(False)
            #self.ok_button.setEnabled(False)
        else:
            self.name.setEnabled(True)
            self.name_set.setEnabled(True)
            self.name_edit.setEnabled(True)
            self.name_button.setEnabled(True)
            self.elements.setEnabled(True)
            self.elements_button.setEnabled(True)

            self.add.setEnabled(True)
            self.add_button.setEnabled(True)
            self.add_edit.setEnabled(True)
            self.remove.setEnabled(True)
            self.remove_button.setEnabled(True)
            self.remove_edit.setEnabled(True)
            self.delete_group_button.setEnabled(True)
Example #10
0
    def create_widgets(self):
        """creates the menu objects"""
        # Name
        self.name = QLabel("Name:")
        self.name_set = QPushButton("Set")
        self.name_edit = QLineEdit(str(self._default_name).strip())
        self.name_button = QPushButton("Default")

        # elements
        self.elements = QLabel("Element IDs:")
        self.elements_edit = QLineEdit(str(self._default_elements).strip())
        self.elements_button = QPushButton("Default")

        # add
        self.add = QLabel("Add Elements:")
        self.add_edit = QElementEdit(self, str(''))
        self.add_button = QPushButton("Add")

        # remove
        self.remove = QLabel("Remove Elements:")
        self.remove_edit = QElementEdit(self, str(''))
        self.remove_button = QPushButton("Remove")

        # applies a unique implicitly
        self.eids = parse_patran_syntax(str(self._default_elements),
                                        pound=self.elements_pound)

        # closing
        #self.apply_button = QPushButton("Apply")
        self.ok_button = QPushButton("Close")
        #self.cancel_button = QPushButton("Cancel")

        self.set_as_main_button = QPushButton("Set As Main")
        self.create_group_button = QPushButton('Create New Group')
        self.delete_group_button = QPushButton('Delete Group')

        self.name.setEnabled(False)
        self.name_set.setEnabled(False)
        self.name_edit.setEnabled(False)
        self.name_button.setEnabled(False)
        self.elements.setEnabled(False)
        self.elements_button.setEnabled(False)
        self.elements_edit.setEnabled(False)
        self.add.setEnabled(False)
        self.add_button.setEnabled(False)
        self.add_edit.setEnabled(False)
        self.remove.setEnabled(False)
        self.remove_button.setEnabled(False)
        self.remove_edit.setEnabled(False)
        self.delete_group_button.setEnabled(False)
Example #11
0
    def create_widgets(self):
        # Name
        self.name = QtGui.QLabel("Name:")
        self.name_set = QtGui.QPushButton("Set")
        self.name_edit = QtGui.QLineEdit(str(self._default_name).strip())
        self.name_button = QtGui.QPushButton("Default")

        # elements
        self.elements = QtGui.QLabel("Element IDs:")
        self.elements_edit = QtGui.QLineEdit(str(self._default_elements).strip())
        self.elements_button = QtGui.QPushButton("Default")

        # add
        self.add = QtGui.QLabel("Add:")
        self.add_edit = QtGui.QLineEdit(str(''))
        self.add_button = QtGui.QPushButton("Add")

        # remove
        self.remove = QtGui.QLabel("Remove:")
        self.remove_edit = QtGui.QLineEdit(str(''))
        self.remove_button = QtGui.QPushButton("Remove")

        # applies a unique implicitly
        self.eids = parse_patran_syntax(str(self._default_elements), pound=self.elements_pound)

        # closing
        #self.apply_button = QtGui.QPushButton("Apply")
        self.ok_button = QtGui.QPushButton("Close")
        #self.cancel_button = QtGui.QPushButton("Cancel")

        self.set_as_main_button = QtGui.QPushButton("Set As Main")
        self.create_group_button = QtGui.QPushButton('Create New Group')
        self.delete_group_button = QtGui.QPushButton('Delete Group')

        self.name.setEnabled(False)
        self.name_set.setEnabled(False)
        self.name_edit.setEnabled(False)
        self.name_button.setEnabled(False)
        self.elements.setEnabled(False)
        self.elements_button.setEnabled(False)
        self.elements_edit.setEnabled(False)
        self.add.setEnabled(False)
        self.add_button.setEnabled(False)
        self.add_edit.setEnabled(False)
        self.remove.setEnabled(False)
        self.remove_button.setEnabled(False)
        self.remove_edit.setEnabled(False)
        self.delete_group_button.setEnabled(False)
Example #12
0
 def element_ids(self):
     return parse_patran_syntax(self.element_str, pound=self.elements_pound)
Example #13
0
 def node_ids(self):
     return parse_patran_syntax(self.node_str, pound=self.nodes_pound)
Example #14
0
 def element_ids(self):
     return parse_patran_syntax(self.element_str, pound=self.elements_pound)
Example #15
0
    def create_widgets(self):
        """creates the menu objects"""
        #icon = QtGui.QPixmap(os.path.join(ICON_PATH, 'node.png'))
        #icon = QtGui.QPixmap(os.path.join(ICON_PATH, 'element.png'))
        # Name
        self.pick_style_label = QLabel('Pick Style:')
        #self.pick_node_button = QPushButton('Node')
        self.pick_element_button = QPushButton('Element')
        self.pick_area_button = QPushButton('Area')
        #self.pick_node_button.setIcon(icon)
        #self.pick_area_button.setIcon(icon)

        # Name
        self.name_label = QLabel('Name:')
        self.name_set = QPushButton('Set')
        self.name_edit = QLineEdit(str(self._default_name).strip())
        self.name_button = QPushButton('Default')

        # elements
        self.elements_label = QLabel('Element IDs:')
        self.elements_edit = QLineEdit(str(self._default_elements).strip())
        self.elements_button = QPushButton('Default')
        self.elements_highlight_button = QPushButton('Show')

        # add
        self.add_label = QLabel('Add Elements:')
        self.add_edit = QElementEdit(self, self.model_name, pick_style='area')
        self.add_button = QPushButton('Add')
        self.add_highlight_button = QPushButton('Show')

        # remove
        self.remove_label = QLabel('Remove Elements:')
        self.remove_edit = QElementEdit(self,
                                        self.model_name,
                                        pick_style='area')
        self.remove_button = QPushButton('Remove')
        self.remove_highlight_button = QPushButton('Show')

        # applies a unique implicitly
        self.eids = parse_patran_syntax(str(self._default_elements),
                                        pound=self.elements_pound)

        # closing
        #self.apply_button = QPushButton('Apply')
        self.ok_button = QPushButton('Close')
        #self.cancel_button = QPushButton('Cancel')

        self.set_as_main_button = QPushButton('Set As Main')
        self.create_group_button = QPushButton('Create New Group')
        self.delete_group_button = QPushButton('Delete Group')

        self.name_label.setEnabled(False)
        self.name_set.setEnabled(False)
        self.name_edit.setEnabled(False)
        self.name_button.setEnabled(False)

        self.elements_label.setEnabled(False)
        self.elements_button.setEnabled(False)
        self.elements_edit.setEnabled(False)
        self.elements_highlight_button.setEnabled(False)

        self.add_label.setEnabled(False)
        self.add_button.setEnabled(False)
        self.add_edit.setEnabled(False)
        self.add_highlight_button.setEnabled(False)

        self.remove_label.setEnabled(False)
        self.remove_button.setEnabled(False)
        self.remove_edit.setEnabled(False)
        self.remove_highlight_button.setEnabled(False)