da_all_events
Description
da_all_events.c is a Motif GUI source file that implements a generic event handler for all drawing areas (DA1, DA2, DA3, DA4) within the βSubmetrix 2000 unravellerβ application. This module centralizes the processing of various X events, allowing for interactive features such as rubber-band selection, context-menu display, and dynamic adjustment of processing parameters directly from the user interface. It determines which drawing area (DA) triggered the event and uses that context to modify global application state and refresh the display.
Interactive Mode
This module handles the following interactive features for drawing areas:
- Mouse Motion (
MotionNotify): If a rubber-band selection is active (Button1 held down), it continuously updates the visual feedback of the rubber band within the active drawing area (theDA). - Button 1 Press (
ButtonPress): Initiates a rubber-band selection within the active DA. - Button 1 Release (
ButtonRelease): Finalizes the rubber-band selection within the active DA. - Button 3 Press (
ButtonPress): Displays a popup menu (da_all_popup), providing context-sensitive options to the user within the active DA. - Key Presses (
KeyPress): Responds to various key presses, primarily for adjusting parameters:XK_KP_Add,XK_KP_Subtract: Adjustsqua_thresh(quality threshold) ifRTS_ANGDIFFSis the currentdisplay_stateof the active DA.XK_Up,XK_Down: Adjustsport_pc(port amplitude percentage threshold) andstbd_pc(starboard amplitude percentage threshold) ifRTS_LOG_AMPLis the currentdisplay_stateof the active DA. It also adjustsqua_threshifRTS_ANGDIFFSis thedisplay_state.XK_space: IfRTS_ANGLEis thedisplay_state, it toggles themethodfor phase-to-angle conversion between method 1 and 2 (and updatesqua_threshaccordingly) and re-primes lookup tables (prime_LUTs).
How It Works
The da_all_events function is registered as an event handler for multiple drawing area widgets.
- Event Source Identification: Upon an event, it first determines which
DrawingArea(DA1-DA4) triggered the event by comparingevent->xany.windowwith thewindowmember of eachjX_win_paramstructure. ThetheDApointer is then set to the correspondingjX_win_paramstructure. - Event Dispatch: A
switchstatement onevent->typedispatches to specific handlers for different X events. - Rubber Banding (
jX_rubber_band): Mouse motion events with Button1 pressed are used to draw a dynamic rubber band. ThetheDAstructure stores the state of the rubber band. - Parameter Adjustment: Key presses check the
display_stateof thetheDAto determine which global processing parameters (e.g.,qua_thresh,port_pc,stbd_pc,method) to modify. After modification,handle_SUBX_block()(not shown in this file, but implied for reprocessing) anddraw_view()/expose_view()are typically called to update the display. - Popup Menu (
XmMenuPosition,XtManageChild): Button3 press triggers the display of a Motif popup menu (da_all_popup). - Coordinate Scaling (
jX_scaled_values): (Though not explicitly called in the keypress handlers for parameter adjustment, itβs a common helper function injX_winfor mapping screen coordinates to data coordinates). - Redrawing (
expose_view):Exposeevents trigger a call toexpose_view, which is responsible for redrawing the contents of the drawing area. This module extensively uses global variables to communicate and modify application state across different parts of the GUI and processing logic.