purpose:Called after constructor to register
the id of the Window2D & theparent_gui pointer. Would
be in constructor, but we didn't know howto alter the arguments to the
constructor

parameters:i is the id of the window, corresponding
to the axis perpendicular tothe window (X = 0, Y = 1, Z =
2); g is the GUI that contains the window

post:internal data members x and y
are set, that map the x and y directionsof this window (right and up directions
respectively) to directionsin the voxel data set;id and parent_gui are initialized;registered == 1

void InitSlice(void)

purpose:called by gui when vox_data loads
new data - Window2D must allocate itsslice buffers and slice parameters
to match vox_data, & set up a defaultview

pre:Window2D has been registered with
gui;vox_data global has valid voxel
data

post:slice_width & slice height
match dimensions of data in vox_data;a padding of extra rows and columns
is computed for textures withoutpower-of-two dimensions;the slice buffers used are allocatedslice_num == -1, so that first
draw will load vox slices;init_slice == 1

void ResetView(void)

ResetView()

purpose:slice texture will be fit to viewport
on next draw()pre:Register() and InitSlice() have
been called

post:view_pos is set to the center
of the slice textures;view_zoom is set so texture spans
one of the viewport dimensions

void MakeSegTextureCurrent(void)

purpose:reloads the segmentation slice
at the current slice number; used wheneverthe seg slice has possibly become
out of date, i.e., when the rgb ofa color index is changed, or a
user has painted in one of the windows.

pre:Register() and InitSlice() have
been calledvox data has data with extents
matching this window's width and heightpost:segmentation slice texture contains
the voxel data set cross-sectionin direction 'id', and section
number 'slice_num'

int CachedPolygon(void)

purpose:returns the cached_polygon flag
of the polygon_drawing object

post:return value is 1 if polygon_drawing
has a cached polygon, 0 otherwise

void AcceptPolygon(void)

purpose:the gui calls this when the user
presses the accept polygon button; thismeans the polygon that was being
edited will be rasterized into the voxeldata set according to the current
drawing color and painting mode

pre:Register() and InitSlice() have
been calledvox data has data with extents
matching this window's width and height

post:if drawing lock held and polygon_drawing
state was EDITING_STATE, voxels interior to polygon
and "writable" are set with the current drawing color obtained from global_state->GetDrawingColor();
the three coverage modes determine which voxels
inside the polygon are written over: PAINT_OVER_ALL:
all voxels PAINT_OVER_COLORS: all
voxels that aren't labeled clear PAINT_OVER_ONE:
all voxels of the color obtained from
global_state->GetOverWriteColor() drawing lock released and
polygon_drawing state is INACTIVE_STATEelse state not changed.

void PastePolygon(void)

purpose:brings the last drawn polygon
back for reuse

pre:Register() and InitSlice() have
been called

post:if polygon_drawing state previously
INACTIVE_STATE, drawing lockobtainable, & polygon_drawing
has a cached polygon, cached polygon becomes
the edited polygon, polygon_drawing state is
EDITING_STATE drawing lock is heldelse state does not change

void draw(void)

purpose:draw() overrided the draw() of
the Fl_Gl_Window; called whenwindow issues a redraw(), is shown
or uncovered.

post:if InitSlice() has been called, grey and seg slice textures,
the crosshairs, & the polygon contour being drawn (if one exists) are
displayed,else the screen is cleared

void handle(int event)

purpose:this handle() overrides the handle()
of Fl_Gl_Window

post:if InitSlice() has been called, results depend on
global_state->GetToolbarMode(): NAVIGATION MODE: left drag shifts
the textures; right drag up and down scales the textures POLYGON DRAWING MODE: all events forwarded
to polygon_drawing object CROSSHAIRS MODE: left click or drag
places the crosshairs at the mouse cursor position; any other mode has
no effectelse no change in stateif event is used, 1 is returned,
else 0