Esempio n. 1
1
	def add_row(self,i,thick,material,dos_layer,pl_file,name):
		self.tab.blockSignals(True)

		dos_file=""
		
		if dos_layer.startswith("dos")==True:
			dos_file="active layer"
		else:
			dos_file=dos_layer

		item1 = QTableWidgetItem(str(name))
		self.tab.setItem(i,0,item1)

		item2 = QTableWidgetItem(str(thick))
		self.tab.setItem(i,1,item2)

		combobox = QComboBox()

		#combobox.setEditable(True)

		for a in self.material_files:
			combobox.addItem(str(a))
		self.tab.setCellWidget(i,2, combobox)
		combobox.setCurrentIndex(combobox.findText(material))

		p=combobox.palette()
		p.setColor(QPalette.Active, QPalette.Button, Qt.white);
		p.setColor(QPalette.Inactive, QPalette.Button, Qt.white);
		combobox.setPalette(p)
		
		#item3 = QTableWidgetItem(str(dos_file))
		#self.tab.setItem(i,3,item3)
		combobox_layer_type = QComboBox()
		#combobox.setEditable(True)

		combobox_layer_type.addItem("contact")
		combobox_layer_type.addItem("active layer")
		combobox_layer_type.addItem("other")

		self.tab.setCellWidget(i,3, combobox_layer_type)
		combobox_layer_type.setCurrentIndex(combobox_layer_type.findText(str(dos_file).lower()))

		item3 = QTableWidgetItem(str(dos_layer))
		self.tab.setItem(i,4,item3)

		item3 = QTableWidgetItem(str(pl_file))
		self.tab.setItem(i,5,item3)


		scan_item_add("epitaxy.inp","#layer_material_file"+str(i),_("Material for ")+name,2)
		scan_item_add("epitaxy.inp","#layer_width"+str(i),_("Layer width ")+name,1)

		combobox.currentIndexChanged.connect(self.combo_changed)
		combobox_layer_type.currentIndexChanged.connect(self.layer_type_edit)

		self.tab.blockSignals(False)
	def load(self):
		self.mesh_model.clear()
		lines=[]
		pos=0
		if inp_load_file(lines,os.path.join(os.getcwd(),"mesh.inp"))==True:
			pos=pos+1	#first comment
			mesh_layers=int(lines[pos])

			for i in range(0, mesh_layers):
				pos=pos+1					#token
				token=lines[pos]
				scan_item_add("mesh.inp",token,"Mesh width"+str(i),1)
				pos=pos+1
				thicknes=lines[pos]	#read value

				pos=pos+1					#token
				token=lines[pos]
				scan_item_add("mesh.inp",token,"Mesh points"+str(i),1)

				pos=pos+1
				points=lines[pos] 		#read value

				iter = self.mesh_model.append()

				self.mesh_model.set (iter,
				  MESH_THICKNES, str(thicknes),
				  MESH_POINTS, str(points)
				)
Esempio n. 3
0
def epitaxy_update_scan():
    global epi
    scan_remove_file("epitaxy.inp")
    for i in range(0, len(epi)):
        scan_item_add("epitaxy.inp", "#layer_material_file" + str(i),
                      _("Material for ") + str(epi[i].name), 2)
        scan_item_add("epitaxy.inp", "#layer_width" + str(i),
                      _("Layer width ") + str(epi[i].name), 1)
Esempio n. 4
0
    def load(self):
        lines = []
        self.tab.clear()
        self.tab.setHorizontalHeaderLabels(
            [_("Function"),
             _("Enabled"), _("a"),
             _("b"), _("c")])

        lines = inp_load_file(self.file_name)
        #print(self.file_name,lines)
        pos = 0

        while True:
            if lines[pos] == "#end":
                break
            if lines[pos] == "#ver":
                break

            tag = lines[pos]
            scan_item_add(self.file_name, tag, tag, 1)
            pos = pos + 1  #skip hash tag

            function = lines[pos]  #read label
            pos = pos + 1

            tag = lines[pos]
            scan_item_add(self.file_name, tag, tag, 1)
            pos = pos + 1  #skip hash tag

            enabled = lines[pos]  #read value
            pos = pos + 1

            tag = lines[pos]
            scan_item_add(self.file_name, tag, tag, 1)
            pos = pos + 1  #skip hash tag

            a = lines[pos]  #read value
            pos = pos + 1

            tag = lines[pos]
            scan_item_add(self.file_name, tag, tag, 1)
            pos = pos + 1  #skip hash tag

            b = lines[pos]  #read value
            pos = pos + 1

            tag = lines[pos]
            scan_item_add(self.file_name, tag, tag, 1)
            pos = pos + 1  #skip hash tag
            c = lines[pos]  #read value
            pos = pos + 1

            tab_add(
                self.tab,
                [str(function),
                 str(enabled),
                 str(a), str(b),
                 str(c)])
Esempio n. 5
0
	def update_light_source_model(self):
		models=find_light_source()
		for i in range(0, len(models)):
			self.light_source_model.append_text(models[i])

		used_model=inp_get_token_value("optics.inp", "#sun")
		if models.count(used_model)==0:
			used_model="sun"
			inp_update_token_value("optics.inp", "#sun","sun",1)

		self.light_source_model.set_active(models.index(used_model))
		scan_item_add("optics.inp","#sun","Light source",1)
Esempio n. 6
0
	def update_cb_model(self):
		models=find_models()
		for i in range(0, len(models)):
			self.cb_model.append_text(models[i])

		used_model=inp_get_token_value("light.inp", "#light_model")
		if models.count(used_model)==0:
			used_model="exp"
			inp_update_token_value("light.inp", "#light_model","exp",1)

		self.cb_model.set_active(models.index(used_model))
		scan_item_add("light.inp","#light_model","Optical model",1)
