Esempio n. 1
0
 def get_shape_pos(self, shape) -> str:
     # as hex, just the last few digits of the id, to reduce noise.  None protection.
     if shape:
         x, y = getpos(shape)
         width, height = shape.GetBoundingBoxMax(
         )  # wx.ogl doesn't have shape._width etc. so derive
         return f"({int(x):3},{int(y):3}) size: {width:3.0f}, {height:3.0f}"
         # return f"({int(x)},{int(y)}) size: {shape._width}, {shape._height} {shape._lineControlPoints}"
     else:
         return ""
Esempio n. 2
0
 def test_move_center(self):
     app = wx.App()
     OGLInitialize()
     shape = self._create_rect(100, 100)
     shape.move_center(60, 60)
     self.assertEqual([10,110], shape.x)
     self.assertEqual([10,110], shape.y)
     self.assertEqual(100, shape._width)
     self.assertEqual(100, shape._height)
     self.assertEqual(60, shape._xpos)
     self.assertEqual(60, shape._ypos)
     self.assertEqual((100, 100), shape.GetBoundingBoxMax())
     self.assertEqual((10, 10), getpos(shape))
Esempio n. 3
0
 def test_set_height(self):
     app = wx.App()
     OGLInitialize()
     shape = self._create_rect(100, 100)
     shape._height = 40
     if PRO_EDITION:
         self.assertEqual([0,100], shape.x)
         self.assertEqual([30,70], shape.y)
     self.assertEqual(100, shape._width)
     self.assertEqual(40, shape._height)
     self.assertEqual(50, shape._xpos)
     self.assertEqual(50, shape._ypos)
     self.assertEqual((100, 40), shape.GetBoundingBoxMax())
     self.assertEqual((0, 30), getpos(shape))
Esempio n. 4
0
 def test_zero_dimension_rect(self):
     app = wx.App()
     OGLInitialize()
     shape = self._create_rect(0, 0)
     shape._xpos = 50
     shape._ypos = 50
     if PRO_EDITION:
         self.assertEqual([50,50], shape.x)
         self.assertEqual([50,50], shape.y)
     self.assertEqual(0, shape._width)
     self.assertEqual(0, shape._height)
     self.assertEqual(50, shape._xpos)
     self.assertEqual(50, shape._ypos)
     self.assertEqual((0, 0), shape.GetBoundingBoxMax())
     self.assertEqual((50, 50), getpos(shape))
Esempio n. 5
0
    def test_basics(self):
        app = wx.App()
        OGLInitialize()
        shape = self._create_rect(100, 100)

        # expected, actual

        if PRO_EDITION:
            self.assertEqual([0,100], shape.x)
            self.assertEqual([0,100], shape.y)
        self.assertEqual(100, shape._width)
        self.assertEqual(100, shape._height)
        self.assertEqual(50.0, shape._xpos)
        self.assertEqual(50.0, shape._ypos)
        self.assertEqual((100, 100), shape.GetBoundingBoxMax())
        self.assertEqual((0, 0), getpos(shape))
Esempio n. 6
0
    def test_zero_dimension_line(self):
        app = wx.App()
        OGLInitialize()
        shape = LineShape()
        if PRO_EDITION:
            self.assertEqual([0,0], shape.x)
            self.assertEqual([0,0], shape.y)
        self.assertFalse(hasattr(shape, "_width"))  # Line shapes don't have these, use boundingbox
        self.assertFalse(hasattr(shape, "_height"))

        # ogltwo fails this because for a line without line control points, xpos and ypos
        # which are derived from boundingbox, end up in -2000 land - yikes!
        # perhaps we re-implement xpos and ypos for Lines? to be based on .x.y point lists?
        # OK I did that - and these tests pass - but what implications for the rest of the system?
        self.assertEqual(0, shape._xpos)
        self.assertEqual(0, shape._ypos)

        self.assertEqual((-20000, -20000), shape.GetBoundingBoxMax())  # cos no _lineControlPoints
        # self.assertEqual((0, 0), getpos(shape))

        shape._xpos = 50
        shape._ypos = 50
        shape._lineControlPoints = [wx.RealPoint(40, 60), wx.RealPoint(60, 40)]

        if PRO_EDITION:
            self.assertEqual([50,50], shape.x)
            self.assertEqual([50,50], shape.y)

        # Lines don't have ._width, ._height attributes, according to wx.ogl
        # self.assertEqual(0, shape._width)
        # self.assertEqual(0, shape._height)

        self.assertEqual(50, shape._xpos)
        self.assertEqual(50, shape._ypos)
        self.assertEqual((20, 20), shape.GetBoundingBoxMax())
        self.assertEqual((40, 40), getpos(shape))