Module gki
source code
IRAF GKI interpreter -- abstract implementation
The main classes here are GkiKernel and GkiController.
GkiKernel is the base class for graphics kernel implementations. Methods:
control() append()
Called by irafexecute to plot IRAF GKI metacode.
pushStdio() popStdio() getStdin/out/err()
Hooks to allow text I/O to special graphics devices, e.g. the
status line.
flush()
Flush graphics. May print or write a file for hardcopy devices.
clearReturnData()
Empty out return data buffer.
gcur()
Activate interactive graphics and return key pressed, position, etc.
redrawOriginal()
Redraw graphics without any annotations, overlays, etc.
undoN()
Allows annotations etc. to be removed.
Classes that implement a kernel provide methods named gki_* and control_*
which are called by the translate and control methods using dispatch
tables (functionTable and controlFunctionTable). The complete lists
of methods are in opcode2name and control2name. Python introspection
is used to determine which methods are implemented; it is OK for
unused methods to be omitted.
GkiProxy is a GkiKernel proxy class that implements the GkiKernel
interface and allows switching between GkiKernel objects (effectively
allowing the kernel type to change.)
GkiController is a GkiProxy that allows switching between different
graphics kernels as directed by commands embedded in the metacode stream.
$Id: gki.py 808 2007-12-03 23:00:03Z sontag $
|
|
EditHistory
Keeps track of where undoable appends are made so they can be
removed from the buffer on request.
|
|
|
GkiBuffer
implement a buffer for gki which allocates memory in blocks so that
a new memory allocation is not needed everytime metacode is
appended
|
|
|
GkiReturnBuffer
A fifo buffer used to queue up metacode to be returned to the IRAF
subprocess
|
|
|
GkiKernel
Abstract class intended to be subclassed by implementations of GKI
kernels.
|
|
|
DrawBuffer
implement a buffer for draw commands which allocates memory in
blocks so that a new memory allocation is not needed everytime
functions are appended
|
|
|
GkiProxy
Base class for kernel proxy
|
|
|
GkiController
Proxy that switches between interactive and other kernels
|
|
|
GkiNull
A version of the graphics kernel that does nothing except warn the
user that it does nothing.
|
|
|
GkiRedirection
A graphics kernel whose only responsibility is to redirect metacode
to a file-like object.
|
|
|
GkiNoisy
Print metacode stream information
|
|
|
IrafGkiConfig
Holds configurable aspects of IRAF plotting behavior
|
|
|
IrafLineStyles
|
|
|
IrafHatchFills
|
|
|
LineAttributes
|
|
|
FillAttributes
|
|
|
MarkerAttributes
|
|
|
TextAttributes
|
|
|
FilterStderr
Filter GUI messages out of stderr during plotting
|
|
|
StatusLine
|
|
|
|
|
|
gkiTranslate(metacode,
functionTable)
General Function that can be used for decoding and interpreting the
GKI metacode stream. |
source code
|
|
|
|
getGraphcap(filename=None)
Get graphcap file from filename (or cached version if possible) |
source code
|
|
|
|
|
|
|
|
|
|
|
|
|
nIrafColors = 16
|
|
|
BOI = -1
|
|
|
NOP = 0
|
|
|
GKI_MAX = 32767
|
|
|
GKI_MAX_FLOAT = float(GKI_MAX)
|
|
|
NDC_MAX = GKI_MAX_FLOAT/(GKI_MAX_FLOAT+ 1)
|
|
|
GKI_MAX_OP_CODE = 27
|
|
|
GKI_FLOAT_FACTOR = 100.
|
|
|
MAX_ERROR_COUNT = 7
|
|
|
GKI_EOF = 0
|
|
|
GKI_OPENWS = 1
|
|
|
GKI_CLOSEWS = 2
|
|
|
GKI_REACTIVATEWS = 3
|
|
|
GKI_DEACTIVATEWS = 4
|
|
|
GKI_MFTITLE = 5
|
|
|
GKI_CLEARWS = 6
|
|
|
GKI_CANCEL = 7
|
|
|
GKI_FLUSH = 8
|
|
|
GKI_POLYLINE = 9
|
|
|
GKI_POLYMARKER = 10
|
|
|
GKI_TEXT = 11
|
|
|
GKI_FILLAREA = 12
|
|
|
GKI_PUTCELLARRAY = 13
|
|
|
GKI_SETCURSOR = 14
|
|
|
GKI_PLSET = 15
|
|
|
GKI_PMSET = 16
|
|
|
GKI_TXSET = 17
|
|
|
GKI_FASET = 18
|
|
|
GKI_GETCURSOR = 19
|
|
|
GKI_GETCELLARRAY = 20
|
|
|
GKI_ESCAPE = 25
|
|
|
GKI_SETWCS = 26
|
|
|
GKI_GETWCS = 27
|
|
|
GKI_ILLEGAL_LIST = 21, 22, 23, 24
|
|
|
CONTROL_OPENWS = 1
|
|
|
CONTROL_CLOSEWS = 2
|
|
|
CONTROL_REACTIVATEWS = 3
|
|
|
CONTROL_DEACTIVATEWS = 4
|
|
|
CONTROL_CLEARWS = 6
|
|
|
CONTROL_SETWCS = 26
|
|
|
CONTROL_GETWCS = 27
|
|
|
opcode2name = {}
|
|
|
control2name = {}
|
|
|
standardWarning = ...
|
|
|
standardNotImplemented = """This IRAF task requires a graphics...
|
|
|
_clearCodes = [GKI_EOF, GKI_OPENWS, GKI_REACTIVATEWS, GKI_CLEA...
|
|
|
tasknameStack = []
|
|
|
graphcapDict = {}
|
|
|
_irafGkiConfig = IrafGkiConfig()
|
|
|
kernel = GkiController()
|
Imports:
numpy,
IntType,
TypeType,
BooleanType,
CodeType,
UnboundMethodType,
StringType,
BuiltinMethodType,
FloatType,
DictionaryType,
NotImplementedType,
BuiltinFunctionType,
DictProxyType,
GeneratorType,
InstanceType,
ObjectType,
DictType,
GetSetDescriptorType,
FileType,
EllipsisType,
StringTypes,
ListType,
MethodType,
TupleType,
ModuleType,
FrameType,
LongType,
BufferType,
TracebackType,
ClassType,
MemberDescriptorType,
UnicodeType,
SliceType,
ComplexType,
LambdaType,
FunctionType,
XRangeType,
NoneType,
os,
sys,
string,
re,
wutil,
graphcap,
iraf,
CHARPATH_UP,
FONT_BOLD,
JUSTIFIED_BOTTOM,
CHARPATH_DOWN,
JUSTIFIED_TOP,
JUSTIFIED_LEFT,
FQUALITY_NORMAL,
JUSTIFIED_RIGHT,
CHARPATH_LEFT,
FONT_ROMAN,
FONT_GREEK,
FONT_ITALIC,
fontdata,
FQUALITY_HIGH,
FQUALITY_LOW,
JUSTIFIED_NORMAL,
CHARPATH_RIGHT,
JUSTIFIED_CENTER,
FQUALITY_MEDIUM,
irafgwcs,
gwm,
gkiiraf
|
General Function that can be used for decoding and interpreting the
GKI metacode stream. FunctionTable is a 28 element list containing the
functions to invoke for each opcode encountered. This table should be
different for each kernel that uses this function and the control method.
This may be called with either a gkiBuffer or a simple numerical array.
If a gkiBuffer, it translates only the previously untranslated part of
the gkiBuffer and updates the nextTranslate pointer.
|
|
Print contents of window (default active window) to stdplot
window must be a GkiKernel object (with a gkibuffer attribute.)
|
standardWarning
- Value:
"""
The graphics kernel for IRAF tasks has just received a metacode
instruction (%s) it never expected to see. Please inform the
STSDAS group of this occurrence."""
|
|
standardNotImplemented
- Value:
"""This IRAF task requires a graphics kernel facility not implemented
in the Pyraf graphics kernel (%s)."""
|
|
_clearCodes
- Value:
[GKI_EOF, GKI_OPENWS, GKI_REACTIVATEWS, GKI_CLEARWS, GKI_CANCEL,]
|
|