Esempio n. 7
0
	def load(self):
		lines=[]
		self.tab.clear()
		self.tab.setHorizontalHeaderLabels([_("Function"), _("Enabled"), _("a"), _("b"), _("c")])

		inp_load_file(lines,self.file_name)
		print(self.file_name,lines)
		pos=0

		while True:
			if lines[pos]=="#end":
				break
			if lines[pos]=="#ver":
				break

			tag=lines[pos]
			scan_item_add(self.file_name,tag,tag,1)
			pos=pos+1	#skip hash tag

			function=lines[pos]	#read label
			pos=pos+1

			tag=lines[pos]
			scan_item_add(self.file_name,tag,tag,1)
			pos=pos+1	#skip hash tag

			enabled=lines[pos] 	#read value
			pos=pos+1

			tag=lines[pos]
			scan_item_add(self.file_name,tag,tag,1)
			pos=pos+1	#skip hash tag

			a=lines[pos] 	#read value
			pos=pos+1

			tag=lines[pos]
			scan_item_add(self.file_name,tag,tag,1)
			pos=pos+1	#skip hash tag

			b=lines[pos] 	#read value
			pos=pos+1

			tag=lines[pos]
			scan_item_add(self.file_name,tag,tag,1)
			pos=pos+1	#skip hash tag
			c=lines[pos] 	#read value
			pos=pos+1

			tab_add(self.tab,[ str(function), str(enabled), str(a), str(b), str(c)])
Esempio n. 8
0
    def save_data(self):
        file_name = "fxmesh" + str(self.index) + ".inp"
        scan_remove_file(file_name)

        out_text = []

        for i in range(0, self.tab.rowCount()):
            out_text.append("#fx_segment" + str(i) + "_start")
            scan_item_add(file_name, out_text[len(out_text) - 1],
                          _("Part ") + str(i) + " " + _("start"), 1)
            out_text.append(str(tab_get_value(self.tab, i, 0)))

            out_text.append("#fx_segment" + str(i) + "_stop")
            scan_item_add(file_name, out_text[len(out_text) - 1],
                          _("Part ") + str(i) + " " + _("stop"), 1)
            out_text.append(str(tab_get_value(self.tab, i, 1)))

            out_text.append("#fx_segment" + str(i) + "_points")
            scan_item_add(file_name, out_text[len(out_text) - 1],
                          _("Part ") + str(i) + " " + _("points"), 1)
            out_text.append(str(tab_get_value(self.tab, i, 2)))

            out_text.append("#fx_segment" + str(i) + "_mul")
            scan_item_add(file_name, out_text[len(out_text) - 1],
                          _("Part ") + str(i) + " " + _("mul"), 1)
            out_text.append(str(tab_get_value(self.tab, i, 3)))

        out_text.append("#ver")
        out_text.append("1.1")
        out_text.append("#end")

        inp_save(file_name, out_text)
        self.update_scan_tokens()
Esempio n. 9
0
	def update_light_source_model(self):
		self.light_source_model.blockSignals(True)
		models=find_light_source()
		for i in range(0, len(models)):
			self.light_source_model.addItem(models[i])

		used_model=inp_get_token_value("light.inp", "#sun")

		print("models================",models,used_model)
		if models.count(used_model)==0:
			used_model="sun"
			inp_update_token_value("light.inp", "#sun","sun",1)

		self.light_source_model.setCurrentIndex(self.light_source_model.findText(used_model))
		scan_item_add("light.inp","#sun","Light source",1)
		self.light_source_model.blockSignals(False)
Esempio n. 10
0
    def change_dir_and_refresh_interface(self, new_dir):
        scan_items_clear()
        self.splash.inc_value()

        scan_items_populate_from_known_tokens()
        self.splash.inc_value()

        self.splash.inc_value()

        set_sim_path(new_dir)
        self.splash.inc_value()

        calculate_paths()
        self.splash.inc_value()

        epitaxy_load(get_sim_path())
        self.splash.inc_value()

        contacts_load()
        self.splash.inc_value()

        if mesh_load_all() == False:
            error_dlg(
                self,
                _("There was a problem loading the electrical mesh, I suspect you are trying to open a file generated in a very old version of gpvdm."
                  ))
            return

        self.statusBar().showMessage(get_sim_path())
        self.splash.inc_value()

        self.update_interface()
        self.splash.inc_value()

        if self.notebook.terminal != None:
            self.my_server.set_terminal(self.notebook.terminal)

        if self.notebook.update_display_function != None:
            self.my_server.set_display_function(
                self.notebook.update_display_function)

        scan_item_add("sim.inp", "#simmode", "sim mode", 1)
        scan_item_add("light.inp", "#Psun", "light intensity", 1)
        #scan_populate_from_file("light.inp")

        self.ribbon.update()
        self.splash.inc_value()
Esempio n. 11
0
    def update_scan_tokens(self):
        file_name = "fxmesh" + str(self.index) + ".inp"
        scan_remove_file(file_name)

        for i in range(0, len(self.list)):
            scan_item_add(file_name, "#fx_segment" + str(i) + "_start",
                          _("Part ") + str(i) + " " + _("start"), 1)
            scan_item_add(file_name, "#fx_segment" + str(i) + "_stop",
                          _("Part ") + str(i) + " " + _("stop"), 1)
            scan_item_add(file_name, "#fx_segment" + str(i) + "_points",
                          _("Part ") + str(i) + " " + _("points"), 1)
            scan_item_add(file_name, "#fx_segment" + str(i) + "_mul",
                          _("Part ") + str(i) + " " + _("mul"), 1)
Esempio n. 12
0
	def save_data(self):
		file_name="fxmesh"+str(self.index)+".inp"
		scan_remove_file(file_name)

		out_text=[]
		out_text.append("#fx_start")
		out_text.append(str(float(self.fx_start)))
		out_text.append("#fx_segments")
		out_text.append(str(self.tab.rowCount()))

		for i in range(0,self.tab.rowCount()):
			out_text.append("#fx_segment"+str(i)+"_len")
			scan_item_add(file_name,out_text[len(out_text)-1],_("Part ")+str(i)+_(" period"),1)
			out_text.append(str(tab_get_value(self.tab,i, 0)))

			out_text.append("#fx_segment"+str(i)+"_dfx")
			scan_item_add(file_name,out_text[len(out_text)-1],_("Part ")+str(i)+_(" dfx"),1)
			out_text.append(str(tab_get_value(self.tab,i, 1)))

			out_text.append("#fx_segment"+str(i)+"_mul")
			scan_item_add(file_name,out_text[len(out_text)-1],_("Part ")+str(i)+_(" mul"),1)
			out_text.append(str(tab_get_value(self.tab,i, 2)))


		out_text.append("#ver")
		out_text.append("1.0")
		out_text.append("#end")

		inp_write_lines_to_file(os.path.join(os.getcwd(),file_name),out_text)
		self.update_scan_tokens()
