def load_sim(self, filename): new_path = os.path.dirname(filename) if filename.startswith(get_share_path()) == True: error_dlg( self, _("You should not try to open simulations in the root gpvdm directory." )) return if ver_check_compatibility(filename) == True: self.change_dir_and_refresh_interface(new_path) else: update = yes_no_dlg( self, _("The simulation you want to import looks like it was made on an old version of gpvdm, do you want to try to open it anyway?" )) if update == True: update_simulaton_to_new_ver(filename) self.change_dir_and_refresh_interface(new_path) if os.path.isdir(os.path.join(new_path, "materials")) == False: copy = yes_no_dlg( self, _("It looks like there is no materials database in the simulation directory should I import one?" )) if copy == True: clone_materials(new_path)
def callback_delete_page(self): tab = self.notebook.currentWidget() response=yes_no_dlg(self,_("Should I remove the laser file ")+tab.tab_name) if response == True: inp_remove_file(tab.file_name) index=self.notebook.currentIndex() self.notebook.removeTab(index)
def close_clicked(self): result = yes_no_dlg( self, "Are you sure you don't want to report the error? It would be really helpful if you did." ) if result == True: self.close() else: self.on_ok_clicked()
def callback_import(self): response = yes_no_dlg( self, _("Are you sure you wisht to import this, it will overwrite ")) if response == True: out_file = os.path.join(self.path, self.out_file) self.data.save(out_file) self.data_written.emit() self.close()
def callback_delete_page(self): tab = self.notebook.currentWidget() response=yes_no_dlg(self, _("Should I remove the fit file ")+tab.tab_name.split("@")[0]) if response==True: inp_remove_file("fit"+str(tab.index)+".inp") inp_remove_file("fit_data"+str(tab.index)+".inp") inp_remove_file("fit_patch"+str(tab.index)+".inp") self.notebook.remove_page(pageNum) global_object_get("tb_item_sim_mode_update")()
def update_now(): response=yes_no_dlg(self,_("This feature is sill under development. It searches the gpvdm web page for updates then uses them to update gpvdm. Use it at your own risk - I take no responsibility for any data loss! Do you wish to continue?")) if response==True: ret='\n'.join(update_fetch()) dialog=sim_warnings() dialog.init(ret) response=dialog.run() dialog.destroy() md.destroy()
def callback_delete_page(self): if self.notebook.count() > 1: tab = self.notebook.currentWidget() response = yes_no_dlg( self, _("Should I remove the laser file ") + tab.tab_name) if response == True: inp_remove_file(tab.file_name) index = self.notebook.currentIndex() self.notebook.removeTab(index)
def on_ok_clicked(self): ret=tab_get_selected(self.tab) if ret==False: error_dlg(self,_("You have not selected anything")) else: file_path=os.path.join(get_device_lib_path(),ret[0]) md = yes_no_dlg(self,"You are about to import the simulation file "+file_path+" into this simulation. The result will be that all model parameters will be overwritten. Do you really want to do that?") if response == True: self.file_path=file_path self.close()
def callback_delete_page(self): tab = self.notebook.currentWidget() response=yes_no_dlg(self,_("Should I remove the experiment file ")+tab.tab_name.split("@")[0]) if response == True: inp_remove_file("fxdomain"+str(tab.index)+".inp") inp_remove_file("fxmesh"+str(tab.index)+".inp") index=self.notebook.currentIndex() self.notebook.removeTab(index) self.changed.emit()
def callback_delete_page(self): tab = self.notebook.currentWidget() name = inp_get_token_value(tab.file_name, "#measure_name") response = yes_no_dlg(self, _("Should I remove the measurment file ") + name) if response == True: inp_remove_file(os.path.join(get_sim_path(), tab.file_name)) index = self.notebook.currentIndex() self.notebook.removeTab(index)
def layer_delete(self): epi=get_epi() obj=self.gl_objects_get_first_selected() if obj!=None: s=epi.find_shape_by_id(obj.id[0]) if s!=None: response=yes_no_dlg(self,"Do you really want to delete the object: "+s.name) if response == True: epi=get_epi() epi.remove_by_id(s.id) epi.save() self.force_redraw()
def callback_delete_page(self): tab = self.notebook.currentWidget() index=self.notebook.currentIndex() name=self.notebook.tabText(index) dir_to_del=os.path.join(self.sim_dir,name) response=yes_no_dlg(self,_("Should I remove the simulation directory ")+dir_to_del) if response==True: index=self.notebook.currentIndex() self.notebook.removeTab(index) gpvdm_delete_file(dir_to_del)
def callback_delete_page(self): tab = self.notebook.currentWidget() response = yes_no_dlg( self, _("Should I remove the fit file ") + tab.tab_name.split("@")[0]) if response == True: inp_remove_file("fit" + str(tab.index) + ".inp") inp_remove_file("fit_data" + str(tab.index) + ".inp") inp_remove_file("fit_patch" + str(tab.index) + ".inp") inp_remove_file("fit_math" + str(tab.index) + ".inp") index = self.notebook.currentIndex() self.notebook.removeTab(index)
def closeEvent(self, event): if self.allow_exit == False: response = yes_no_dlg( self, _("Gpvdm will not work until you register. Would do you want to exit gpvdm?" )) if response == True: sys.exit(0) event.ignore() else: event.accept()
def callback_delete_page(self): tab = self.notebook.currentWidget() name=tab.tab_name dir_to_del=os.path.join(self.sim_dir,name) response=yes_no_dlg(self,_("Should I remove the simulation directory ")+dir_to_del) if response==True: index=self.notebook.currentIndex() self.notebook.removeTab(index) print(_("I am going to delete file"),dir_to_del) delete_second_level_link_tree(dir_to_del)
def callback_click(self, component): if component == "edit-undo": result = yes_no_dlg( self, _("Do you really which to reset the circuit to the default?")) if result == True: f = inp() f.set_file_name("diagram.inp") f.delete() self.ersatzschaltbild.objects_pop() self.ersatzschaltbild.repaint() return self.ersatzschaltbild.selected = component
def callback_delete_page(self): tab = self.notebook.currentWidget() response = yes_no_dlg( self, _("Should I remove the experiment file ") + tab.tab_name.split("@")[0]) if response == True: inp_remove_file( os.path.join(get_sim_path(), "jv" + str(tab.index) + ".inp")) index = self.notebook.currentIndex() self.notebook.removeTab(index) self.changed.emit()
def delete(self): files = "" for i in self.selectedItems(): files = files + os.path.join(self.path, i.text()) + "\n" ret = yes_no_dlg( self, _("Are you sure you want to delete the files ?") + "\n\n" + files) if ret == True: for i in self.selectedItems(): decode = self.decode_name(i.text()) if decode.type == "scan_dir": scans = scans_io(self.path) scans.delete(decode.display_name) else: file_to_remove = os.path.join(self.path, decode.file_name) gpvdm_delete_file(file_to_remove)
def callback_delete_page(self): tab = self.notebook_pointer.currentWidget() name = inp_get_token_value(tab.file_name, self.name_token) name = name.split("@")[0] response = yes_no_dlg(self, self.delete_dlg_text + name) if response == True: file_number = extract_number_from_file_name(tab.file_name) for b in self.base_file_name: file_name = b + file_number + ".inp" inp_remove_file(os.path.join(get_sim_path(), file_name)) index = self.notebook_pointer.currentIndex() self.notebook_pointer.removeTab(index) self.changed.emit()
def callback_open(self, widget, data=None): dialog = QFileDialog(self) dialog.setWindowTitle(_("Open an existing gpvdm simulation")) dialog.setNameFilter('Simulations - gpvdm (*.gpvdm *.opvdm)') dialog.setFileMode(QFileDialog.ExistingFile) if dialog.exec_() == QDialog.Accepted: filename = dialog.selectedFiles()[0] new_path=os.path.dirname(filename) if ver_check_compatibility(filename)==True: self.change_dir_and_refresh_interface(new_path) else: reply = yes_no_dlg(self,"The simulation you want to import looks like it was made on an old version of gpvdm, do you want to try to open it anyway?") if reply == True: update_simulaton_to_new_ver(dialog.get_filename()) self.change_dir_and_refresh_interface(new_path)
def callback_delete_page(self): files = inp_ls_seq_files(os.path.join(get_sim_path(), "sim.gpvdm"), self.base_file_name[0]) if (len(files) < 2): error_dlg(self, _("You should not delete the last tab.")) return tab = self.notebook_pointer.currentWidget() name = inp_get_token_value(tab.file_name, self.name_token) name = name.split("@")[0] response = yes_no_dlg(self, self.delete_dlg_text + name) if response == True: file_number = extract_number_from_file_name(tab.file_name) for b in self.base_file_name: file_name = b + file_number + ".inp" inp_remove_file(os.path.join(get_sim_path(), file_name)) index = self.notebook_pointer.currentIndex() self.notebook_pointer.removeTab(index) self.changed.emit()
def callback_delete_shape(self): tab = self.notebook.currentWidget() s = self.epi.find_shape_by_file_name(tab.file_name) name = s.name response = yes_no_dlg(self, "Do you really want to delete the file: " + name) if response == True: inp_remove_file(os.path.join(get_sim_path(), tab.file_name)) index = self.notebook.currentIndex() self.notebook.removeTab(index) for i in range(0, len(get_epi().layers[self.layer_index].shapes)): if get_epi().layers[self.layer_index].shapes[ i].file_name + ".inp" == tab.file_name: get_epi().layers[self.layer_index].shapes.pop(i) get_epi().clean_unused_files() get_epi().save() break global_object_run("gl_force_redraw")
def close_clicked(self): result=yes_no_dlg(self,"Are you sure you don't want to report the error? It would be really helpful if you did.") if result == True: self.close() else: self.on_ok_clicked()
def __init__(self): QWidgetSavePos.__init__(self, "optics") self.setWindowIcon(icon_get("optics")) self.setMinimumSize(1000, 600) self.setWindowTitle( _("Optical simulation editor") + " (https://www.gpvdm.com)") self.ribbon = optics_ribbon() self.edit_list = [] self.line_number = [] self.articles = [] input_files = [] input_files.append( os.path.join(get_sim_path(), "optical_output", "light_2d_photons.dat")) input_files.append( os.path.join(get_sim_path(), "optical_output", "light_2d_photons_asb.dat")) plot_labels = [] plot_labels.append(_("Photon distribution")) plot_labels.append(_("Photon distribution absorbed")) self.setWindowIcon(icon_get("optics")) self.main_vbox = QVBoxLayout() self.ribbon.optics.run.start_sim.connect(self.callback_run) self.ribbon.optics.fx_box.cb.currentIndexChanged.connect( self.mode_changed) self.ribbon.optics.help.triggered.connect(self.callback_help) self.ribbon.tb_save.clicked.connect(self.callback_save) self.ribbon.optics.configwindow.triggered.connect( self.callback_configwindow) self.ribbon.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) self.main_vbox.addWidget(self.ribbon) self.progress_window = progress_class() self.notebook = QTabWidget() css_apply(self.notebook, "tab_default.css") self.notebook.setMovable(True) self.plot_widgets = [] self.progress_window.start() for i in range(0, len(input_files)): self.plot_widgets.append(plot_widget(enable_toolbar=False)) self.plot_widgets[i].hide_title = True self.plot_widgets[i].set_labels([plot_labels[0]]) self.plot_widgets[i].load_data([input_files[i]]) #self.plot_widgets[i].watermark_alpha=0.5 self.plot_widgets[i].do_plot() #self.plot_widgets[i].show() self.notebook.addTab(self.plot_widgets[i], plot_labels[i]) self.fig_photon_density = band_graph() self.fig_photon_density.set_data_file("light_1d_photons_tot_norm.dat") self.notebook.addTab(self.fig_photon_density, _("Photon density")) #self.fig_photon_abs = band_graph() #self.fig_photon_abs.set_data_file("light_1d_photons_tot_abs_norm.dat") #self.notebook.addTab(self.fig_photon_abs,_("Photon absorbed")) self.fig_gen_rate = band_graph() self.fig_gen_rate.set_data_file("light_1d_Gn.dat") self.notebook.addTab(self.fig_gen_rate, _("Generation rate")) self.fig_photon_density.draw_graph() #self.fig_photon_abs.draw_graph() self.fig_gen_rate.draw_graph() self.progress_window.stop() self.notebook.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.main_vbox.addWidget(self.notebook) self.setLayout(self.main_vbox) if os.path.isfile( os.path.join(get_sim_path(), "optical_output", "light_2d_photons.dat")) == False: response = yes_no_dlg( self, "You have not yet run a full optical simulation, to use this feature you need to. Would you run one now?" ) if response == True: self.callback_run() else: self.close()
def mouseReleaseEvent(self, event): if self.editable==False: return if inp().isfile(self.file_name)==False: result=yes_no_dlg(self,_("Are you sure you want to edit the circuit directly? The circuit will no longer automaticly be updated as you change the layer structure, and the electrical parameters editor will be disabled. Use can use the reset function in the circuit diagram editor to resore this functionality")) if result == False: return if event.button() == Qt.LeftButton: x0,y0,x1,y1,direction=self.find_click_points(event) c=component() c.x0=x0 c.y0=y0 c.x1=x1 c.y1=y1 index=self.find_component_index(c) if self.selected=="clean": if index!=-1: self.objects.pop(index) else: if index==-1: c.name=self.selected c.lines=self.load_component(c) #if direction=="up": # self.rotate(c.lines) self.objects.append(c) else: if self.objects[index].name=="resistor": self.a=inp_dialog() ret=self.a.run(["#resistance",str(self.objects[index].R),"#end"]) if ret==QDialog.Accepted: self.objects[index].R=float(self.a.tab.f.get_token("#resistance")) elif self.objects[index].name=="capacitor": self.a=inp_dialog() ret=self.a.run(["#capacitance",str(self.objects[index].C),"#end"]) if ret==QDialog.Accepted: self.objects[index].C=float(self.a.tab.f.get_token("#capacitance")) elif self.objects[index].name=="inductor": self.a=inp_dialog() ret=self.a.run(["#inductance",str(self.objects[index].L),"#end"]) if ret==QDialog.Accepted: self.objects[index].L=float(self.a.tab.f.get_token("#inductance")) elif self.objects[index].name=="diode": self.a=inp_dialog() ret=self.a.run(["#J0",str(self.objects[index].J0),"#nid",str(self.objects[index].nid),"#end"]) if ret==QDialog.Accepted: self.objects[index].nid=float(self.a.tab.f.get_token("#nid")) self.objects[index].J0=float(self.a.tab.f.get_token("#J0")) #if new_sim_name!=None: self.repaint() self.save() elif event.button() == Qt.RightButton: #do what you want here print("Right Button Clicked")
def on_item_activated(self, item): text = item.text() if text == "..": if self.path == self.root_dir: self.set_path("/gpvdmroot") else: old_path = self.path self.set_path(os.path.dirname(self.path)) #print(self.path,old_path,os.path.dirname(self.path)) if old_path == self.path: self.set_path("/gpvdmroot") self.fill_store() return decode = self.decode_name(text) full_path = os.path.join(self.path, decode.file_name) if decode.file_name.startswith("http"): webbrowser.open(decode) return elif decode.file_name == "home_dir": self.set_path(get_home_path()) self.fill_store() return elif decode.file_name == "desktop_dir": self.set_path(get_desktop_path()) self.fill_store() return elif decode.file_name == "gpvdm_configure": self.set_path("/gpvdmroot/gpvdm_configure") self.fill_store() return elif decode.file_name == "music_dir": self.set_path(get_music_path()) self.fill_store() return elif decode.file_name == "downloads_dir": self.set_path(get_downloads_path()) self.fill_store() return elif decode.file_name == "simulation_dir": self.set_path(get_sim_path()) self.fill_store() return elif decode.file_name.startswith("mount_point") == True: point = decode.split("::::") self.set_path(point[1]) self.fill_store() return elif decode == "gpvdm_cluster_config": self.win = cluster_config_window(self) self.win.show() return elif decode.file_name == "gpvdm_language_config": self.config_window = class_config_window() from tab_lang import language_tab_class self.config_window.files = [] self.config_window.description = [] self.config_window.init() lang_tab = language_tab_class() self.config_window.notebook.addTab(lang_tab, _("Language")) self.config_window.show() return elif decode.file_name == "gpvdm_solver_config": self.config_window = class_config_window() self.config_window.files = ["math.inp"] self.config_window.description = [_("Solver configuration")] self.config_window.init() self.config_window.show() return elif decode.file_name == "gpvdm_dump_config": self.config_window = class_config_window() self.config_window.files = ["dump.inp"] self.config_window.description = [_("Output files")] self.config_window.init() self.config_window.show() return elif decode.file_name == "gpvdm_gui_config": self.config_window = class_config_window() self.config_window.files = ["config.inp"] self.config_window.description = [ _("GUI configuration"), ] self.config_window.init() self.config_window.show() return elif decode.file_name == "gpvdm_server_config": self.config_window = class_config_window() self.config_window.files = ["server.inp"] self.config_window.description = [_("Server configuration")] self.config_window.init() self.config_window.show() return elif decode.file_name == "gpvdm_key": from lock_key_manager import lock_key_manager from msg_dlg import msg_dlg self.lock_key_manager = lock_key_manager( show_text=False, override_text=_("Please enter your license key:")) ret = self.lock_key_manager.run() if ret == QDialog.Accepted: msgBox = msg_dlg() msgBox.setText("License updated") reply = msgBox.exec_() elif decode.file_name == "gpvdm_cache": from cache import cache self.c = cache() self.c.show() elif decode.type == "scan_dir": from scan_tab import scan_vbox #print(full_path) self.scan_window = scan_vbox(full_path) self.scan_window.show() return elif decode.type == "parameter_dir": self.set_path(full_path) self.fill_store() return dir_type = get_dir_type(full_path) if self.open_own_files == True: self.file_path = full_path if dir_type == "spectra": from spectra_main import spectra_main self.mat_window = spectra_main(full_path) self.mat_window.show() return if dir_type == "shape": from shape_editor import shape_editor self.windows.append(shape_editor(full_path)) self.windows[-1].show() return if dir_type == "light": from optics import class_optical self.optics_window = class_optical() self.optics_window.show() if dir_type == "material": from materials_main import materials_main self.mat_window = materials_main(full_path) self.mat_window.show() return if dir_type == "emission": from emission_main import emission_main self.emission_window = emission_main(full_path) self.emission_window.show() return if dir_type == "snapshots": from cmp_class import cmp_class help_window().help_set_help([ "plot_time.png", _("<big><b>Examine the results in time domain</b></big><br> After you have run a simulation in time domain, if is often nice to be able to step through the simulation and look at the results. This is what this window does. Use the slider bar to move through the simulation. When you are simulating a JV curve, the slider sill step through voltage points rather than time points." ) ]) self.snapshot_window.append(cmp_class(full_path)) self.snapshot_window[-1].show() #print("snapshots!!") return if dir_type == "backup": ret = yes_no_dlg( self, _("Are you sure you want restore this file from the backup, it will overwrite all files in the simulation directory?" ) + "\n\n" + full_path) if ret == True: from backup import backup_restore backup_restore(get_sim_path(), full_path) if dir_type == "file": self.file_path = full_path if os.path.basename(full_path) == "sim_info.dat": self.sim_info_window = sim_info(full_path) self.sim_info_window.show() return if isfiletype(full_path, "dat") == True: text = peek_data(full_path) if text.startswith(b"#multiplot"): my_multiplot = multiplot() my_multiplot.plot(full_path) else: plot_gen([full_path], [], "auto") return if isfiletype(full_path, "gpvdm") == True: return desktop_open(full_path) return #self.reject.emit() if dir_type == "dir" or dir_type == "backup_main" or dir_type == "multi_plot_dir": self.file_path = full_path self.set_path(full_path) self.fill_store() else: self.accept.emit()
def callback_menu(self,event): if self.enable_menu==False: return menu = QMenu(self) newmaterialAction=False newspectraAction=False newdirAction = menu.addAction(_("New directory")) if self.menu_new_material_enabled==True: newmaterialAction = menu.addAction(_("New material")) if self.menu_new_spectra_enabled==True: newspectraAction = menu.addAction(_("New spectra")) deleteAction = menu.addAction(_("Delete file")) renameAction = menu.addAction(_("Rename")) renameAction.setEnabled(False) deleteAction.setEnabled(False) if len(self.selectedItems())==1: renameAction.setEnabled(True) if len(self.selectedItems())>0: deleteAction.setEnabled(True) action = menu.exec_(self.mapToGlobal(event)) if action == newdirAction: new_sim_name=dlg_get_text( _("New directory name:"), _("New directory"),"document-new") new_sim_name=new_sim_name.ret if new_sim_name!=None: name=os.path.join(self.path,new_sim_name) os.mkdir(name) elif action == newmaterialAction: new_sim_name=dlg_get_text( _("New material name:"), _("New material name"),"organic_material") new_sim_name=new_sim_name.ret if new_sim_name!=None: new_material=os.path.join(self.path,new_sim_name) clone_material(new_material,os.path.join(get_base_material_path(),"generic","generic_organic")) elif action == newspectraAction: new_sim_name=dlg_get_text( _("New spectra name:"), _("New spectra name"),"spectra_file") new_sim_name=new_sim_name.ret if new_sim_name!=None: new_material=os.path.join(self.path,new_sim_name) clone_spectra(new_material,get_base_spectra_path()) elif action == deleteAction: files="" for i in self.selectedItems(): files=files+os.path.join(self.path,i.text())+"\n" ret=yes_no_dlg(self,_("Are you sure you want to delete the files ?")+"\n\n"+files) if ret==True: for i in self.selectedItems(): file_to_remove=os.path.join(self.path,i.text()) gpvdm_delete_file(file_to_remove) elif action == renameAction: old_name=self.currentItem().text() new_sim_name=dlg_get_text( _("Rename:"), self.currentItem().text(),"rename") new_sim_name=new_sim_name.ret if new_sim_name!=None: new_name=os.path.join(self.path,new_sim_name) old_name=os.path.join(self.path,old_name) #print(old_name, new_name) os.rename(old_name, new_name) self.fill_store()