예제 #1
0
 def testBbSpaceChildren(self):
     """Tests PlotNode() set/get bbSpaceChildren."""
     myObj = PlotNode.PlotNodeBbox()
     #print '\nTRACE myObj', myObj
     myObj.bbSpaceChildren = Coord.Dim(42, 'px')
     #print '\nTRACE myObj', myObj
     self.assertEqual(myObj.bbSpaceChildren, Coord.Dim(42, 'px'))
예제 #2
0
 def testCentre_02(self):
     """Tests PlotNode() get the centre point."""
     myObj = PlotNode.PlotNodeBbox()
     myObj.width = Coord.Dim(3, 'in')
     self.assertEqual(myObj.width, Coord.Dim(3, 'in'))
     myObj.depth = Coord.Dim(1, 'in')
     self.assertEqual(myObj.depth, Coord.Dim(1, 'in'))
     myPad = Coord.Pad(
         Coord.Dim(0.1, 'in'),  # prev
         Coord.Dim(0.3, 'in'),  # next
         Coord.Dim(0.5, 'in'),  # parent
         Coord.Dim(0.7, 'in'),  # child
     )
     myObj.bbSelfPadding = myPad
     myObj.bbSpaceChildren = Coord.Dim(0.9, 'in')
     self.assertEqual(
         myObj.plotPointCentre(
             Coord.Pt(
                 Coord.Dim(0.0, 'in'),
                 Coord.Dim(0.0, 'in'),
             ), ),
         Coord.Pt(
             Coord.Dim(1.6, 'in'),
             Coord.Dim(1.0, 'in'),
         ),
     )
예제 #3
0
 def testWidthDepth(self):
     """Tests PlotNode() set/get width and depth."""
     myObj = PlotNode.PlotNodeBbox()
     myObj.width = Coord.Dim(42, 'in')
     myObj.depth = Coord.Dim(1, 'in')
     self.assertEqual(myObj.width, Coord.Dim(42, 'in'))
     self.assertEqual(myObj.depth, Coord.Dim(1, 'in'))
예제 #4
0
 def testBbSpacePaddingNullNode(self):
     """Tests PlotNode() set/get bbSpacePadding on a null node."""
     myObj = PlotNode.PlotNodeBbox()
     myObj.width = None
     myObj.depth = None
     myPad = Coord.Pad(
         Coord.Dim(1, 'px'),  # prev
         Coord.Dim(2, 'px'),  # next
         Coord.Dim(3, 'px'),  # parent
         Coord.Dim(4, 'px'),  # child
     )
     myObj.bbSelfPadding = myPad
     self.assertEqual(
         myObj.bbSelfPadding,
         Coord.Pad(
             Coord.Dim(1, 'px'),
             Coord.Dim(2, 'px'),
             Coord.Dim(3, 'px'),
             Coord.Dim(4, 'px'),
         ))
     self.assertEqual(
         myObj.bbSelfWidth,
         Coord.Dim(0, None),
     )
     self.assertEqual(
         myObj.bbSelfDepth,
         Coord.Dim(0, None),
     )
예제 #5
0
 def testSigma_03(self):
     """Tests PlotNode() get sigma width and depth (parent is null node)."""
     myObj = PlotNode.PlotNodeBbox()
     myObj.width = None
     self.assertEqual(myObj.width, None)
     myObj.depth = None
     self.assertEqual(myObj.depth, None)
     myPad = Coord.Pad(
         Coord.Dim(0.5, 'in'),  # prev
         Coord.Dim(0.5, 'in'),  # next
         Coord.Dim(0.5, 'in'),  # parent
         Coord.Dim(0.5, 'in'),  # child
     )
     myObj.bbSelfPadding = myPad
     myObj.bbSpaceChildren = Coord.Dim(0.5, 'in')
     self.assertEqual(myObj.bbSpaceChildren, Coord.Dim(0.5, 'in'))
     myObj.bbChildren = Coord.Box(
         Coord.Dim(4, 'in'),
         Coord.Dim(2.5, 'in'),
     )
     self.assertEqual(
         myObj.bbChildrenWidth,
         Coord.Dim(4, 'in'),
     )
     self.assertEqual(
         myObj.bbChildrenDepth,
         Coord.Dim(2.5, 'in'),
     )
     self.assertEqual(myObj.bbChildren,
                      Coord.Box(
                          Coord.Dim(4, 'in'),
                          Coord.Dim(2.5, 'in'),
                      ))
     self.assertEqual(
         myObj.bbSigmaWidth,
         Coord.Dim(4.0, 'in'),
     )
     self.assertEqual(
         myObj.bbSigmaDepth,
         Coord.Dim(2.5, 'in'),
     )
     self.assertEqual(
         myObj.bbSigma,
         Coord.Box(
             Coord.Dim(4.0, 'in'),
             Coord.Dim(2.5, 'in'),
         ))
