Beispiel #1
0
    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()
Beispiel #2
0
	def init(self):
		self.progress_window=progress_class()
		self.progress_window.init()

		self.articles=[]
		self.dump_dir=os.path.join(os.getcwd(),"light_dump")
		find_models()
		self.main_vbox=gtk.VBox()
		self.gen_main_menu(self,self.main_vbox)
		toolbar = gtk.Toolbar()

		toolbar.set_style(gtk.TOOLBAR_ICONS)
		toolbar.set_size_request(-1, 50)
		self.main_vbox.pack_start(toolbar, False, False, 0)
		
		self.edit_list=[]
		self.line_number=[]


		self.cb = gtk.combo_box_new_text()
		self.cb.set_wrap_width(5)
		self.cb_id=self.cb.connect("changed", self.on_changed)
		self.update_cb()


		self.cb_model = gtk.combo_box_new_text()
		self.cb_model.set_wrap_width(5)
		self.cb_model.connect("changed", self.on_cb_model_changed)
		self.update_cb_model()

		self.light_source_model = gtk.combo_box_new_text()
		self.light_source_model.set_wrap_width(5)
		self.light_source_model.connect("changed", self.on_light_source_model_changed)
		self.update_light_source_model()
		self.light_source_model.show()

		self.fig_photon_density = band_graph()
		self.fig_photon_density.set_data_file("light_1d_photons_tot_norm.dat")
		self.fig_photon_density.init()

		self.fig_photon_abs = band_graph()
		self.fig_photon_abs.set_data_file("light_1d_photons_tot_abs_norm.dat")
		self.fig_photon_abs.init()

		tool_bar_pos=0

		image = gtk.Image()
   		image.set_from_file(os.path.join(get_image_file_path(),"play.png"))
		self.play = gtk.ToolButton(image)
   		#image.set_from_file(self.icon_theme.lookup_icon("media-playback-start", 32, 0).get_filename())
		refresh = gtk.ToolButton(image)
		refresh.connect("clicked", self.callback_refresh)
		toolbar.insert(refresh, tool_bar_pos)
		toolbar.show_all()
		tool_bar_pos=tool_bar_pos+1

		ti_light = gtk.ToolItem()
		lable=gtk.Label("Optical mode:")
		lable.show()
		ti_hbox = gtk.HBox(False, 2)
		ti_hbox.show()
        
		ti_hbox.pack_start(lable, False, False, 0)
		ti_hbox.pack_start(self.cb, False, False, 0)
		self.cb.show()

		lable=gtk.Label("Optical model:")
		lable.show()
	        ti_hbox.pack_start(lable, False, False, 0)
		ti_hbox.pack_start(self.cb_model, False, False, 0)
		self.cb_model.show()
		

		ti_light.add(ti_hbox);
		toolbar.insert(ti_light, tool_bar_pos)
		ti_light.show()

		tool_bar_pos=tool_bar_pos+1

		sep = gtk.SeparatorToolItem()
		sep.set_draw(False)
		sep.set_expand(False)
		toolbar.insert(sep, tool_bar_pos)
		sep.show()
		tool_bar_pos=tool_bar_pos+1

		lable=gtk.Label("Light source:")
		lable.show()
		ti_hbox.pack_start(lable, False, False, 0)
		ti_hbox.pack_start(self.light_source_model, False, False, 0)
		self.cb_model.show()

		sep = gtk.SeparatorToolItem()
		sep.set_draw(False)
		sep.set_expand(True)
		toolbar.insert(sep, tool_bar_pos)
		sep.show()
		tool_bar_pos=tool_bar_pos+1

		help = gtk.ToolButton(gtk.STOCK_HELP)
		toolbar.insert(help, tool_bar_pos)
		help.connect("clicked", self.callback_help)
		help.show()
		tool_bar_pos=tool_bar_pos+1


		self.notebook.append_page(self.fig_photon_density,gtk.Label("Photon density") )
		self.notebook.append_page(self.fig_photon_abs,gtk.Label("Photon absorbed") )

		self.main_vbox.pack_start(self.notebook, False, False, 0)

		optics_config=tab_class()
		optics_config.show()
		self.notebook.append_page(optics_config,gtk.Label("Optical setup"))
		optics_config.visible=True
		optics_config.init("optics.inp","Config")
		optics_config.label_name="Optics config"
		optics_config.file_name="optics.inp"

		#Photon distribution
		photon_dist=photon_dist_class()
		photon_dist.show()