Esempio n. 13
0
	def save_data(self):
		file_name="fxmesh"+str(self.index)+".inp"
		scan_remove_file(file_name)

		out_text=[]
		out_text.append("#fx_start")
		out_text.append(str(float(self.fx_start)))
		out_text.append("#fx_segments")
		out_text.append(str(int(len(self.store))))
		i=0
		for line in self.store:
			out_text.append("#fx_segment"+str(i)+"_len")
			scan_item_add(file_name,out_text[len(out_text)-1],_("Part ")+str(i)+_(" period"),1)
			out_text.append(str(line[SEG_LENGTH]))

			out_text.append("#fx_segment"+str(i)+"_dfx")
			scan_item_add(file_name,out_text[len(out_text)-1],_("Part ")+str(i)+_(" dfx"),1)
			out_text.append(str(line[SEG_DFX]))

			out_text.append("#fx_segment"+str(i)+"_mul")
			scan_item_add(file_name,out_text[len(out_text)-1],_("Part ")+str(i)+_(" mul"),1)
			out_text.append(str(line[SEG_MUL]))
			i=i+1

		out_text.append("#ver")
		out_text.append("1.0")
		out_text.append("#end")
		
		inp_write_lines_to_file(os.path.join(os.getcwd(),file_name),out_text)
		self.update_scan_tokens()
Esempio n. 14
0
	def update_scan_tokens(self):
		file_name="fxmesh"+str(self.index)+".inp"
		scan_remove_file(file_name)

		for i in range(0,len(self.list)):
			scan_item_add(file_name,"#fx_segment"+str(i)+"_len",_("Part ")+str(i)+_(" period"),1)
			scan_item_add(file_name,"#fx_segment"+str(i)+"_dfx",_("Part ")+str(i)+_(" dfx"),1)
			scan_item_add(file_name,"#fx_segment"+str(i)+"_mul",_("Part ")+str(i)+_(" mul"),1)
Esempio n. 15
0
	def __create_model(self):

		# create list store
		model = gtk.ListStore(str,str,str,str,str,str,str)

		# add items

		self.rebuild_mat_list()

		for i in range(0,epitaxy_get_layers()):
			thick=epitaxy_get_width(i)
			material=epitaxy_get_mat_file(i)
			dos_layer=epitaxy_get_electrical_layer(i)
			pl_file=epitaxy_get_pl_file(i)
			name=epitaxy_get_name(i)

			dos_file=""

			if dos_layer=="none":
				dos_file=_("no")
			else:
				dos_file=_("yes")

			scan_item_add("epitaxy.inp","#layer"+str(i),_("Material for ")+str(material),2)
			scan_item_add("epitaxy.inp","#layer"+str(i),_("Layer width ")+str(material),1)

			iter = model.append()

			model.set (iter,
			  COLUMN_NAME, str(name),
			  COLUMN_THICKNES, str(thick),
			  COLUMN_MATERIAL, str(material),
			  COLUMN_DEVICE, str(dos_file),
			  COLUMN_DOS_LAYER, str(dos_layer),
			  COLUMN_PL_FILE, str(pl_file)
			)
		return model
Esempio n. 16
0
	def rebuild_mat_list(self):
		self.material_files=[]
		mat=find_materials()
		for i in range(0,len(mat)):
			self.material_files.append(mat[i])
			scan_remove_file(os.path.join(get_materials_path(),mat[i]))			
			scan_item_add(os.path.join("materials",mat[i],"fit.inp"),"#wavelength_shift_alpha","Absorption spectrum wavelength shift",1)
			scan_item_add(os.path.join("materials",mat[i],"fit.inp"),"#n_mul","Refractive index spectrum multiplier",1)
			scan_item_add(os.path.join("materials",mat[i],"fit.inp"),"#alpha_mul","Absorption spectrum multiplier",1)
Esempio n. 17
0
	def update_cb_model(self):
		self.cb_model.blockSignals(True)

		self.cb_model.clear()
		models=find_models()
		if len(models)==0:
			error_dlg(self,_("I can't find any optical plugins, I think the model is not installed properly."))
			return

		for i in range(0, len(models)):
			self.cb_model.addItem(models[i])

		used_model=inp_get_token_value("light.inp", "#light_model")
		print(models,used_model)
		if models.count(used_model)==0:
			used_model="exp"
			inp_update_token_value("light.inp", "#light_model","exp",1)
			self.cb_model.setCurrentIndex(self.cb_model.findText(used_model))
		else:
			self.cb_model.setCurrentIndex(self.cb_model.findText(used_model))

		scan_item_add("light.inp","#light_model","Optical model",1)

		self.cb_model.blockSignals(False)
