Exemple #1
0
 def points_ra(self, lw=0):
     r = self.r
     R = self.R()
     a = self.a
     A = self.A()
     la, La = self.arcFixes(lw)
     return [ra2xy(r+lw, a+la), ra2xy(R-lw, a+La),
             ra2xy(R-lw, A-La), ra2xy(r+lw, A-la)]
Exemple #2
0
 def points_ra(self, lw=0):
     r = self.r
     R = self.R()
     a = self.a
     A = self.A()
     la, La = self.arcFixes(lw)
     return [
         ra2xy(r + lw, a + la),
         ra2xy(R - lw, a + La),
         ra2xy(R - lw, A - La),
         ra2xy(r + lw, A - la)
     ]
 def test_geometry_pos(self):
     x0, y0 = 180, 180
     r, dr = 10, 10
     d = r + dr
     pos = [[180, 160], [160, 160], [160, 180], [180, 180]]
     for i in range(0, 3):
         x, y = ra2xy(r, 90*i)
         x += x0
         y = y0 - y
         assert QRect(pos[i][0], pos[i][1], d, d) == RingSegment(r, 90*i, dr, 90).geometry(x, y)
Exemple #4
0
 def test_geometry_pos(self):
     x0, y0 = 180, 180
     r, dr = 10, 10
     d = r + dr
     pos = [[180, 160], [160, 160], [160, 180], [180, 180]]
     for i in range(0, 3):
         x, y = ra2xy(r, 90 * i)
         x += x0
         y = y0 - y
         assert QRect(pos[i][0], pos[i][1], d,
                      d) == RingSegment(r, 90 * i, dr, 90).geometry(x, y)
Exemple #5
0
 def text_bbox_scr(self, lw=0):
     ## Text: get inscribed circle center tr, and size of inscribed square in it
     R = self.R()
     ha = self.da / 2
     hr = self.dr / 2
     hra = R - R / (1 + sin(radians(ha)))
     tr = min(hr, hra) if ha < 90 else hr
     tr -= lw
     ta = tr / sqrt(2)
     l, t = self.topLeft_ra()
     cx, cy = ra2xy(R - tr, ha + self.a)
     qr = QRect(cx - ta - l, t - cy - ta, 2 * ta, 2 * ta)
     return qr
Exemple #6
0
 def text_bbox_scr(self, lw=0):
     ## Text: get inscribed circle center tr, and size of inscribed square in it
     R = self.R()
     ha = self.da/2
     hr = self.dr/2
     hra = R - R/(1 + sin(radians(ha)))
     tr = min(hr, hra) if ha < 90 else hr
     tr -= lw
     ta = tr / sqrt(2)
     l, t = self.topLeft_ra()
     cx, cy = ra2xy(R-tr, ha+self.a)
     qr = QRect(cx-ta-l, t-cy-ta, 2*ta, 2*ta)
     return qr
Exemple #7
0
    def doLayout(self, center):
        # WARNING: case of empty list -- len([]) == 0
        a = float(360) / max(1, len(self.sectors))

        for i, wrapper in enumerate(self.sectors):
            item = wrapper.item
            wdg = item.widget()
            sp = self.spacing()  # may be linear or angle

            segment = RingSegment(self.r, a*i + sp/2., self.dr, a - sp)
            x, y = ra2xy(self.r, a*i)
            wdg.setGeometry(segment.geometry(center.x() + x, center.y() - y))
            wdg.gPath = segment.path()
            wdg.gText = segment.text_bbox_scr()
            wdg.setMask(segment.region())
Exemple #8
0
 def test_ra2xy(self):
     assert similar([0, 10], ra2xy(10, 90))
     assert similar([8.66, 5], ra2xy(10, 30))