Example #1
0
    def __update_matrix(self):
        rot = rotate(self.__theta)

        if self.side == SIDE.Top:
            sign = -1
        else:
            sign = 1

        self.matrix = translate(self.center.x, self.center.y).dot(rotate(self.__theta))
Example #2
0
    def __update_matrix(self):
        rot = rotate(self.__theta)

        if self.side == SIDE.Top:
            sign = -1
        else:
            sign = 1

        self.matrix = translate(self.center.x,
                                self.center.y).dot(rotate(self.__theta))
Example #3
0
    def update_matrix(self):

        rot = rotate(self._cmodel.theta)

        center_to_corner = Vec2(
            0,
            self._model.pin_space * (self._model.pin_count - 1) / 2)

        center_to_corner_w = project_point(rot, center_to_corner)

        self._cmodel.center = self.p1_point.get() - center_to_corner_w

        self.matrix = translate(self._cmodel.center.x,
                                self._cmodel.center.y).dot(
                                    rotate(self._cmodel.theta))
Example #4
0
File: dip.py Project: pcbre/pcbre
    def __init__(self, view, model, cmodel):
        self._model = model
        self._cmodel = cmodel

        self.p1_point = EditablePoint(Point2(0, 0))

        rmat = rotate(self._cmodel.theta)

        dy = -(model.pin_count / 2 - 1) * model.pin_space

        v_aligned = Vec2(0, dy)

        v_delta = project_point(rmat, v_aligned)

        # the pin on the end of the same row as P1
        self.p_bottom_corner = OffsetDefaultPoint(self.p1_point, v_delta)

        # Opposite corner point
        self.p_opposite = WidthProjectedPoint(self)

        points = [self.p1_point, self.p_bottom_corner, self.p_opposite]

        super(DIPEditFlow, self).__init__(view, points, True)

        self.update_matrix()
Example #5
0
    def gen_dim(self, idx, always_above = True):
        """
        Generate rendering data for the dimension-lines
        :param idx:
        :return:
        """
        a = self.im2V(self.model.dim_handles[0 + idx])
        b = self.im2V(self.model.dim_handles[1 + idx])

        d = b-a

        delta = (b-a).norm()

        normal = Point2(rotate(math.pi / 2)[:2,:2].dot(delta))

        if always_above:
            if numpy.cross(Vec2(1,0), normal) > 0:
                normal = -normal

        res = numpy.array([
            a + normal * 8,
            a + normal * 20,
            a + normal * 15,
            b + normal * 15,
            b + normal * 8,
            b + normal * 20,
            ])

        return res
Example #6
0
    def __init__(self, view, model):
        self._model = model

        self.p1_point = EditablePoint(Point2(0, 0))

        self.__theta = 0
        self.__corner = Point2(0, 0)

        rmat = rotate(self.theta)

        dy = -(model.pin_count / 2 - 1) * model.pin_space

        v_aligned = Vec2(0, dy)

        v_delta = projectPoint(rmat, v_aligned)

        # the pin on the end of the same row as P1
        self.p_bottom_corner = OffsetDefaultPoint(self.p1_point, v_delta)

        # Opposite corner point
        self.p_opposite = WidthProjectedPoint(self)

        points = [self.p1_point, self.p_bottom_corner, self.p_opposite]

        super(DIPEditFlow, self).__init__(view, points, True)

        if self.view.viewState.current_layer is None:
            self.side = SIDE.Top

        else:
            self.side = self.view.viewState.current_layer.side

        self.update_matrix()
Example #7
0
        def other_corner_offset():
            x = self._model.pin_spacing * ((self._model.side1_pins - 1) / 2 +
                                           (self._model.side3_pins - 1) / 2)
            y = self._model.dim_2_pincenter

            r = rotate(self._cmodel.theta)
            return project_point(r, Point2(x, y))
