Example #1
0
	def __init__(self):
		QWidgetSavePos.__init__(self,"dim_editor")

		self.setWindowTitle(_("xz dimension editor")+" https://www.gpvdm.com")
		self.setWindowIcon(icon_get("dimensions"))
		self.resize(400,200)

		self.cost_window=False

		self.main_vbox=QVBoxLayout()

		self.toolbar=QToolBar()
		self.toolbar.setToolButtonStyle( Qt.ToolButtonTextUnderIcon)
		self.toolbar.setIconSize(QSize(42, 42))

		spacer = QWidget()


		spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
		self.toolbar.addWidget(spacer)

		self.help = QAction(icon_get("internet-web-browser"), _("Help"), self)
		self.toolbar.addAction(self.help)
		
		self.main_vbox.addWidget(self.toolbar)
	
		self.widget0 = QWidget()
		self.widget0_hbox=QHBoxLayout()
		self.widget0.setLayout(self.widget0_hbox)

		self.widget0_label=QLabel("x size")
		self.widget0_hbox.addWidget(self.widget0_label)

		self.widget0_edit=QLineEdit()
		self.widget0_edit.setText(str(mesh_get_xlen()))
		self.widget0_edit.textChanged.connect(self.apply)
		self.widget0_hbox.addWidget(self.widget0_edit)
		self.widget0_label=QLabel("m")
		self.widget0_hbox.addWidget(self.widget0_label)

		self.main_vbox.addWidget(self.widget0)

		self.widget1 = QWidget()
		self.widget1_hbox=QHBoxLayout()
		self.widget1.setLayout(self.widget1_hbox)
		self.widget1_label=QLabel("z size")
		self.widget1_hbox.addWidget(self.widget1_label)
		self.widget1_edit=QLineEdit()
		self.widget1_edit.setText(str(mesh_get_zlen()))
		self.widget1_edit.textChanged.connect(self.apply)
		self.widget1_hbox.addWidget(self.widget1_edit)
		self.widget1_label=QLabel("m")
		self.widget1_hbox.addWidget(self.widget1_label)
		self.main_vbox.addWidget(self.widget1)

		
		#self.tab.itemSelectionChanged.connect(self.callback_tab_selection_changed)


		self.setLayout(self.main_vbox)