Esempio n. 18
0
    def init(self, filename, tab_name):
        self.vbox = QVBoxLayout()
        self.file_name = filename
        self.tab_name = tab_name

        self.tab = QGridLayout()
        widget = QWidget()
        widget.setLayout(self.tab)
        self.vbox.addWidget(widget)

        scan_remove_file(filename)

        self.edit_list = []
        inp_load_file(self.lines, filename)

        n = 0
        pos = 0
        my_token_lib = tokens()
        height = 27
        widget_number = 0
        while pos < len(self.lines):
            token = self.lines[pos]
            if token == "#ver":
                break

            if token == "#end":
                break

            if token.startswith("#"):
                show = False
                units = "Units"

                pos = pos + 1
                value = self.lines[pos]

                result = my_token_lib.find(token)
                if result != False:
                    units = result.units
                    text_info = result.info
                    show = True

                    # self.set_size_request(600,-1)
                if show == True:
                    description = QLabel()
                    description.setText(latex_to_html(text_info))

                    if result.opt[0] == "switch":
                        edit_box = gtkswitch()
                        edit_box.set_value(str2bool(value))
                        edit_box.changed.connect(functools.partial(self.callback_edit, filename, token, edit_box))
                    elif result.opt[0] == "leftright":
                        edit_box = leftright()
                        edit_box.set_value(str2bool(value))
                        edit_box.changed.connect(functools.partial(self.callback_edit, filename, token, edit_box))
                    elif result.opt[0] == "text":
                        edit_box = QLineEdit()
                        if self.editable == False:
                            edit_box.setReadOnly(True)
                        edit_box.setText(value)
                        # edit_box.set_text(self.lines[pos]);
                        edit_box.textChanged.connect(functools.partial(self.callback_edit, filename, token, edit_box))
                        # edit_box.show()
                    else:
                        edit_box = QComboBox()
                        for i in range(0, len(result.opt)):
                            edit_box.addItem(result.opt[i])

                        all_items = [edit_box.itemText(i) for i in range(edit_box.count())]
                        for i in range(0, len(all_items)):
                            if all_items[i] == token:
                                edit_box.setCurrentIndex(i)

                        edit_box.currentIndexChanged.connect(
                            functools.partial(self.callback_edit, filename, token, edit_box)
                        )

                    edit_box.setFixedSize(300, 25)
                    unit = QLabel()
                    unit.setText(latex_to_html(units))

                    self.tab.addWidget(description, widget_number, 0)
                    self.tab.addWidget(edit_box, widget_number, 1)
                    self.tab.addWidget(unit, widget_number, 2)

                    scan_item_add(filename, token, text_info, 1)

                    widget_number = widget_number + 1
            pos = pos + 1

        spacer = QWidget()
        spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.vbox.addWidget(spacer)

        self.setLayout(self.vbox)
Esempio n. 19
0
    def init(self, filename, tab_name):
        self.scroll = QScrollArea()
        self.main_box_widget = QWidget()
        self.vbox = QVBoxLayout()
        self.hbox = QHBoxLayout()
        self.hbox.setAlignment(Qt.AlignTop)
        self.file_name = filename
        self.tab_name = tab_name

        self.tab = QGridLayout()
        widget = QWidget()
        widget.setLayout(self.tab)
        self.vbox.addWidget(widget)

        scan_remove_file(filename)

        self.edit_list = []
        self.lines = inp_load_file(filename)
        if self.lines == False:
            error_dlg(self, _("File not found.") + " " + filename)
            return
        n = 0
        pos = 0
        my_token_lib = tokens()
        widget_number = 0

        while (1):
            ret, pos = inp_get_next_token_array(self.lines, pos)

            token = ret[0]
            if token == "#ver":
                break

            if token == "#end":
                break

            if token.startswith("#"):
                show = False
                units = "Units"

                value = ret[1]

                result = my_token_lib.find(token)
                if result != False:
                    units = result.units
                    text_info = result.info
                    show = True

                #self.set_size_request(600,-1)
                if show == True:
                    description = QLabel_click()
                    description.setText(latex_to_html(text_info))
                    if os.path.isfile(
                            os.path.splitext(filename)[0] + "_" + token[1:] +
                            ".ref"):
                        description.setStyleSheet('color: green')

                    description.clicked.connect(
                        functools.partial(self.callback_ref, filename, token,
                                          description))

                    if result.widget == "gtkswitch":
                        edit_box = gtkswitch()
                        edit_box.setFixedSize(300, 25)
                        edit_box.set_value(str2bool(value))
                        edit_box.changed.connect(
                            functools.partial(self.callback_edit, filename,
                                              token, edit_box))
                    elif result.widget == "leftright":
                        edit_box = leftright()
                        edit_box.setFixedSize(300, 25)
                        edit_box.set_value(str2bool(value))
                        edit_box.changed.connect(
                            functools.partial(self.callback_edit, filename,
                                              token, edit_box))
                    elif result.widget == "gpvdm_select":
                        edit_box = gpvdm_select(file_box=True)
                        edit_box.setFixedSize(300, 25)
                        edit_box.setText(value)
                        edit_box.edit.textChanged.connect(
                            functools.partial(self.callback_edit, filename,
                                              token, edit_box))
                    elif result.widget == "QLineEdit":
                        edit_box = QLineEdit()
                        edit_box.setFixedSize(300, 25)
                        if self.editable == False:
                            edit_box.setReadOnly(True)
                        edit_box.setText(value)
                        #edit_box.set_text(self.lines[pos]);
                        edit_box.textChanged.connect(
                            functools.partial(self.callback_edit, filename,
                                              token, edit_box))
                        #edit_box.show()
                    elif result.widget == "QColorPicker":
                        r = float(ret[1])
                        g = float(ret[2])
                        b = float(ret[3])
                        edit_box = QColorPicker(r, g, b)
                        edit_box.setFixedSize(300, 25)
                        edit_box.changed.connect(
                            functools.partial(self.callback_edit, filename,
                                              token, edit_box))
                    elif result.widget == "QComboBoxLang":
                        edit_box = QComboBoxLang()
                        edit_box.setFixedSize(300, 25)
                        for i in range(0, len(result.defaults)):
                            edit_box.addItemLang(result.defaults[i][0],
                                                 result.defaults[i][1])

                        edit_box.setValue_using_english(value)

                        edit_box.currentIndexChanged.connect(
                            functools.partial(self.callback_edit, filename,
                                              token, edit_box))
                    elif result.widget == "QParasitic":
                        edit_box = QParasitic()
                        edit_box.setFixedSize(300, 25)
                        edit_box.setValue(value)
                        edit_box.textChanged.connect(
                            functools.partial(self.callback_edit, filename,
                                              token, edit_box))

                    elif result.widget == "QChangeLog":
                        edit_box = QChangeLog()
                        edit_box.setMinimumHeight(100)
                        if self.editable == False:
                            edit_box.setReadOnly(True)
                        edit_box.setText(value)
                        edit_box.textChanged.connect(
                            functools.partial(self.callback_edit, filename,
                                              token, edit_box))
                    else:
                        edit_box = QComboBox()
                        edit_box.setFixedSize(300, 25)
                        for i in range(0, len(result.defaults)):
                            edit_box.addItem(result.defaults[i])

                        all_items = [
                            edit_box.itemText(i)
                            for i in range(edit_box.count())
                        ]
                        for i in range(0, len(all_items)):
                            if all_items[i] == value:
                                edit_box.setCurrentIndex(i)
                                break

                        edit_box.currentIndexChanged.connect(
                            functools.partial(self.callback_edit, filename,
                                              token, edit_box))

                    unit = QLabel()
                    unit.setText(latex_to_html(units))

                    self.tab.addWidget(description, widget_number, 0)
                    self.tab.addWidget(edit_box, widget_number, 1)
                    self.tab.addWidget(unit, widget_number, 2)

                    scan_item_add(filename, token, text_info, 1)

                    widget_number = widget_number + 1

        spacer = QWidget()
        spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.vbox.addWidget(spacer)
        self.main_box_widget.setLayout(self.vbox)

        self.scroll.setWidget(self.main_box_widget)

        self.icon_widget = QWidget()
        self.icon_widget_vbox = QVBoxLayout()
        self.icon_widget.setLayout(self.icon_widget_vbox)

        if self.icon_file != "":
            self.image = QLabel()
            icon = QIcon_load(self.icon_file)
            self.image.setPixmap(icon.pixmap(icon.actualSize(QSize(32, 32))))
            self.icon_widget_vbox.addWidget(self.image)

            spacer2 = QWidget()
            spacer2.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)
            self.icon_widget_vbox.addWidget(spacer2)

            self.hbox.addWidget(self.icon_widget)

        self.hbox.addWidget(self.scroll)

        self.setLayout(self.hbox)