Example #8
0
File: dip.py Project: balr0g/pcbre
    def __init__(self, view, model):
        self._model = model

        self.p1_point = EditablePoint(Point2(0, 0))

        self.__theta = 0
        self.__corner = Point2(0, 0)

        rmat = rotate(self.theta)

        dy = -(model.pin_count / 2 - 1) * model.pin_space

        v_aligned = Vec2(0, dy)

        v_delta = projectPoint(rmat, v_aligned)

        # the pin on the end of the same row as P1
        self.p_bottom_corner = OffsetDefaultPoint(self.p1_point, v_delta)

        # Opposite corner point
        self.p_opposite = WidthProjectedPoint(self)

        points = [self.p1_point, self.p_bottom_corner, self.p_opposite]

        super(DIPEditFlow, self).__init__(view, points, True)

        if self.view.viewState.current_layer is None:
            self.side = SIDE.Top

        else:
            self.side = self.view.viewState.current_layer.side

        self.update_matrix()
Example #9
0
    def gen_dim(self, idx, always_above = True):
        """
        Generate rendering data for the dimension-lines
        :param idx:
        :return:
        """
        a = self.im2V(self.model.dim_handles[0 + idx])
        b = self.im2V(self.model.dim_handles[1 + idx])

        d = b-a

        delta = (b-a).norm()

        normal = Point2(rotate(math.pi / 2)[:2,:2].dot(delta))

        if always_above:
            if numpy.cross(Vec2(1,0), normal) > 0:
                normal = -normal

        res = numpy.array([
            a + normal * 8,
            a + normal * 20,
            a + normal * 15,
            b + normal * 15,
            b + normal * 8,
            b + normal * 20,
            ])

        return res
Example #10
0
    def gen_dim(self, idx: int, always_above: bool = True) -> 'npt.NDArray[numpy.float64]':
        """
        Generate rendering data for the dimension-lines
        :param idx:
        :return:
        """
        a = self.im2V(self.model.dim_handles[0 + idx])
        b = self.im2V(self.model.dim_handles[1 + idx])

        d = b - a

        delta = (b - a).norm()

        normal = Vec2.from_mat(rotate(math.pi / 2)[:2, :2].dot(delta))

        if always_above:
            if numpy.cross(Vec2(1, 0), normal) > 0:
                normal = -normal

        res = numpy.array([
            a + normal * 8,
            a + normal * 20,
            a + normal * 15,
            b + normal * 15,
            b + normal * 8,
            b + normal * 20,
        ], dtype=numpy.float64)

        return res
Example #11
0
File: dip.py Project: pcbre/pcbre
    def update_matrix(self):

        rot = rotate(self._cmodel.theta)

        sign = self.get_cur_sign()

        center_to_corner = Vec2(
            sign * self._model.pin_width / 2,
            self._model.pin_space * (self._model.pin_count / 2 - 1) / 2)

        center_to_corner_w = project_point(rot, center_to_corner)

        self._cmodel.center = self.p1_point.get() - center_to_corner_w

        self.matrix = translate(self._cmodel.center.x,
                                self._cmodel.center.y).dot(
                                    rotate(self._cmodel.theta))
Example #12
0
        def p2_corner_offset():
            x = self._model.pin_spacing * ((self._model.side1_pins - 1) /
                                           2) + self._model.dim_1_pincenter / 2
            y = self._model.dim_2_pincenter / 2 - (
                self._model.side2_pins - 1) / 2 * self._model.pin_spacing

            r = rotate(self._cmodel.theta)
            return project_point(r, Point2(x, y))
Example #13
0
    def update_matrix(self):

        rot = rotate(self.theta)

        if self.side == SIDE.Top:
            sign = -1
        else:
            sign = 1

        center_to_corner = Vec2(
            sign * self._model.pin_width / 2, self._model.pin_space * (self._model.pin_count / 2 - 1) / 2
        )

        center_to_corner_w = projectPoint(rot, center_to_corner)

        self.center = self.p1_point.get() - center_to_corner_w

        self.matrix = translate(self.center.x, self.center.y).dot(rotate(self.theta))
Example #14
0
File: dip.py Project: balr0g/pcbre
    def update_matrix(self):

        rot = rotate(self.theta)

        if self.side == SIDE.Top:
            sign = -1
        else:
            sign = 1

        center_to_corner = Vec2(
            sign * self._model.pin_width / 2,
            self._model.pin_space * (self._model.pin_count / 2 - 1) / 2)

        center_to_corner_w = projectPoint(rot, center_to_corner)

        self.center = self.p1_point.get() - center_to_corner_w

        self.matrix = translate(self.center.x,
                                self.center.y).dot(rotate(self.theta))
