def _update_image_properties(self): """ Actualiza los campos que muestran las propiedades de la imagen """ index = self._images_list.currentRow() #obtener el índice de la imagen seleccionada if 0 <= index < self._images_list.count(): id = self._images_ids[index] #obtener el id de la imagen según el índice img = Application.get_images()[id] self._images_list.currentItem().setText(img.DisplayName) index = self._images_list.currentRow() #obtener el índice de la imagen seleccionada id = self._images_ids[index] #obtener el id de la imagen según el índice img = Application.get_images()[id] #imagen para obtener las propiedades #actualizar los atributos de la imagen que se muestran self._properties_tree.blockSignals(True) self._id_prop.setText(1,str(img.Id)) self._name_prop.setText(1,str(img.DisplayName)) self._format_prop.setText(1,str(img.OriginalFormat)) self._file_prop.setText(1,str(img.OriginalFile)) self._dim_prop.setText(1,str(img.Dimension)) self._pt_prop.setText(1,str(img.PixelType)) self._size_prop.setText(1,str(img.Size)) self._sizeX_prop.setText(1,str(img.Size[0])) self._sizeY_prop.setText(1,str(img.Size[1])) self._sizeZ_prop.setText(1,str(img.Size[2])) self._spc_prop.setText(1,str(img.Spacing)) self._spcX_prop.setText(1,str(img.Spacing[0])) self._spcY_prop.setText(1,str(img.Spacing[1])) self._spcZ_prop.setText(1,str(img.Spacing[2])) self._properties_tree.blockSignals(False)
def _load_series(self): img_ldr = SeriesLoader() #crear un cargador res, img = img_ldr.run() #ejecutar el cargador if res == ImageLoader.OK: Application.add_image( img) #agregar la nueva imagen cargada a la aplicación #notificar al sincronizador de las propiedades de las imágenes que hay una nueva imagen cargada self._images_ui_synchronizer.add_image(img)
def _processImage(self): wt = WaitProcess wt.run() wt.change_value(50) wt.change_info("Procesando imagen") Application.processImage() wt.change_value(80) wt.change_info("Visualizando datos") #actualizar la vista de los tres planos de la imagen procesada self._processed_planes.Image = Application.get_processed_image() self._filters_ui_synchronizer._update_filters_properties() wt.stop()
def _update_filters_properties(self): """ Actualiza las propiedades que se muestran de los filtros """ self._properties_tree.blockSignals(True) smooth = Application.get_current_document()._smooth_pipe self._iterations_prop.setText(1,str(smooth.NumberOfIterations)) self._time_step_prop.setText(1,str(smooth.TimeStep)) self._conductance_prop.setText(1,str(smooth.Conductance)) self._smoother_prop.setText(1,str([smooth.NumberOfIterations,smooth.TimeStep, smooth.Conductance])) state = Qt.Unchecked if Application.get_current_document().usingSmoother(): state = Qt.Checked self._smoother_prop.setCheckState(0,state) segment = Application.get_current_document()._segment_pipe self._seed_prop.setText(1,str(segment.Seed)) self._seedX_prop.setText(1,str(segment.Seed[0])) self._seedY_prop.setText(1,str(segment.Seed[1])) self._seedZ_prop.setText(1,str(segment.Seed[2])) self._min_threshold_prop.setText(1,str(segment.LowerThreshold)) self._max_threshold_prop.setText(1,str(segment.UpperThreshold)) self._replace_value_prop.setText(1,str(segment.ReplaceValue)) state = Qt.Unchecked if Application.get_current_document().usingSegmentor(): state = Qt.Checked self._segment_prop.setCheckState(0,state) confidence = Application.get_current_document()._confidence_connected_pipe self._conf_seed_prop.setText(1,str(confidence.Seed)) self._conf_seedX_prop.setText(1,str(confidence.Seed[0])) self._conf_seedY_prop.setText(1,str(confidence.Seed[1])) self._conf_seedZ_prop.setText(1,str(confidence.Seed[2])) self._conf_radius_prop.setText(1,str(confidence.InitialRadius)) self._conf_mult_value_prop.setText(1,str(confidence.Multiplier)) self._conf_repl_value_prop.setText(1,str(confidence.ReplaceValue)) self._conf_iter_prop.setText(1,str(confidence.NumberOfIterations)) state = Qt.Unchecked if Application.get_current_document().usingConfidenceConnected(): state = Qt.Checked self._confidence_prop.setCheckState(0,state) voting = Application.get_current_document()._voting_pipe self._radius_prop.setText(1,str(voting.Radius)) self._radiusX_prop.setText(1,str(voting.Radius[0])) self._radiusY_prop.setText(1,str(voting.Radius[1])) self._radiusZ_prop.setText(1,str(voting.Radius[2])) self._foreground_prop.setText(1,str(voting.Foreground)) self._background_prop.setText(1,str(voting.Background)) self._survival_prop.setText(1,str(voting.SurvivalValue)) self._birth_prop.setText(1,str(voting.BirthValue)) state = Qt.Unchecked if Application.get_current_document().usingVoter(): state = Qt.Checked self._voting_prop.setCheckState(0,state) self._properties_tree.blockSignals(False)
def _update_image(self,item,col): """ Actualiza las propiedades de la imagen luego de haberlas editado @param item: item que se editó @param col: columna del item que se editó @return: None """ #cambiaron la etiqueta de la propiedad no el valor if col == 0: self._update_editable_labels() #restaurar las etiquetas return id = self.get_selected_image_id() #obtener el id de la imagen seleccionada if id is None: #no se ha seleccionado ninguna imagen return img = Application.get_images()[id] if item.text(0) == "Nombre": #actualizamos el nombre img.DisplayName = self._name_prop.text(1) elif item.text(0) in ["X","Y","Z"]: #actualizamos el espaciado spc = [self._spcX_prop.text(1), self._spcY_prop.text(1), self._spcZ_prop.text(1)] try: spc = map(float,spc) #verificar que no haya un espaciado mayor que 100 o menor o igual que 0 if any(map(lambda x: 100.0<=x or x<=0.0,spc)): raise ValueError() img.Spacing = spc except ValueError: pass self._update_image_properties()
def _update_current_image_name(self, item, col): id = self._images_ui_synchronizer.get_selected_image_id() img = Application.get_current_image() if id is None or img is None: return if id == img.Id and col == 1 and item.text(0) == "Nombre": self._ui.imageName.setText(item.text(1))
def base(browser_type, base_url, path): driver = None if browser_type == "firefox": driver = webdriver.Firefox(path) elif browser_type == "chrome": driver = webdriver.Chrome(path) driver.maximize_window() yield Application(driver, base_url) driver.close()
def app(request, browser_type, base_url): if browser_type == "firefox": driver = webdriver.Firefox() elif browser_type == "chrome": driver = webdriver.Chrome() elif browser_type == "ie": driver = webdriver.Ie() request.addfinalizer(driver.quit) return Application(driver, base_url)
def app(request, browser_type, base_url): if browser_type == "firefox": driver = webdriver.Firefox() elif browser_type == "chrome": driver = webdriver.Chrome() elif browser_type == "ie": driver = webdriver.Ie() #driver.implicitly_wait(30) request.addfinalizer(driver.quit) #close brawser return Application(driver, base_url)
def application(self, request): """ Фикстура для инициализации тестовой конфигурации :param request: :param driver: Appium driver :param test_path: директория с тестами :rtype class :return: объект класса Application """ return Application(request)
def _update_image(self): wt = WaitProcess wt.run() wt.change_info("Obteniendo imagen") wt.change_value(5) id = self._images_ui_synchronizer.get_selected_image_id() #verificar si la imagen seleccionada es distinta de la imagen actual clean_pipes = (Application.get_current_image_id() != id) #limpia las tuberías en caso de ser necesario if id is not None: if clean_pipes: Application.get_current_document().clean_pipes() wt.change_info("Cambiando imagen") wt.change_value(50) Application.set_current_image_id(id) #cambiar la imagen actual img = Application.get_current_image() #obtener la imagen actual self._ui.imageName.setText( img.DisplayName) #actualiza el nombre mostrado de la imagen wt.change_info("Visualizando imagen") wt.change_value(65) #actualizar la vista de los tres planos de la imagen self._planes.Image = img #habilitar el procesameinto de la imagen self._ui.processImage.setEnabled(True) #habilitar la configuración de los filtros self._ui.filters.setEnabled(True) #habilitar la salva de la configuración de los filtros self._ui.actionGuardar_2.setEnabled(True) #habilitar la carga de la configuración de los filtros self._ui.actionCargar_configuraci_n.setEnabled(True) #actualizar la información de los filtros self._filters_ui_synchronizer.update() wt.stop()
def app(request, browser_type, base_url): if browser_type == "firefox": driver = webdriver.Remote('http://172.17.10.17:4444/wd/hub', webdriver.DesiredCapabilities.FIREFOX) # FIXME разобраться у удаленным запуском хрома(сервер пишет нужно указать какие-то опции) elif browser_type == "chrome": driver = webdriver.Remote('http://172.17.10.17:4444/wd/hub', webdriver.DesiredCapabilities.CHROME) # TODO установить драйвер для IE elif browser_type == "ie": driver = webdriver.Remote('http://172.17.10.17:4444/wd/hub', webdriver.DesiredCapabilities.Ie) # driver.implicitly_wait(10) request.addfinalizer(driver.quit) return Application(driver, base_url)
def _calculate_data(self): img = Application.get_processed_image() if img is None: return self._ui.calculate.setEnabled(False) writer = itk.ImageFileWriter[ img.ImageType].New() #crear el writer de ITK writer.SetFileName( self._temp_file_path) #ponerle el nombre seleccionado writer.SetInput(img.InternalImage) #conectar la imagen a guardar writer.Update() #guardar la imagen! subprocess.call([ self._volume_exec_path, self._temp_file_path, self._volume_file_path ]) #os.system('"'+self._volume_exec_path+'" "'+self._temp_file_path+'" '+self._volume_file_path) spc = img.Spacing spc_factor = spc[0] * spc[1] * spc[2] f = open(self._volume_file_path, 'rt') try: self._vol = float(f.readline()) * spc_factor self._lenX = float(f.readline()) * spc[0] self._startX = map(int, f.readline()[1:-2].split(", ")) self._endX = map(int, f.readline()[1:-2].split(", ")) self._lenY = float(f.readline()) * spc[1] self._startY = map(int, f.readline()[1:-2].split(", ")) self._endY = map(int, f.readline()[1:-2].split(", ")) self._lenZ = float(f.readline()) * spc[2] self._startZ = map(int, f.readline()[1:-2].split(", ")) self._endZ = map(int, f.readline()[1:-2].split(", ")) finally: f.close() self._update_labels() self._ui.calculate.setEnabled(True) self._ui.save.setEnabled(True)
def save_configuration(self): res = self._file_save_dialog.exec_( ) #ejecutar el diálogo para obtener el nombre del fichero if res == QFileDialog.Rejected: #se canceló la salva return file_name = unicode(self._file_save_dialog.selectedFiles() [0]) #obtener el nombre del fichero doc = Application.get_current_document( ) #referencia al docmento actual de la aplicación f = open(file_name, "wt") try: smoother = doc._smooth_pipe f.write(str(doc.usingSmoother()) + "\n") f.write(str(smoother.NumberOfIterations) + "\n") f.write(str(smoother.TimeStep) + "\n") f.write(str(smoother.Conductance) + "\n") segmentor = doc._segment_pipe f.write(str(doc.usingSegmentor()) + "\n") f.write(str(segmentor.Seed) + "\n") f.write(str(segmentor.LowerThreshold) + "\n") f.write(str(segmentor.UpperThreshold) + "\n") f.write(str(segmentor.ReplaceValue) + "\n") conf_conn = doc._confidence_connected_pipe f.write(str(doc.usingConfidenceConnected()) + "\n") f.write(str(conf_conn.Seed) + "\n") f.write(str(conf_conn.InitialRadius) + "\n") f.write(str(conf_conn.Multiplier) + "\n") f.write(str(conf_conn.ReplaceValue) + "\n") f.write(str(conf_conn.NumberOfIterations) + "\n") voter = doc._voting_pipe f.write(str(doc.usingVoter()) + "\n") f.write(str(voter.Radius) + "\n") f.write(str(voter.Background) + "\n") f.write(str(voter.Foreground) + "\n") f.write(str(voter.SurvivalValue) + "\n") f.write(str(voter.BirthValue) + "\n") finally: f.close()
def load_configuration(self): res = self._file_load_dialog.exec_( ) #ejecutar el diálogo para obtener el nombre del fichero if res == QFileDialog.Rejected: #se canceló la salva return file_name = unicode(self._file_load_dialog.selectedFiles() [0]) #obtener el nombre del fichero doc = Application.get_current_document( ) #referencia al docmento actual de la aplicación f = open(file_name, "rt") try: smoother = doc._smooth_pipe doc.useSmoother(self._read_bool(f)) smoother.NumberOfIterations = self._read_int(f) smoother.TimeStep = self._read_float(f) smoother.Conductance = self._read_float(f) segmentor = doc._segment_pipe doc.useSegmentor(self._read_bool(f)) segmentor.Seed = self._read_int_list(f) segmentor.LowerThreshold = self._read_float(f) segmentor.UpperThreshold = self._read_float(f) segmentor.ReplaceValue = self._read_float(f) conf_conn = doc._confidence_connected_pipe doc.useConfidenceConnected(self._read_bool(f)) conf_conn.Seed = self._read_int_list(f) conf_conn.InitialRadius = self._read_int(f) conf_conn.Multiplier = self._read_float(f) conf_conn.ReplaceValue = self._read_float(f) conf_conn.NumberOfIterations = self._read_int(f) voter = doc._voting_pipe doc.useVoter(self._read_bool(f)) voter.Radius = self._read_int_list(f) voter.Background = self._read_float(f) voter.Foreground = self._read_float(f) voter.SurvivalValue = self._read_int(f) voter.BirthValue = self._read_int(f) finally: f.close()
from graphviz import Digraph from model.microservices import Microservices from model.process import Process from model.application import Application from model.infrastructure import Infrastructure from model.observability import Observability from model.test import Test dot = Digraph(comment='Microservices Roadmap', format='png') root = Microservices() root.build(dot) application = Application() application.build(dot) infrastructure = Infrastructure() infrastructure.build(dot) observability = Observability() observability.build(dot) process = Process() process.build(dot) test = Test() test.build(dot) dot.render('images/roadmap.gv', view=True)
class TestFirst: def setup(self): core.config.browser = webdriver.Firefox() core.config.browser.implicitly_wait(5) core.config.browser.get(core.config.url) self.app = Application() self.app.login(core.config.credentials) def teardown(self): self.app.logout() core.config.browser.close() @logger def test_001_add(self): """test_001_add""" self.app.add_movie(movie) self.app.check_movie_in_list(movie['title']) db_conditions.delete(movie) @logger def test_002_delete(self): """test_002_delete""" db_conditions.add(movie) self.app.refresh() self.app.navigate_to_movie(movie['title']) self.app.delete_movie() self.app.check_movie_is_not_on_page(movie['title'])
def setup(self): core.config.browser = webdriver.Firefox() core.config.browser.implicitly_wait(5) core.config.browser.get(core.config.url) self.app = Application() self.app.login(core.config.credentials)
def app(self, driver, base_url: str, test_path): config_name = self.get_config_name() return Application(driver, base_url, test_path, config_name)
def _save_image(self): img_svr = ImageSaver() #crear el diálogo img_svr.saveImage(Application.get_processed_image()) #salvar la imagen
def app(request): driver = webdriver.Chrome() driver.implicitly_wait(10) request.addfinalizer(driver.quit) return Application(driver)
from tkinter import Tk from model.application import Application if __name__ == '__main__': root = Tk() root.title("Campo Minado") Application(root) root.mainloop()
from controller.configuration_manager import ConfigurationManager from controller.image_loader import ImageLoader from controller.interface_runner import InterfaceRunner from controller.main_window import MainWindow from controller.slice_visualization import SliceVisualization from controller.three_planes_visualization import ThreePlanesVisualization from model.application import Application from model.image import Image __author__ = 'Alvaro Javier' #app = QApplication([]) #app.exec_() Application.init() InterfaceRunner.init() ConfigurationManager.init() main_wnidow = MainWindow() InterfaceRunner.start_even_loop(main_wnidow) #img_ldr = ImageLoader() #res,img = img_ldr.run() #if res == ImageLoader.Canceled: # sys.exit(1) #img = Application.Images()[0] #img.InternalImage.SetSpacing((1.015625, 1.015625, 1.800000)) #img.InternalImage.SetSpacing((0.9375, 0.9375, 3.1))
def app(request): driver = webdriver.Firefox() # driver.implicitly_wait(30) request.addfinalizer(driver.quit) return Application(driver)
def _update_filters(self,item,col): """ Actualiza las propiedades de los filtros luego de editarlas @param item: item que se editó @param col: columna del item que se editó @return: None """ #cambiaron la etiqueta de la propiedad no el valor if col == 0: self._update_editable_labels() if item.text(0) == "Suavizador": Application.get_current_document().useSmoother(item.checkState(0) == Qt.Checked) elif item.text(0) == "Segmentador": Application.get_current_document().useSegmentor(item.checkState(0) == Qt.Checked) elif item.text(0) == "Segmentador estadístico": Application.get_current_document().useConfidenceConnected(item.checkState(0) == Qt.Checked) elif item.text(0) == "Votación": Application.get_current_document().useVoter(item.checkState(0) == Qt.Checked) return if item.text(0) == "Iteraciones" and item.parent().text(0) == "Suavizador": try: num = int(item.text(1)) if num<0 or num>20: raise ValueError() Application.get_current_document()._smooth_pipe.NumberOfIterations = num except ValueError: pass elif item.text(0) == "Iteraciones" and item.parent().text(0) == "Segmentador estadístico": try: num = int(item.text(1)) if num<0 or num>50: raise ValueError() Application.get_current_document()._confidence_connected_pipe.NumberOfIterations = num except ValueError: pass elif item.text(0) == "Paso de tiempo": try: num = float(item.text(1)) if num<0.0 or num>1.0: #límites del paso de tiempo raise ValueError() Application.get_current_document()._smooth_pipe.TimeStep = num except ValueError: pass elif item.text(0) == "Conductancia": try: num = float(item.text(1)) if num<0.0 or num>100.0: #límites rasonables de conductancia raise ValueError() Application.get_current_document()._smooth_pipe.Conductance = num except ValueError: pass elif item.parent().text(0) == "Semilla" and item.parent().parent().text(0) == "Segmentador": #los hijos de 'Semilla' son las coordenadas seed = [ self._seedX_prop.text(1), self._seedY_prop.text(1), self._seedZ_prop.text(1) ] try: seed = map(int,seed) #verificar que no se incluya como semilla un valor mayor que el tamaño de la imagen o #menor que cero if any(map(lambda x: x<0,seed)) or\ any(imap(lambda x,y: x>=y,seed,Application.get_current_image().Size)): raise ValueError() Application.get_current_document()._segment_pipe.Seed = seed except ValueError: pass elif item.parent().text(0) == "Semilla" and item.parent().parent().text(0) == "Segmentador estadístico": #los hijos de 'Semilla' son las coordenadas seed = [ self._conf_seedX_prop.text(1), self._conf_seedY_prop.text(1), self._conf_seedZ_prop.text(1) ] try: seed = map(int,seed) #verificar que no se incluya como semilla un valor mayor que el tamaño de la imagen o #menor que cero if any(map(lambda x: x<0,seed)) or\ any(imap(lambda x,y: x>=y,seed,Application.get_current_image().Size)): raise ValueError() Application.get_current_document()._confidence_connected_pipe.Seed = seed except ValueError: pass elif item.text(0) == "Mínimo": try: min = float(self._min_threshold_prop.text(1)) Application.get_current_document()._segment_pipe.LowerThreshold = min except ValueError: pass elif item.text(0) == "Máximo": try: max = float(self._max_threshold_prop.text(1)) Application.get_current_document()._segment_pipe.UpperThreshold = max except ValueError: pass elif item.text(0) == "Relleno" and item.parent().parent().text(0) == "Segmentador": try: val = float(self._replace_value_prop.text(1)) Application.get_current_document()._segment_pipe.ReplaceValue = val except ValueError: pass elif item.text(0) == "Relleno" and item.parent().parent().text(0) == "Segmentador estadístico": try: val = float(self._conf_repl_value_prop.text(1)) Application.get_current_document()._confidence_connected_pipe.ReplaceValue = val except ValueError: pass elif item.parent().text(0) == "Radio": radius = [ self._radiusX_prop.text(1), self._radiusY_prop.text(1), self._radiusZ_prop.text(1) ] try: radius = map(str,radius) radius = map(int,radius) #verificar que no se incluya como radio un valor sensato (por ahora entre 0 y 20) if any(map(lambda x: x<0 or x>20,radius)): raise ValueError() Application.get_current_document()._voting_pipe.Radius = radius except ValueError: pass elif item.text(0) == "Radio inicial": try: val = int(self._conf_radius_prop.text(1)) if val<0 or val>20: raise ValueError() Application.get_current_document()._confidence_connected_pipe.InitialRadius = val except ValueError: pass elif item.text(0) == "Multiplicador": try: val = float(self._conf_mult_value_prop.text(1)) if val<0: raise ValueError() Application.get_current_document()._confidence_connected_pipe.Multiplier = val except ValueError: pass elif item.text(0) == "Fondo": try: val = int(self._background_prop.text(1)) if val<0 or val>255: raise ValueError() Application.get_current_document()._voting_pipe.Background = val except ValueError: pass elif item.text(0) == "Máscara": try: val = int(self._foreground_prop.text(1)) if val<0: raise ValueError() Application.get_current_document()._voting_pipe.Foreground = val except ValueError: pass elif item.text(0) == "Supervivencia": try: val = int(self._survival_prop.text(1)) if val<0: raise ValueError() Application.get_current_document()._voting_pipe.SurvivalValue = val except ValueError: pass elif item.text(0) == "Nacimiento": try: val = int(self._birth_prop.text(1)) if val<0: raise ValueError() Application.get_current_document()._voting_pipe.BirthValue = val except ValueError: pass self._update_filters_properties()
def main(): # app = Application() app.execute()
def base(browser_type, base_url): driver = Browser(browser_type).create() driver.maximize_window() yield Application(driver, base_url) driver.close()