Esempio n. 1
0
    def gl_objects_save(self, file_name):
        f = open(file_name, "w")
        f.write("#gobj\n")
        for o in self.objects:
            ret = ""
            ret = ret + o.type

            ret = ret + ";;" + "{:e}".format(
                gl_scale.project_screen_x_to_m(o.xyz.x))
            ret = ret + ";;" + "{:e}".format(
                gl_scale.project_screen_y_to_m(o.xyz.y))
            ret = ret + ";;" + "{:e}".format(
                gl_scale.project_screen_z_to_m(o.xyz.z))
            ret = ret + ";;" + "{:e}".format(o.dxyz.x / scale_get_xmul())
            ret = ret + ";;" + "{:e}".format(o.dxyz.y / scale_get_ymul())
            ret = ret + ";;" + "{:e}".format(o.dxyz.z / scale_get_zmul())

            ret = ret + ";;" + str(o.r)
            ret = ret + ";;" + str(o.g)
            ret = ret + ";;" + str(o.b)

            ret = ret + ";;" + str(o.alpha)
            ret = ret + ";;" + str(o.selected)
            ret = ret + ";;" + str(o.selectable)
            ret = ret + ";;" + str(o.moveable)
            ret = ret + ";;" + str(o.allow_cut_view)

            ret = ret + ";;" + str(o.text)

            ret = ret + ";;" + str(o.origonal_object)
            f.write(ret + "\n")

        f.close()
Esempio n. 2
0
    def shape_to_screen(self, a, pos, s):
        if s.shape_enabled == True:
            a.type = "solid_and_mesh"
            if self.draw_device_cut_through == True:  # and l!=len(epi.layers)-1
                a.type = "box_cut_through"
        else:
            a.type = "marker"

        a.id = [s.id]
        a.xyz.x = gl_scale.project_m2screen_x(pos.x)
        #a.xyz.y=gl_scale.project_m2screen_y(pos.y)
        if s.shape_flip_y == False:
            a.xyz.y = gl_scale.project_m2screen_y(pos.y)
        else:
            a.xyz.y = gl_scale.project_m2screen_y(pos.y + s.dy)

        a.xyz.z = gl_scale.project_m2screen_z(pos.z)
        #print(">>>>>>",project_m2screen_z(0))

        a.dxyz.x = s.dx * scale_get_xmul()
        a.dxyz.y = s.dy * scale_get_ymul()
        a.dxyz.z = s.dz * scale_get_zmul()
        if s.shape_flip_y == False:
            a.dxyz.y = a.dxyz.y * -1.0

        a.r = s.r
        a.g = s.g
        a.b = s.b

        a.alpha = 1.0
        if len(s.shapes) > 0:
            a.alpha = 0.5

        a.allow_cut_view = True
        a.selectable = True
        v = vec()
        v.x = s.dx
        v.y = s.dy
        v.z = s.dz
        #resize the shape to the mesh
        if s.triangles != None:
            a.triangles = triangles_mul_vec(s.triangles.data, v)

            if s.shape_flip_y == True:
                a.triangles = triangles_flip(a.triangles)

            a.triangles = scale_trianges_m2screen(a.triangles)

        self.gl_objects_add(a)
    def draw_light_profile(self):

        self.gl_objects_remove_regex("light_profile")
        name = inp_get_token_value(os.path.join(get_sim_path(), "light.inp"),
                                   "#light_profile")
        if name != "box":
            epi = get_epi()

            s = shape()
            s.type = name
            s.load_triangles()
            s.triangles.data = triangles_remove_below(s.triangles.data, 0.1)

            a = gl_base_object()
            a.id = ["light_profile"]
            a.type = "open_triangles"

            a.x = gl_scale.project_m2screen_x(0)
            a.y = gl_scale.project_m2screen_y(0)
            a.z = gl_scale.project_m2screen_z(0)

            a.dx = 1.0
            a.dy = scale_get_ymul() * 1.0
            a.dz = 1.0

            a.r = 0.0
            a.g = 1.0
            a.b = 0.0
            a.alpha = 1.0

            my_vec = vec()
            my_vec.x = get_mesh().get_xlen()
            my_vec.y = epi.ylen() * 1.0
            my_vec.z = get_mesh().get_zlen()

            t = triangles_mul_vec(s.triangles.data, my_vec)

            my_vec = vec()
            my_vec.x = 0.0
            my_vec.y = -epi.ylen() * 3.0
            my_vec.z = 0.0

            t = triangles_add_vec(t, my_vec)

            a.triangles = scale_trianges_m2screen(t)
            #triangles_mul_vec(triangles_flip_in_box(s.triangles.data),my_vec)
            #print("bing!",gl_scale.project_m2screen_x(0))
            self.gl_objects_add(a)