Example #2
0
File: gl.py Project: mandulaj/gpvdm
		def render(self):
			#print("do draw")
			clear_color()
			glClearColor(self.view.bg_color[0], self.view.bg_color[1], self.view.bg_color[2], 0.5)
			gl_save_clear()


			dos_start=-1
			dos_stop=-1
			epi_y_len=epitaxy_get_y_len()
			
			if epi_y_len<=0:
				return

			self.x_mul=1e3
			self.y_mul=self.gl_device_height/epi_y_len
			self.z_mul=1e3


			x_len=mesh_get_xlen()

			max_gui_device_x=x_len*self.x_mul
			max_gui_device_y=1.0
			max_gui_device_z=mesh_get_zlen()*self.z_mul

			l=epitaxy_get_layers()-1

			xpoints=int(mesh_get_xpoints())
			ypoints=int(mesh_get_ypoints())
			zpoints=int(mesh_get_zpoints())

			if ypoints>10:
				ypoints=10
			
			if xpoints>10:
				xpoints=10
				
			if ypoints>10:
				ypoints=10

			self.emission=False
			self.ray_model=False
			
			lines=inp_load_file(os.path.join(get_sim_path(),"led.inp"))
			if lines!=False:
				self.ray_model=val=str2bool(inp_search_token_value(lines, "#led_on"))
				
			lines=[]

			for i in range(0,epitaxy_get_layers()):
				if epitaxy_get_pl_file(i)!="none":
					lines=inp_load_file(os.path.join(get_sim_path(),epitaxy_get_pl_file(i)+".inp"))
					if lines!=False:
						if str2bool(lines[1])==True:
							self.emission=True
					
			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
			glLoadIdentity()

			glTranslatef(self.view.x_pos, self.view.y_pos, self.view.zoom) # Move Into The Screen
			
			glRotatef(self.view.xRot, 1.0, 0.0, 0.0)
			glRotatef(self.view.yRot, 0.0, 1.0, 0.0)
			glRotatef(self.view.zRot, 0.0, 0.0, 1.0)

			glColor3f( 1.0, 1.5, 0.0 )
			glPolygonMode(GL_FRONT, GL_FILL);

			threed_files=glob.glob("*.3d")
			if len(threed_files)>0:
				gl_save_load()
				gl_save_draw()
				draw_grid()
				return

			#glClearColor(0.92, 0.92, 0.92, 0.5) # Clear to black.

			lines=[]

			pos=0.0
				
			for i in range(0,epitaxy_get_layers()):

				thick=epitaxy_get_width(l-i)*self.y_mul
				obj=epitaxy_get_layer(l-i)
				red=obj.r
				green=obj.g
				blue=obj.b
				alpha=obj.alpha
				if i==l-self.selected_layer:
					box_lines(0.0,pos,0,max_gui_device_x,thick,max_gui_device_z)

				if epitaxy_get_electrical_layer(l-i).startswith("dos")==True and ypoints!=0 and xpoints!=0 and zpoints!=0:
					dy=thick/float(ypoints)
					dx=max_gui_device_x/float(xpoints)
					dz=max_gui_device_z/float(zpoints)
					xshrink=0.8
					zshrink=0.8
					
					if dos_start==-1:
						dos_start=pos
					
					dos_stop=pos+thick
			
					if xpoints==1:
						xshrink=1.0

					if zpoints==1:
						zshrink=1.0

					if xpoints==1 and zpoints==1:
						box(0.0,pos,0,max_gui_device_x,thick,max_gui_device_z,red,green,blue,alpha)
					else:
						for y in range(0,ypoints):
							for x in range(0,xpoints):
								for z in range(0,zpoints):
									box(dx*x,pos+y*(dy),z*dz,dx*xshrink,dy*0.8,dz*zshrink,red,green,blue,alpha)
					if self.tab_active_layers==True:
						tab(0.0,pos,max_gui_device_z,max_gui_device_x,thick,max_gui_device_z)
				
				elif epitaxy_get_electrical_layer(l-i).lower()=="contact" and (i==l or i==0):
					for c in contacts_get_array():
						if (c.position=="top" and i==l) or (c.position=="bottom" and i==0):
							if xpoints==1 and zpoints==1:
								xstart=0.0
								xwidth=max_gui_device_x
							else:
								xstart=max_gui_device_x*(c.start/x_len)
								xwidth=max_gui_device_x*(c.width/x_len)
								#print("contacts",xstart,xwidth,c.width,x_len)
								if (c.start+c.width)>x_len:
									xwidth=max_gui_device_x-xstart
								
							if c.depth>0.0:
								etch_depth=c.depth*self.y_mul
								if c.position=="top":
									box(xstart,pos-etch_depth-self.dy_layer_offset,0,xwidth,etch_depth,max_gui_device_z,0.0,0.0,1.0,1.0)
								else:
									box(xstart,pos+self.dy_layer_offset+thick,0,xwidth,etch_depth,max_gui_device_z,0.0,0.0,1.0,1.0)
									
							if c.active==True:
								box(xstart,pos,0,xwidth,thick,max_gui_device_z,0.0,1.0,0.0,alpha)
							else:
								box(xstart,pos,0,xwidth,thick,max_gui_device_z,red,green,blue,alpha)


				else:
					box(0.0,pos,0,max_gui_device_x,thick,max_gui_device_z,red,green,blue,alpha)
				

				if self.view.render_text==True:
					if epitaxy_get_electrical_layer(l-i).startswith("dos")==True:
						text=epitaxy_get_name(l-i)+" ("+_("active")+")"
					else:
						text=epitaxy_get_name(l-i)

					set_color(1.0,1.0,1.0,"text")

					font = QFont("Arial")
					font.setPointSize(18)
					if self.view.zoom>-20:
						self.renderText (max_gui_device_x+0.1,pos+thick/2,max_gui_device_z, text,font)

				pos=pos+thick+self.dy_layer_offset

			draw_mode(pos-self.dy_layer_offset,max_gui_device_z)
			draw_rays(self.ray_file,pos-self.dy_layer_offset,max_gui_device_x,self.y_mul,max_gui_device_z*1.05)
			#print(self.graph_path)

			if self.view.render_photons==True:
				#print(pos)
				self.draw_photons(max_gui_device_x,pos,max_gui_device_z)

			full_data_range=self.graph_z_max-self.graph_z_min
			graph(0.0,dos_start,max_gui_device_z+0.5,max_gui_device_x,dos_stop-dos_start,full_data_range,self.graph_data)

			if self.view.render_grid==True:
				draw_grid()

			if self.view.zoom<-60:
				draw_stars()