Example #15
0
    def render_handle(self, position, color, diagonal=False, filled=False):
        if diagonal:
            r = rotate(math.pi/4)
        else:
            r = numpy.identity(3)

        m = self.viewState.glWMatrix.dot(translate(*position).dot(r))
        GL.glUniformMatrix3fv(self.mat_loc, 1, True, m.astype(numpy.float32))
        GL.glUniform4f(self.col_loc, *color)
        GL.glDrawArrays(GL.GL_TRIANGLE_FAN if filled else GL.GL_LINE_LOOP, 0, 4)
Example #16
0
    def render_handle(self, position, color, diagonal=False, filled=False):
        if diagonal:
            r = rotate(math.pi/4)
        else:
            r = numpy.identity(3)

        m = self.viewState.glWMatrix.dot(translate(*position).dot(r))
        GL.glUniformMatrix3fv(self.mat_loc, 1, True, m.astype(numpy.float32))
        GL.glUniform4f(self.col_loc, *color)
        GL.glDrawArrays(GL.GL_TRIANGLE_FAN if filled else GL.GL_LINE_LOOP, 0, 4)
Example #17
0
    def __build_trace(self) -> None:
        # Update trace VBO
        self.working_array["vertex"][0] = (0, 0)
        self.working_array["ptid"][0] = 0
        self.working_array["vertex"][1] = (0, 0)
        self.working_array["ptid"][1] = 1

        end = Vec2(1, 0)
        for i in range(0, NUM_ENDCAP_SEGMENTS):
            theta = math.pi * i / (NUM_ENDCAP_SEGMENTS - 1) + math.pi / 2
            m = rotate(theta).dot(end.homol())
            self.working_array["vertex"][2 + i] = m[:2]
            self.working_array["ptid"][2 + i] = 0
            self.working_array["vertex"][2 + i + NUM_ENDCAP_SEGMENTS] = -m[:2]
            self.working_array["ptid"][2 + i + NUM_ENDCAP_SEGMENTS] = 1

        # Force data copy
        self.trace_vbo.bind()
        self.trace_vbo.set_array(self.working_array)
Example #18
0
    def __build_trace(self):
        # Update trace VBO
        self.working_array["vertex"][0] = (0, 0)
        self.working_array["ptid"][0] = 0
        self.working_array["vertex"][1] = (0, 0)
        self.working_array["ptid"][1] = 1

        end = Vec2(1, 0)
        for i in range(0, NUM_ENDCAP_SEGMENTS):
            theta = math.pi * i / (NUM_ENDCAP_SEGMENTS - 1) + math.pi / 2
            m = rotate(theta).dot(end.homol())
            self.working_array["vertex"][2 + i] = m[:2]
            self.working_array["ptid"][2 + i] = 0
            self.working_array["vertex"][2 + i + NUM_ENDCAP_SEGMENTS] = -m[:2]
            self.working_array["ptid"][2 + i + NUM_ENDCAP_SEGMENTS] = 1

        # Force data copy
        self.trace_vbo.copied = False
        self.trace_vbo.bind()
Example #19
0
 def matrix(self) -> 'npt.NDArray[numpy.float64]':
     return translate(self.center.x, self.center.y) @ (
         rotate(self.theta) @ (cflip(self.side == SIDE.Bottom)))
Example #20
0
File: pad.py Project: pcbre/pcbre
 def __p2p_mat(self) -> 'npt.NDArray[numpy.float64]':
     return rotate(-self.theta) @ translate(-self.rel_center.x,
                                            -self.rel_center.y)
Example #21
0
 def get(self):
     r = rotate(self.parent._cmodel.theta)
     cv = Vec2(-self.parent._model.dim_1_body / 2,
               -self.parent._model.dim_2_body / 2)
     return self.parent._cmodel.center + project_point(r, cv)
Example #22
0
 def set(self, val):
     r = rotate(-self.parent.theta)
     p = projectPoint(r, val - self.parent.center)
     self.parent._model.dim_1_body = abs(p.x) * 2
     self.parent._model.dim_2_body = abs(p.y) * 2
