def test_list_from_stl(self): '''Tests if list(stl) returns all the facets''' stl = Stl(asset('block.stl')) facets = list(stl) assert len(facets) == 12 assert len(facets[0]['vertex']) == 3 assert facets[0]['vertex'][0]['x'] == 0
def test_add_facets_updates_stats(self): '''Tests if adding new facets updates the mesh stats''' stl = Stl(asset('block.stl')) max_x = stl.stats['max']['x'] bounding_diameter = stl.stats['bounding_diameter'] stl.add_facets([(((0, 0, 0), (1, 1, 1), (max_x + 1, 0, 0)), (1, 0, 0))]) assert max_x + 1 == stl.stats['max']['x'] assert bounding_diameter < stl.stats['bounding_diameter']
def test_add_facets_updates_stats(self): '''Tests if adding new facets updates the mesh stats''' stl = Stl(asset('block.stl')) max_x = stl.stats['max']['x'] bounding_diameter = stl.stats['bounding_diameter'] stl.add_facets([(((0, 0, 0), (1, 1, 1), (max_x + 1, 0, 0)), (1, 0, 0)) ]) assert max_x + 1 == stl.stats['max']['x'] assert bounding_diameter < stl.stats['bounding_diameter']
def test_saved_equals_original_binary(self): '''Tests if saved binary file is identical to the loaded one''' stl1 = Stl(asset('block.stl')) stl1.write_binary(asset('block_binary.stl')) stl2 = Stl(asset('block_binary.stl')) stl2.write_binary(asset('block_binary2.stl')) assert filecmp.cmp(asset('block_binary.stl'), asset('block_binary2.stl'))
def test_stats_are_same_with_created(self, type): ''''Test a manually constructed cube has the same stats as if loaded''' XYZ = ('x', 'y', 'z') stl1 = Stl(asset('block.stl')) if type == 'iterable': facets = [[[[v[a] for a in XYZ] for v in f['vertex']], [f['normal'][a] for a in XYZ]] for f in stl1] else: facets = list(stl1) stl2 = Stl() stl2.add_facets(facets) stats1, stats2 = stl1.stats, stl2.stats for stats in (stats1, stats2): del stats['type'] # ASCII != INMEMORY del stats['original_num_facets'] # 12 != 0 del stats['header'] # nothing != "solid admesh" assert stats1 == stats2
def test_header(self): '''Tests the header of the block''' stl = Stl(asset('block.stl')) assert stl.stats['header'] == 'solid admesh'.encode('UTF-8')
def test_volume(self): '''Tests the volume of the block''' stl = Stl(asset('block.stl')) stl.calculate_volume() assert stl.stats['volume'] == 1
def test_number_of_facets(self): '''Tests if block has 12 facets''' stl = Stl(asset('block.stl')) assert stl.stats['number_of_facets'] == 12
def __init__(self, dc): super().__init__() global ts ts = TranslatedStrings() self.dc = dc self.archivos = dict() self.setWindowTitle(ts("Filtrar registros")) self.setWindowIcon(\ QIcon(utils.ruta_absoluta('resources/icons/tsr.png'))) self.setSizeGripEnabled(False) self.setModal(True) self.grid = QGridLayout(self) lbl_bhp = QLabel(self) pixmap = QPixmap(utils.ruta_absoluta('resources/logos/bhp.png')) lbl_bhp.setPixmap(pixmap) self.grid.addWidget(lbl_bhp, 0, 0) lbl_tsr = QLabel(self) pixmap2 = QPixmap(utils.ruta_absoluta('resources/logos/tsr.png')) lbl_tsr.setPixmap(pixmap2) self.grid.addWidget(lbl_tsr, 0, 1) self.filtro_1 = None self.filtro_2 = None self.filtro_3 = None ### #Filtro para Región ### self.lbl_f1 = QLabel(ts("Región"), self) self.grid.addWidget(self.lbl_f1, 1, 0) self.cmb_filtro1 = QComboBox(self) self.cmb_filtro1.addItems(list(utils.region())) self.cmb_filtro1.currentTextChanged.connect(self.filtro1_selected) self.grid.addWidget(self.cmb_filtro1, 1, 1) ### #Filtro Gerencia ### self.lbl_f2 = QLabel(ts("Gerencia"), self) self.grid.addWidget(self.lbl_f2, 2, 0) self.cmb_filtro2 = QComboBox(self) self.cmb_filtro2.addItems(list( utils.asset(self.cmb_filtro1.currentText()))) self.cmb_filtro2.currentTextChanged.connect(self.filtro2_selected) self.grid.addWidget(self.cmb_filtro2, 2, 1) ### #Filtro Gerencia General ### self.lbl_f3 = QLabel(ts("Gerencia General"), self) self.grid.addWidget(self.lbl_f3, 3, 0) self.cmb_filtro3 = QComboBox(self) self.cmb_filtro3.addItems(list( utils.operation(self.cmb_filtro2.currentText()))) self.grid.addWidget(self.cmb_filtro3, 3, 1) ### #Filtro Dia-mes ### self.lbl_c1 = QLabel(ts("Seleccionar Fecha Inicio Programación OVCC")) self.grid.addWidget(self.lbl_c1, 5, 0) fecha_actual = QDate.currentDate() self.calendar = QCalendarWidget(self) if fecha_actual.dayOfWeek() == 1: self.calendar.setMinimumDate(fecha_actual) self.calendar.setSelectedDate(fecha_actual) else: dif = -(fecha_actual.dayOfWeek() - 1) fecha_actual = fecha_actual.addDays(dif) self.calendar.setMinimumDate(fecha_actual.addDays(7)) self.calendar.setSelectedDate(fecha_actual.addDays(7)) self.calendar.setFirstDayOfWeek(Qt.Monday) self.calendar.setVerticalHeaderFormat(QCalendarWidget.VerticalHeaderFormat.NoVerticalHeader) self.calendar.clicked.connect(self.date_filter) self.grid.addWidget(self.calendar, 5, 1) ### #Botones ### self.btn_continuar = QPushButton(ts("Continuar"), self) self.btn_continuar.clicked.connect(self.filtrar) self.grid.addWidget(self.btn_continuar, 6, 1) self.btn_atras = QPushButton(ts("Atrás"), self) self.grid.addWidget(self.btn_atras, 6, 0) ### #Creacion layout ### self.setLayout(self.grid)
def test_saved_binary_is_binary(self): '''Tests if saved binary file is identical to the loaded one''' stl1 = Stl(asset('block.stl')) stl1.write_binary(asset('block_binary.stl')) stl2 = Stl(asset('block_binary.stl')) assert stl2.stats['type'] == Stl.BINARY
def test_save_load_unicode(self): '''Tests saving and loading files with Unicode filenames''' stl1 = Stl(asset('block.stl')) stl1.write_ascii(asset(u'block_ěščřž.stl')) stl2 = Stl(asset(u'block_ěščřž.stl'))
def test_add_facets_increases_len(self): stl = Stl(asset('block.stl')) facet_count = len(stl) stl.add_facets([(((0, 0, 0), (1, 1, 1), (1, 0, 0)), (1, 0, 0))]) assert len(stl) == facet_count + 1
def test_str(self): '''Tests the output of str''' stl = Stl(asset('block.stl')) assert str(stl) == "Stl('admesh')"
def test_saved_equals_original_ascii(self): '''Tests if saved ASCII file is identical to the loaded one''' stl = Stl(asset('block.stl')) stl.write_ascii(asset('block_ascii.stl')) assert filecmp.cmp(asset('block.stl'), asset('block_ascii.stl'))
def test_len_is_number_of_facets(self): '''Tests if len() of Stl object is number of factes''' stl = Stl(asset('block.stl')) assert len(stl) == 12
def test_ascii_is_ascii(self): '''Tests if loaded ASCII file is recognized as ASCII''' stl = Stl(asset('block.stl')) assert stl.stats['type'] == Stl.ASCII
def filtro1_selected(self, text): self.cmb_filtro2.clear() lvl2_items = list( utils.asset(self.cmb_filtro1.currentText())) self.cmb_filtro2.addItems(lvl2_items)