Esempio n. 4
0
    def curciut_mesh_add_links(self, z):
        epi = get_epi()
        mesh = get_mesh()
        for zi in range(0, len(z)):

            for x_sub_mesh_index in range(0, len(mesh.x.layers)):

                xl = mesh.x.layers[x_sub_mesh_index]
                if xl.points == 0:  #if there is a gap in the mesh
                    if x_sub_mesh_index != 0 and x_sub_mesh_index != len(
                            mesh.x.layers
                    ) - 1:  #get left and right points to the gap
                        xl_l = mesh.x.layers[x_sub_mesh_index - 1]
                        xl_r = mesh.x.layers[x_sub_mesh_index + 1]

                        x0 = xl_l.mesh[-1]
                        x1 = xl_r.mesh[
                            0]  #look for a shape which fills the gap

                        shapes = epi.get_shapes_between_x(x0, x1)
                        for s in shapes:
                            if s.shape_electrical != "none":
                                f = inp()
                                f.load(s.shape_electrical + ".inp")
                                component = f.get_token(
                                    "#electrical_component")
                                nl = epi.find_layer_by_id(s.id)
                                y0 = epi.layers[nl].start
                                if component == "link":
                                    a = gl_base_object()
                                    a.id = ["electrical_mesh"]
                                    a.type = "line"
                                    a.xyz.x = gl_scale.project_m2screen_x(x0)
                                    a.xyz.y = gl_scale.project_m2screen_y(y0 +
                                                                          s.dy)
                                    a.xyz.z = z[zi]
                                    a.dxyz.x = (x1 - x0) * scale_get_xmul()
                                    a.dxyz.y = s.dy * scale_get_ymul() * 0.9
                                    a.dxyz.z = 0.0
                                    a.r = 1.0
                                    a.g = 0.0
                                    a.b = 0.0
                                    a.alpha = 1.0
                                    self.gl_objects_add(a)
Esempio n. 5
0
    def shape_layer(self, epi_layer, shape_list, y_padding=0.0, name="name"):
        self.gl_objects_remove_regex(name)
        for s in shape_list:
            n = 0
            for pos in s.expand_xyz0(epi_layer):

                a = gl_base_object()
                if n == 0:
                    a.origonal_object = True
                n = n + 1

                a.id = [s.id]
                a.type = "solid_and_mesh"

                a.xyz.x = gl_scale.project_m2screen_x(pos.x)
                a.xyz.y = gl_scale.project_m2screen_y(pos.y)
                a.xyz.z = gl_scale.project_m2screen_z(pos.z)
                #print(">>>>>>",project_m2screen_z(0))

                a.dxyz.x = s.dx * scale_get_xmul()
                a.dxyz.y = s.dy * scale_get_ymul()
                a.dxyz.z = s.dz * scale_get_zmul()
                if s.shape_flip_y == False:
                    a.dxyz.y = a.dxyz.y * -1.0

                a.r = s.r
                a.g = s.g
                a.b = s.b
                a.allow_cut_view = True
                a.selectable = True
                v = vec()
                v.x = s.dx
                v.y = s.dy
                v.z = s.dz
                #resize the shape to the mesh
                if s.triangles != None:
                    a.triangles = triangles_mul_vec(s.triangles.data, v)

                    if s.shape_flip_y == True:
                        a.triangles = triangles_flip(a.triangles)

                    a.triangles = scale_trianges_m2screen(a.triangles)

                self.gl_objects_add(a)
Esempio n. 6
0
        def draw_device2(self, x, z):
            y = scale_get_device_y()
            epi = get_epi()
            contact_layers = epi.contacts.get_layers_with_contacts()
            top_contact_layer = epi.get_top_contact_layer()
            btm_contact_layer = epi.get_btm_contact_layer()
            #print(contact_layers)
            l = 0
            btm_layer = len(epitaxy_get_epi()) - 1

            for obj in epi.layers:
                y_len = obj.dy * scale_get_ymul()
                y = y - y_len

                obj.z0 = 0.0
                obj.x0 = 0.0
                obj.y0 = epi.get_layer_start(l)

                name = obj.name
                display_name = name
                #alpha=obj.alpha
                #if len(obj.shapes)>0:

                contact_layer = False
                if l == top_contact_layer:
                    contact_layer = True

                if l == btm_contact_layer:
                    contact_layer = True
                #print(">>>>",l,contact_layer,contact_layers)
                if contact_layer == False:
                    self.shape_layer(obj)

                if obj.dos_file.startswith("dos") == True:
                    o = gl_base_object()
                    o.xyz.x = x + scale_get_device_x() + 0.1
                    o.xyz.y = y
                    o.xyz.z = z

                    o.dxyz.x = 0.1
                    o.dxyz.y = y_len

                    o.r = 0.0
                    o.g = 0.0
                    o.b = 1.0

                    o.type = "plane"
                    display_name = display_name + " (" + _("active") + ")"
                    self.gl_objects_add(o)

                if self.view.render_text == True:
                    if self.view.zoom < 40:
                        o = gl_base_object()
                        o.r = 1.0
                        o.g = 1.0
                        o.b = 1.0
                        o.xyz.x = x + scale_get_device_x() + 0.2
                        o.xyz.y = y  #+y_len/2
                        o.xyz.z = z + (len(epi.layers) - l) * 0.1
                        o.id = ["text"]
                        o.type = "text"
                        o.text = display_name
                        #self.set_color(o)
                        self.gl_objects_add(o)

                l = l + 1
