def __init__(self): QWidget.__init__(self) self.complex_display=False self.hbox=QVBoxLayout() self.gl_cmp=gl_cmp(os.path.join(os.getcwd(),"snapshots")) toolbar=QToolBar() toolbar.setIconSize(QSize(42, 42)) self.tb_rotate = QAction(QIcon(os.path.join(get_image_file_path(),"rotate.png")), _("Rotate"), self) self.tb_rotate.triggered.connect(self.tb_rotate_click) toolbar.addAction(self.tb_rotate) self.tb_rotate.setEnabled(True) self.tb_contact = QAction(QIcon(os.path.join(get_image_file_path(),"contact.png")), _("Contacts"), self) self.tb_contact.triggered.connect(self.callback_contacts) toolbar.addAction(self.tb_contact) self.tb_mesh = QAction(QIcon(os.path.join(get_image_file_path(),"mesh.png")), _("Edit the electrical mesh"), self) self.tb_mesh.triggered.connect(self.callback_edit_mesh) toolbar.addAction(self.tb_mesh) self.tb_config = QAction(QIcon(os.path.join(get_image_file_path(),"cog.png")), _("Configuration"), self) self.tb_config.triggered.connect(self.callback_configure) toolbar.addAction(self.tb_config) self.hbox.addWidget(toolbar) enable_3d=inp_get_token_value(os.path.join(os.getcwd(),"config.inp") , "#gui_config_3d_enabled") if enable_3d==None: enable_3d="True" enable_3d=str2bool(enable_3d) if enable_3d==True: self.display=glWidget(self) self.hbox.addWidget(self.display) self.display.setMinimumSize(800, 600) self.timer=QTimer() self.timer.setSingleShot(True) self.timer.timeout.connect(self.timer_update) self.timer.start(2000) else: self.add_fallback() self.setLayout(self.hbox) self.electrical_mesh=tab_electrical_mesh() self.electrical_mesh.changed.connect(self.recalculate) self.contacts_window=contacts_window() self.contacts_window.changed.connect(self.recalculate) self.gl_cmp.slider.changed.connect(self.recalculate)
def __init__(self, path): QWidgetSavePos.__init__(self, "spectra_main") self.path = path self.setMinimumSize(900, 600) self.setWindowIcon(icon_get("shape")) self.setWindowTitle( os.path.basename(self.path) + " " + _("Shape editor")) self.main_vbox = QVBoxLayout() self.ribbon = ribbon_shape() #self.ribbon.import_data.clicked.connect(self.callback_import) #self.ribbon.tb_ref.triggered.connect(self.callback_ref) self.ribbon.tb_import.triggered.connect(self.callback_import_image) self.ribbon.help.triggered.connect(self.callback_help) self.main_vbox.addWidget(self.ribbon) self.notebook = QTabWidget() self.notebook.setMovable(True) self.main_vbox.addWidget(self.notebook) self.three_d_shape = glWidget(self) self.three_d_shape.triangle_file = "" self.three_d_shape.draw_electrical_mesh = False self.three_d_shape.view.draw_device = False self.three_d_shape.enable_draw_ray_mesh = True self.three_d_shape.enable_draw_light_source = False self.three_d_shape.enable_draw_rays = False self.three_d_shape.view.render_photons = False self.load_data() self.notebook.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.ribbon.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) #self.alpha.init(enable_toolbar=False) #self.alpha.set_labels([_("Spectra")]) #self.alpha.load_data([fname]) #self.alpha.do_plot() self.notebook.addTab(self.three_d_shape, _("Shape")) self.setLayout(self.main_vbox) self.notebook.currentChanged.connect(self.changed_click)
def __init__(self,path): QWidgetSavePos.__init__(self,"shape_import") self.path=path self.discretizer=image_discretizer(self.path) self.setMinimumSize(900, 900) self.setWindowIcon(icon_get("shape")) #self.setWindowTitle(_("Import microscope image")+" (https://www.gpvdm.com)") self.setWindowTitle(os.path.basename(self.path)+" "+_("Shape editor")) self.scripts=scripts(path=self.path,api_callback=self.discretizer.force_update) self.scripts.ribbon.help.setVisible(False) self.scripts.ribbon.plot.setVisible(False) self.scripts.ribbon.hashtag.setVisible(False) self.main_vbox = QVBoxLayout() self.ribbon=ribbon_shape_import() f=inp() f.load(os.path.join(self.path,"shape_import.inp")) self.ribbon.tb_norm_y.setChecked(str2bool(f.get_token("#shape_import_y_norm"))) self.ribbon.tb_norm_z.setChecked(str2bool(f.get_token("#shape_import_z_norm"))) self.ribbon.tb_blur.setChecked(str2bool(f.get_token("#shape_import_blur_enabled"))) self.ribbon.mesh_edit.triggered.connect(self.callback_mesh_editor) self.ribbon.mesh_build.clicked.connect(self.callback_mesh_build) server_get().sim_finished.connect(self.ribbon.mesh_build.stop) server_get().sim_started.connect(self.ribbon.mesh_build.start) self.ribbon.edit_norm_y.triggered.connect(self.callback_edit_norm_y) self.ribbon.menu_blur.triggered.connect(self.callback_menu_blur) self.ribbon.tb_honeycomb_menu_edit.triggered.connect(self.callback_honeycomb_menu_edit) #self.ribbon.tb_boundary_menu_edit.triggered.connect(self.callback_boundary_menu_edit) self.ribbon.tb_gaus_menu_edit.triggered.connect(self.callback_gaus_menu_edit) self.ribbon.tb_gaus.triggered.connect(self.callback_tb_gaus) self.ribbon.tb_honeycomb.triggered.connect(self.callback_tb_honeycomb) self.ribbon.tb_boundary.triggered.connect(self.callback_boundary_menu_edit) self.ribbon.tb_norm_y.triggered.connect(self.callback_norm_y) self.ribbon.tb_norm_z.triggered.connect(self.callback_norm_z) self.ribbon.tb_blur.triggered.connect(self.callback_blur_enable) self.ribbon.tb_rotate.triggered.connect(self.callback_rotate) self.ribbon.import_image.clicked.connect(self.callback_open_image) self.ribbon.save_data.clicked.connect(self.callback_import) self.ribbon.show_mesh.clicked.connect(self.callback_show_mesh) self.ribbon.tb_script.clicked.connect(self.callback_script) #self.ribbon.help.triggered.connect(self.callback_help) self.main_vbox.addWidget(self.ribbon) self.notebook = QTabWidget() self.notebook.setMovable(True) self.main_vbox.addWidget(self.notebook) self.notebook.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.ribbon.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) #3d widget self.three_d_shape=glWidget(self) self.three_d_shape.triangle_file="" self.three_d_shape.draw_electrical_mesh=False self.three_d_shape.view.draw_device=False self.three_d_shape.enable_draw_ray_mesh=True self.three_d_shape.enable_draw_light_source=False self.three_d_shape.enable_draw_rays=False self.three_d_shape.view.render_photons=False self.notebook.addTab(self.three_d_shape,_("Shape")) self.notebook.addTab(self.discretizer,_("Image")) self.setLayout(self.main_vbox) self.load_data() self.notebook.currentChanged.connect(self.changed_click)
def __init__(self): QWidget.__init__(self) self.complex_display = False self.hbox = QVBoxLayout() self.gl_cmp = gl_cmp(os.path.join(get_sim_path(), "snapshots")) toolbar = QToolBar() toolbar.setIconSize(QSize(42, 42)) #self.tb_layer_editor = QAction(icon_get("layers"), _("Layer\neditor"), self) #self.tb_layer_editor.triggered.connect(self.callback_layer_editor) #toolbar.addAction(self.tb_layer_editor) spacer = QWidget() spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) toolbar.addWidget(spacer) self.xy = QAction(icon_get("xy"), _("xy"), self) self.xy.triggered.connect(self.callback_xy) toolbar.addAction(self.xy) self.yz = QAction(icon_get("yz"), _("yz"), self) self.yz.triggered.connect(self.callback_yz) toolbar.addAction(self.yz) self.xz = QAction(icon_get("xz"), _("xz"), self) self.xz.triggered.connect(self.callback_xz) toolbar.addAction(self.xz) self.tb_rotate = QAction(icon_get("rotate.png"), _("Rotate"), self) self.tb_rotate.triggered.connect(self.tb_rotate_click) toolbar.addAction(self.tb_rotate) self.tb_rotate.setEnabled(True) self.tb_config = QAction(icon_get("preferences-system"), _("Configuration"), self) self.tb_config.triggered.connect(self.callback_configure) toolbar.addAction(self.tb_config) self.fx_box = fx_selector() self.fx_box.file_name_set_start("light_ray_") self.fx_box.file_name_set_end(".dat") self.fx_box.update() self.fx_box.cb.currentIndexChanged.connect(self.fx_box_changed) toolbar.addWidget(self.fx_box) self.hbox.addWidget(toolbar) enable_3d = inp_get_token_value( os.path.join(get_sim_path(), "config.inp"), "#gui_config_3d_enabled") if enable_3d == None: enable_3d = "True" enable_3d = str2bool(enable_3d) if enable_3d == True: self.display = glWidget(self) self.update_ray_file() self.hbox.addWidget(self.display) #self.display.setMinimumSize(800, 600) self.timer = QTimer() self.timer.setSingleShot(True) self.timer.timeout.connect(self.timer_update) self.timer.start(5000) else: self.add_fallback() self.setLayout(self.hbox) global_object_register("display_recalculate", self.recalculate) global_object_register("display_set_selected_layer", self.set_selected_layer)
def __init__(self): QWidget.__init__(self) self.complex_display = False self.hbox = QVBoxLayout() self.data = dat_file() self.my_server = server_get() mesh = get_mesh() if mesh.y.circuit_model == True and mesh.x.tot_points == 1 and mesh.z.tot_points == 1: self.display = circuit_editor() epi = get_epi() pos = 3 self.display.ersatzschaltbild.add_object(pos, 3, pos + 1, 3, "bat") pos = pos + 1 for l in epi.layers: f = inp() f.load( os.path.join(get_sim_path(), l.shape_electrical + ".inp")) component = f.get_token("#electrical_component") if component == "resistance": self.display.ersatzschaltbild.add_object( pos, 3, pos + 1, 3, "resistor") if component == "diode": self.display.ersatzschaltbild.add_object( pos, 3, pos + 1, 3, "diode") pos = pos + 1 self.display.ersatzschaltbild.add_object(pos, 3, pos + 1, 3, "ground") self.display.ersatzschaltbild.objects_push() if inp().isfile(os.path.join(get_sim_path(), "diagram.inp")) == True: self.display.ersatzschaltbild.load() else: toolbar = QToolBar() toolbar.setIconSize(QSize(42, 42)) spacer = QWidget() spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) toolbar.addWidget(spacer) self.tb_refresh = QAction(icon_get("view-refresh"), _("Refresh"), self) self.tb_refresh.triggered.connect(self.rebuild_mesh) toolbar.addAction(self.tb_refresh) self.xy = QAction(icon_get("xy"), _("xy"), self) self.xy.triggered.connect(self.callback_xy) toolbar.addAction(self.xy) self.yz = QAction(icon_get("yz"), _("yz"), self) self.yz.triggered.connect(self.callback_yz) toolbar.addAction(self.yz) self.xz = QAction(icon_get("xz"), _("xz"), self) self.xz.triggered.connect(self.callback_xz) toolbar.addAction(self.xz) self.tb_rotate = QAction(icon_get("rotate.png"), _("Rotate"), self) self.tb_rotate.triggered.connect(self.tb_rotate_click) toolbar.addAction(self.tb_rotate) self.tb_rotate.setEnabled(True) self.hbox.addWidget(toolbar) self.display = glWidget(self) #self.data.load(os.path.join(get_sim_path(),"electrical_mesh.dat") #self.display.pre_built_scene=gl_scale.project_base_objects_from_m_2_screen(self.data.data) self.display.draw_electrical_mesh = False self.display.view.draw_device = False self.display.enable_draw_ray_mesh = False self.display.enable_draw_light_source = False self.display.enable_draw_rays = False self.display.view.render_photons = False self.display.force_redraw() #global_object_register("display_mesh_recalculate",self.recalculate) self.hbox.addWidget(self.display) self.setLayout(self.hbox)
def init(self, input_files, plot_labels, config_file): three_d = False data_type = "xy" if len(input_files) == 1: data = dat_file() data.load(input_files[0]) data_type = data.type three_d = False if data_type == "gobj": three_d = True if data_type == "zxy-d": three_d = True if three_d == True: self.setWindowTitle( _("3D object viewer") + " https://www.gpvdm.com") self.setWindowIcon(icon_get("shape")) self.plot = glWidget(self) self.main_vbox.addWidget(self.plot) self.setLayout(self.main_vbox) #self.plot.triangle_file=input_files[0] self.plot.draw_electrical_mesh = False self.plot.view.draw_device = False self.plot.enable_draw_ray_mesh = False self.plot.enable_draw_light_source = False self.plot.enable_draw_rays = False self.plot.view.render_photons = False if data_type == "zxy-d": self.plot.plot_graph = True self.plot.graph_data.load(input_files[0]) self.show() if data_type == "gobj": self.plot.pre_built_scene = gl_scale.project_base_objects_from_m_2_screen( data.data) self.show() self.plot.force_redraw() #self.plot.render() #self.plot.gl_objects_load(ret) #print(self.plot.graph_data.data) elif data_type == "circuit": self.setWindowTitle( _("3D object viewer") + " https://www.gpvdm.com") self.setWindowIcon(icon_get("shape")) self.plot = glWidget(self) self.main_vbox.addWidget(self.plot) self.setLayout(self.main_vbox) self.plot.draw_electrical_mesh = False self.plot.view.draw_device = False self.plot.enable_draw_ray_mesh = False self.plot.enable_draw_light_source = False self.plot.enable_draw_rays = False self.plot.plot_graph = False self.plot.plot_circuit = True self.plot.view.render_photons = False self.plot.graph_data.load(input_files[0]) self.show() elif data_type == "poly": self.setWindowTitle( _("3D object viewer") + " https://www.gpvdm.com") self.setWindowIcon(icon_get("shape")) self.plot = glWidget(self) self.main_vbox.addWidget(self.plot) self.setLayout(self.main_vbox) #self.plot.triangle_file=input_files[0] self.plot.draw_electrical_mesh = False self.plot.view.draw_device = False self.plot.enable_draw_ray_mesh = True self.plot.enable_draw_light_source = False self.plot.enable_draw_rays = False self.plot.scene_built = True self.plot.view.render_photons = False data = dat_file() if data.load(input_files[0]) == True: a = gl_base_object() a.id = ["bing"] a.type = "open_triangles" a.r = data.r a.g = data.g a.b = data.b a.triangles = project_trianges_m2screen(data.data) self.plot.gl_objects_add(a) self.show() else: self.shown = True self.plot = plot_widget() if len(plot_labels) == 0: for i in range(0, len(input_files)): plot_labels.append( os.path.basename(input_files[i]).replace("_", "\_")) #print plot_labels for i in range(0, len(plot_labels)): if len(plot_labels[i]) > 0: if plot_labels[i][0] == "\\": plot_labels[i] = plot_labels[i][1:] plot_labels[i].replace("\\", "/") self.plot.load_data(input_files) self.plot.set_labels(plot_labels) self.plot.do_plot() self.plot.show()