Example #23
0
 def matrix(self):
     return translate(self.center.x, self.center.y).dot(
         rotate(self.theta).dot(cflip(self.side == SIDE.Bottom)))
Example #24
0
 def __inv_p2p_mat(self):
     return translate(self.rel_center.x, self.rel_center.y).dot(rotate(self.theta))
Example #25
0
 def matrix(self):
     return translate(self.center.x, self.center.y).dot(rotate(self.theta).dot(cflip(self.side == SIDE.Bottom)))
Example #26
0
 def rotate(self, angle):
     self.transform = self.transform.dot(M.rotate(math.radians(angle)))
Example #27
0
File: pad.py Project: balr0g/pcbre
 def __inv_p2p_mat(self):
     return translate(self.rel_center.x,
                      self.rel_center.y).dot(rotate(self.theta))
Example #28
0
 def rotate(self, angle):
     self.transform = self.transform.dot(M.rotate(math.radians(angle)))
Example #29
0
 def flip_rotate_matrix(self) -> 'npt.NDArray[numpy.float64]':
     return cast('npt.NDArray[numpy.float64]',
                 rotate(self.rotate_theta).dot(scale(-1 if self.flip_x else 1, -1 if self.flip_y else 1))
                 )
Example #30
0
        def other_corner_offset():
            x = self._model.pin_spacing * ((self._model.side1_pins - 1) / 2 + (self._model.side3_pins - 1) / 2)
            y = self._model.dim_2_pincenter

            r = rotate(self.__theta)
            return projectPoint(r, Point2(x, y))
Example #31
0
 def get(self):
     r = rotate(self.parent.theta)
     cv = Vec2(-self.parent._model.dim_1_body/2, -self.parent._model.dim_2_body/2)
     return self.parent.center + projectPoint(r, cv)
Example #32
0
 def point_inside(self, pt):
     v = pt - self.center
     v_in_cmp = projectPoint(rotate(-self.theta), v)
     return self.theta_bbox.point_test(v_in_cmp)
Example #33
0
 def __p2p_mat(self):
     return rotate(-self.theta).dot(translate(-self.rel_center.x, -self.rel_center.y))
Example #34
0
 def rotate(self, angle: float) -> None:
     # Angle is in a clockwise direction
     self.__rotate_flip = M.rotate(math.radians(-angle)) @ self.__rotate_flip
     self.__update()
Example #35
0
 def point_inside(self, pt):
     v = pt - self.center
     v_in_cmp = projectPoint(rotate(-self.theta), v)
     return self.theta_bbox.point_test(v_in_cmp)
Example #36
0
File: pad.py Project: pcbre/pcbre
 def __inv_p2p_mat(self) -> 'npt.NDArray[numpy.float64]':
     return translate(self.rel_center.x, self.rel_center.y) @ rotate(
         self.theta)
Example #37
0
 def flip_rotate_matrix(self):
     return rotate(self.rotate_theta).dot(scale(-1 if self.flip_x else 1, -1 if self.flip_y else 1))
Example #38
0
    def __update_matrix(self):
        rot = rotate(self._cmodel.theta)

        self.matrix = translate(self._cmodel.center.x,
                                self._cmodel.center.y).dot(
                                    rotate(self._cmodel.theta))
Example #39
0
        def p2_corner_offset():
            x = self._model.pin_spacing * ((self._model.side1_pins - 1) / 2) + self._model.dim_1_pincenter/2
            y = self._model.dim_2_pincenter / 2 - (self._model.side2_pins - 1) / 2 * self._model.pin_spacing

            r = rotate(self.__theta)
            return projectPoint(r, Point2(x, y))
Example #40
0
 def set(self, val):
     r = rotate(-self.parent._cmodel.theta)
     p = project_point(r, val - self.parent._cmodel.center)
     self.parent._model.dim_1_body = abs(p.x) * 2
     self.parent._model.dim_2_body = abs(p.y) * 2
Example #41
0
File: pad.py Project: balr0g/pcbre
 def __p2p_mat(self):
     return rotate(-self.theta).dot(
         translate(-self.rel_center.x, -self.rel_center.y))
Example #42
0
 def flip_rotate_matrix(self):
     return rotate(self.rotate_theta).dot(scale(-1 if self.flip_x else 1, -1 if self.flip_y else 1))