canvas::edit::points(n)
π canvas::edit::points β Editing a cloud of points on a canvas π
okay bestie, welcome to the canvas::edit::points(n) page. The original header had it filed under "Variations on a canvas", and we're folding the manual name up here instead of copying that header line, periodt. This is the manual for a class whose instances handle editing a cloud of point markers on a canvas β main character energy for Tk canvases, no cap. β¨
π NAME π
canvas::edit::points β Editing a cloud of points on a canvas.
β¨ SYNOPSIS β¨
Here's the whole synopsis vibe, copied exactly so nothing gets lost:
package require Tcl 8.5
package require Tk 8.5
package require canvas::edit::points ?0.1?
::canvas::edit points objectName canvas options...
objectName destroy
objectName enable
objectName disable
objectName active
objectName add x y
objectName clear
createCmd canvas x y
highlightCmd on canvas item
highlightCmd off canvas state
dataCmd add editorObj id x y
dataCmd remove editorObj id
dataCmd move start editorObj id
dataCmd move delta editorObj id x y dx dy
dataCmd move done editorObj id
π¦ DESCRIPTION π¦
This package provides a class whose instances handle editing a cloud of point markers on a canvas. Instances can be configured with regard to the visual appearance of markers (regular, and highlighted). Note that instances do not store the edited points themselves, but delegate this to a configurable object. Literally delegation, it's giving trust fall, slay. π«Ά
πΈ CLASS API πΈ
::canvas::edit points objectName canvas options...β this, the class command, creates and configures a new instance of a point cloud editor, named objectName. The instance will be connected to the specified canvas widget. The result of the command is the fully qualified name of the instance command. The options accepted here, and their values, are explained in the section Options. That's theOPTIONSsection below, iykyk.
π INSTANCE API π
Instances of the point cloud editors provide the following API, bestie:
objectName destroyβ this method destroys the point cloud editor and releases all its internal resources. Note that this operation does not destroy the items of the point markers the editor managed on the attached canvas, nor the canvas itself. The result of the method is an empty string. It's giving cleanup, not scorched earth. π§ΉobjectName enableβ this method activates editing of the point cloud on the canvas. This is the default after instance creation. A call is ignored if the editor is already active. The result of the method is an empty string. The complementary method isdisable. The interogatory method for the current state isactive. Original spelling, keeping it. πobjectName disableβ this method disables editing of the point cloud on the canvas. A call is ignored if the editor is already disabled. The result of the method is an empty string. The complementary method isenable. The interogatory method for the current state isactive.objectName activeβ this method queries the editor state. The result of the method is a boolean value, true if the editor is active, and false otherwise, i.e. disabled. The methods to change the state areenableanddisable.objectName add x yβ this method programmatically creates a point at the specified location. The result of the method is an empty string. Note that this method goes through the whole set of callbacks invoked when the user interactively creates a point, i.e.-create-cmd, and, more importantly,-data-cmd. This is the method through which to load pre-existing points into an editor instance.objectName clearβ this method programmatically removes all points from the editor. The result of the method is an empty string. Note that this method goes through the same callback invoked when the user interactively removes a point, i.e.-data-cmd.
π₯ OPTIONS π₯
The class command accepts the following options. Every single one, no skipping, fr fr:
-tagstring β the value of this option is the name of the canvas tag with which to identify all items of all points managed by the editor. This option can only be set at construction time. If not specified it defaults toPOINT.-create-cmdcommand-prefix β the value of this option is a command prefix the editor will invoke when it has to create a new point. This option can only be set at construction time. If not specified it defaults to a command which will create a black-bordered blue circle of radius 3 centered on the location of the new point. The signature of this command prefix is:createCmd canvas x yβ the result of the command prefix must be a list of the canvas items it created to represent the marker. Note here that the visual representation of a "point" may consist of multiple canvas items in an arbitrary shape. The returned list of items is allowed to be empty, and such is taken as signal that the callback vetoed the creation of the point.
-highlight-cmdcommand-prefix β the value of this option is a command prefix the editor will invoke when it has to (un)highlight a point. This option can only be set at construction time. If not specified it defaults to a command which will re-color the item to highlight inred(and restores the color for unhighlighting). The two signatures of this command prefix are:highlightCmd on canvas itemβ this method of the command prefix has to perform whatever is needed to highlight the point the item is a part of (remember the note above about points allowed to be constructed from multiple canvas items). The result of the command can be anything and will be passed as is as argumentstateto theoffmethod.highlightCmd off canvas stateβ this method is invoked to unhighlight a point described by thestate, which is the unchanged result of theonmethod of the command prefix. The result of this method is ignored. Note any interaction between dragging and highlighting of points is handled within the editor, and that the callback bears no responsibility for doing such.
-data-cmdcommand-prefix β the value of this option is a command prefix the editor will invoke when a point was edited in some way. This is how the editor delegates the actual storage of point information to an outside object. This option can only be set at construction time. If not specified it defaults to an empty string and is ignored by the editor, i.e. not invoked. The signatures of this command prefix are:dataCmd add editorObj id x yβ this callback is invoked when a new point was added to the instance, either interactively, or programmatically. See instance methodaddfor the latter. Theididentifies the point within the editor and will be used by the two other callbacks to specify which point to modify. The last two argumentsxandyspecify the location of the new point in canvas coordinates. The result of this method is ignored.dataCmd remove editorObj idβ this callback is invoked when a point removed from the editor instance. Theididentifies the removed point within the editor. The result of this method is ignored.dataCmd move start editorObj idβ this callback is invoked when the movement of a point in the editor instance has started. Theididentifies the point within the editor about to be moved. The result of this method is ignored.dataCmd move delta editorObj id x y dx dyβ this callback is invoked when the point moved in the editor instance. Theididentifies the moved point within the editor, and the remaining argumentsx,y,dx, anddyprovide the new absolute location of the point, and full delta to the original location. At the time of the calls the system is not committed to the move yet. Only after methodmove donewas invoked and has accepted or rejected the last position will the editor update its internal data structures, either committing to the new location, or rolling the move back to the original one. Given this the location data provided here should be saved only in temporary storage until then. The result of this method is ignored.dataCmd move done editorObj idβ this callback is invoked when the movement of a point in the editor instance is complete. Theididentifies the moved point within the editor. The result of this method must be a boolean value. If the method returns false the move is vetoed and rollbed back. Original spelling, keeping that too. π
π BUGS, IDEAS, FEEDBACK π
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category canvas of the Tklib Trackers at http://core.tcl.tk/tklib/reportlist. Please also report any ideas for enhancements you may have for either package and/or documentation. Not me being dramatic β the original says "undoubtedly," so it's canon. π
π KEYWORDS π
canvas, editing, point cloud, points.
Signing off with source tklib, version 0.1, manual canvas::edit::points(n) β and the original footer didn't give a separate date, so that's the whole footer tea, no cap π
β¨
π¦ where this page comes from
- alpine 3.24: tk-lib-doc 0.7-r0 Β· TCL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms