Beispiel #1
0
    def test_IsInPosition_Rect_Required(self):
        restrictions_dict = [{
            "Shape": "rect",
            "X": 10.0,
            "Y": 10.0,
            "X2": 20.0,
            "Y2": 20.0,
            "Type": "required",
            "R": 1.0
        }]
        restrictions = self.Settings.current_snapshot(
        ).get_trigger_position_restrictions(restrictions_dict)
        self.assertFalse(
            trigger.is_in_position(restrictions, 0, 0, self.PrinterTolerance))
        self.assertFalse(
            trigger.is_in_position(restrictions, 100, 0,
                                   self.PrinterTolerance))
        self.assertFalse(
            trigger.is_in_position(restrictions, 20.1, 20.1,
                                   self.PrinterTolerance))
        self.assertFalse(
            trigger.is_in_position(restrictions, 15, 25,
                                   self.PrinterTolerance))
        self.assertFalse(
            trigger.is_in_position(restrictions, 25, 15,
                                   self.PrinterTolerance))

        self.assertTrue(
            trigger.is_in_position(restrictions, 10, 10,
                                   self.PrinterTolerance))
        self.assertTrue(
            trigger.is_in_position(restrictions, 15, 15,
                                   self.PrinterTolerance))
        self.assertTrue(
            trigger.is_in_position(restrictions, 20, 20,
                                   self.PrinterTolerance))
Beispiel #2
0
    def test_IsInPosition_Circle_Required(self):
        restrictions_dict = [{
            "Shape": "circle",
            "R": 1.0,
            "Y": 10.0,
            "X": 10.0,
            "Type": "required",
            "X2": 20.0,
            "Y2": 20.0
        }]
        restrictions = self.Settings.current_snapshot(
        ).get_trigger_position_restrictions(restrictions_dict)
        # tests outside area
        self.assertFalse(
            trigger.is_in_position(restrictions, 0, 0, self.PrinterTolerance))
        self.assertFalse(
            trigger.is_in_position(restrictions, 100, 0,
                                   self.PrinterTolerance))
        self.assertFalse(
            trigger.is_in_position(restrictions, 9, 9, self.PrinterTolerance))
        self.assertFalse(
            trigger.is_in_position(restrictions, 11, 11,
                                   self.PrinterTolerance))
        self.assertFalse(
            trigger.is_in_position(restrictions, 9, 11, self.PrinterTolerance))
        self.assertFalse(
            trigger.is_in_position(restrictions, 11, 9, self.PrinterTolerance))

        # tests inside area
        self.assertTrue(
            trigger.is_in_position(restrictions, 10, 10,
                                   self.PrinterTolerance))
        self.assertTrue(
            trigger.is_in_position(restrictions, 10, 9, self.PrinterTolerance))
        self.assertTrue(
            trigger.is_in_position(restrictions, 9, 10, self.PrinterTolerance))
        self.assertTrue(
            trigger.is_in_position(restrictions, 10, 11,
                                   self.PrinterTolerance))
        self.assertTrue(
            trigger.is_in_position(restrictions, 11, 10,
                                   self.PrinterTolerance))
Beispiel #3
0
    def test_IsInPosition_Circle_ForbiddenAndRequired(self):
        # test to restrictions, forbidden and required, have them overlap.
        restrictions_dict = [
            {
                "Shape": "circle",
                "R": 1.0,
                "Y": 10.0,
                "X": 10.0,
                "Type": "required",
                "X2": 20.0,
                "Y2": 20.0
            },
            {
                "Shape": "circle",
                "R": 1.0,
                "Y": 10.0,
                "X": 11.0,
                "Type": "forbidden",
                "X2": 25.0,
                "Y2": 25.0
            },
        ]
        restrictions = self.Settings.current_snapshot(
        ).get_trigger_position_restrictions(restrictions_dict)
        # out of all areas, restricted and forbidden
        self.assertFalse(
            trigger.is_in_position(restrictions, 0, 0, self.PrinterTolerance))
        self.assertFalse(
            trigger.is_in_position(restrictions, 100, 0,
                                   self.PrinterTolerance))

        # test only in forbidden area
        self.assertFalse(
            trigger.is_in_position(restrictions, 12, 10,
                                   self.PrinterTolerance))
        self.assertFalse(
            trigger.is_in_position(restrictions, 11, 11,
                                   self.PrinterTolerance))
        self.assertFalse(
            trigger.is_in_position(restrictions, 11, 9, self.PrinterTolerance))

        # test in required area only
        self.assertTrue(
            trigger.is_in_position(restrictions, 10, 11,
                                   self.PrinterTolerance))
        self.assertTrue(
            trigger.is_in_position(restrictions, 10, 9, self.PrinterTolerance))
        self.assertTrue(
            trigger.is_in_position(restrictions, 9, 10, self.PrinterTolerance))

        # test overlapping area
        self.assertFalse(
            trigger.is_in_position(restrictions, 10, 10,
                                   self.PrinterTolerance))
        self.assertFalse(
            trigger.is_in_position(restrictions, 11, 10,
                                   self.PrinterTolerance))
        self.assertFalse(
            trigger.is_in_position(restrictions, 10.5, 10,
                                   self.PrinterTolerance))
Beispiel #4
0
 def test_is_in_position_Circle_Forbidden(self):
     restrictions_dict = [{
         "Shape": "circle",
         "R": 1.0,
         "Y": 10.0,
         "X": 10.0,
         "Type": "forbidden",
         "X2": 0,
         "Y2": 0
     }]
     restrictions = self.Settings.profiles.current_snapshot(
     ).get_trigger_position_restrictions(restrictions_dict)
     # tests outside forbidden area
     self.assertTrue(
         trigger.is_in_position(restrictions, 0, 0, self.PrinterTolerance))
     self.assertTrue(
         trigger.is_in_position(restrictions, 100, 0,
                                self.PrinterTolerance))
     self.assertTrue(
         trigger.is_in_position(restrictions, 9, 9, self.PrinterTolerance))
     self.assertTrue(
         trigger.is_in_position(restrictions, 11, 11,
                                self.PrinterTolerance))
     self.assertTrue(
         trigger.is_in_position(restrictions, 9, 11, self.PrinterTolerance))
     self.assertTrue(
         trigger.is_in_position(restrictions, 11, 9, self.PrinterTolerance))
     # tests inside forbidden area
     self.assertFalse(
         trigger.is_in_position(restrictions, 10, 10,
                                self.PrinterTolerance))
     self.assertFalse(
         trigger.is_in_position(restrictions, 10, 9, self.PrinterTolerance))
     self.assertFalse(
         trigger.is_in_position(restrictions, 9, 10, self.PrinterTolerance))
     self.assertFalse(
         trigger.is_in_position(restrictions, 10, 11,
                                self.PrinterTolerance))
     self.assertFalse(
         trigger.is_in_position(restrictions, 11, 10,
                                self.PrinterTolerance))