def Salvar(self): ''' Escribo PNG y PGW ''' dialegObertura = QFileDialog() dialegObertura.setDirectoryUrl(QUrl(self.dadesdir)) self.fileName, _ = dialegObertura.getSaveFileName( self, 'Guardar mapeta', '', 'PNG(*.png)') if self.fileName: # Guardo el pixmap como png self.colocoCirculo.scaled_pixmap.save(self.fileName) # Calculo info para el PQW # rango mundo x e y xdist = self.colocoCirculo.Pmax.x() - self.colocoCirculo.Pmin.x() ydist = self.colocoCirculo.Pmax.y() - self.colocoCirculo.Pmin.y() # ancho y alto de la imagen iheight = self.colocoCirculo.scaled_pixmap.height() iwidth = self.colocoCirculo.scaled_pixmap.width() # Preparo nombre del PGW split_nombre = os.path.splitext(self.fileName) filenamePgw = split_nombre[0] + ".pgw" # Escribo PGW wld = open(filenamePgw, "w") wld.writelines("%s\n" % (xdist / iwidth)) wld.writelines("0.0\n") wld.writelines("0.0\n") wld.writelines("%s\n" % (ydist / iheight)) wld.writelines("%s\n" % self.colocoCirculo.Pmin.x()) wld.writelines("%s\n" % self.colocoCirculo.Pmin.y()) wld.close
def open_test_suite(self): """ Open a test suite file and loads the test cases from the suite into the tool. There is a chained process flow when you open a test suite: open_test_suite() calls select_target() select_target then calls load_test_cases() Once a test suite is opened, the user may later choose a new target for the same test suite as teh select_target() method call load_test_cases(). """ self.test_case_data_list = [] url = QUrl() # This File Dialog should start in url.setScheme("file") # the test suites folder by default. url.setPath( "%s/../testsuites" %MY_PATH ) # TODO: os.path.join() options = QFileDialog.Options() options |= QFileDialog.DontUseNativeDialog file_dialog = QFileDialog() file_dialog.setDirectoryUrl(url) self.testsuite_file, _ = file_dialog.getOpenFileName(self,"QFileDialog.getOpenFileName()", "","All Files (*)", options=options) if self.testsuite_file: self.test_suite_label.setText("Test Suite: %s" %self.testsuite_file.split('/')[LAST]) message = "Loaded Test Suite: %s" %self.testsuite_file logger.info(message) # Crate a list of test cases from the test suite file. However, these # test cases are only file names with not path. We'll have to add the path # based on the target selected. try: f = open(self.testsuite_file, 'r') lines = f.readlines() f.close() self.suite_text_area.clear() for line in lines: line = line.strip() self.suite_text_area.append(line) except: message = "Unalbe to read test cases from test suite %s" %self.testsuite_file logger.error(message) self.suite_text_area.setText(message) lines = [] self.test_case_file_list = [] # a list of test case file names with no paths for line in lines: line = line.strip() if len(line) < 1: pass elif line.startswith('#'): pass else: self.test_case_file_list.append(line) self.test_case_count = len(self.test_case_file_list) message = "Found %d test cases in %s" %(self.test_case_count, self.testsuite_file.split('/')[LAST]) logger.info(message) self.status_bar.showMessage(message) # open the select a test target for this suite self.select_target()
def Cargar(self): ''' Leo PNG y PGW ''' dialegObertura = QFileDialog() dialegObertura.setDirectoryUrl(QUrl(self.dadesdir)) # Images (*.png );;World files (*.pgw) self.fileName,_ = dialegObertura.getOpenFileName(parent=self,\ caption= 'Cargar mapeta',\ directory='', filter="World files(*.pgw);;Images(*.png);;Tot(*.*)") if self.fileName: split_nombre = os.path.splitext(self.fileName) filenamePGW = split_nombre[0] + ".pgw" filenamePNG = split_nombre[0] + ".png" datos_mapeta = self.CalcularPNGyRangoMapeta(filenamePNG) pixmap = QPixmap(filenamePNG) self.label.setPixmap(pixmap) literal = "xmin,ymin=" + str(round( datos_mapeta[1], 3)) + " " + str(round(datos_mapeta[2], 3)) self.xmin_ymin.setText(literal) literal = "xmax,ymax=" + str(round( datos_mapeta[3], 3)) + " " + str(round(datos_mapeta[4], 3)) self.xmax_ymax.setText(literal) self.spinBox.setValue(datos_mapeta[5]) self.xmin = datos_mapeta[1] self.ymin = datos_mapeta[2] self.xmax = datos_mapeta[3] self.ymax = datos_mapeta[4] pass # TODO: Actualizar variables necesarias para poder hacer recalculos self.rang = QgsRectangle(self.xmin, self.ymin, self.xmax, self.ymax) self.canvas.setExtent(self.rang)