Example #3
0
    def build_top_widget(self):
        self.items = []
        #input description+units	//output label // Output unit// equation to si //mull si to display //Need area
        self.items.append(
            [_("Wavelength"), "nm",
             _("Wavelength"), "nm", "1e-9", 1e9, False])
        self.items.append(
            [_("Wavelength"), "um",
             _("Wavelength"), "nm", "1e-6", 1e9, False])
        self.items.append(
            [_("Wavelength"), "cm",
             _("Wavelength"), "nm", "1e-3", 1e9, False])
        self.items.append(
            [_("Wavelength"), "m",
             _("Wavelength"), "nm", "1.0", 1e9, False])
        self.items.append(
            [_("J"), "mA/cm2",
             _("J"), "A/m2", "10000.0/1000.0", 1.0, False])
        self.items.append([_("J"), "A/m2", _("J"), "A/m2", "1.0", 1.0, False])
        self.items.append([
            _("Amps"), "A",
            _("J"), "A/m2", "1.0/(self.get_area())", 1.0, True
        ])
        self.items.append([
            _("-Amps"), "A",
            _("J"), "A/m2", "-1.0/(self.get_area())", 1.0, True
        ])
        self.items.append(
            [_("Voltage"), "V",
             _("Voltage"), "V", "1.0", 1.0, False])
        self.items.append(
            [_("-Voltage"), "V",
             _("Voltage"), "V", "-1.0", 1.0, False])
        self.items.append(
            [_("Voltage"), "mV",
             _("Voltage"), "V", "1e-3", 1.0, False])

        self.items.append([
            _("Refractive index"), "au",
            _("Refractive index"), "au", "1.0", 1.0, False
        ])
        self.items.append([
            _("Absorption"), "m^{-1}",
            _("Absorption"), "m^{-1}", "1.0", 1.0, False
        ])
        self.items.append([
            _("Absorption"), "m^{-cm}",
            _("Absorption"), "m^{-1}", "1.0", 1e2, False
        ])
        self.items.append([
            _("Attenuation coefficient"), "au",
            _("Absorption"), "m^{-1}", "4*3.14159/x", 1.0, False
        ])

        self.items.append([_("Time"), "s", _("Time"), "s", "1.0", 1.0, False])

        i = 0
        self.x_label = self.items[i][2]
        self.x_units = self.items[i][3]
        self.x_mul_to_si = self.items[i][4]
        self.x_disp_mul = self.items[i][5]

        self.y_label = self.items[i][2]
        self.y_units = self.items[i][3]
        self.y_mul_to_si = self.items[i][4]
        self.y_disp_mul = self.items[i][5]

        self.top_widget = QWidget()
        self.top_vbox = QVBoxLayout()
        self.x_combo = QComboBox()
        self.add_units(self.x_combo)
        self.y_combo = QComboBox()
        self.add_units(self.y_combo)

        self.units_x_label = QLabel(_("x units:"))
        self.units_data_label = QLabel(_("y units:"))

        self.x_combo.currentIndexChanged.connect(self.callback_edited)
        self.y_combo.currentIndexChanged.connect(self.callback_edited)

        self.title_widget = QWidget()
        self.title_hbox = QHBoxLayout()
        self.title_label = QLabel(_("Title:"))
        self.title_entry = QLineEdit()
        self.title_hbox.addWidget(self.title_label)
        self.title_hbox.addWidget(self.title_entry)
        self.title_widget.setLayout(self.title_hbox)
        self.top_vbox.addWidget(self.title_widget)

        self.xlabel_widget = QWidget()
        self.xlabel_hbox = QHBoxLayout()
        self.xlabel_label = QLabel(_("x-label:"))
        self.xlabel_entry = QLineEdit()
        self.x_column_label = QLabel(_("x-column:"))
        self.x_spin = QSpinBox()
        self.x_spin.setValue(0)
        self.x_spin.valueChanged.connect(self.callback_edited)

        self.xlabel_hbox.addWidget(self.xlabel_label)
        self.xlabel_hbox.addWidget(self.xlabel_entry)
        self.xlabel_hbox.addWidget(self.x_column_label)
        self.xlabel_hbox.addWidget(self.x_spin)
        self.xlabel_hbox.addWidget(self.units_x_label)
        self.xlabel_hbox.addWidget(self.x_combo)
        self.xlabel_widget.setLayout(self.xlabel_hbox)
        self.top_vbox.addWidget(self.xlabel_widget)

        self.ylabel_widget = QWidget()
        self.ylabel_hbox = QHBoxLayout()
        self.ylabel_label = QLabel(_("y-label:"))
        self.ylabel_entry = QLineEdit()
        self.y_column_label = QLabel(_("y-column:"))
        self.y_spin = QSpinBox()
        self.y_spin.setValue(1)
        self.y_spin.valueChanged.connect(self.callback_edited)

        self.ylabel_hbox.addWidget(self.ylabel_label)
        self.ylabel_hbox.addWidget(self.ylabel_entry)
        self.ylabel_hbox.addWidget(self.y_column_label)
        self.ylabel_hbox.addWidget(self.y_spin)
        self.ylabel_hbox.addWidget(self.units_data_label)
        self.ylabel_hbox.addWidget(self.y_combo)
        self.ylabel_widget.setLayout(self.ylabel_hbox)
        self.top_vbox.addWidget(self.ylabel_widget)

        self.area_widget = QWidget()
        self.area_hbox = QHBoxLayout()
        self.area_label = QLabel(_("device area:"))
        self.area_hbox.addWidget(self.area_label)
        self.area_entry = QLineEdit()
        self.area_entry.setText(
            str(round(mesh_get_xlen() * mesh_get_zlen() * 100 * 100, 3)))
        self.area_hbox.addWidget(self.area_entry)
        self.area_units = QLabel("cm2")
        self.area_hbox.addWidget(self.area_units)
        self.area_widget.setLayout(self.area_hbox)
        self.top_vbox.addWidget(self.area_widget)

        self.area_widget.hide()

        self.xlabel_entry.textEdited.connect(self.callback_edited)
        self.ylabel_entry.textEdited.connect(self.callback_edited)
        self.title_entry.textEdited.connect(self.callback_edited)
        self.area_entry.textEdited.connect(self.callback_edited)
        self.top_widget.setLayout(self.top_vbox)