예제 #6
0
    def testBbSpacePadding(self):
        """Tests PlotNode() set/get bbSpacePadding."""
        myObj = PlotNode.PlotNodeBbox()
        myObj.width = Coord.Dim(12, 'px')
        myObj.depth = Coord.Dim(6, 'px')
        #print '\nTRACE myObj', myObj
        myPad = Coord.Pad(
            Coord.Dim(1, 'px'),  # prev
            Coord.Dim(2, 'px'),  # next
            Coord.Dim(3, 'px'),  # parent
            Coord.Dim(4, 'px'),  # child
        )
        #print '\nTRACE myPad setting', myPad
        myObj.bbSelfPadding = myPad
        #print '\nTRACE myObj setting done', myObj
        a = myObj.bbSelfPadding
        self.assertEqual(
            myObj.bbSelfPadding,
            Coord.Pad(
                Coord.Dim(1, 'px'),
                Coord.Dim(2, 'px'),
                Coord.Dim(3, 'px'),
                Coord.Dim(4, 'px'),
            ))
        #print '\nTRACE myObj', myObj
        self.assertEqual(
            myObj.bbSelfWidth,
            # 1 + 12 + 2 = 15
            Coord.Dim(15, 'px'),
        )
        self.assertEqual(
            myObj.bbSelfDepth,
            # 3 + 6 + 4
            Coord.Dim(13, 'px'),
        )
        #print
        #print str(myObj)
        self.assertEqual(
            str(myObj),
            """|.......PlotNode: w=Dim(12px), d=Dim(6px)
|bbSpaceChildren: None
|..bbSelfPadding: Pad(prev=Dim(1px), next=Dim(2px), parent=Dim(3px), child=Dim(4px))
|.....bbChildren: None
|........bbSigma: Box(width=Dim(15px), depth=Dim(13px))""",
        )
예제 #7
0
 def testBbChildren(self):
     """Tests PlotNode() set/get bbChildren."""
     myObj = PlotNode.PlotNodeBbox()
     myObj.bbChildren = Coord.Box(
         Coord.Dim(1, 'px'),
         Coord.Dim(2, 'px'),
     )
     self.assertEqual(myObj.bbChildren,
                      Coord.Box(
                          Coord.Dim(1, 'px'),
                          Coord.Dim(2, 'px'),
                      ))
     self.assertEqual(
         myObj.bbChildrenWidth,
         Coord.Dim(1, 'px'),
     )
     self.assertEqual(
         myObj.bbChildrenDepth,
         Coord.Dim(2, 'px'),
     )
예제 #8
0
 def testCtor(self):
     """Tests PlotNode() constructor empty."""
     myObj = PlotNode.PlotNodeBbox()
     self.assertEqual(myObj.width, None)
     self.assertEqual(myObj.depth, None)
예제 #9
0
 def testBbChildren_00(self):
     """TestPlotNodeBboxWithChildren.testBbChildren_00() - three children."""
     myObj = PlotNode.PlotNodeBbox()
     myObj.width = Coord.Dim(12, 'mm')
     myObj.depth = Coord.Dim(8, 'mm')
     #print '\nTRACE myObj', myObj
     myObj.bbSelfPadding = Coord.Pad(
         Coord.Dim(1, 'mm'),  # prev
         Coord.Dim(3, 'mm'),  # next
         Coord.Dim(5, 'mm'),  # parent
         Coord.Dim(7, 'mm'),  # child
     )
     myObj.bbSpaceChildren = Coord.Dim(16, 'mm')
     self.assertEqual(True, myObj.bbChildrenWidth is None)
     self.assertEqual(True, myObj.bbChildrenDepth is None)
     self.assertEqual(0, myObj.numChildren)
     myObj.extendChildBbox(
         Coord.Box(
             Coord.Dim(15, 'mm'),
             Coord.Dim(7, 'mm'),
         ))
     # Child box now w:15, d:7
     self.assertEqual(1, myObj.numChildren)
     self.assertEqual(myObj.bbChildrenWidth, Coord.Dim(15, 'mm'))
     self.assertEqual(myObj.bbChildrenDepth, Coord.Dim(7, 'mm'))
     myObj.extendChildBbox(
         Coord.Box(
             Coord.Dim(31, 'mm'),
             Coord.Dim(29, 'mm'),
         ))
     # Child box now w:15+31=46, d:max(7,29)=29
     self.assertEqual(2, myObj.numChildren)
     self.assertEqual(myObj.bbChildrenWidth, Coord.Dim(46, 'mm'))
     self.assertEqual(myObj.bbChildrenDepth, Coord.Dim(29, 'mm'))
     myObj.extendChildBbox(
         Coord.Box(
             Coord.Dim(11, 'mm'),
             Coord.Dim(9, 'mm'),
         ))
     # Child box now w:46+11=57, d:max(29,9)=29
     self.assertEqual(3, myObj.numChildren)
     self.assertEqual(myObj.bbChildrenWidth, Coord.Dim(57, 'mm'))
     self.assertEqual(myObj.bbChildrenDepth, Coord.Dim(29, 'mm'))
     # bbSigma:
     # Width is 57mm as children are wider than me
     # Depth is 5 + 8 + 7 + 16 + 29 = 65mm
     #print
     #print 'myObj.bbSigma:', myObj.bbSigma
     self.assertEqual(myObj.bbSigma,
                      Coord.Box(
                          Coord.Dim(57, 'mm'),
                          Coord.Dim(65, 'mm'),
                      ))
     # Set my datum up
     myD = Coord.Pt(
         Coord.Dim(135, 'mm'),
         Coord.Dim(19, 'mm'),
     )
     # x should be 135 + 0.5 * (57-(1+12+3) + 1) = 135 + 0.5 * 41 + 1 = 156.5
     #print
     #print 'myObj.plotPointSelf:', myObj.plotPointSelf(myD)
     self.assertEqual(
         myObj.plotPointSelf(myD),
         Coord.Pt(
             Coord.Dim(156.5, 'mm'),
             Coord.Dim(24, 'mm'),
         ))
     #childBboxDatum
     #print
     #print 'myObj.childBboxDatum:', myObj.childBboxDatum(myD)
     self.assertEqual(myObj.childBboxDatum(myD),
                      Coord.Pt(
                          Coord.Dim(135, 'mm'),
                          Coord.Dim(55, 'mm'),
                      ))