Esempio n. 20
0
	def update_scan_tokens(self):
		file_name="time_mesh_config"+str(self.index)+".inp"
		scan_remove_file(file_name)

		for i in range(0,len(self.list)):
			scan_item_add(file_name,"#time_segment"+str(i)+"_len",_("Part ")+str(i)+_(" period"),1)
			scan_item_add(file_name,"#time_segment"+str(i)+"_dt",_("Part ")+str(i)+_(" dt"),1)
			scan_item_add(file_name,"#time_segment"+str(i)+"_voltage_start",_("Part ")+str(i)+_(" start voltage"),1)
			scan_item_add(file_name,"#time_segment"+str(i)+"_voltage_stop",_("Part ")+str(i)+_(" stop voltage"),1)
			scan_item_add(file_name,"#time_segment"+str(i)+"_mul",_("Part ")+str(i)+_(" mul"),1)
			scan_item_add(file_name,"#time_segment"+str(i)+"_sun",_("Part ")+str(i)+_(" Sun"),1)
			scan_item_add(file_name,"#time_segment"+str(i)+"_laser",_("Part ")+str(i)+_(" CW laser"),1)
Esempio n. 21
0
    def update_scan_tokens(self):
        scan_remove_file(self.file_name)

        for i in range(0, len(self.list)):
            scan_item_add(self.file_name, "#time_segment" + str(i) + "_len",
                          _("Part ") + str(i) + _(" period"), 1)
            scan_item_add(self.file_name, "#time_segment" + str(i) + "_dt",
                          _("Part ") + str(i) + _(" dt"), 1)
            scan_item_add(self.file_name,
                          "#time_segment" + str(i) + "_voltage_start",
                          _("Part ") + str(i) + _(" start voltage"), 1)
            scan_item_add(self.file_name,
                          "#time_segment" + str(i) + "_voltage_stop",
                          _("Part ") + str(i) + _(" stop voltage"), 1)
            scan_item_add(self.file_name, "#time_segment" + str(i) + "_mul",
                          _("Part ") + str(i) + _(" mul"), 1)
            scan_item_add(self.file_name, "#time_segment" + str(i) + "_sun",
                          _("Part ") + str(i) + _(" Sun"), 1)
            scan_item_add(self.file_name, "#time_segment" + str(i) + "_laser",
                          _("Part ") + str(i) + _(" CW laser"), 1)
Esempio n. 22
0
	def init(self,filename,fullname):
		scan_remove_file(filename)
		self.widget_type=[]
		self.file_name=filename
		self.edit_list=[]
		self.line_number=[]
		inp_load_file(self.lines,filename)

		n=0
		pos=0
		my_token_lib=tokens()
		height=27
		for i in range(0, len(self.lines)/2):

			show=False
			units="Units"
			token=self.lines[pos]
			result=my_token_lib.find(token)
			if result!=False:
				units=result.units
				text_info=result.info
				show=True
			pos=pos+1
			self.set_size_request(600,-1)
			if show == True :
				hbox=gtk.HBox()
				hbox.show()
				label = gtk.Label()
				label.set_size_request(400,height)
				label.set_markup(latex_to_pygtk_subscript(text_info))
				label.set_use_markup(True)
				hbox.pack_start(label, False, False, padding=1)
				label.show()

				self.line_number.append(pos)

				if result.opt[0]=="text":
					edit_box=gtk.Entry(max=0)
					edit_box.set_text(self.lines[pos]);
					edit_box.connect("changed", self.callback_edit, token)
					edit_box.show()
					self.widget_type.append("edit")
				else:
					edit_box=gtk.combo_box_new_text()
					index=0
					true_false=False
					if len(result.opt)==2:
						if result.opt[0]==_("true") and result.opt[1]==_("false"):
							true_false=True

					for i in range(0,len(result.opt)):
						edit_box.append_text(result.opt[i])
						if true_false==False:
							if yes_no(self.lines[pos])==yes_no(result.opt[i]):
								index=i
						else:
							if str2bool(self.lines[pos])==True:
								index=0
							else:
								index=1

					edit_box.set_active(index);
					
					edit_box.connect("changed", self.callback_edit, token)
					edit_box.show()
					self.widget_type.append("combo")
				edit_box.set_size_request(300,height)
				self.edit_list.append(edit_box)
				hbox.pack_start(edit_box, False, False, padding=1)

				label = gtk.Label()
				label.set_markup(latex_to_pygtk_subscript(units))
				label.set_use_markup(True)
				label.set_size_request(200,height)
				label.show()
				hbox.pack_start(label, False, False, padding=1)
				label.show()
				self.pack_start(hbox, False, False, padding=1)
				#self.add()
				line=1
				scan_item_add(filename,token,text_info,line)
				
				n=n+1

			pos=pos+1