##################
		input_files=[]
		input_files.append("./light_dump/light_2d_photons.dat")
		input_files.append("./light_dump/light_2d_photons_asb.dat")
		input_files.append("./light_dump/reflect.dat")

		plot_labels=[]
		plot_labels.append("Photon distribution")
		plot_labels.append("Photon distribution absorbed")
		plot_labels.append("Reflection")

		self.plot_widgets=[]
		self.progress_window.start()
		for i in range(0,len(input_files)):
			self.plot_widgets.append(plot_widget())
			self.plot_widgets[i].init(self)
			self.plot_widgets[i].set_labels([plot_labels[0]])
			self.plot_widgets[i].load_data([input_files[i]],os.path.splitext(input_files[i])[0]+".oplot")

			self.plot_widgets[i].do_plot()
			self.plot_widgets[i].show()

			self.notebook.append_page(self.plot_widgets[i],gtk.Label(plot_labels[i]))

		self.connect("delete-event", self.callback_close) 

		self.add(self.main_vbox)
		self.set_size_request(850,-1)
		self.main_vbox.show()

		self.fig_photon_density.draw_graph()
		self.fig_photon_abs.draw_graph()

		self.set_icon_from_file(os.path.join(get_image_file_path(),"image.jpg"))
		self.set_title("Optical Model - (www.opvdm.com)")
		self.set_position(gtk.WIN_POS_CENTER)
		self.progress_window.stop()
Beispiel #3
0
    def __init__(self):
        QWidget.__init__(self)
        self.setWindowIcon(icon_get("optics"))

        self.setMinimumSize(1000, 600)

        self.ribbon = optics_ribbon()

        self.edit_list = []
        self.line_number = []
        self.articles = []
        input_files = []
        input_files.append(
            os.path.join(get_sim_path(), "light_dump", "light_2d_photons.dat"))
        input_files.append(
            os.path.join(get_sim_path(), "light_dump",
                         "light_2d_photons_asb.dat"))
        input_files.append(
            os.path.join(get_sim_path(), "light_dump", "reflect.dat"))

        plot_labels = []
        plot_labels.append(_("Photon distribution"))
        plot_labels.append(_("Photon distribution absorbed"))
        plot_labels.append(_("Reflection"))

        self.setGeometry(300, 300, 600, 600)
        self.setWindowTitle(
            _("Optical simulation editor") + " (https://www.gpvdm.com)")

        self.setWindowIcon(icon_get("optics"))

        self.main_vbox = QVBoxLayout()

        self.ribbon.run.triggered.connect(self.callback_run)

        self.ribbon.fx_box.cb.currentIndexChanged.connect(self.mode_changed)

        self.ribbon.help.triggered.connect(self.callback_help)

        self.ribbon.tb_save.triggered.connect(self.callback_save)

        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.fig_photon_density = band_graph()
        self.fig_photon_density.set_data_file("light_1d_photons_tot_norm.dat")
        self.fig_photon_density.init()
        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.fig_photon_abs.init()
        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.fig_gen_rate.init()
        self.notebook.addTab(self.fig_gen_rate, _("Generation rate"))

        widget = tab_class()
        widget.init(os.path.join(get_sim_path(), "light.inp"),
                    _("Optical setup"))
        self.notebook.addTab(widget, _("Optical setup"))

        self.plot_widgets = []
        self.progress_window.start()
        for i in range(0, len(input_files)):
            self.plot_widgets.append(plot_widget())
            self.plot_widgets[i].init(enable_toolbar=False)
            self.plot_widgets[i].set_labels([plot_labels[0]])
            self.plot_widgets[i].load_data(
                [input_files[i]],
                os.path.splitext(input_files[i])[0] + ".oplot")

            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.draw_graph()
        self.fig_photon_abs.draw_graph()
        self.fig_gen_rate.draw_graph()
        self.progress_window.stop()

        self.main_vbox.addWidget(self.notebook)

        self.setLayout(self.main_vbox)

        return
