- fixed the Tcl commands AddCircle, AddPolygon, AddPolyline and AddRectangle to have stored bounds therefore making them movable/selectable on canvas
This commit is contained in:
@@ -51,17 +51,18 @@ class TclCommandAddCircle(TclCommand):
|
||||
:return:
|
||||
"""
|
||||
|
||||
obj_name = args['name']
|
||||
name = args['name']
|
||||
center_x = args['center_x']
|
||||
center_y = args['center_y']
|
||||
radius = args['radius']
|
||||
|
||||
try:
|
||||
obj = self.app.collection.get_by_name(str(obj_name))
|
||||
obj = self.app.collection.get_by_name(str(name))
|
||||
except Exception:
|
||||
return "Could not retrieve object: %s" % obj_name
|
||||
return "Could not retrieve object: %s" % name
|
||||
if obj is None:
|
||||
return "Object not found: %s" % obj_name
|
||||
return "Object not found: %s" % name
|
||||
if obj.kind != 'geometry':
|
||||
self.raise_tcl_error('Expected Geometry, got %s %s.' % (name, type(obj)))
|
||||
|
||||
obj.add_circle([float(center_x), float(center_y)], float(radius))
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
from camlib import Geometry
|
||||
from tclCommands.TclCommand import *
|
||||
|
||||
|
||||
@@ -51,7 +50,7 @@ class TclCommandAddPolygon(TclCommandSignaled):
|
||||
if obj is None:
|
||||
self.raise_tcl_error("Object not found: %s" % name)
|
||||
|
||||
if not isinstance(obj, Geometry):
|
||||
if obj.kind != 'geometry':
|
||||
self.raise_tcl_error('Expected Geometry, got %s %s.' % (name, type(obj)))
|
||||
|
||||
if len(unnamed_args) % 2 != 0:
|
||||
@@ -61,4 +60,3 @@ class TclCommandAddPolygon(TclCommandSignaled):
|
||||
points = [[float(unnamed_args[2*i]), float(unnamed_args[2*i+1])] for i in range(nr_points)]
|
||||
|
||||
obj.add_polygon(points)
|
||||
obj.plot()
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
from camlib import Geometry
|
||||
import collections
|
||||
from tclCommands.TclCommand import TclCommandSignaled
|
||||
from tclCommands.TclCommand import *
|
||||
|
||||
|
||||
class TclCommandAddPolyline(TclCommandSignaled):
|
||||
@@ -52,7 +50,7 @@ class TclCommandAddPolyline(TclCommandSignaled):
|
||||
if obj is None:
|
||||
self.raise_tcl_error("Object not found: %s" % name)
|
||||
|
||||
if not isinstance(obj, Geometry):
|
||||
if obj.kind != 'geometry':
|
||||
self.raise_tcl_error('Expected Geometry, got %s %s.' % (name, type(obj)))
|
||||
|
||||
if len(unnamed_args) % 2 != 0:
|
||||
@@ -62,4 +60,3 @@ class TclCommandAddPolyline(TclCommandSignaled):
|
||||
points = [[float(unnamed_args[2*i]), float(unnamed_args[2*i+1])] for i in range(nr_points)]
|
||||
|
||||
obj.add_polyline(points)
|
||||
obj.plot()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import collections
|
||||
from tclCommands.TclCommand import TclCommandSignaled
|
||||
from tclCommands.TclCommand import *
|
||||
|
||||
|
||||
class TclCommandAddRectangle(TclCommandSignaled):
|
||||
@@ -52,17 +51,23 @@ class TclCommandAddRectangle(TclCommandSignaled):
|
||||
:return: None or exception
|
||||
"""
|
||||
|
||||
obj_name = args['name']
|
||||
name = args['name']
|
||||
x0 = args['x0']
|
||||
y0 = args['y0']
|
||||
x1 = args['x1']
|
||||
y1 = args['y1']
|
||||
|
||||
if unnamed_args:
|
||||
self.raise_tcl_error(
|
||||
"Too many arguments. Correct format: %s" % '["add_rectangle geo_name xmin ymin xmax ymax"]')
|
||||
|
||||
try:
|
||||
obj = self.app.collection.get_by_name(str(obj_name))
|
||||
obj = self.app.collection.get_by_name(str(name))
|
||||
except Exception:
|
||||
return "Could not retrieve object: %s" % obj_name
|
||||
return "Could not retrieve object: %s" % name
|
||||
if obj is None:
|
||||
return "Object not found: %s" % obj_name
|
||||
return "Object not found: %s" % name
|
||||
if obj.kind != 'geometry':
|
||||
self.raise_tcl_error('Expected Geometry, got %s %s.' % (name, type(obj)))
|
||||
|
||||
obj.add_polygon([(x0, y0), (x1, y0), (x1, y1), (x0, y1)])
|
||||
|
||||
Reference in New Issue
Block a user