Synopsis
The ChipsId structure is used to specify the currency state and coordinate system.
Syntax
ChipsId()
Description
The ChipsId object allows the user to set or modify the currency of ChIPS by specifying the ids of the windows, frames, plots, axes, curves, contours, images, histograms, labels, lines, points, color bars, and regions that the operation should affect. It also contains entries to specify coordinate systems and coordinate system ids. The ChipsId is optional and is generally the first parameter in the command.
A complete list of ChipsId members is available at the end of this document. They are set as:
id = ChipsId() id.window = "all" id.curve = "crv1" id.coord_sys = PLOT_NORM
Object methods may be used to achieve the same results, e.g. id.set_window_id("all"). The available object methods, as well as convenience methods which operate on multiple members simultaneously, are listed at the end of this document.
When a ChipsId object is passed to a command, only the information relevant to the command is utilized. For instance, the window and frame ids may be used when changing the color of a frame background, but the curve id setting is ignored. Blank entries in the ChipsId resolve to the default determined by the currency rules.
Retrieving Object Ids
The ChipsId object also provides a means of retrieving the ids of objects created by add_<object> commands. If an add_curve call is made when no windows exist, a window, frame, plot, axes, and curve objects are all created. The appropriate entries in the input ChipsId object are populated with the object ids.
The id information may be accessed by printing the ChipsId or via the id accessor methods, e.g. id.get_window_id(). The ids are only set when a new instance of the object is added. If a curve is added to an existing plot, only the curve id will be updated in the ChipsId object.
Specifying Coordinate Systems
The coord_sys entry in the ChipsId is used to specify the coordinate system to use when adding objects. For instance, to add a label in plot normalized coordinates, you can set the coord_sys entry to PLOT_NORM and include the ChipsId object in the add_label call:
id = ChipsId() id.coord_sys = PLOT_NORM add_label(id, 0.5, 0.5, "mid")
Note that this can also be achieved using the "coordsys" attribute in the add_<object> call; for instance the above can be replaced by either of
add_label(0.5, 0.5, "mid", ["coordsys", PLOT_NORM]) add_label(0.5, 0.5, "mid", {"coordsys": PLOT_NORM})
Members of the ChipsId Object
Member | Description |
---|---|
window | window id to use to override currency, or the id of the last window created during an add of an object |
frame | frame id to use to override currency, or the id of the last frame created during an add of an object |
plot | plot id to use to override currency, or the id of the last plot created during an add of an object |
axis | axis id to use to override currency, or the id of the last axis created during an add of an object |
xaxis | x axis id to use to override currency, or the id of the last x axis created during an add of an object |
yaxis | y axis id to use to override currency, or the id of the last y axis created during an add of an object |
curve | curve id to use to override currency, or the id of the last curve created |
image | image id to use to override currency, or the id of the last image created |
contour | contour id to use to override currency, or the id of the last contour created |
histogram | histogram id to use to override currency, or the id of the last histogram created |
label | label id to use to override currency, or the id of the last label created |
line | line id to use to override currency, or the id of the last line created |
point | point id to use to override currency, or the id of the last point created |
region | region id to use to override currency, or the id of the last region created |
coord | id of data coordinate system to use |
coord_sys | coordinate system to use |
colorbar | colorbar id to use to override currency, or the id of the last color bar created |
The "attributes" field of the structure contains a list of the above field names: e.g.
cid = ChipsId() cid.frame = "frm1" cid.plot = "plot2" for a in cid.attributes: print("cid.{0} = {1}".format(a, getattr(cid, a)))
produces:
cid.window = None cid.frame = frm1 cid.plot = plot2 cid.axis = None cid.xaxis = None cid.yaxis = None cid.curve = None cid.image = None cid.colorbar = None cid.contour = None cid.histogram = None cid.label = None cid.line = None cid.point = None cid.region = None cid.coord = None cid.coord_sys = 0
Object Methods
Method | Description |
---|---|
clear | resets all object id members to '' and coord_sys to COORD_NONE |
set_all | sets all object id members to all |
set_window_id | sets window id to specified value |
reset_window_id | sets window id to specified value, resets all other object id members to '' |
get_window_id | retrieves window id value |
set_frame_id | sets frame id to specified value |
reset_frame_id | sets frame id to specified value, leaves window id as is, and resets all other object id members to '' |
get_frame_id | retrieves frame id value |
set_plot_id | sets plot id to specified value |
reset_plot_id | sets plot id to specified value, leaves window and frame id as is, and resets all other object id members to '' |
get_plot_id | retrieves plot id value |
set_axis_id | sets axis id to the specified value |
get_axis_id | retrieves axis id value |
set_xaxis_id | sets x axis id to the specified value |
get_xaxis_id | retrieves the x axis id value |
set_yaxis_id | sets y axis id to the specified value |
get_yaxis_id | retrieves the y axis id value |
set_curve_id | sets curve id to the specified value |
get_curve_id | retrieves curve id value |
set_image_id | sets image id to the specified value |
get_image_id | retrieves image id value |
set_contour_id | sets contour id to the specified value |
get_contour_id | retrieves contour id value |
set_histogram_id | sets histogram id to the specified value |
get_histogram_id | retrieves histogram id value |
set_label_id | sets label id to the specified value |
get_label_id | retrieves label id value |
set_line_id | sets line id to the specified value |
get_line_id | retrieves line id value |
set_point_id | sets point id to the specified value |
get_point_id | retrieves point id value |
set_region_id | sets region id to the specified value |
get_region_id | retrieves region id value |
set_colorbar_id | sets color bar id to the specified value |
get_colorbar_id | retrieves color bar id value |
set_coord_sys | sets the coordinate system to the specified value |
get_coord_sys | retrieves the coordinate system value |
set_coord_id | sets data coord system id value |
get_coord_id | retrieves the data coordinate system id value |
Examples
Example 1
chips> add_label(0.5, 0.5, "Hello", "id=a") chips> add_label(0.6, 0.7, "My", "id=b") chips> add_label(0.7, 0.8, "Friend", "id=c") chips> id = ChipsId() chips> id.label = "b" chips> set_label(id, ["font", "greek"]) chips> id.label = "a" chips> set_label(id, ["angle", 45])
Use a ChipsId to modify the currency of labels in several ways.
Example 2
chips> clear() chips> id1 = ChipsId() chips> x = np.arange(1, 5) chips> add_curve(id1, x, x) chips> id2 = ChipsId() chips> add_histogram(id2, x)
Add a curve, using a ChipsId object to retrieve the ids of all the objects that are created. Since there was no window, all fields in id1 will be set, whereas for id2 only the histogram and axis fields are set:
chips> id1 window = win1 frame = frm1 plot = plot1 axis = None xaxis = ax1 yaxis = ay1 curve = crv1 image = None colorbar = None contour = None histogram = None label = None line = None point = None region = None coord = ds0.0.0.3 coord_sys = 3 chips> id2 window = None frame = None plot = None axis = None xaxis = ax1 yaxis = ay1 curve = None image = None colorbar = None contour = None histogram = hist1 label = None line = None point = None region = None coord = None coord_sys = 0
Example 3
chips> add_axis(XY_AXIS, 0.5, -50, 50) chips> add_point(20, 20) chips> id=ChipsId() chips> id.coord_sys = PIXEL chips> add_point(id, 150, 150) chips> id.coord_sys = PLOT_NORM chips> add_point(id, 0.9, 0.2)
Use the ChipsId Object to change the data system used for adding points from data coordinates to pixel coordinates, then to plot normalized coordinates.
An easier way is to change the 'coordsys' attribute; for example
chips> add_point(150, 150, ["coordsys", PIXEL]) chips> add_point(0.9, 0.2, {"coordsys": PLOT_NORM})
Bugs
When an add_<object> call is made which has to start the ChIPS server - so it is the first ChIPS call in a session - and it contains a ChipsId structure as the first argument, then the fields will not be set. A work around is to use a command like info() first, that will cause the server to be started.
See Also
- chips
- chips, chipsgui, chipsrc, show_gui
- concepts
- aspectratio, attributes, chipsopt, colors, coordsys, currency, depthcontrol, entitycreation, preferences, setget