Beispiel #4
0
	def __init__(self):
		QWidget.__init__(self)
		self.dump_dir=os.path.join(os.getcwd(),"light_dump")
		find_models()

		self.setWindowIcon(QIcon(os.path.join(get_image_file_path(),"image.png")))

		self.setMinimumSize(1000, 600)

		self.edit_list=[]
		self.line_number=[]
		self.articles=[]
		input_files=[]
		input_files.append(os.path.join(os.getcwd(),"light_dump","light_2d_photons.dat"))
		input_files.append(os.path.join(os.getcwd(),"light_dump","light_2d_photons_asb.dat"))
		input_files.append(os.path.join(os.getcwd(),"light_dump","reflect.dat"))

		plot_labels=[]
		plot_labels.append("Photon distribution")
		plot_labels.append("Photon distribution absorbed")
		plot_labels.append("Reflection")


		self.setGeometry(300, 300, 600, 600)
		self.setWindowTitle(_("Optical simulation editor (www.gpvdm.com)"))    

		self.setWindowIcon(QIcon(os.path.join(get_image_file_path(),"optics.png")))

		self.main_vbox=QVBoxLayout()

		menubar = QMenuBar()

		file_menu = menubar.addMenu('&File')
		self.menu_refresh=file_menu.addAction(_("&Refresh"))
		self.menu_refresh.triggered.connect(self.update)

		self.menu_close=file_menu.addAction(_("&Close"))
		self.menu_close.triggered.connect(self.callback_close)

		self.main_vbox.addWidget(menubar)

		toolbar=QToolBar()

		toolbar.setIconSize(QSize(48, 48))

		self.run = QAction(QIcon(os.path.join(get_image_file_path(),"play.png")), _("Run"), self)
		self.run.triggered.connect(self.callback_run)
		toolbar.addAction(self.run)


		label=QLabel(_("Wavelengths:"))
		toolbar.addWidget(label)

		self.cb = QComboBox()
		self.update_cb()
		toolbar.addWidget(self.cb)
		self.cb.currentIndexChanged.connect(self.mode_changed)

		label=QLabel(_("Optical model:"))
		toolbar.addWidget(label)

		self.cb_model = QComboBox()
		toolbar.addWidget(self.cb_model)
		self.update_cb_model()
		
		self.cb_model.activated.connect(self.on_cb_model_changed)

		label=QLabel(_("Solar spectrum:"))
		toolbar.addWidget(label)
		self.light_source_model = QComboBox()
		self.update_light_source_model()
		toolbar.addWidget(self.light_source_model)
		self.light_source_model.activated.connect(self.on_light_source_model_changed)
		
		spacer = QWidget()
		spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
		toolbar.addWidget(spacer)


		self.help = QAction(QIcon(os.path.join(get_image_file_path(),"help.png")), 'Help', self)
		self.help.triggered.connect(self.callback_help)
		toolbar.addAction(self.help)

		self.main_vbox.addWidget(toolbar)


		self.progress_window=progress_class()

		self.notebook = QTabWidget()

		self.notebook.setMovable(True)


		self.fig_photon_density = band_graph()
		self.fig_photon_density.set_data_file("light_1d_photons_tot_norm.dat")
		self.fig_photon_density.init()
		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.fig_photon_abs.init()
		self.notebook.addTab(self.fig_photon_abs,"Photon absorbed")

		widget=tab_class()
		widget.init("light.inp","Optical setup")
		self.notebook.addTab(widget,"Optical setup")


		self.plot_widgets=[]
		self.progress_window.start()
		for i in range(0,len(input_files)):
			self.plot_widgets.append(plot_widget())
			self.plot_widgets[i].init()
			self.plot_widgets[i].set_labels([plot_labels[0]])
			self.plot_widgets[i].load_data([input_files[i]],os.path.splitext(input_files[i])[0]+".oplot")

			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.draw_graph()
		self.fig_photon_abs.draw_graph()

		self.progress_window.stop()


		self.main_vbox.addWidget(self.notebook)


		self.setLayout(self.main_vbox)

		return