Example #4
0
		def paintGL(self):
			if self.failed==False:
				dos_start=-1
				dos_stop=-1
				self.x_mul=1e3
				self.z_mul=1e3

				width=mesh_get_xlen()*self.x_mul
				depth=mesh_get_zlen()*self.z_mul

				l=epitaxy_get_layers()-1

				xpoints=int(mesh_get_xpoints())
				ypoints=int(mesh_get_ypoints())
				zpoints=int(mesh_get_zpoints())

				x_len=mesh_get_xlen()

				self.emission=False
				self.ray_model=False
				
				lines=[]
				if inp_load_file(lines,"led.inp")==True:
					self.ray_model=val=str2bool(inp_search_token_value(lines, "#led_on"))
					
				lines=[]

				for i in range(0,epitaxy_get_layers()):
					if epitaxy_get_pl_file(i)!="none":
						if inp_load_file(lines,epitaxy_get_pl_file(i)+".inp")==True:
							if str2bool(lines[1])==True:
								self.emission=True
						
				glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
				glLoadIdentity()

				glTranslatef(self.x_pos, self.y_pos, self.zoom) # Move Into The Screen
				
				glRotatef(self.xRot, 1.0, 0.0, 0.0)
				glRotatef(self.yRot, 0.0, 1.0, 0.0)
				glRotatef(self.zRot, 0.0, 0.0, 1.0)

				glColor3f( 1.0, 1.5, 0.0 )
				glPolygonMode(GL_FRONT, GL_FILL);


				#glClearColor(0.92, 0.92, 0.92, 0.5) # Clear to black.
				glClearColor(0.0, 0.0, 0.0, 0.5)
				lines=[]


				if self.suns!=0:
					if self.suns<=0.01:
						den=1.4
					elif self.suns<=0.1:
						den=0.8
					elif self.suns<=1.0:
						den=0.6
					elif self.suns<=10.0:
						den=0.3
					else:
						den=0.2
				
					x=np.arange(0, width , den)
					z=np.arange(0, depth , den)
					for i in range(0,len(x)):
						for ii in range(0,len(z)):
							draw_photon(x[i],z[ii],False)

				if self.emission==True and self.ray_model==False:
					den=0.6
					x=np.arange(0, width , den)
					y=np.arange(0, depth , den)
					for i in range(0,len(x)):
						for ii in range(0,len(y)):
								draw_photon(x[i]+0.1,y[ii]+0.1,True)


				tot=0

				for i in range(0,epitaxy_get_layers()):
					tot=tot+epitaxy_get_width(i)

				pos=0.0
				self.y_mul=0
				if tot>0:
					self.y_mul=1.5/tot
					
					for i in range(0,epitaxy_get_layers()):

						thick=epitaxy_get_width(l-i)*self.y_mul

						red=self.colors[l-i].r
						green=self.colors[l-i].g
						blue=self.colors[l-i].b

						if i==l-self.selected_layer:
							box_lines(0.0,pos,0,width,thick,depth)

						if epitaxy_get_electrical_layer(l-i).startswith("dos")==True:
							dy=thick/float(ypoints)
							dx=width/float(xpoints)
							dz=depth/float(zpoints)
							xshrink=0.8
							zshrink=0.8
							
							if dos_start==-1:
								dos_start=pos
							
							dos_stop=pos+thick
					
							if xpoints==1:
								xshrink=1.0

							if zpoints==1:
								zshrink=1.0

							if xpoints==1 and zpoints==1:
								box(0.0,pos,0,width,thick,depth,red,green,blue)
							else:
								for y in range(0,ypoints):
									for x in range(0,xpoints):
										for z in range(0,zpoints):
											box(dx*x,pos+y*(dy),z*dz,dx*xshrink,dy*0.8,dz*zshrink,red,green,blue)
							tab(0.0,pos,depth,width,thick,depth)
						
						elif epitaxy_get_electrical_layer(l-i).lower()=="contact" and i==l:
							if xpoints==1 and zpoints==1:
								box(0.0,pos,0,width,thick,depth,red,green,blue)
							else:
								for c in contacts_get_array():
									xstart=width*(c.start/x_len)
									xwidth=width*(c.width/x_len)
									#print("contacts",xstart,xwidth,c.width,x_len)
									if (c.start+c.width)>x_len:
										xwidth=width-xstart
									if c.active==True:
										box(xstart,pos,0,xwidth,thick,depth,0.0,1.0,0.0)
									else:
										box(xstart,pos,0,xwidth,thick,depth,red,green,blue)


						else:
							box(0.0,pos,0,width,thick,depth,red,green,blue)
						

						if epitaxy_get_electrical_layer(l-i).startswith("dos")==True:
							text=epitaxy_get_name(l-i)+" (active)"
						else:
							text=epitaxy_get_name(l-i)

						glColor3f(1.0,1.0,1.0)
						font = QFont("Arial")
						font.setPointSize(18)
						if self.zoom>-20:
							self.renderText (width+0.1,pos+thick/2,depth, text,font)

						pos=pos+thick+0.05


				
						glRotatef(self.tet_rotate, tet_x_rate, tet_y_rate, tet_z_rate)

				draw_mode(pos-0.05,depth)
				draw_rays(self.ray_fast,pos-0.05,width,self.y_mul,depth*1.05)
				#print(self.graph_path)

				full_data_range=self.graph_z_max-self.graph_z_min
				graph(0.0,dos_start,depth+0.5,width,dos_stop-dos_start,full_data_range,self.graph_data)
				draw_grid()
				if self.zoom<-60:
					draw_stars()