Esempio n. 23
0
	def change_dir_and_refresh_interface(self,new_dir):
		scan_items_clear()
		os.chdir(new_dir)
		calculate_paths()
		epitaxy_load()
		contacts_load()
		mesh_load_all()

		#print "rod",os.getcwd(),new_dir
		self.statusBar().showMessage(os.getcwd())
		#self.plot_open.setEnabled(False)

		#self.notebook.set_item_factory(self.item_factory)
		if self.notebook.load()==True:
			self.sim_mode_button.update()
			#self.ti_light.connect('refresh', self.notebook.main_tab.update)
			self.run.setEnabled(True)
			self.stop.setEnabled(True)
			self.examine.setEnabled(True)
			self.param_scan.setEnabled(True)
			self.plot_select.setEnabled(True)
			self.undo.setEnabled(True)
			self.jv_button.setEnabled(True)
			self.laser_button.setEnabled(True)
			self.tb_time_domain.setEnabled(True)
			#self.save_sim.setEnabled(True)
			self.experiment_window_button.setEnabled(True)
			self.light_button.setEnabled(True)
			self.light_button.update()
			help_window().help_set_help(["play.png",_("<big><b>Now run the simulation</b></big><br> Click on the play icon to start a simulation.")])

			self.menu_new_optical_material.setEnabled(True)
			self.menu_export_data.setEnabled(True)
			self.menu_import_data.setEnabled(True)
			self.menu_import_lib.setEnabled(True)
			self.menu_run.setEnabled(True)
			self.menu_stop.setEnabled(True)
			self.menu_scan.setEnabled(True)
			self.menu_configure.setEnabled(True)
			self.sim_mode_button.setEnabled(True)
			if enable_betafeatures()==True:
				self.tb_run_fit.setEnabled(True)
				self.qe_button.setEnabled(True)
		else:
			self.run.setEnabled(False)
			self.stop.setEnabled(False)
			self.examine.setEnabled(False)
			self.param_scan.setEnabled(False)
			self.plot_select.setEnabled(False)
			self.undo.setEnabled(False)
			self.jv_button.setEnabled(False)
			#self.save_sim.setEnabled(False)
			self.experiment_window_button.setEnabled(False)

			self.laser_button.setEnabled(False)
			self.tb_time_domain.setEnabled(False)
			self.sim_mode_button.setEnabled(False)
			self.light_button.setEnabled(False)

			help_window().help_set_help(["icon.png",_("<big><b>Hi!</b></big><br> I'm the on-line help system :).  If you find any bugs please report them to [email protected]."),"new.png",_("Click on the new icon to make a new simulation directory.")])

			self.menu_new_optical_material.setEnabled(False)
			self.menu_export_data.setEnabled(False)
			self.menu_import_data.setEnabled(False)
			self.menu_import_lib.setEnabled(False)
			self.menu_run.setEnabled(False)
			self.menu_stop.setEnabled(False)
			self.menu_scan.setEnabled(False)
			self.menu_configure.setEnabled(False)
			if enable_betafeatures()==True:
				self.tb_run_fit.setEnabled(False)
				self.qe_button.setEnabled(False)

		if self.notebook.terminal!=None:
			self.my_server.set_terminal(self.notebook.terminal)

		#self.plotted_graphs.init(os.getcwd(),self.callback_last_menu_click)

		#set_active_name(self.light, inp_get_token_value("light.inp", "#Psun"))

		scan_item_add("sim.inp","#simmode","sim mode",1)
		scan_item_add("light.inp","#Psun","light intensity",1)
		#scan_populate_from_file("light.inp")

		if self.scan_window!=None:
			del self.scan_window
			self.scan_window=None

		if self.experiment_window!=None:
			del self.experiment_window
			self.experiment_window=None

		if self.fxexperiment_window!=None:
			del self.fxexperiment_window
			self.fxexperiment_window=None

		if self.jvexperiment_window!=None:
			del self.jvexperiment_window
			self.jvexperiment_window=None

		if self.sim_info_window!=None:
			del self.sim_info_window
			self.sim_info_window=None

		if self.fit_window!=None:
			del self.fit_window
			self.fit_window=None

		if self.lasers_window!=None:
			del self.lasers_window
			self.lasers_window=None

		if self.config_window!=None:
			del self.config_window
			self.config_window=None

		if self.qe_window!=None:
			del self.qe_window
			self.qe_window=None