Esempio n. 7
0
        def draw_device2(self, x, z):
            y = scale_get_device_y()
            epi = get_epi()
            contact_layers = epi.contacts.get_layers_with_contacts()

            l = 0
            btm_layer = len(epitaxy_get_epi()) - 1

            for obj in epi.layers:
                y_len = obj.dy * scale_get_ymul()
                y = y - y_len
                dy_shrink = 0.0  #y_len*0.1

                name = obj.name
                display_name = name
                alpha = obj.alpha
                if len(obj.shapes) > 0:
                    self.shape_layer(obj, obj.shapes, y_padding=dy_shrink / 2)

                alpha = 1.0
                if len(obj.shapes) > 0:
                    alpha = 0.5

                contact_layer = False
                if l == 0 and "top" in contact_layers:
                    contact_layer = True

                if l == len(epi.layers) - 1 and "bottom" in contact_layers:
                    contact_layer = True
                #print(">>>>",l,contact_layer,contact_layers)
                if name != "air" and contact_layer == False:
                    o = gl_base_object()
                    o.r = obj.r
                    o.g = obj.g
                    o.b = obj.b
                    o.alpha = alpha
                    o.id = [obj.id]
                    o.xyz.x = x
                    o.xyz.y = y + dy_shrink / 2
                    o.xyz.z = z
                    o.dxyz.x = scale_get_device_x()
                    o.dxyz.y = y_len - dy_shrink
                    o.dxyz.z = scale_get_device_z()

                    if obj.shape_enabled == True:
                        if self.draw_device_cut_through == False and l != len(
                                epi.layers) - 1:
                            o.type = "box"

                            self.project_object_through_electrical_mesh(o)
                        else:
                            o.type = "box_cut_through"
                            self.project_object_through_electrical_mesh(o)
                    else:
                        o.type = "marker"
                        self.gl_objects_add(o)

                if obj.dos_file.startswith("dos") == True:
                    o = gl_base_object()
                    o.xyz.x = x + scale_get_device_x() + 0.1
                    o.xyz.y = y
                    o.xyz.z = z

                    o.dxyz.x = 0.1
                    o.dxyz.y = y_len

                    o.r = 0.0
                    o.g = 0.0
                    o.b = 1.0

                    o.type = "plane"
                    display_name = display_name + " (" + _("active") + ")"
                    self.gl_objects_add(o)

                if self.view.render_text == True:
                    if self.view.zoom < 40:
                        o = gl_base_object()
                        o.r = 1.0
                        o.g = 1.0
                        o.b = 1.0
                        o.xyz.x = x + scale_get_device_x() + 0.2
                        o.xyz.y = y  #+y_len/2
                        o.xyz.z = z + (len(epi.layers) - l) * 0.1
                        o.id = ["text"]
                        o.type = "text"
                        o.text = display_name
                        #self.set_color(o)
                        self.gl_objects_add(o)

                l = l + 1
