Skip to content

Commit

Permalink
添加exclude_objects的xy包围盒信息.
Browse files Browse the repository at this point in the history
  • Loading branch information
GuoGeTiertime committed Dec 6, 2024
1 parent d2686d7 commit 1c59a23
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion klippy/extras/exclude_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ def _reset_state(self):
self.excluded_objects = []
self.current_object = None
self.in_excluded_region = False
self.xmin = 0.0
self.xmax = 0.0
self.ymin = 0.0
self.ymax = 0.0

def _reset_file(self):
self._reset_state()
Expand Down Expand Up @@ -173,7 +177,11 @@ def get_status(self, eventtime=None):
status = {
"objects": self.objects,
"excluded_objects": self.excluded_objects,
"current_object": self.current_object
"current_object": self.current_object,
"xmin": self.xmin,
"xmax": self.xmax,
"ymin": self.ymin,
"ymax": self.ymax
}
return status

Expand Down Expand Up @@ -273,6 +281,18 @@ def cmd_EXCLUDE_OBJECT_DEFINE(self, gcmd):
def _add_object_definition(self, definition):
self.objects = sorted(self.objects + [definition],
key=lambda o: o["name"])
if 'polygon' in definition:
for point in definition["polygon"]:
if self.xmin == 0.0 and self.xmax == 0.0 and self.ymin == 0.0 and self.ymax == 0.0:
self.xmin = point[0]
self.xmax = point[0]
self.ymin = point[1]
self.ymax = point[1]
else:
self.xmin = min(self.xmin, point[0])
self.xmax = max(self.xmax, point[0])
self.ymin = min(self.ymin, point[1])
self.ymax = max(self.ymax, point[1])

def _exclude_object(self, name):
self._register_transform()
Expand Down

0 comments on commit 1c59a23

Please sign in to comment.