Esempio n. 24
0
	def change_dir_and_refresh_interface(self,new_dir):
		print "rod",os.getcwd(),new_dir
 		scan_items_clear()
		os.chdir(new_dir)
		calculate_paths()
		epitaxy_load()
		self.config.load(os.getcwd())
		print "rod",os.getcwd(),new_dir
		self.status_bar.push(self.context_id, os.getcwd())
		#self.plot_open.set_sensitive(False)

		self.notebook.set_item_factory(self.item_factory)
		if self.notebook.load()==True:
			self.sim_mode.update()
			self.ti_light.connect('refresh', self.notebook.main_tab.update)
			self.play.set_sensitive(True)
			self.stop.set_sensitive(True)
			self.examine.set_sensitive(True)
			self.param_scan.set_sensitive(True)
			self.plot_select.set_sensitive(True)
			self.undo.set_sensitive(True)
			#self.save_sim.set_sensitive(True)
			self.experiment_window_button.set_sensitive(True)
			my_help_class.help_set_help(["play.png",_("<big><b>Now run the simulation</b></big>\n Click on the play icon to start a simulation.")])

			my_item=self.item_factory.get_item(_("/File/Import data"))
			if my_item!=None:
				my_item.set_sensitive(True)
			my_item=self.item_factory.get_item(_("/File/Export data"))
			if my_item!=None:
				my_item.set_sensitive(True)
			my_item=self.item_factory.get_item(_("/File/Import data"))
			if my_item!=None:
				my_item.set_sensitive(True)
			my_item=self.item_factory.get_item(_("/File/Import from library"))
			if my_item!=None:
				my_item.set_sensitive(True)
			my_item=self.item_factory.get_item(_("/Simulate/Run"))
			if my_item!=None:
				my_item.set_sensitive(True)
			my_item=self.item_factory.get_item(_("/Simulate/Parameter scan"))
			if my_item!=None:
				my_item.set_sensitive(True)

		else:
			self.play.set_sensitive(False)
			self.stop.set_sensitive(False)
			self.examine.set_sensitive(False)
			self.param_scan.set_sensitive(False)
			self.plot_select.set_sensitive(False)
			self.undo.set_sensitive(False)
			#self.save_sim.set_sensitive(False)
			self.experiment_window_button.set_sensitive(False)
			my_help_class.help_set_help(["icon.png",_("<big><b>Hi!</b></big>\n I'm the on-line help system :).  If you find any bugs please report them to [email protected]."),"new.png",_("Click on the new icon to make a new simulation directory.")])

			my_item=self.item_factory.get_item(_("/File/Import data"))
			if my_item!=None:
				my_item.set_sensitive(False)
			my_item=self.item_factory.get_item(_("/File/Export data"))
			if my_item!=None:
				my_item.set_sensitive(False)
			my_item=self.item_factory.get_item(_("/File/Import data"))
			if my_item!=None:
				my_item.set_sensitive(False)
			my_item=self.item_factory.get_item(_("/File/Import from library"))
			if my_item!=None:
				my_item.set_sensitive(False)
			my_item=self.item_factory.get_item(_("/Simulate/Run"))
			if my_item!=None:
				my_item.set_sensitive(False)
			my_item=self.item_factory.get_item(_("/Simulate/Parameter scan"))
			if my_item!=None:
				my_item.set_sensitive(False)

		if self.notebook.terminal!=None:
			self.my_server.set_terminal(self.notebook.terminal)
		self.notebook.show()

		self.plotted_graphs.init(os.getcwd(),self.callback_last_menu_click)

		set_active_name(self.light, inp_get_token_value("light.inp", "#Psun"))

		scan_item_add("sim.inp","#simmode","sim mode",1)
		scan_item_add("light.inp","#Psun","light intensity",1)


		if self.scan_window!=None:
			del self.scan_window
			self.scan_window=None

		if self.experiment_window!=None:
			del self.experiment_window
			self.experiment_window=None

		if self.fxexperiment_window!=None:
			del self.fxexperiment_window
			self.fxexperiment_window=None


		if self.qe_window!=None:
			del self.qe_window
			self.qe_window=None