Esempio n. 8
0
    def draw_contacts(self):
        #print("draw contacts")
        epi = get_epi()
        box = vec()
        pos = vec()
        y_mesh = get_mesh().y
        x_mesh = get_mesh().x
        z_mesh = get_mesh().z

        self.gl_objects_remove_regex("contact")
        top_contact_layer = epi.get_top_contact_layer()
        btm_contact_layer = epi.get_btm_contact_layer()

        for c in epi.contacts.contacts:
            if c.shape_enabled == True:
                a = gl_base_object()
                a.id = [c.id]

                if c.position == "left":
                    if len(x_mesh.points) > 1:
                        sticking_out_bit = 0.2
                        a.type = "solid_and_mesh"
                        a.xyz.x = gl_scale.project_m2screen_x(
                            0) - sticking_out_bit
                        a.xyz.y = gl_scale.project_m2screen_y(c.y0)
                        a.xyz.z = gl_scale.project_m2screen_z(0)
                        a.dxyz.x = 1.0
                        a.dxyz.y = scale_get_ymul() * c.dy
                        a.dxyz.z = scale_get_device_z()

                        a.r = c.r
                        a.g = c.g
                        a.b = c.b
                        a.alpha = 1.0
                        my_vec = vec()
                        my_vec.x = sticking_out_bit / scale_get_xmul(
                        )  #+c.ingress
                        my_vec.y = c.dy
                        my_vec.z = get_mesh().get_zlen()

                        if c.triangles != None:
                            a.triangles = triangles_flip_in_box(
                                c.triangles.data)
                            a.triangles = triangles_mul_vec(a.triangles, box)
                            a.triangles = triangles_add_vec(a.triangles, pos)
                            a.triangles = scale_trianges_m2screen(a.triangles)
                            self.gl_objects_add(a)

                elif c.position == "top":
                    if top_contact_layer != -1:
                        #if epi.layers[0].name!="air":
                        box = vec()
                        if len(x_mesh.points) == 1 and len(z_mesh.points) == 1:
                            xstart = 0
                            box.x = get_mesh().get_xlen()
                        else:
                            xstart = c.x0
                            box.x = c.dx

                        box.y = epi.layers[0].dy  #+c.ingress
                        box.z = get_mesh().get_zlen()

                        if self.draw_device_cut_through == False:
                            a.type = "solid_and_mesh"
                        else:
                            a.type = "solid_and_mesh_cut_through"

                        a.xyz.x = gl_scale.project_m2screen_x(xstart)
                        if c.shape_flip_y == False:
                            a.xyz.y = gl_scale.project_m2screen_y(
                                epi.get_layer_start(0))
                        else:
                            a.xyz.y = gl_scale.project_m2screen_y(
                                epi.get_layer_end(0))
                        a.xyz.z = gl_scale.project_m2screen_z(0.0)

                        a.dxyz.x = box.x * scale_get_xmul()
                        a.dxyz.y = box.y * scale_get_ymul()
                        a.dxyz.z = scale_get_device_z()
                        if c.shape_flip_y == False:
                            a.dxyz.y = a.dxyz.y * -1.0

                        a.r = c.r
                        a.g = c.g
                        a.b = c.b
                        a.alpha = 1.0

                        if c.triangles != None:
                            a.triangles = triangles_mul_vec(
                                c.triangles.data, box)
                            if c.shape_flip_y == True:
                                a.triangles = triangles_flip(a.triangles)

                            a.triangles = scale_trianges_m2screen(a.triangles)
                            self.gl_objects_add(a)

                elif c.position == "bottom":
                    if btm_contact_layer != -1:
                        if len(x_mesh.points) == 1 and len(z_mesh.points) == 1:

                            xstart = 0
                            box.x = get_mesh().get_xlen()
                        else:
                            xstart = c.x0
                            box.x = c.dx

                        box.y = epi.layers[len(epi.layers) - 1].dy  #+c.ingress
                        box.z = get_mesh().get_zlen()

                        a.type = "solid_and_mesh"

                        pos.x = xstart
                        pos.y = epi.get_layer_start(len(epi.layers) - 1)
                        pos.z = 0

                        a.xyz.x = gl_scale.project_m2screen_x(pos.x)
                        a.xyz.y = gl_scale.project_m2screen_y(pos.y)
                        a.xyz.z = gl_scale.project_m2screen_z(pos.z)

                        a.dxyz.x = box.x * scale_get_xmul()
                        a.dxyz.y = -box.y * scale_get_ymul()
                        a.dxyz.z = scale_get_device_z()

                        a.r = epi.layers[len(epi.layers) - 1].r
                        a.g = epi.layers[len(epi.layers) - 1].g
                        a.b = epi.layers[len(epi.layers) - 1].b

                        a.alpha = 1.0
                        my_vec = vec()
                        my_vec.x = c.dx
                        my_vec.y = epi.layers[len(epi.layers) - 1].dy
                        my_vec.z = get_mesh().get_zlen()

                        a.r = c.r
                        a.g = c.g
                        a.b = c.b
                        a.alpha = 1.0

                        a.triangles = triangles_flip_in_box(c.triangles.data)
                        a.triangles = triangles_mul_vec(a.triangles, box)
                        #a.triangles=triangles_add_vec(a.triangles,pos)
                        a.triangles = scale_trianges_m2screen(a.triangles)

                        self.gl_objects_add(a)