Outlines and insides are drawn in the same gray colour. The create oval creates a circle. The first four parameters are the bounding box coordinates of the circle. In other words, they are x, y coordinates of the top-left and bottom-right points of the box, in which the circle is drawn. We create a rectangle item. The coordinates are again the bounding box of the rectangle to be drawn.
This code line creates an arc. First we send the command source splot. After telling wish to read splot. This causes splot to sleep until there is data on the pipe to be read. If you wanted your program to continue running while waiting for output from wish, there are several alternatives.
Any book on Unix systems programming can help. Whenever the scrollbars are moved, they call the replot function within splot. This latter is used to center the image in the canvas when it is drawn.
Note that we must flush stdout after writing a command to it. Otherwise the commands would be buffered and not sent immediately to splot. This function implements a very simple, but relatively fast, 3D perspective transform, and applies it to each point. For each point, we send wish a canvas command to create an oval object based upon its 2D location after the transform.
The variable half is used to center the point set on the canvas. The colornames array is indexed with the type field of each point structure to set the color. There you have it! A complete visualization program in a few kilobytes of C and Tcl code. Try it out: Enter the above code, compile it, and run the program as splot cube. You should be able to tumble and scale the cube in the wish window.
On my systems, this is remarkably fast—I can view datasets of several hundred points with very little noticeable lag. However, the idea here is to code all of the speed-critical parts of the program in C, and allow wish to handle just the user interface. The open call is the same call that is used to open a file. If the first character in the file name argument is a "pipe" symbol , then open will treat the rest of the argument as a program name, and will run that program with the standard input or output connected to a file descriptor.
This "pipe" connection can be used to read the output from that other program or to write fresh input data to it or both. If the "pipe" is opened for both reading and writing you must be aware that the pipes are buffered.
The output of this other program will not be available to a read or gets until its output buffer is filled up or flushed explicitly. Note: as this is internal to this other program, there is no way that your Tcl script can influence that. The other program simply must cooperate. Thus Manpower and manpower are two different identifiers in Tcl. A line containing only whitespace, possibly with a comment, is known as a blank line , and a Tcl interpreter totally ignores it.
Whitespace is the term used in Tcl to describe blanks, tabs, newline characters, and comments. Whitespace separates one part of a statement from another and enables the interpreter to identify where one element in a statement, such as puts, ends and the next element begins.
0コメント