indexing description: "[ Changes a polygon (either position or vertices). ]" date: "$Date$" revision: "$Revision$" class CHANGE_POLYGON inherit COMMAND create make feature -- Initialization make is -- creation procedure. do end feature {HISTORY} -- Access execute (args: TUPLE) is -- change a POLYGON object -- args.item (1) :: polygon: POLYGON do execute_successful := False if args.count = 1 then polygon ?= args.item (1) if polygon.count >= 3 then -- make backup of the polygon (not using polygon.deep_twin because of references to `scene') -- and circular references create polygon_backup.make_obj (create {EM_VECTOR_2D}.make (0,0), polygon.scene) polygon_backup.set_true_values_internal (polygon.true_x, polygon.true_y, polygon.x, polygon.y, polygon, polygon.true_list) polygon_backup.set_true_splitting_lines (polygon.true_splitting_lines) polygon_backup.set_splitting_lines (polygon.splitting_lines) if polygon_backup.count = polygon.count then polygon.set_true_values_internal (polygon.x, polygon.y, polygon.x, polygon.y, polygon, polygon) polygon.set_true_splitting_lines (polygon.splitting_lines) polygon.set_changed execute_successful := True polygon.recreate_collidable end end end end undo (args: TUPLE) is -- Undo command require else polygon_not_void: polygon /= Void polygon_backup_not_void: polygon_backup /= Void do -- copy all values from `polygon_backup' to `polygon' polygon.set_true_values_internal (polygon_backup.true_x, polygon_backup.true_y, polygon_backup.true_x.rounded, polygon_backup.true_y.rounded, polygon_backup.true_list, polygon_backup.true_list) polygon.set_true_splitting_lines (polygon_backup.true_splitting_lines) polygon.set_splitting_lines (polygon_backup.true_splitting_lines) polygon.set_changed polygon.recreate_collidable execute_successful := False undo_successful := True redo_successful := False end redo (args: TUPLE) is -- Redo command require else polygon_not_void: polygon /= Void polygon_backup_not_void: polygon_backup /= Void do polygon.set_true_values_internal (polygon_backup.true_x, polygon_backup.true_y, polygon_backup.x, polygon_backup.y, polygon_backup, polygon_backup) polygon.set_true_splitting_lines (polygon_backup.splitting_lines) polygon.set_splitting_lines (polygon_backup.splitting_lines) polygon.set_changed polygon.recreate_collidable execute_successful := False undo_successful := False redo_successful := True end name: STRING is "edit polygon" -- The name of the current command feature -- Implementation polygon: POLYGON -- reference to the polygon polygon_backup: POLYGON -- backup of the polygon. true_? is the previous step. end