Beispiel #1
0
 def _adjust_bounds(self, widget, axis, change_target):
     bounds = self.get_selected()
     if not bounds:
         return
     axis_index = "XYZ".index(axis)
     change_factor = {"0": 0, "+": 1, "-": -1}[change_target]
     is_margin = self.gui.get_object("TypeRelativeMargin").get_active()
     is_percent = (self.gui.get_object("RelativeUnit").get_active() == 0)
     change_value = change_factor * (0.1 if is_percent else 1)
     change_vector = {"lower": [0, 0, 0], "upper": [0, 0, 0]}
     change_vector["lower"][
         axis_index] = change_value if is_margin else -change_value
     change_vector["upper"][axis_index] = change_value
     for key in ("lower", "upper"):
         if change_target == "0":
             limits = [
                 LimitSingle(0 if (index == axis_index) else orig.value,
                             orig.is_relative).export
                 for index, orig in enumerate(bounds.get_value(key))
             ]
         else:
             limits = [
                 LimitSingle(orig.value + change, orig.is_relative).export
                 for orig, change in zip(bounds.get_value(key),
                                         change_vector[key])
             ]
         bounds.set_value(key, limits)
Beispiel #2
0
 def _transfer_controls_to_bounds(self):
     bounds = self.get_selected()
     if bounds:
         bounds.set_value(
             "reference_models",
             [model.get_id() for model in self.get_selected_models()])
         is_percent = (
             self.gui.get_object("RelativeUnit").get_active() == 0)
         # absolute bounds or margins around models
         if self.gui.get_object("TypeRelativeMargin").get_active():
             specification = BoundsSpecification.MARGINS
         else:
             specification = BoundsSpecification.ABSOLUTE
             # disallow percent values
             is_percent = False
         bounds.set_value("specification", specification.value)
         # overwrite all limit values and set or remove their "relative" flags
         for name, obj_keys in (("lower", ("BoundaryLowX", "BoundaryLowY",
                                           "BoundaryLowZ")),
                                ("upper", ("BoundaryHighX", "BoundaryHighY",
                                           "BoundaryHighZ"))):
             limits = [
                 LimitSingle(
                     self.gui.get_object(name).get_value(),
                     is_percent).export for name in obj_keys
             ]
             bounds.set_value(name, limits)
         tool_limit_mode = {
             0: ToolBoundaryMode.INSIDE,
             1: ToolBoundaryMode.ALONG,
             2: ToolBoundaryMode.AROUND
         }[self.gui.get_object("ToolLimit").get_active()]
         bounds.set_value("tool_boundary", tool_limit_mode.value)