Esempio n. 25
0
	def wow(self):
		self.edit_list=[]
		self.line_number=[]
		self.lines=[]
		self.save_file_name="lumo0.inp"

		inp_load_file(self.lines,"./lumo0.inp")

		n=0
		pos=0

		while True:
			if self.lines[pos]=="#end":
				break
			if self.lines[pos]=="#ver":
				break

			tag=self.lines[pos]
			scan_item_add("lumo0.inp",tag,tag,1)
			pos=pos+1	#skip hash tag

			function=self.lines[pos]	#read label
			pos=pos+1

			tag=self.lines[pos]
			scan_item_add("lumo0.inp",tag,tag,1)
			pos=pos+1	#skip hash tag

			enabled=self.lines[pos] 	#read value
			pos=pos+1
			
			tag=self.lines[pos]
			scan_item_add("lumo0.inp",tag,tag,1)
			pos=pos+1	#skip hash tag

			a=self.lines[pos] 	#read value
			pos=pos+1

			tag=self.lines[pos]
			scan_item_add("lumo0.inp",tag,tag,1)
			pos=pos+1	#skip hash tag

			b=self.lines[pos] 	#read value
			pos=pos+1

			tag=self.lines[pos]
			scan_item_add("lumo0.inp",tag,tag,1)
			pos=pos+1	#skip hash tag
			c=self.lines[pos] 	#read value
			pos=pos+1

			articles.append([ str(function), str(enabled), str(a), str(b), str(c), True ])


		self.save_file_name="homo0.inp"

		inp_load_file(self.lines,"./homo0.inp")
		n=0
		pos=0

		while True:
			if self.lines[pos]=="#end":
				break
			if self.lines[pos]=="#ver":
				break

			tag=self.lines[pos]
			scan_item_add("homo0.inp",tag,tag,1)
			pos=pos+1	#skip hash tag


			function=self.lines[pos]	#read label
			pos=pos+1

			tag=self.lines[pos]
			scan_item_add("homo0.inp",tag,tag,1)
			pos=pos+1	#skip hash tag

			enabled=self.lines[pos] 	#read value
			pos=pos+1

			tag=self.lines[pos]
			scan_item_add("homo0.inp",tag,tag,1)			
			pos=pos+1	#skip hash tag

			a=self.lines[pos] 	#read value
			pos=pos+1

			tag=self.lines[pos]
			scan_item_add("homo0.inp",tag,tag,1)
			pos=pos+1	#skip hash tag

			b=self.lines[pos] 	#read  value
			pos=pos+1

			tag=self.lines[pos]
			scan_item_add("homo0.inp",tag,tag,1)
			pos=pos+1	#skip hash tag
			c=self.lines[pos] 	#read  value
			pos=pos+1

			HOMO_articles.append([ str(function), str(enabled), str(a), str(b), str(c), True ])


		tooltips = gtk.Tooltips()

		toolbar = gtk.Toolbar()
		toolbar.set_orientation(gtk.ORIENTATION_VERTICAL)
		toolbar.set_style(gtk.TOOLBAR_ICONS)
		toolbar.set_size_request(50, -1)

		save = gtk.ToolButton(gtk.STOCK_SAVE)
		tooltips.set_tip(save, "Save image")
		pos=0
		toolbar.insert(save, pos)
		save.connect("clicked", self.callback_save)
		toolbar.show_all()
		self.pack_start(toolbar, False, True, 0)


 		vbox = gtk.VBox(False, 2)
		self.LUMO_model = self.__create_model()
		self.HOMO_model = self.__create_model_mesh()
		self.LUMO_fig = Figure(figsize=(5,4), dpi=100)


		self.draw_graph_lumo()
		self.canvas_lumo = FigureCanvas(self.LUMO_fig)  # a gtk.DrawingArea
		self.canvas_lumo.figure.patch.set_facecolor('white')
		self.canvas_lumo.show()
		vbox.pack_start(self.canvas_lumo, True, True, 1)
		
		self.pack_start(vbox, True, True, 0)
		#self.attach(vbox, 0, 3, 0, 2)
		vbox.show()
		#Layer editor

		self.LUMO_fig.tight_layout(pad=0.5)

	        vbox = gtk.VBox(False, 2)
		

		frame = gtk.Frame()
		frame.set_label("LUMO")
		vbox_layers = gtk.VBox(False, 2)
		treeview = gtk.TreeView(self.LUMO_model)
		treeview.set_size_request(400, 100)
		treeview.set_rules_hint(True)
		treeview.get_selection().set_mode(gtk.SELECTION_SINGLE)
		self.__add_columns(treeview)
	        vbox_layers.pack_start(treeview, False, False, 0)
		treeview.show()

		add_button = gtk.Button("Add",gtk.STOCK_ADD)
		add_button.connect("clicked", self.on_add_item_clicked, self.LUMO_model)
		add_button.show()

		delete_button = gtk.Button("Delete",gtk.STOCK_DELETE)
		delete_button.connect("clicked", self.on_remove_item_from_lumo_clicked, treeview)
		delete_button.show()

	        hbox = gtk.HBox(False, 2)
        
	        hbox.pack_start(add_button, False, False, 0)
	        hbox.pack_start(delete_button, False, False, 0)
		hbox.show()

		vbox_layers.pack_start(hbox, False, False, 0)
		vbox_layers.show()

		frame.add(vbox_layers)
		frame.show()
	        vbox.pack_start(frame, False, False, 0)

		#spacer
		label=gtk.Label(" \n\n    ")
		#self.attach(label, 4, 5, 1, 2,gtk.SHRINK ,gtk.SHRINK)
		vbox.pack_start(label, False, False, 0)

		label.show()



		#mesh editor
		frame = gtk.Frame()
		frame.set_label("H**O")
		vbox_mesh = gtk.VBox(False, 2)
		treeview = gtk.TreeView(self.HOMO_model)
		treeview.set_size_request(400, 100)
		treeview.set_rules_hint(True)
		treeview.get_selection().set_mode(gtk.SELECTION_SINGLE)
		self.__add_columns_mesh(treeview)
		vbox_mesh.pack_start(treeview, False, False, 0)
		treeview.show()

		add_button = gtk.Button("Add",gtk.STOCK_ADD)
		add_button.connect("clicked", self.on_add_HOMO_clicked, self.HOMO_model)
		add_button.show()

		delete_button = gtk.Button("Delete",gtk.STOCK_DELETE)
		delete_button.connect("clicked", self.on_remove_item_from_homo_clicked, treeview)
		delete_button.show()

	        hbox = gtk.HBox(False, 2)
        
	        hbox.pack_start(add_button, False, False, 0)
	        hbox.pack_start(delete_button, False, False, 0)
		vbox_mesh.pack_start(hbox, False, False, 0)
		frame.add(vbox_mesh)
		vbox.pack_start(frame, False, False, 0)
		frame.show()
		vbox_mesh.show()
		hbox.show()
		self.pack_start(vbox, False, False, 0)
		#self.attach(vbox, 3, 4, 0, 1,gtk.SHRINK ,gtk.SHRINK)
		vbox.show()
Esempio n. 26
0
	def save_data(self):
		file_name="time_mesh_config"+str(self.index)+".inp"
		scan_remove_file(file_name)

		out_text=[]
		out_text.append("#start_time")
		out_text.append(str(float(self.start_time)))
		out_text.append("#fs_laser_time")
		out_text.append(str(float(self.fs_laser_time)))
		out_text.append("#time_segments")
		out_text.append(str(int(len(self.store))))
		i=0
		for line in self.store:
			out_text.append("#time_segment"+str(i)+"_len")
			scan_item_add(file_name,out_text[len(out_text)-1],_("Part ")+str(i)+_(" period"),1)
			out_text.append(str(line[SEG_LENGTH]))

			out_text.append("#time_segment"+str(i)+"_dt")
			scan_item_add(file_name,out_text[len(out_text)-1],_("Part ")+str(i)+_(" dt"),1)
			out_text.append(str(line[SEG_DT]))

			out_text.append("#time_segment"+str(i)+"_voltage_start")
			scan_item_add(file_name,out_text[len(out_text)-1],_("Part ")+str(i)+_(" start voltage"),1)
			out_text.append(str(line[SEG_VOLTAGE_START]))

			out_text.append("#time_segment"+str(i)+"_voltage_stop")
			scan_item_add(file_name,out_text[len(out_text)-1],_("Part ")+str(i)+_(" stop voltage"),1)
			out_text.append(str(line[SEG_VOLTAGE_STOP]))

			out_text.append("#time_segment"+str(i)+"_mul")
			scan_item_add(file_name,out_text[len(out_text)-1],_("Part ")+str(i)+_(" mul"),1)
			out_text.append(str(line[SEG_MUL]))

			out_text.append("#time_segment"+str(i)+"_sun")
			scan_item_add(file_name,out_text[len(out_text)-1],_("Part ")+str(i)+_(" sun"),1)
			out_text.append(str(line[SEG_SUN]))

			out_text.append("#time_segment"+str(i)+"_laser")
			scan_item_add(file_name,out_text[len(out_text)-1],_("Part ")+str(i)+_(" laser"),1)
			out_text.append(str(line[SEG_LASER]))
			i=i+1

		out_text.append("#ver")
		out_text.append("1.1")
		out_text.append("#end")
		
		inp_write_lines_to_file(os.path.join(os.getcwd(),file_name),out_text)
		self.update_scan_tokens()