static void gsr_deselect_all(Panel_item item)
{
    Select_Info *reg_work = (Select_Info*)xv_get(item,XV_KEY_DATA, PANEL_SEL_REG);
    int *new_sel,num_iteams = 1;
    int i;

    switch(reg_work->sel_type) {
    case 0:
	reg_work->num_sel = 1;
	break;
    case 1:
	reg_work->num_sel = 0;
	break;
    case 2:
	reg_work->num_sel = 2;
	break;
    }

    new_sel = (int*)Malloc(sizeof(int)*(reg_work->num_sel+1));
  
    for (i = 0;i<reg_work->num_sel;i++) {
	new_sel[i] = i;
    }

    free(reg_work->sel_reg);
    reg_work->sel_reg = new_sel;
    redraw_gsrwin(reg_work->can);

    switch(reg_work->sel_type) {
    case 1:
	event_hand_spectrum(reg_work);
	break;
    case 2:
	if (reg_work->num_wind == 1) {
	    reg_work->sel_reg[1] = 0;
	}
	redrawXcorr();
	break;
    }

    return;
}
static void Zlab_event_proc(Xv_Window window, Event *event)
{
    int itrc;
    
    itrc= (int)xv_get(window, XV_KEY_DATA, TRACK_INDEX)+lowZTrkIndex;
    if (itrc>LastTrack || traces[itrc]->wave==NULL)
	return;	/* ignore */
    switch(event_action(event)) {
    case ACTION_MENU:
    case MS_RIGHT: {
	if(event_is_up(event)) {
	    open_info_win();
	    DisplayTraceInfo(itrc);
	}
	break;
    }
    default:
	break;
    }
}
void RedrawScreen()
{
    int i;

    if(Mode_CLI) return;

    for(i=0; i < NumTracks; i++) {
	XClearWindow(theDisp, tracks[i]->xwin);
	UpdatePlotTrack(i+lowTrkIndex,tracks[i]);
	UpdateLabTrack(traces[i+lowTrkIndex],tracks[i]);
    }
    if(Mode_align) RedrawTScale();

    if(Mode_noBorder) {
	GC gc= DefaultGC(theDisp, DefaultScreen(theDisp));
	Window win= (Window)xv_get(tracesFrame, XV_XID);
	XDrawRectangle(theDisp, win, gc, 0,100, 500,500);
    }
    XFlush(theDisp);
}
/*
 * Create object `status_pu' in the specified instance.
 */
Xv_opaque
status_pu_status_pu_status_pu_create(status_pu_status_pu_objects *ip, Xv_opaque owner)
{
	extern Notify_value	status_pu_status_pu_event_callback(Xv_window, Event *, Notify_arg, Notify_event_type);
	Xv_opaque	obj;
	
	obj = xv_create(owner, FRAME_CMD,
		XV_KEY_DATA, INSTANCE, ip,
		XV_WIDTH, 543,
		XV_HEIGHT, 435,
		XV_LABEL, "CIDD Status",
		XV_SHOW, FALSE,
		FRAME_SHOW_FOOTER, FALSE,
		FRAME_SHOW_RESIZE_CORNER, TRUE,
		FRAME_CMD_PUSHPIN_IN, TRUE,
		NULL);
	xv_set(obj, WIN_CONSUME_EVENTS,
		NULL, NULL);
	notify_interpose_event_func(obj,
		(Notify_func) status_pu_status_pu_event_callback, NOTIFY_SAFE);
	xv_set(xv_get(obj, FRAME_CMD_PANEL), WIN_SHOW, FALSE, NULL);
	return obj;
}
Exemple #5
0
/************************************************************************
 *                                                                      *
 *  Process slice extraction command
 *  ( STATIC )
 *									*/
void
VolData::execute(Panel_item item, Event *)
{
    int i;
    int j;
    int k;
    int first;
    int inc;
    int last;
    int planelist[] = {front_plane, top_plane, side_plane};
    Panel_item firstlist[] = {vdat->front.first,
			      vdat->top.first,
			      vdat->side.first};
    Panel_item inclist[] = {vdat->front.inc,
			    vdat->top.inc,
			    vdat->side.inc};
    Panel_item lastlist[] = {vdat->front.last,
			     vdat->top.last,
			     vdat->side.last};

    int nslices;
    int norient = (int)xv_get(vdat->orient, PANEL_VALUE);
    for (k=0; k<3; k++){
	if (norient & (1 << planelist[k])){
	    first = num_text_value(firstlist[k]);
	    inc = num_text_value(inclist[k]);
	    last = num_text_value(lastlist[k]);
	    if (item == vdat->mip_button){
		// Do a MIP extraction
		vdat->extract_mip(planelist[k], first, last, inc);
	    }else{
		// Extract individual slices
		vdat->extract_planes(planelist[k], first, last, inc);
	    }
	}
    }
}
Exemple #6
0
/************************************************************************
*									*
*  Put a line in the macro window without making it visible.
*  If "format" is NULL, just make it visible.
*									*/
void
msgmacro_print(char *format, ...)
{
   char msgbuf[128];	/* message buffer */
   va_list vargs;	/* variable argument pointer */

   /* Create window message if it is not created */
   if (wmacromsg->popup == NULL)
   {
      msgprt_win_create(wmacromsg);
      xv_set(wmacromsg->popup,
	     FRAME_LABEL, "Macro Edit",
	     NULL);
      xv_set(wmacromsg->textsw,
	     TEXTSW_BROWSING, FALSE,
	     WIN_KBD_FOCUS, TRUE,
	     NULL);
  }

   if (format == NULL){
      xv_set(wmacromsg->popup, XV_SHOW, TRUE, NULL);
      xv_set(wmacromsg->popup, FRAME_CMD_PUSHPIN_IN, TRUE, NULL);
   }

   if (format == NULL)
      return;
   
   va_start(vargs, format);
   (void)vsprintf(msgbuf, format, vargs);
   va_end(vargs);

   int point = (int)xv_get(wmacromsg->textsw, TEXTSW_INSERTION_POINT);
   show_msg_text(wmacromsg->textsw, msgbuf);
   if (point == 0){
       xv_set(wmacromsg->textsw, TEXTSW_FIRST, point, NULL);
   }
}
Exemple #7
0
/************************************************************************
*                                                                       *
*  Creator of window.							*
*									*/
Win_movie::Win_movie(void)
{
   int xitempos;	// current panel item position
   int yitempos;	// current panel item position
   Panel_item item;	// Panel item
   int xpos, ypos;      // window position
   int name_width;      // width of filename (in pixel)
   int num_names;       // number of filenames showed at one time
   char initname[128];	// init file

   low_frame = 0 ;
   high_frame = 0 ;

   Win_movie::get_the_frame();

   (void)init_get_win_filename(initname);
   // Get the position of the control panel
   if (init_get_val(initname, "WINPRO_MOVIE", "dd", &xpos, &ypos) == NOT_OK)
   {
      xpos = 400;
      ypos = 20;
   }

   frame = xv_create(NULL, FRAME, NULL);

   popup = xv_create(frame, FRAME_CMD,
	XV_X,		xpos,
	XV_Y,		ypos,
	FRAME_LABEL,	"Movie Control",
	FRAME_DONE_PROC,	&Win_movie::done_proc,
	FRAME_CMD_PUSHPIN_IN,	TRUE,
	NULL);
   
   panel = (Panel)xv_get(popup, FRAME_CMD_PANEL);

   xitempos = 150;
   yitempos = 10;
   item = xv_create(panel,	PANEL_BUTTON,
		XV_X,		xitempos,
		XV_Y,		yitempos,
		PANEL_LABEL_STRING,	"Load Frames ...",
		PANEL_NOTIFY_PROC,	&Win_movie::movie_load,
		NULL);

   xitempos = 20;
   yitempos += (int)(DEFAULT_VERT_GAP * 1.17);
   start_stop_item = xv_create(panel, PANEL_CHOICE,
		    XV_X, xitempos,
		    XV_Y, yitempos,
		    PANEL_CHOICE_STRINGS, "REVERSE", "STOP", "FORWARD", NULL,
		    PANEL_NOTIFY_PROC, (&Win_movie::start_stop),
		    PANEL_VALUE, 1,
		    XV_SHOW, FALSE,
		    NULL);

   xitempos = 10;
   yitempos += (int)(DEFAULT_VERT_GAP * 1.17);
   delay_item = xv_create(panel, PANEL_TEXT,
	     XV_X,		xitempos,
	     XV_Y,		yitempos,
	     PANEL_LABEL_STRING,  "Frames/sec",
	     PANEL_NOTIFY_PROC, NULL,
	     PANEL_VALUE, "10",
	     PANEL_VALUE_DISPLAY_LENGTH, 5,
	     NULL);

   //xitempos = 60;
   xitempos = 10;
   yitempos += DEFAULT_VERT_GAP;
   movie_speedometer = xv_create(panel, PANEL_GAUGE,
				 XV_X, xitempos,
				 XV_Y, yitempos,
				 PANEL_LABEL_STRING, "Speed (%)  ",
				 PANEL_MIN_VALUE, 0,
				 PANEL_MAX_VALUE, 100,
				 PANEL_TICKS, 3,
				 PANEL_GAUGE_WIDTH, 100,
				 PANEL_VALUE, 0,
				 NULL);

/*
   yitempos += DEFAULT_VERT_GAP;
   xitempos += 20;
   item = xv_create(panel, PANEL_MESSAGE,
		    XV_X, xitempos,
		    XV_Y, yitempos,
		    PANEL_LABEL_STRING, "Movie speed (%)",
		    NULL);
*/

   xitempos = 10;
   yitempos += (int)(DEFAULT_VERT_GAP * 1.17);
   item = xv_create(panel, PANEL_MESSAGE,
		    XV_X, xitempos,
		    XV_Y, yitempos,
		    PANEL_LABEL_STRING, "Display frames:",
		    NULL);

   xitempos += 100;
   low_frame_item = xv_create(panel, /*PANEL_TEXT,*/ PANEL_NUMERIC_TEXT,
	     XV_X, xitempos,
	     XV_Y, yitempos,
	     PANEL_LABEL_STRING,  "First",
	     //PANEL_NOTIFY_LEVEL,  PANEL_ALL,
	     PANEL_NOTIFY_PROC, Win_movie::low_frame_set,
	     PANEL_VALUE_DISPLAY_LENGTH, 4,
	     PANEL_MIN_VALUE, 1,
	     PANEL_MAX_VALUE, 1,
	     PANEL_VALUE, 1,
	     NULL);

   xitempos += 2;
   yitempos += DEFAULT_VERT_GAP;
   high_frame_item = xv_create(panel, /*PANEL_TEXT,*/ PANEL_NUMERIC_TEXT,
	     XV_X, xitempos,
	     XV_Y, yitempos,
	     PANEL_LABEL_STRING,  "Last",
	     //PANEL_NOTIFY_LEVEL,  PANEL_ALL,
	     PANEL_NOTIFY_PROC, Win_movie::high_frame_set,
	     PANEL_VALUE_DISPLAY_LENGTH, 4,
	     PANEL_MIN_VALUE, 1,
	     PANEL_MAX_VALUE, 1,
	     PANEL_VALUE, 1,
	     NULL);

   xitempos += -25;
   yitempos += DEFAULT_VERT_GAP;
   frame_slider = xv_create(panel, PANEL_NUMERIC_TEXT, //PANEL_SLIDER,
	     XV_X, xitempos,
	     XV_Y, yitempos,
	     PANEL_LABEL_STRING, "Current",
	     PANEL_MIN_VALUE, 1,
	     PANEL_MAX_VALUE, 1,
	     //PANEL_SLIDER_WIDTH, 150,
	     //PANEL_TICKS, 2,
	     PANEL_VALUE_DISPLAY_LENGTH, 3,
	     PANEL_NOTIFY_PROC, &Win_movie::slider_slid,
	     XV_SHOW, FALSE,
	     NULL);
   
   window_fit(panel);
   window_fit(popup);
   window_fit(frame);

   xv_set(popup, XV_SHOW, TRUE, NULL);

   (void)init_get_win_filename(initname);

   // Get the initialized file-browser window position and its size
   if (init_get_val(initname, "FILE_BROWSER", "dddd", &xpos, &ypos,
       &name_width, &num_names) == NOT_OK)
   {   
      // Default
      xpos = ypos = 0;
      name_width = 0;
      num_names = 0;
   }  

   // Create frame-browser
   if (framelist_win_create(frame, xpos, ypos, name_width,
       num_names)  == NOT_OK)
   {
      STDERR("window_create_frame_browser:framelist_win_create");
      exit(1);
   }

   framelist_notify_func ((long)&Win_movie::get_name);
}
Exemple #8
0
static void
show_msg_text ( Textsw msg_textsw,
 	char  *msg_text)
{
   /********************************************************************
   LOCAL VARIABLES:

   msg            A buffer for prefixing the message text with a newline.
   max_len        The number of characters available in the text sub-window's
                  memory allocation.
   text_len       The number of characters currently used by the text sub-
                  window's displayed text.
   msg_len        The length of the message to be displayed, including the
                  added newline if present.
   insert         The insertion point of the new message in the text sub-
                  window; used to scroll the sub-window, if necessary, to
                  display (at least the start of) the new message. This needs
                  worrying about since the sub-window will NOT automatically
                  scroll up to display the new message, if it is already
                  scrolled up so that the current last line is not displayed
                  in the window!
   ***********************************************************************/
   char msg[MAX_MSG_LEN + 1];
   int  max_len,
        text_len,
        msg_len;
   Textsw_index insert;

   /* get the number of characters available in the text sub-window's memory
      allocation, and the number of characters already in the window */

   max_len  = (int)xv_get (msg_textsw, TEXTSW_MEMORY_MAXIMUM) - WIN_OVERHEAD;
   text_len = (int)xv_get (msg_textsw, TEXTSW_LENGTH);

   /* format the message for display: be sure that message */
   /* is NULL-terminated */

   msg [MAX_MSG_LEN] = '\0';

   /* The first message should not start with a new-line */
   if (text_len == 0) {
      if (msg_text[0] == '\n')
         (void)strncpy (msg, msg_text+1, MAX_MSG_LEN);
      else
         (void)strncpy (msg, msg_text, MAX_MSG_LEN);
   }
   else
      strncpy (msg, msg_text, MAX_MSG_LEN);

   /* if there is enough memory available in the text sub-window for this
      message, or room can be made by removing the oldest message(s) ... */

   if ( (msg_len = strlen (msg)) < (max_len - text_len) ||
       remove_old_msg (msg_textsw, msg_len, text_len, max_len) == TRUE) {

      /* save the index of the current insertion point in the text; the
         message will be put AFTER this location */

      insert = (Textsw_index)xv_get (msg_textsw, TEXTSW_INSERTION_POINT);

      /* move past the new line, if present, in order to display (at least
         the start of) the new message */

      if (msg[0] == '\n')
         ++insert;
 
      /* display this message in the text sub-window */

      textsw_insert (msg_textsw, msg, msg_len);

      /* normalize, if needed, the display of the messages in the window
         so that (at least the start of) the new message is displayed */

      /*
#define	_OTHER_TEXTSW_FUNCTIONS
      textsw_possibly_normalize (msg_textsw, insert);
      */
   }
   else {
      STDERR_1("Message window won't hold the following:%s", msg);
   }
}
/************************************************************************
*                                                                       *
*  Creator of window.							*
*									*/
Win_histenhance::Win_histenhance(void)
{
   Panel panel;		// panel
   int xitempos;	// current panel item position
   int yitempos;	// current panel item position
   Panel_item item;	// Panle item
   int xpos, ypos;      // window position
   char initname[128];	// init file

   (void)init_get_win_filename(initname);

   // Get the position of the control panel
   if (init_get_val(initname, "WINPRO_HIST", "dd", &xpos, &ypos) == NOT_OK)
   {
      WARNING_OFF(Sid);
      xpos = 400;
      ypos = 40;
   }

   frame = xv_create(NULL, FRAME, NULL);

   popup = xv_create(frame, FRAME_CMD,
	XV_X,		xpos,
	XV_Y,		ypos,
	FRAME_LABEL,	"Histogram-Enhancement",
	FRAME_DONE_PROC,	&Win_histenhance::done_proc,
	FRAME_CMD_PUSHPIN_IN,	TRUE,
	NULL);
   
   panel = (Panel)xv_get(popup, FRAME_CMD_PANEL);

   xitempos = 5;
   yitempos = 5;
   item = xv_create(panel,	PANEL_BUTTON,
		XV_X,		xitempos,
		XV_Y,		yitempos,
		PANEL_LABEL_STRING,	"Equalization",
		PANEL_CLIENT_DATA,	HIST_EQUALIZATION,
		PANEL_NOTIFY_PROC,	&Win_histenhance::hist_execute,
		NULL);
   yitempos += (int)xv_get(item, XV_HEIGHT) + 7;
   item = xv_create(panel,	PANEL_BUTTON,
		XV_X,		xitempos,
		XV_Y,		yitempos,
		PANEL_LABEL_STRING,	"Hyperbolization",
		PANEL_CLIENT_DATA,	HIST_HYPERBOLIZATION,
		PANEL_NOTIFY_PROC,	&Win_histenhance::hist_execute,
		NULL);
   xitempos += (int)xv_get(item, XV_WIDTH) + 8;
   yitempos = 5;
   item = xv_create(panel,	PANEL_BUTTON,
		XV_X,		xitempos,
		XV_Y,		yitempos,
		PANEL_LABEL_STRING,	"Low Intensity",
		PANEL_CLIENT_DATA,	HIST_LOWINTENSITY,
		PANEL_NOTIFY_PROC,	&Win_histenhance::hist_execute,
		NULL);
   yitempos += (int)xv_get(item, XV_HEIGHT) + 7;
   item = xv_create(panel,	PANEL_BUTTON,
		XV_X,		xitempos,
		XV_Y,		yitempos,
		PANEL_LABEL_STRING,	"High Intensity",
		PANEL_CLIENT_DATA,	HIST_HIGHINTENSITY,
		PANEL_NOTIFY_PROC,	&Win_histenhance::hist_execute,
		NULL);
   /*
   xitempos = 7;
   yitempos += (int)xv_get(item, XV_HEIGHT) + 10;
   apply_item = xv_create(panel,	PANEL_CHOICE,
		XV_X,		xitempos,
		XV_Y,		yitempos,
		PANEL_LABEL_STRING,	"Apply To",
		PANEL_CHOICE_STRINGS,	"A selected frame",
					"All selected frames",
					NULL,
		NULL);
   */

   window_fit(panel);
   window_fit(popup);
   window_fit(frame);
   xv_set(popup, XV_SHOW, TRUE, NULL);
}
static void InitXSpctrmFrame()
{
    Panel panel;
    Menu menu;
    char dash_list[2];
    
    xspctrm_frame= xv_create(tracesFrame, FRAME,
	XV_HEIGHT, xspctrmwin_h+40, XV_WIDTH, xspctrmwin_w,
	NULL);		  
    xspctrm_cvs= xv_create(xspctrm_frame, CANVAS,
	XV_X, 0, XV_Y, 40,
	CANVAS_RETAINED, TRUE,
	CANVAS_REPAINT_PROC, redrawXSpctrm,		  
	CANVAS_RESIZE_PROC, resizeXSpctrm,		  
	NULL);		  
    xspc_win= xv_get(canvas_paint_window(xspctrm_cvs), XV_XID);
    createGC( xspc_win, &xspc_gc);
    createGC( xspc_win, &xspc_dot_gc);
    dash_list[0]= 1;
    dash_list[1]= 5;
    XSetLineAttributes(theDisp, xspc_dot_gc, 1, LineOnOffDash,
		       CapRound, JoinRound);
    createGC( xspc_win, &xspc_smdot_gc);
    XSetLineAttributes(theDisp, xspc_smdot_gc, 1, LineOnOffDash,
		       CapRound, JoinRound);
    XSetDashes(theDisp, xspc_smdot_gc,2,dash_list,2);
    panel= (Panel)xv_create(xspctrm_frame, PANEL,
	XV_X, 0, XV_Y, 0, XV_HEIGHT, 40,
	NULL);
    (void)xv_create(panel, PANEL_BUTTON,
	PANEL_LABEL_STRING, "Quit",
	PANEL_NOTIFY_PROC, close_xspctrm_win,
	NULL);
    (void)xv_create(panel, PANEL_BUTTON,
	PANEL_LABEL_STRING, "Redo",
	PANEL_NOTIFY_PROC, redo_xspctrm,
	NULL);
    (void)xv_create(panel, PANEL_BUTTON,
	PANEL_LABEL_STRING, "Next",
	PANEL_NOTIFY_PROC, next_xspctrm,
	NULL);
    menu= (Menu)xv_create(NULL,MENU,
	MENU_STRINGS,
		"Linear Scale", "Log-Linear Sc", "Log Scale",
		NULL,
	MENU_NOTIFY_PROC,   scale_menu_proc,
	NULL);
    (void)xv_create(panel, PANEL_BUTTON,
	PANEL_LABEL_STRING, "Scale",
	PANEL_ITEM_MENU, menu,
	NULL);
    menu= (Menu)xv_create(NULL,MENU,
	MENU_STRINGS,
		"trace portion", "no trace",
		"taper etc.", "no taper", "grid on", "grid off",
		NULL,
	MENU_NOTIFY_PROC,   options_menu_proc,
	NULL);
    (void)xv_create(panel, PANEL_BUTTON,
	PANEL_LABEL_STRING, "Options",
	PANEL_ITEM_MENU, menu,
	NULL);
    itrc_txt= (Panel_item)xv_create(panel, PANEL_NUMERIC_TEXT,
	PANEL_LABEL_STRING, "Trc No.",
	PANEL_VALUE_DISPLAY_WIDTH, 60,			  
	NULL);
    itrc2_txt= (Panel_item)xv_create(panel, PANEL_NUMERIC_TEXT,
	PANEL_LABEL_STRING, "Trc No.",
	PANEL_VALUE_DISPLAY_WIDTH, 60,			  
	NULL);
}
Exemple #11
0
/************************************************************************
*									*
*  User has entered a filename.  If it is a directory, go into that     *
*  directory and list all directory files.  Otherwise, return to        *
*  the user function call.						*
*									*/
static void
file_execute_proc(void)
{
    static char markers[] = "/"; /* List of spurious symbols at end of names */
    char fullname[MAXPATHLEN];
    char filename[MAXPATHLEN];
    char *p;				/* Temp */
    char *q;
    char *uname;			/* user seleted filename */
    int i;
    struct stat statbuf;		/* status of a file */

    uname = (char *) xv_get(fhdl->filename, PANEL_VALUE);
    if (*uname == NULL){
	err_msg("No file name entered");
	return;
    }
    if (expand_filename(uname, filename) == NULL){
	err_msg("Can't expand filename");
	return;
    }

    // Strip off any trailing markers
    while ( (p=strpbrk(filename+strlen(filename)-1, markers))
	   && (p > filename))	// Don't remove everything
    {
	*p = 0;
    }

    if (*filename == '/'){
	// We have given a full path name
	strcpy(fullname, filename);
    }else{
	strcpy(fullname, dirname);
	strcat(fullname, "/");
	strcat(fullname, filename);
    }
    
    // Avoid uncontrolled pathname growth

    // Remove excess slashes ("//" is same as "/")
    while (p=strstr(fullname, "//")){
	// Move portion of string beyond first "/" down one place
	do{
	    *p = *(p+1);
	} while (*p++);
    }

    // Remove "/./" elements
    while (p=strstr(fullname, "/./")){
	// Move portion of string beyond "/." down two places
	do{
	    *p = *(p+2);
	} while (*p++);
    }

    // Remove trailing "/."
    i = strlen(fullname);
    if (strcmp(fullname+i-2, "/.") == 0){
	// Filename ends in "/."; cut it off
	fullname[i-2] = 0;
    }

    // Remove "/../" elements (along with preceding element)
    while (p=strstr(fullname, "/../")){
	q = p + 3;				// Point to following "/"
	while ( (*(--p) != '/') && (p > fullname) ); // Point to previous "/"
	do{
	    *p = *q++;			// Move following stuff down
	} while (*p++);
    }

    // Remove trailing "/.." (along with preceding element)
    i = strlen(fullname);
    if (strcmp(fullname+i-3, "/..") == 0){
	// Filename ends in "/.."; cut off last two elements
	for (i=0; (i<2) && (p=strrchr(fullname, '/')); i++){
	    *p = 0;
	}
    }

    // Make sure something is left of the name
    if ( *fullname == 0 ){
	strcpy(fullname, "/");
    }

    int staterr;
    if ((staterr=stat(fullname, &statbuf)) == 0
	&& (statbuf.st_mode & S_IFMT) == S_IFDIR)
    {
	strcpy(dirname, fullname);
	
	/* Get the files */
	if (file_listing(dirname) == NOT_OK){
	    err_msg("Error in file_listing");
	    return;
	}

	/* Update the directory message */
	show_dir_path(short_path(dirname));
	xv_set(fhdl->filename, PANEL_VALUE, "", NULL);

	/* Remember new default directory */
	if (curfinfo){
	    free(curfinfo->dirpath);
	    curfinfo->dirpath = strdup(dirname);
	}
    }else{
	if (curfinfo == NULL){
	    err_msg("No registered function");
	    return;
	}
	/* in this case we will only load/save one file */
	if (xv_get(fhdl->load_but, PANEL_SHOW_ITEM) == TRUE){
	    if (staterr){
		err_msg("Can't find file: %s", short_path(fullname));
		return;
	    }else if ((statbuf.st_mode & S_IFMT) != S_IFREG){
		err_msg("Error: Invalid file or directory.");
		return;
	    }else{
		if (curfinfo->loadfunc){
		    curfinfo->loadfunc(dirname, filename);
		}
	    }
	}else{
	    if (curfinfo->savefunc && (staterr||confirm_overwrite(filename))){
		curfinfo->savefunc(dirname, filename);
	    }
	}
    }
}
/* use this to redraw the whole window */
void redraw_gsrwin(Canvas what_win)
{
    int num_select = 0,select_num = 0;
    int i,j,k;
    int x,y;
    int full_width,full_height;
    int sub_width,sub_height;
    int num_hor,len_hor;
    int num_ver,len_ver;
    float y_max,y_min;

    Select_Info *sel_win = NULL;

    /* find which window we are working on */
    sel_win = find_sel_win(what_win);
    if (sel_win==NULL) {
	fprintf (stderr,"what is up with redraw no window found\n");
	return;
    }
  
    if (sel_win->num_wind == 0) {
	/* close up shop */
	fprintf(stderr,"no regions selected\n");
	return;
    }

    XClearWindow(theDisp,sel_win->wind);
    /* figure out the size of the main window */
    /* and each of the selection windows      */

    num_hor = sel_win->num_col;
    num_ver = sel_win->num_row;
    if (sel_win->num_wind>(num_hor*num_ver)) {num_hor+=1;}

    full_width = (int)xv_get(sel_win->can,CANVAS_WIDTH);
    full_height = (int)xv_get(sel_win->can,CANVAS_HEIGHT);
    sel_win->hor_size = (full_width-gsr_boarh*2)/num_hor;
    sel_win->ver_size = (full_height-gsr_boarv*2)/num_ver;
    sub_width = 2*sel_win->hor_size/3;
    sub_height = sel_win->ver_size/2;
    sel_win->trace_hbox = sub_width;
    sel_win->trace_vbox = sub_height;

    /* draw the individual traces */
    for (j = 0;j<sel_win->num_wind;j++) {
	float min,max;
	double h_scale, v_scale;

	/* figure location of window */    
	x = floor(j/num_ver);
	y = j-x*num_ver;
	x = gsr_boarh+(x+.25)*sel_win->hor_size;
	y = gsr_boarv+(y+.25)*sel_win->ver_size;

	/* figure the scale of the window */
	ind_win_max_min(&max,&min,&sel_win->regs[j],0,sel_win->regs[j].info.n_values);
	h_scale = (double)(sel_win->regs[j].info.n_values-1)/sub_width;
	v_scale = (double)(max-min)/sub_height;
	sel_win->regs[j].dcOffset = max;

	draw_ind_trace(sel_win,x,y,h_scale,v_scale,j);
    }
    /* now indicate selection locations */
    update_sel_disp (sel_win);
}
Exemple #13
0
/************************************************************************
*									*
*  This function will starts a pull-right menu from a specified		*
*  directory.  It lists all files in a menu.				*
*									*/
Menu
filelist_menu_pullright(Menu_item /*mi*/, Menu_generate op,
			u_long callback_func, char *start_dirpath)
{
   static Menu menu=NULL;

   //fprintf(stderr,"filelist_menu_pullright(): mi=%d, op=%d\n", mi, op);/*CMP*/
   if (op == MENU_DISPLAY)
   {
      Menu_item item;
      char *dirpath;

      if (start_dirpath == NULL)
	 dirpath = ".";			/* Use current directory */
      else
	 dirpath = start_dirpath;	/* Use a specified directory */

      //
      // Don't destroy old menus, may still be in use by pinned-up menus.
      // ***********************************************************
      // 		THIS IS A MEMORY LEAK
      // ***********************************************************
      // Have to figure out how to tell a menu is no longer needed.
      // Or, better, rewrite the pinnable, popup menus as popup panels
      // and then restore this commented put stuff.
      //
      //if (menu)
      //{
      //   int j;
      //   free((char *)xv_get(menu, MENU_CLIENT_DATA));
 
         /* Destroy all items in the menu				*/
         /* Note that these codes are needed because XView DOES NOT	*/
         /* destroy all items in a menu although XView manual		*/
         /* says it does.						*/
      //   for (j=(int)xv_get(menu, MENU_NITEMS); j>0; j--)
      //   {
      //      item = (Menu_item)xv_get(menu, MENU_NTH_ITEM, j);
      //      xv_set(menu, MENU_REMOVE, j, NULL);
      //      xv_destroy(item);
      //   }
      //   xv_destroy(menu);
      //} 

      if (item = add_path_to_menu(dirpath, callback_func))
      {
         menu = (Menu)xv_get(item, MENU_PULLRIGHT);
 
         /* Destroy the item since we already get its pullrigh menu	*/
         xv_destroy(item);
      }
      else
      {
         menu = xv_create(NULL, MENU,
                MENU_TITLE_ITEM,        strcpy(title, dirpath),
                MENU_STRINGS,   "<No such directory>", NULL,
                NULL);
      }
   }
   return(menu);
}
Exemple #14
0
static VsFunc *
power_scale()
{
    char buf[20];
    int bound;
    int h;
    int i;
    int j;
    int nbins;
    int ncols;
    char *string;
    float power;
    float value;
    int w;
    float x;

    h = vsi.canvas_height - 1;
    w = vsi.canvas_width - 1;

    power = knot2pwrparm(vsi.knotlists[vsi.myknots][1].x,
			 vsi.knotlists[vsi.myknots][1].y);

    sprintf(buf,"%-.3g", power);
    xv_set(vsi.power, PANEL_VALUE, buf, NULL);

    ncols = vsi.gs_num;
    if (power > 1){
	value = pow(ncols, power);
	if (value >= 1024){
	    nbins = 1024;
	}else{
	    nbins = (int)value;
	}
    }else if(power < 1){
	value = 5 * ncols / power;
	if (value >= 1024){
	    nbins = 1024;
	}else{
	    nbins = (int)value;
	}
    }else{
	nbins = ncols;
    }
    VsFunc *rtn = new VsFunc(nbins);
    string = (char *)xv_get(vsi.min_data, PANEL_VALUE);
    sscanf(string,"%f", &value);
    rtn->min_data = value;
    string = (char *)xv_get(vsi.max_data, PANEL_VALUE);
    sscanf(string,"%f", &value);
    rtn->max_data = value;
    rtn->negative = vsi.negative_val;

    x = bound = 0;
    for (i=j=0; i<ncols; i++){
	// Here is the function:
	x = pow((double)(i+1)/ncols, power);
	bound = (int)(nbins * x);
	if (bound >= nbins){
	    bound = nbins - 1;
	}
	if (vsi.negative_val){
	    for ( ; j<bound; j++){
		rtn->lookup->table[j] = vsi.gs_start + vsi.gs_num - 1 - i;
	    }
	}else{
	    for ( ; j<bound; j++){
		rtn->lookup->table[j] = i + vsi.gs_start;
	    }
	}
    }

    // Fill out the end of the curve with the last value
    if (vsi.negative_val){
	for ( ; j<nbins; j++){
	    rtn->lookup->table[j] = vsi.gs_start;
	}
    }else{
	for ( ; j<nbins; j++){
	    rtn->lookup->table[j] = ncols - 1 + vsi.gs_start;
	}
    }
    set_ouflow(rtn);

    build_curve_data(rtn);
    canvas_repaint_proc();

    return rtn;
}
Exemple #15
0
/* initialized to the variables indicated by the user. */
void
vs_win_create(Frame owner,	/* owner frame handle */
	      int x,		/* x location of window */
	      int y,		/* y location of window */
	      int wd,		/* width of canvas */
	      int ht,		/* height of canvas */
	      Siscms *siscms,	/* SIS color map */
	      int gs_start,	/* start index of greyscale map */
	      int gs_size)	/* size of greyscale map */
{
    Menu color_menu;

    /* Initialize variables */
    vsi.cm = siscms;
    vsi.gs_start = gs_start;
    vsi.gs_num = gs_size;

    if (wd == 0){
	vsi.canvas_width = 350;
    }else{
    	vsi.canvas_width = wd;
    }
    if (ht == 0){
	vsi.canvas_height = 350;
    }else{
    	vsi.canvas_height = ht;
    }

    vsi.curve_pts = (Gpoint *)malloc(sizeof(Gpoint) *  65536 * 2);
    vsi.n_curve_pts = 0;/*CMP*/
    if (!vsi.curve_pts){
	perror("vs_win_create(): Out of memory for curve_pts");
	exit(1);
    }

    vsi.popup =
    xv_create(owner, FRAME_CMD,
	      XV_X, x,
	      XV_Y, y,
	      WIN_SHOW, FALSE,
	      FRAME_LABEL, "Vertical Scaling",
	      FRAME_CMD_PUSHPIN_IN, TRUE,
	      FRAME_SHOW_RESIZE_CORNER, TRUE,
	      FRAME_SHOW_FOOTER, TRUE,
	      NULL);

    vsi.panel = (Panel) xv_get(vsi.popup, FRAME_CMD_PANEL);
    xv_set(vsi.panel, PANEL_LAYOUT, PANEL_VERTICAL, NULL);

    vsi.func_choice =
    xv_create(vsi.panel, PANEL_CHOICE,
	      PANEL_LAYOUT, PANEL_VERTICAL,
	      PANEL_CHOICE_STRINGS, "Curve", "Linear", "Spline", NULL,
	      PANEL_NOTIFY_PROC, update_callback,
	      NULL);

    vsi.negative =
    xv_create(vsi.panel, PANEL_TOGGLE,
	      /*PANEL_NEXT_COL, -1,*/
	      PANEL_CHOICE_STRINGS, "Negative", NULL,
	      PANEL_NOTIFY_PROC, update_callback,
	      NULL);

    /*Rect *rect = (Rect*)xv_get(vsi.func_choice, PANEL_CHOICE_RECT, 2);
    vsi.exponent =
    xv_create(vsi.panel, PANEL_TEXT,
	      XV_X, rect->r_left + rect->r_width + 5,
	      XV_Y, rect->r_top + 5,
	      PANEL_VALUE, "0",
	      PANEL_VALUE_DISPLAY_LENGTH, 7,
	      PANEL_VALUE_STORED_LENGTH, 7,
	      PANEL_NOTIFY_PROC, update_callback,
	      NULL);

    rect = (Rect*)xv_get(vsi.func_choice, PANEL_CHOICE_RECT, 3);
    vsi.power =
    xv_create(vsi.panel, PANEL_TEXT,
	      XV_X, rect->r_left + rect->r_width + 5,
	      XV_Y, rect->r_top + 5,
	      PANEL_VALUE, "1",
	      PANEL_VALUE_DISPLAY_LENGTH, 7,
	      PANEL_VALUE_STORED_LENGTH, 7,
	      PANEL_NOTIFY_PROC, update_callback,
	      NULL);
	      */

    // Dummy menu--the real one is created and attached below
    color_menu = (Menu)xv_create(NULL, MENU,
				 NULL);
    vsi.oflow_color =
    xv_create(vsi.panel, PANEL_BUTTON,
	      PANEL_NEXT_COL, -1,
	      PANEL_ITEM_MENU, color_menu,
	      PANEL_LABEL_STRING, "Overflow",
	      NULL);

    vsi.uflow_color =
    xv_create(vsi.panel, PANEL_BUTTON,
	      PANEL_ITEM_MENU, color_menu,
	      PANEL_LABEL_STRING, "Underflow",
	      NULL);

    vsi.min_data =
    xv_create(vsi.panel, PANEL_TEXT,
	      XV_X, 0,
	      XV_Y, ((int)xv_get(vsi.negative, XV_Y)
		     + (int)xv_get(vsi.negative, XV_HEIGHT) + 10),
	      PANEL_VALUE, "0",
	      PANEL_VALUE_DISPLAY_LENGTH, 10,
	      PANEL_VALUE_STORED_LENGTH, 10,
	      PANEL_NOTIFY_PROC, update_callback,
	      NULL);

    vsi.range_label =
    xv_create(vsi.panel, PANEL_MESSAGE,
	      XV_Y, (int)xv_get(vsi.min_data, XV_Y),
	      PANEL_LABEL_STRING, "<- Data Range ->",
	      PANEL_LABEL_BOLD, FALSE,
	      NULL);
    xv_set(vsi.range_label,
	   XV_X, (vsi.canvas_width - (int)xv_get(vsi.range_label, XV_WIDTH))/2,
	   NULL);

    vsi.max_data =
    xv_create(vsi.panel, PANEL_TEXT,
	      XV_Y, (int)xv_get(vsi.min_data, XV_Y),
	      PANEL_VALUE, "0.03",
	      PANEL_VALUE_DISPLAY_LENGTH, 10,
	      PANEL_VALUE_STORED_LENGTH, 10,
	      PANEL_NOTIFY_PROC, update_callback,
	      NULL);
    xv_set(vsi.max_data,
	   XV_X, vsi.canvas_width - (int)xv_get(vsi.max_data, XV_WIDTH),
	   NULL);

    window_fit_height(vsi.panel);

    vsi.canvas =
    xv_create(vsi.popup, 	CANVAS,
	      CANVAS_AUTO_EXPAND,	TRUE,
	      CANVAS_AUTO_SHRINK,	TRUE,
	      CANVAS_FIXED_IMAGE,	FALSE,
	      WIN_BELOW,		vsi.panel,
	      XV_HEIGHT,		vsi.canvas_height,
	      XV_WIDTH,			vsi.canvas_width,
	      CANVAS_HEIGHT,		vsi.canvas_height,
	      CANVAS_WIDTH,		vsi.canvas_width,
	      OPENWIN_SHOW_BORDERS,	FALSE,
	      CANVAS_REPAINT_PROC,	canvas_repaint_proc,
	      CANVAS_RESIZE_PROC,	canvas_resize_proc,
	      NULL);

    vsi.gdev = g_device_create(vsi.canvas, vsi.cm);
    G_Set_Op(vsi.gdev, GXcopy);

    color_menu = make_color_menu(oflow_callback);
    xv_set(vsi.oflow_color, PANEL_ITEM_MENU, color_menu, NULL);
    color_menu = make_color_menu(uflow_callback);
    xv_set(vsi.uflow_color, PANEL_ITEM_MENU, color_menu, NULL);

    xv_set(canvas_paint_window(vsi.canvas),
	   WIN_EVENT_PROC, canvas_event_proc,
	   WIN_CONSUME_EVENTS,
	     LOC_DRAG,
	     ACTION_SELECT,
	     NULL,
	   NULL);

    window_fit(vsi.canvas);
    xv_set(vsi.panel, XV_WIDTH, (int)xv_get(vsi.canvas, XV_WIDTH), NULL);
    window_fit(vsi.popup);

    vsi.uflow_cmi = vsi.gs_start;
    vsi.oflow_cmi = vsi.gs_start + vsi.gs_num - 1;

    // Note that LIN_KNOTS are same as SPL_KNOTS
    vsi.knotlists[LIN_KNOTS] = (Fpoint *)malloc(4 * sizeof(Fpoint));
    vsi.knotlists[LOG_KNOTS] = (Fpoint *)malloc(3 * sizeof(Fpoint));
    vsi.knotlists[PWR_KNOTS] = (Fpoint *)malloc(3 * sizeof(Fpoint));
    vsi.knotlists[CRV_KNOTS] = (Fpoint *)malloc(3 * sizeof(Fpoint));
    if (!vsi.knotlists[LIN_KNOTS]
	|| !vsi.knotlists[LOG_KNOTS]
	|| !vsi.knotlists[PWR_KNOTS]
	|| !vsi.knotlists[CRV_KNOTS] )
    {
	perror("vs_win_create(): Out of memory for knotlists");
	exit(1);
    }
    vsi.nknots[LIN_KNOTS] = 4;
    vsi.knotlists[LIN_KNOTS][0].x = vsi.knotlists[LIN_KNOTS][0].y = 0;
    vsi.knotlists[LIN_KNOTS][1].x = vsi.knotlists[LIN_KNOTS][1].y = 0.33;
    vsi.knotlists[LIN_KNOTS][2].x = vsi.knotlists[LIN_KNOTS][2].y = 0.67;
    vsi.knotlists[LIN_KNOTS][3].x = vsi.knotlists[LIN_KNOTS][3].y = 1;

    vsi.nknots[LOG_KNOTS] = 3;
    vsi.knotlists[LOG_KNOTS][0].x = vsi.knotlists[LOG_KNOTS][0].y = 0;
    vsi.knotlists[LOG_KNOTS][1].x = vsi.knotlists[LOG_KNOTS][1].y = 0.5;
    vsi.knotlists[LOG_KNOTS][2].x = vsi.knotlists[LOG_KNOTS][2].y = 1;

    vsi.nknots[PWR_KNOTS] = 3;
    vsi.knotlists[PWR_KNOTS][0].x = vsi.knotlists[PWR_KNOTS][0].y = 0;
    vsi.knotlists[PWR_KNOTS][1].x = vsi.knotlists[PWR_KNOTS][1].y = 0.5;
    vsi.knotlists[PWR_KNOTS][2].x = vsi.knotlists[PWR_KNOTS][2].y = 1;

    vsi.nknots[CRV_KNOTS] = 3;
    vsi.knotlists[CRV_KNOTS][0].x = vsi.knotlists[CRV_KNOTS][0].y = 0;
    vsi.knotlists[CRV_KNOTS][1].x = vsi.knotlists[CRV_KNOTS][1].y = 0.5;
    vsi.knotlists[CRV_KNOTS][2].x = vsi.knotlists[CRV_KNOTS][2].y = 1;


    func_update();
}	/* end of vs_win_create() */
void ResizeScreen(Xv_Window window, Event *event)
{
    int newht, cfght, neww, cfgw;
    char *s;
    int tsht= 30;
    int panel_width = top_panel_width;

    if (event_action(event)==WIN_REPAINT) {
	if(Mode_noBorder) {
	    GC gc= DefaultGC(theDisp, DefaultScreen(theDisp));
	    XFillRectangle(theDisp, xv_get(window,XV_XID), gc,
			   TXTCANV_WIDTH-2,0,5,FrmHeight);
	}
	return;
    }

    
    /* only handles RESIZE events for this event_proc */
    if (event_action(event)!=WIN_RESIZE) return;

    newht= (int)xv_get(tracesFrame, XV_HEIGHT);
    neww=  (int)xv_get(tracesFrame, XV_WIDTH);

    /* ignore synthetic events from window manager */
    if (event_xevent(event)->xconfigure.send_event!=TRUE) {
	int y, i, newtrkht;
	Track *trk;

	FrmHeight=newht; FrmWidth=neww;
	if((newht-panel_width-tsht)/NumTracks<30)
	    tsht= 15;
	if(Mode_align) {
	    newtrkht= (float)(newht-panel_width-tsht)/NumTracks;
	    tsht= newht-panel_width-newtrkht*NumTracks;
	}else {
	    newtrkht= (float)(newht-panel_width)/NumTracks;
	}
	y=panel_width;
	xv_set(tracesScvs, XV_X, neww-XVSBARWIDTH, XV_Y, panel_width, NULL);
	for(i=0; i < NumTracks; i++) {
	    trk= tracks[i];
	    trk->height=newtrkht; trk->width=neww-TXTCANV_WIDTH-XVSBARWIDTH;
	    if (trk->TxtCanvas) {
		if(Mode_noBorder) {
		    xv_set(trk->TxtCanvas,
			   XV_X, 0, XV_Y, y,
			   XV_WIDTH, TXTCANV_WIDTH-2,
			   XV_HEIGHT, newtrkht,
			   NULL);
		}else {
		    xv_set(trk->TxtCanvas,
			   XV_X, 0, XV_Y, y,
			   XV_WIDTH, TXTCANV_WIDTH,
			   XV_HEIGHT, newtrkht,
			   NULL);
		}
	    }
	    if (trk->canvas) {
		xv_set(trk->canvas,
		       XV_X, TXTCANV_WIDTH, XV_Y, y,
		       XV_WIDTH, neww-TXTCANV_WIDTH-19,
		       XV_HEIGHT, newtrkht,
		       NULL);
	    }
	    y+=newtrkht;
	}
	AdjustSbar();
	SetSbarPosition();
	for(i=0; i <= LastTrack; i++) {
	    /* can't do this: clipping won't work 
	     *	traces[i]->axis_needScale= 1;
	     */
	    RescaleTrace(traces[i], newtrkht, tracks[0]->width);
	}
	if (Mode_align) {
	    ResizeTScale(y, neww-19, tsht);
	}
	/* don't trust all the canvas being auto-repainted, known
	   to fail user's expectations: here's the forbidden fix,
	   but let the user control it. */
	if (Mode_Auto_redraw)
	    RedrawScreen();
    }
    return;
}
Exemple #17
0
/************************************************************************
 *                                                                       *
 *  slider_slid                                                          *
 *									*/
void
Win_movie::slider_slid(Panel_item, Event *)
{
    frame_number = (int)xv_get(frame_slider, PANEL_VALUE) - 1;
    Win_movie::show_frame() ;
}
static void CreateTrk(Frame frame, int i, int height, int width, int y)
{
    Canvas canvas, txtcanvas;
    Track *trk;
    extern Display *theDisp;
    int theScrn;

    trk= tracks[i]= (Track *)Malloc(sizeof(Track));
    if (trk==NULL) return;  /* not enuff mem */
    if (Mode_noBorder) {
	txtcanvas= (Canvas)xv_create(frame, CANVAS,
				     XV_X, 0, XV_Y, y,
				     XV_WIDTH, TXTCANV_WIDTH-2,
				     XV_HEIGHT, height,
				     /*	     CANVAS_AUTO_EXPAND, FALSE,	    -- allow for resize
					     CANVAS_AUTO_SHRINK, FALSE, */
				     OPENWIN_SHOW_BORDERS, FALSE,
				     CANVAS_X_PAINT_WINDOW, TRUE,
				     CANVAS_RETAINED, FALSE,
				     CANVAS_REPAINT_PROC, repaintTrackLabs,
				     XV_KEY_DATA, TRACK_INDEX, i,  /* for identification */
				     NULL);
	canvas= (Canvas)xv_create(frame, CANVAS,
				  XV_X, TXTCANV_WIDTH, XV_Y, y,
				  XV_WIDTH, FrmWidth-TXTCANV_WIDTH-19,
				  XV_HEIGHT, height,
				  CANVAS_X_PAINT_WINDOW, TRUE,
				  OPENWIN_SHOW_BORDERS, FALSE,
				  /*	     CANVAS_AUTO_EXPAND, FALSE,
					     CANVAS_AUTO_SHRINK, FALSE,*/
				  CANVAS_RETAINED, FALSE,
				  CANVAS_REPAINT_PROC, repaintTracks,
				  XV_KEY_DATA, TRACK_INDEX, i,  /* for identification */
				  NULL);
    }else {
	/* well, guess what? OPENWIN_SHOW_BORDERS can only be used in
	   xv_create! */
	txtcanvas= (Canvas)xv_create(frame, CANVAS,
				     XV_X, 0, XV_Y, y,
				     XV_WIDTH, TXTCANV_WIDTH,
				     XV_HEIGHT, height,
				     /*	     CANVAS_AUTO_EXPAND, FALSE,	    -- allow for resize
					     CANVAS_AUTO_SHRINK, FALSE, */
				     CANVAS_X_PAINT_WINDOW, TRUE,
				     CANVAS_RETAINED, FALSE,
				     CANVAS_REPAINT_PROC, repaintTrackLabs,
				     XV_KEY_DATA, TRACK_INDEX, i,  /* for identification */
				     NULL);
	canvas= (Canvas)xv_create(frame, CANVAS,
				  XV_X, TXTCANV_WIDTH, XV_Y, y,
				  XV_WIDTH, FrmWidth-TXTCANV_WIDTH-19,
				  XV_HEIGHT, height,
				  CANVAS_X_PAINT_WINDOW, TRUE,
				  /*	     CANVAS_AUTO_EXPAND, FALSE,
					     CANVAS_AUTO_SHRINK, FALSE,*/
				  CANVAS_RETAINED, FALSE,
				  CANVAS_REPAINT_PROC, repaintTracks,
				  XV_KEY_DATA, TRACK_INDEX, i,  /* for identification */
				  NULL);

    }
    trk->height= height;
    trk->width= width-TXTCANV_WIDTH-19;
    trk->canvas= canvas;
    trk->TxtCanvas= txtcanvas;
    trk->xwin=(Window)xv_get(canvas_paint_window(canvas),XV_XID);
    trk->txtwin=(Window)xv_get(canvas_paint_window(txtcanvas),XV_XID);

    /* standard GC */
    createGC( trk->xwin, &trk->gc);
    /* xor GC */
    createGC( trk->xwin, &trk->ovrGC);
    XSetFunction(theDisp, trk->ovrGC, GXxor);
    theScrn = DefaultScreen(theDisp);
    XSetForeground(theDisp, trk->ovrGC,
		   WhitePixel(theDisp, theScrn)^BlackPixel(theDisp, theScrn));
    /* text font for track labels */
    createGC(trk->txtwin, &trk->txtgc);
    /*    XSetFunction(theDisp, trk->txtgc, GXxor); */

    xv_set(canvas_paint_window(canvas),
	   WIN_EVENT_PROC, Cvs_event_proc,
	   WIN_CONSUME_EVENTS, KBD_DONE, KBD_USE, LOC_WINENTER,
	   LOC_WINEXIT, WIN_ASCII_EVENTS, WIN_MOUSE_BUTTONS, LOC_DRAG,
	   NULL,
	   NULL);
    xv_set(canvas_paint_window(txtcanvas),
	   WIN_EVENT_PROC, TxtCvs_event_proc,
	   WIN_CONSUME_EVENTS, WIN_MOUSE_BUTTONS,
	   NULL,
	   NULL);
}
/* do it by ResizeZTRk-- so that ZTrkHeight is set properly */
void ResizeZlab(int shrink)
{
    int iztrk, y;
    int show= ZTrkHeight>=105;
    
    y= (Mode_align && Mode_ZDisplayTScale)? ZTSHEIGHT : 0;
    for(iztrk=0; iztrk < NumZTracks; iztrk++) {
	Panel_item item0, item1, item2, item3, item4, item5;
	if (ZLab_canvas[iztrk]) {
	    int ht= (iztrk!=NumZTracks-1)? ZTrkHeight :
		ZCvsHeight-ZTrkHeight*(NumZTracks-1);
	    xv_set(ZLab_canvas[iztrk],
		   XV_Y, y, /* iztrk*ZTrkHeight */
		   XV_WIDTH, ZTrkLabWidth,
		   XV_HEIGHT, ht,
		   /*		   CANVAS_WIDTH, ZTrkLabWidth, 
				   CANVAS_HEIGHT, ZTrkHeight, */
		   NULL);
	    item0= (Panel_item)xv_get(ZLab_panel[iztrk],PANEL_FIRST_ITEM);
	    item1= (Panel_item)xv_get(item0,PANEL_NEXT_ITEM);
	    item2= (Panel_item)xv_get(item1,PANEL_NEXT_ITEM);
	    item3= (Panel_item)xv_get(item2,PANEL_NEXT_ITEM);
	    item4= (Panel_item)xv_get(item3,PANEL_NEXT_ITEM);
	    item5= (Panel_item)xv_get(item4,PANEL_NEXT_ITEM);
	    if (shrink) {
		xv_set(item0, XV_X, 5, XV_Y, ZTrkHeight - 60,
		       XV_SHOW, (show? TRUE:FALSE),
		       NULL);
		xv_set(item1, XV_X, 35, XV_Y, ZTrkHeight - 60,
		       XV_SHOW, (show? TRUE:FALSE),
		       NULL);
		xv_set(item2, XV_X, 65, XV_Y, ZTrkHeight - 60,
		       XV_SHOW, (show? TRUE:FALSE),
		       NULL);
		xv_set(item3, XV_X, 5, XV_Y, ZTrkHeight - 30,
		       XV_SHOW, (show? TRUE:FALSE),
		       NULL);
		xv_set(item4, XV_X, 35, XV_Y, ZTrkHeight - 30,
		       XV_SHOW, (show? TRUE:FALSE),
		       NULL);
		xv_set(item5, XV_X, 65, XV_Y, ZTrkHeight - 30,
		       XV_SHOW, (show? TRUE:FALSE),
		       NULL);
	    }else {
		xv_set(item5, XV_X, 65, XV_Y, ZTrkHeight - 30,
		       XV_SHOW, (show? TRUE:FALSE),
		       NULL);
		xv_set(item4, XV_X, 35, XV_Y, ZTrkHeight - 30,
		       XV_SHOW, (show? TRUE:FALSE),
		       NULL);
		xv_set(item3, XV_X, 5, XV_Y, ZTrkHeight - 30,
		       XV_SHOW, (show? TRUE:FALSE),
		       NULL);
		xv_set(item2, XV_X, 65, XV_Y, ZTrkHeight - 60,
		       XV_SHOW, (show? TRUE:FALSE),
		       NULL);
		xv_set(item1, XV_X, 35, XV_Y, ZTrkHeight - 60,
		       XV_SHOW, (show? TRUE:FALSE),
		       NULL);
		xv_set(item0, XV_X, 5, XV_Y, ZTrkHeight - 60,
		       XV_SHOW, (show? TRUE:FALSE),
		       NULL);
	    }
	    xv_set(ZLab_panel[iztrk],
		   XV_X, 1,
		   XV_HEIGHT, ht-1, NULL); /* make sure it fills the area */

	    y+= ZTrkHeight;
	}
    }
}
Exemple #20
0
/************************************************************************
 *                                                                      *
 *  Process file selection command
 *  ( STATIC )
 *									*/
void
VolData::fmenu_proc(Menu menu, Menu_item menu_item)
{
    vdat->set_data((Imginfo *)xv_get(menu_item, MENU_CLIENT_DATA), FALSE);
}
void InitZTrkLab(Frame frame)
{
    Server_image raise, lower, compress, expand, center, zero;
    int i, y;
    int show= ZTrkHeight>=105;

    ZLab_win= (Window *)Malloc(sizeof(Window)*NumZTracks);
    ZLab_canvas= (Canvas *)Malloc(sizeof(Canvas)*NumZTracks);
    ZLab_canvas2= (Canvas *)Malloc(sizeof(Canvas)*NumZTracks);
    ZLab_panel= (Panel *)Malloc(sizeof(Panel)*NumZTracks);

    if (ZLab_win==NULL || ZLab_canvas==NULL || ZLab_panel==NULL ||
	ZLab_canvas2==NULL )
	return;	    /* not enuff memory */
    /* creates button images */
    raise = (Server_image)xv_create(NULL, SERVER_IMAGE,
				    XV_WIDTH, raise_width,
				    XV_HEIGHT, raise_height,
				    SERVER_IMAGE_DEPTH, 1,
				    SERVER_IMAGE_X_BITS, raise_bits,
				    NULL);
    lower = (Server_image)xv_create(NULL, SERVER_IMAGE,
				    XV_WIDTH, lower_width,
				    XV_HEIGHT, lower_height,
				    SERVER_IMAGE_DEPTH, 1,
				    SERVER_IMAGE_X_BITS, lower_bits,
				    NULL);
    center = (Server_image)xv_create(NULL, SERVER_IMAGE,
				     XV_WIDTH, center_width,
				     XV_HEIGHT, center_height,
				     SERVER_IMAGE_DEPTH, 1,
				     SERVER_IMAGE_X_BITS, center_bits,
				     NULL);
    zero = (Server_image)xv_create(NULL, SERVER_IMAGE,
				   XV_WIDTH, zero_width,
				   XV_HEIGHT, zero_height,
				   SERVER_IMAGE_DEPTH, 1,
				   SERVER_IMAGE_X_BITS, zero_bits,
				   NULL);
    expand = (Server_image)xv_create(NULL, SERVER_IMAGE,
				     XV_WIDTH, expand_width,
				     XV_HEIGHT, expand_height,
				     SERVER_IMAGE_DEPTH, 1,
				     SERVER_IMAGE_X_BITS, expand_bits,
				     NULL);
    compress = (Server_image)xv_create(NULL, SERVER_IMAGE,
				       XV_WIDTH, compress_width,
				       XV_HEIGHT, compress_height,
				       SERVER_IMAGE_DEPTH, 1,
				       SERVER_IMAGE_X_BITS, compress_bits,
				       NULL);

    /* set up the label canvas */
    y= (Mode_align && Mode_ZDisplayTScale)? ZTSHEIGHT : 0;
    for(i=0; i < NumZTracks; i++) {
	Panel panel;
	Canvas canvas;
	Panel_item item0, item1, item2;
	int ht;

	ht= (i!=NumZTracks-1)? ZTrkHeight :
	    ZCvsHeight-ZTrkHeight*(NumZTracks-1);
	canvas = (Canvas)xv_create(frame, CANVAS,
				   XV_X, 0, XV_Y, y,		   
				   XV_WIDTH, ZTrkLabWidth,
				   XV_HEIGHT, ht,
				   /* CANVAS_WIDTH, ZTrkLabWidth,
				      CANVAS_HEIGHT, ZTrkHeight,
				      CANVAS_AUTO_EXPAND, FALSE,
				      CANVAS_AUTO_SHRINK, FALSE, */
				   CANVAS_X_PAINT_WINDOW, TRUE,
				   CANVAS_REPAINT_PROC, Zlab_repaint_proc,
				   XV_KEY_DATA, TRACK_INDEX, i,	/* for identification */
				   NULL);
	ZLab_canvas[i]= canvas;       

	panel = (Panel)xv_create(canvas, PANEL,
				 XV_X, 1,		 
				 XV_HEIGHT, ht-1,
				 XV_WIDTH, ZTrkLabWidth,
				 /* PANEL_LAYOUT, PANEL_HORIZONTAL,
				 PANEL_ITEM_X_GAP, 3,
				 PANEL_ITEM_Y_GAP, 3, */
				 NULL);
	ZLab_panel[i]= panel;

	/* raise trace */
	item0= (Panel_item)xv_create(panel, PANEL_BUTTON,
				     XV_X, 5, XV_Y, ZTrkHeight - 60,
				     PANEL_LABEL_IMAGE,	raise,
				     PANEL_NOTIFY_PROC,	Zlab_notify_raise,
				     XV_SHOW, (show? TRUE:FALSE),
				     XV_KEY_DATA, TRACK_INDEX, i,
				     NULL);

	/* lower trace */
	item1= (Panel_item)xv_create(panel, PANEL_BUTTON,
				     XV_X, 45, XV_Y, ZTrkHeight - 60,
				     PANEL_LABEL_IMAGE,	lower,
				     PANEL_NOTIFY_PROC,	Zlab_notify_lower,
				     XV_SHOW, (show? TRUE:FALSE),
				     XV_KEY_DATA, TRACK_INDEX, i,
				     NULL);

	/* center trace */
	item2= (Panel_item)xv_create(panel, PANEL_BUTTON,
				     XV_X, 65, XV_Y, ZTrkHeight - 60,
				     PANEL_LABEL_IMAGE,	center,
				     PANEL_NOTIFY_PROC,	Zlab_notify_center,
				     XV_SHOW, (show? TRUE:FALSE),
				     XV_KEY_DATA, TRACK_INDEX, i,
				     NULL);

	/* expand vertically */
	(void)xv_create(panel, PANEL_BUTTON,
			XV_X, 5, XV_Y, ZTrkHeight - 30,
			PANEL_LABEL_IMAGE,	expand,
			PANEL_NOTIFY_PROC,	Zlab_notify_expand,
			PANEL_NEXT_ROW, -1,
			XV_SHOW, (show? TRUE:FALSE),
			XV_KEY_DATA, TRACK_INDEX, i,
			NULL);

	/* compress vertically */
	(void)xv_create(panel, PANEL_BUTTON,
			XV_X, 35, XV_Y, ZTrkHeight - 30,
			PANEL_LABEL_IMAGE,	compress,
			PANEL_NOTIFY_PROC,	Zlab_notify_compress,
			XV_SHOW, (show? TRUE:FALSE),
			XV_KEY_DATA, TRACK_INDEX, i,
			NULL);

	/* zero bias and unity gain for trace */
	(void)xv_create(panel, PANEL_BUTTON,
			XV_X, 65, XV_Y, ZTrkHeight - 30,
			PANEL_LABEL_IMAGE,	zero,
			PANEL_NOTIFY_PROC,	Zlab_notify_zero,
			XV_SHOW, (show? TRUE:FALSE),
			XV_KEY_DATA, TRACK_INDEX, i,
			NULL);

	canvas = (Canvas)xv_create(canvas, CANVAS,
				   XV_X, 5, XV_Y, 10,		   
				   XV_WIDTH, ZTrkLabWidth-10,
				   XV_HEIGHT, 30, /* ZTrkHeight,*/
				   CANVAS_X_PAINT_WINDOW, TRUE,
				   CANVAS_REPAINT_PROC, Zlab_repaint_proc,
				   OPENWIN_SHOW_BORDERS, FALSE,
				   XV_KEY_DATA, TRACK_INDEX, i,	/* for identification */
				   NULL);
	xv_set(canvas_paint_window(canvas),
	       WIN_EVENT_PROC, Zlab_event_proc,
	       WIN_CONSUME_EVENTS,
	       LOC_DRAG, LOC_MOVE, WIN_ASCII_EVENTS, WIN_MOUSE_BUTTONS,
	       LOC_WINENTER, LOC_WINEXIT,
	       NULL,
	       XV_KEY_DATA, TRACK_INDEX, i,	/* for identification */
	       NULL);
	ZLab_canvas2[i]= canvas;       
	ZLab_win[i]= (Window)xv_get(canvas_paint_window(canvas),XV_XID);

	y+=ZTrkHeight;
    }
}
Exemple #22
0
/************************************************************************
 *                                                                       *
 *  Creator of window.							*
 *									*/
VolData::VolData()
{
    Panel panel;		// panel
    int xitempos;		// current panel item position
    int yitempos;		// current panel item position
    Panel_item item;		// Panel item
    int xpos, ypos;		// window position
    char initname[1024];	// init file

    gframe = NULL;
    vimage = NULL;

    // Get the initialized file of window position
    (void)init_get_win_filename(initname);

    // Get the position of the control panel
    if (init_get_val(initname, "WINPRO_SLICER", "dd", &xpos, &ypos) == NOT_OK){
	xpos = 400;
	ypos = 60;
    }

    frame = xv_create(NULL, FRAME, NULL);
    popup = xv_create(frame, FRAME_CMD,
		      XV_X,		xpos,
		      XV_Y,		ypos,
		      FRAME_LABEL,	"Slice Extraction",
		      FRAME_CMD_PUSHPIN_IN,	TRUE,
		      NULL);
    
    panel = (Panel)xv_get(popup, FRAME_CMD_PANEL);
    xv_set(panel,
	   PANEL_LAYOUT, PANEL_VERTICAL,
	   PANEL_ITEM_X_GAP, 20,
	   NULL);

    orient = xv_create(panel, PANEL_CHECK_BOX,
		     PANEL_LAYOUT, PANEL_VERTICAL,
		     PANEL_LABEL_STRING, "Orientation",
		     PANEL_CHOICE_STRINGS,
		     "xy (front)", "xz (top)", "yz (side)", NULL,
		     PANEL_VALUE, 1,
		     NULL);
    /* NB: THESE NUMBERS MUST MATCH BUTTON ORDER. */
    front_plane = 0;
    top_plane = 1;
    side_plane = 2;

    item = extract_button = xv_create(panel, PANEL_BUTTON,
				      PANEL_LABEL_STRING, "Extract Slices",
				      PANEL_NOTIFY_PROC, &VolData::execute,
				      PANEL_INACTIVE, TRUE,
				      NULL);

    xitempos = (int)xv_get(item, XV_X);
    yitempos = (int)xv_get(item, XV_Y);

    item = xv_create(panel, PANEL_MESSAGE,
		     PANEL_NEXT_COL, -1,
		     PANEL_LABEL_STRING, "First",
		     PANEL_LABEL_BOLD, TRUE,
		     NULL);

    front.first = xv_create(panel, PANEL_NUMERIC_TEXT,
		     PANEL_VALUE_DISPLAY_LENGTH, 4,
		     PANEL_MIN_VALUE, 0,
		     PANEL_MAX_VALUE, 0,
		     PANEL_NOTIFY_PROC, VolData::slice_callback,
		     NULL);

    top.first = xv_create(panel, PANEL_NUMERIC_TEXT,
		     PANEL_VALUE_DISPLAY_LENGTH, 4,
		     PANEL_MIN_VALUE, 0,
		     PANEL_MAX_VALUE, 0,
		     PANEL_NOTIFY_PROC, VolData::slice_callback,
		     NULL);

    side.first = xv_create(panel, PANEL_NUMERIC_TEXT,
		     PANEL_VALUE_DISPLAY_LENGTH, 4,
		     PANEL_MIN_VALUE, 0,
		     PANEL_MAX_VALUE, 0,
		     PANEL_NOTIFY_PROC, VolData::slice_callback,
		     NULL);

    item = xv_create(panel, PANEL_MESSAGE,
		     PANEL_NEXT_COL, -1,
		     PANEL_LABEL_STRING, "Last",
		     PANEL_LABEL_BOLD, TRUE,
		     NULL);

    front.last = xv_create(panel, PANEL_NUMERIC_TEXT,
		     PANEL_VALUE_DISPLAY_LENGTH, 4,
		     PANEL_MIN_VALUE, 0,
		     PANEL_MAX_VALUE, 0,
		     PANEL_NOTIFY_PROC, VolData::slice_callback,
		     NULL);

    top.last = xv_create(panel, PANEL_NUMERIC_TEXT,
		     PANEL_VALUE_DISPLAY_LENGTH, 4,
		     PANEL_MIN_VALUE, 0,
		     PANEL_MAX_VALUE, 0,
		     PANEL_NOTIFY_PROC, VolData::slice_callback,
		     NULL);

    side.last = xv_create(panel, PANEL_NUMERIC_TEXT,
		     PANEL_VALUE_DISPLAY_LENGTH, 4,
		     PANEL_MIN_VALUE, 0,
		     PANEL_MAX_VALUE, 0,
		     PANEL_NOTIFY_PROC, VolData::slice_callback,
		     NULL);

    item = xv_create(panel, PANEL_MESSAGE,
		     PANEL_NEXT_COL, -1,
		     PANEL_LABEL_STRING, "Incr",
		     PANEL_LABEL_BOLD, TRUE,
		     NULL);

    front.inc = xv_create(panel, PANEL_NUMERIC_TEXT,
		     PANEL_VALUE_DISPLAY_LENGTH, 4,
		     PANEL_MIN_VALUE, 1,
		     PANEL_MAX_VALUE, 1,
		     NULL);

    top.inc = xv_create(panel, PANEL_NUMERIC_TEXT,
		     PANEL_VALUE_DISPLAY_LENGTH, 4,
		     PANEL_MIN_VALUE, 1,
		     PANEL_MAX_VALUE, 1,
		     NULL);

    side.inc = xv_create(panel, PANEL_NUMERIC_TEXT,
		     PANEL_VALUE_DISPLAY_LENGTH, 4,
		     PANEL_MIN_VALUE, 1,
		     PANEL_MAX_VALUE, 1,
		     NULL);

    mip_button = xv_create(panel, PANEL_BUTTON,
			   XV_X, (xitempos +
				  (int)xv_get(extract_button, XV_WIDTH) + 5),
			   XV_Y, yitempos,
			   PANEL_LABEL_STRING, "Extract MIPs",
			   PANEL_NOTIFY_PROC, &VolData::execute,
			   PANEL_INACTIVE, TRUE,
			   NULL);

    disp_button = xv_create(panel, PANEL_BUTTON,
			    XV_X, ((int)xv_get(mip_button, XV_X)
				   + (int)xv_get(mip_button, XV_WIDTH)
				   + 5),
			    XV_Y, yitempos,
			    PANEL_LABEL_STRING, "Put 3D",
			    PANEL_NOTIFY_PROC, &VolData::enframe,
			    NULL);


    del_button = xv_create(panel, PANEL_BUTTON,
			   XV_X, ((int)xv_get(disp_button, XV_X)
				  + (int)xv_get(disp_button, XV_WIDTH)
				  + 5),
			   XV_Y, yitempos,
			   PANEL_LABEL_STRING, "Unload ...",
			   PANEL_NOTIFY_PROC, &VolData::unload,
			   NULL);

    yitempos += (int)xv_get(extract_button, XV_HEIGHT) + 5;

    file_menu = (Menu)xv_create(NULL, MENU,
				MENU_NOTIFY_PROC, &VolData::fmenu_proc,
				NULL);

    fchoice = xv_create(panel, PANEL_ABBREV_MENU_BUTTON,
			XV_X, xitempos,
			XV_Y, yitempos,
			PANEL_LABEL_STRING, "File",
			PANEL_ITEM_MENU, file_menu,
			NULL);

    pfname = xv_create(panel, PANEL_MESSAGE,
		       XV_X, (xitempos +
			      (int)xv_get(fchoice, XV_WIDTH) + 5),
		       XV_Y, yitempos,
		       PANEL_LABEL_STRING, "    *** NO DATA ***",
		       /*PANEL_LABEL_BOLD, TRUE,*/
		       NULL);

    window_fit(panel);
    window_fit(popup);
    window_fit(frame);
}
Exemple #23
0
static void
settings_update()
{
    static char *func = "";
    static float exponent = 0;
    static float power = 1;
    static float max = 0.03;
    static float min = 0;
    int i;
    char buf[20];
    char *string;
    float value;
    int ival;

    // Check for new functional form
    i = (int)xv_get(vsi.func_choice, PANEL_VALUE);
    string = (char *)xv_get(vsi.func_choice, PANEL_CHOICE_STRING, i);
    if (strcmp(string, func) != 0){
	if (func && *func){
	    free(func);
	}
	func = strdup(string);
	set_func_command();
    }

    // Check for new exponent in log function
    /*value = 0;
    string = (char *)xv_get(vsi.exponent, PANEL_VALUE);
    sscanf(string,"%f", &value);
    if (value < -100) value = -100;
    if (value > 100) value = 100;
    sprintf(buf,"%-.3g",value);
    if (value != exponent){
	exponent = value;
	xv_set(vsi.exponent, PANEL_VALUE, buf, NULL); // Set label
	// Set control knot position
	vsi.knotlists[LOG_KNOTS][1] = exp2knot(value);
	set_func_command();
	}*/

    // Check for new exponent in power function
    /*value = 0;
    string = (char *)xv_get(vsi.power, PANEL_VALUE);
    sscanf(string,"%f", &value);
    if (value < 0.01) value = 0.01;
    if (value > 100) value = 100;
    sprintf(buf,"%-.3g",value);
    if (value != power){
	power = value;
	xv_set(vsi.power, PANEL_VALUE, buf, NULL); // Set label
	vsi.knotlists[PWR_KNOTS][1] = pwr2knot(value);
	set_func_command();
	}*/

    ival = (int)xv_get(vsi.negative, PANEL_VALUE);
    if (ival != vsi.negative_val){
	vsi.negative_val = ival;
	build_background();
	set_negative_command();
    }

    value = 0;
    string = (char *)xv_get(vsi.min_data, PANEL_VALUE);
    sscanf(string,"%f", &value);
    vsi.min_data_val = value;

    value = 0;
    string = (char *)xv_get(vsi.max_data, PANEL_VALUE);
    sscanf(string,"%f", &value);
    vsi.max_data_val = value;
    if (vsi.min_data_val != min || vsi.max_data_val != max){
	min = vsi.min_data_val;
	max = vsi.max_data_val;
	set_domain_command();
    }
}
Exemple #24
0
/************************************************************************
 *                                                                       *
 *  get_name                                                              *
 *									*/
double
Win_movie::get_name(char *s1, char *s2, int where)
{
    Movie_frame *insert_point, *list_point, *newframe ;
    int zip ;
    double the_vs = 0.0;

#ifdef DMALLOC
    cerr << "v1.1 ";
    malloc_verify();
#endif

    if ((strcmp(s1,"delete")==0) && (strcmp(s2,"delete")==0)){
	if ((where<number_of_frames)&&(number_of_frames>0)){
	    insert_point = movie_head ;
	    for (zip = 0 ; zip < where ; zip++ ){
		insert_point = insert_point->nextframe ;
	    }
	    insert_point->prevframe->nextframe = insert_point->nextframe ; 
	    insert_point->nextframe->prevframe = insert_point->prevframe ; 
	    if (where==0){
		movie_head = insert_point->nextframe ;
	    }
	    delete insert_point ;
	    if (number_of_frames==1){       /* if there was only one, */
		movie_head = NULL ;          /* there are none now. */
	    }
	}
    }else{
	char *filename = new char[strlen(s1) + strlen(s2) + 2];
	strcpy(filename, s1);
	strcat(filename, "/");
	strcat(filename, s2);
    
	if (movie_head == NULL){
	    movie_head = new Movie_frame(filename);
	    delete [] filename;
	    if ((the_vs = get_stuff (movie_head)) == -1.0){
		delete movie_head ;
		movie_head = NULL;
		return (-1.0);
	    }else{
		movie_head->nextframe = movie_head ;
		movie_head->prevframe = movie_head ;
	    }
	}else{
	    insert_point = movie_head ;
	    for (zip = 0 ; zip < where ; zip++ ){
		insert_point = insert_point->nextframe ;
	    }
	    newframe = new Movie_frame(filename);
	    delete [] filename;
	    if ((the_vs = get_stuff (newframe)) == -1.0){  
		delete newframe ;
		newframe = NULL; 
		return (-1.0);
	    }else{ 
		newframe->nextframe = insert_point ;
		newframe->prevframe = insert_point->prevframe;
		insert_point->prevframe->nextframe = newframe ;
		insert_point->prevframe = newframe ;
	    }
	    
	    if (where==0){
		movie_head = newframe;
	    }
	}
    }

#ifdef DMALLOC
    cerr << "v1.2 ";
    malloc_verify();
#endif

    number_of_frames = 0 ;
    list_point = movie_head ;
    if (movie_head != NULL){
	do{
	    list_point = list_point->nextframe ;
	    number_of_frames++ ;
	} while (list_point != movie_head);
    }
    
    frame_number = high_frame = number_of_frames - 1 ;

    // If we have more than 1 frame, show frame slider and start/stop buttons

    int slider_show = number_of_frames > 1 ? TRUE : FALSE;
    xv_set(frame_slider,
	   PANEL_MAX_VALUE, number_of_frames,
	   PANEL_VALUE, number_of_frames,
	   XV_SHOW, slider_show,
	   NULL);
    xv_set(start_stop_item, XV_SHOW, slider_show, NULL);

    if (number_of_frames){
	xv_set(high_frame_item,
	       PANEL_VALUE, number_of_frames,
	       PANEL_MAX_VALUE, number_of_frames,
	       NULL);
	xv_set(low_frame_item, PANEL_MAX_VALUE, number_of_frames, NULL);
	int t = (int)xv_get(low_frame_item, PANEL_VALUE);
	if (t <= 0){
	    xv_set(low_frame_item, PANEL_VALUE, 1, NULL);
	}else if (t > number_of_frames){
	    xv_set(low_frame_item, PANEL_VALUE, number_of_frames, NULL);
	}
    }else{
	xv_set(high_frame_item, PANEL_VALUE, 1, NULL);
	xv_set(low_frame_item, PANEL_VALUE, 1, NULL);
    }

#ifdef DMALLOC
    cerr << "v1.3 ";
    malloc_verify();
#endif
    
    return the_vs;
}
Exemple #25
0
/************************************************************************
*                                                                       *
*  Create the window
*									*/
Win_math::Win_math(void)
{
    Panel panel;		// panel
    Panel_item item;	// Panle item
    int xpos, ypos;      // window position
    char initname[128];	// init file
    Frame get_base_frame();/*CMP*/

    busy = FALSE;
    //dst_frame2file = NULL;
    //src_frame2file = NULL;

    // Get the initialized file of window position
    (void)init_get_win_filename(initname);

    // Get the position of the control panel
    if (init_get_val(initname, "WINPRO_MATH", "dd", &xpos, &ypos) == NOT_OK){
	xpos = 400;
	ypos = 40;
    }

    frame = get_base_frame();

    popup = (Frame)xv_create(frame, FRAME_CMD,
			     XV_X,		xpos,
			     XV_Y,		ypos,
			     FRAME_LABEL,	"Image Math",
			     FRAME_DONE_PROC,	&Win_math::done_proc,
			     FRAME_CMD_PUSHPIN_IN,	TRUE,
			     FRAME_CMD_DEFAULT_PIN_STATE, FRAME_CMD_PIN_IN,
			     FRAME_SHOW_RESIZE_CORNER, TRUE,
			     NULL);
    
    panel = (Panel)xv_get(popup, FRAME_CMD_PANEL);
    xv_set(panel, PANEL_LAYOUT, PANEL_HORIZONTAL, NULL);

    /*Selection_requestor sel =
    xv_create(panel, SELECTION_REQUESTOR,
	      SEL_REPLY_PROC, &Win_math::selection_proc,
	      NULL);*/

    item = xv_create(panel, PANEL_BUTTON,
		     PANEL_NEXT_ROW, -1,
		     PANEL_LABEL_STRING, "Execute",
		     PANEL_NOTIFY_PROC, &Win_math::execute,
		     NULL);
    xv_set(panel, PANEL_DEFAULT_ITEM, item, NULL);

    Menu menu = xv_create(NULL, MENU,
			  MENU_GEN_PROC, &Win_math::math_menu_load_pullright,
			  NULL);
    item = xv_create(panel, PANEL_BUTTON,
		     PANEL_NEXT_ROW, -1,
		     PANEL_LABEL_STRING, "Expression",
		     PANEL_ITEM_MENU, menu,
		     NULL);

    /*window_fit(panel);*/
    window_fit_height(panel);

    expression_box =
    xv_create(popup, TEXTSW,
	      XV_X, 0,
	      WIN_BELOW, panel,
	      WIN_WIDTH, WIN_EXTEND_TO_EDGE,
	      WIN_ROWS, 3,
	      NULL);

    /*xv_set(panel, WIN_BELOW, expression_box, NULL);*/

    window_fit(popup);
}
Exemple #26
0
/************************************************************************
*                                                                       *
*  Process arithmetic.							*
*  (STATIC)								*
*									*/
void
Win_arith::arith_execute(Panel_item item)
{
   Gframe *src1, *src2, *dst;	// source and destination frames
   int apply_on;		// 0: image <op> contsant
				// 1: image <op> image
   Arithtype optype;		// operation type

   apply_on = (int)xv_get(winarith->apply_item, PANEL_VALUE);

   // For image & constant, assign the first item of the frame containing 
   // data to be the source.  Then assign second item of the frame to be
   // the destination.  If only 1 frame is selected, source and 
   // destination are the same.  For 2 images, assign the first two frames
   // to be sources and the third one to be destination.  If only two
   // frames are selected, assign the second one to be destination
   // (Note that the first, second, third items depend on the order
   // you select the frame.)

   src1 = Frame_select::get_selected_frame(1);

   if (src1 == NULL)
   {
      msgerr_print("arith_execute:No frame is being selected.");
      return;
   }
   else if (src1->imginfo == NULL)
   {
      msgerr_print("arith_execute:Source 1 doesn't contain image");
      return;
   }

   if (apply_on == 1)	// image <op> constant
   {
      if ((dst = Frame_select::get_selected_frame(2)) == NULL)
         dst = src1;
      
      // Only let maximum two selected frame active at a time
      if (Frame_select::get_selected_frame(3))
      {
	 msgerr_print("arith_execute:Maximum 2 frames can be selected at this process");
	 return;
      }
   }
   else			// image <op> image
   {
      if ((src2 = Frame_select::get_selected_frame(2)) == NULL)
      {
         msgerr_print("arith_execute:Source 2 is not selected");
	 return;
      }
      else if (src2->imginfo == NULL)
      {
         msgerr_print("arith_execute:Source 2 doesn't contain image");
         return;
      }

      if ((dst = Frame_select::get_selected_frame(3)) == NULL)
         dst = src2;

      // Only let maximum three selected frame active at a time
      if (Frame_select::get_selected_frame(4))
      {
	 msgerr_print("arith_execute:Maximum 3 frames can be selected at this process");
	 return;
      }
   }

   optype = (Win_arith::Arithtype)xv_get(item, PANEL_CLIENT_DATA);

   // Processing beginnin
   win_print_msg("Arithmetic: Processing.......");

   if (apply_on == 1)
   {
      float const_val = (float)atof((char *)xv_get(winarith->constant_item, 
			   PANEL_VALUE));
      operation_image_and_const(optype, src1, const_val, dst);
   }
   else
      operation_two_images(optype, src1, src2, dst);

   // Display the resul image in the destination frame.  Note that we
   // obtain its information (starting data pointm width and height of
   // data) from source image.
   Frame_data::display_data(dst, src1->imginfo->datastx,
         src1->imginfo->datasty, src1->imginfo->datawd,
         src1->imginfo->dataht, dst->imginfo->vs);

   win_print_msg("Arithmetic: Done.");
}
Exemple #27
0
/************************************************************************
*                                                                       *
*  Creator of window.							*
*									*/
Win_arith::Win_arith(void)
{
   Panel panel;		// panel
   int xitempos;	// current panel item position
   int yitempos;	// current panel item position
   Panel_item item;	// Panle item
   int xpos, ypos;      // window position
   char initname[128];	// init file

   // Get the initialized file of window position
   (void)init_get_win_filename(initname);

   // Get the position of the control panel
   if (init_get_val(initname, "WINPRO_ARITH", "dd", &xpos, &ypos) == NOT_OK)
   {
      xpos = 400;
      ypos = 40;
   }

   frame = xv_create(NULL, FRAME, NULL);

   popup = xv_create(frame, FRAME_CMD,
	XV_X,		xpos,
	XV_Y,		ypos,
	FRAME_LABEL,	"Arithmetic",
	FRAME_DONE_PROC,	&Win_arith::done_proc,
	FRAME_CMD_PUSHPIN_IN,	TRUE,
	NULL);
   
   panel = (Panel)xv_get(popup, FRAME_CMD_PANEL);

   xitempos = 5;
   yitempos = 5;
   item = xv_create(panel,	PANEL_BUTTON,
		XV_X,		xitempos,
		XV_Y,		yitempos,
		PANEL_LABEL_STRING,	"Add",
		PANEL_CLIENT_DATA,	ARITH_ADDITION,
		PANEL_NOTIFY_PROC,	&Win_arith::arith_execute,
		NULL);
   xitempos += (int)xv_get(item, XV_WIDTH) + 5;
   item = xv_create(panel,	PANEL_BUTTON,
		XV_X,		xitempos,
		XV_Y,		yitempos,
		PANEL_LABEL_STRING,	"Subtract",
		PANEL_CLIENT_DATA,	ARITH_SUBTRACTION,
		PANEL_NOTIFY_PROC,	&Win_arith::arith_execute,
		NULL);
   xitempos += (int)xv_get(item, XV_WIDTH) + 5;
   item = xv_create(panel,	PANEL_BUTTON,
		XV_X,		xitempos,
		XV_Y,		yitempos,
		PANEL_LABEL_STRING,	"Multiply",
		PANEL_CLIENT_DATA,	ARITH_MULTIPLICATION,
		PANEL_NOTIFY_PROC,	&Win_arith::arith_execute,
		NULL);
   xitempos += (int)xv_get(item, XV_WIDTH) + 5;
   item = xv_create(panel,	PANEL_BUTTON,
		XV_X,		xitempos,
		XV_Y,		yitempos,
		PANEL_LABEL_STRING,	"Divide",
		PANEL_CLIENT_DATA,	ARITH_DIVISION,
		PANEL_NOTIFY_PROC,	&Win_arith::arith_execute,
		NULL);
   xitempos = 7;
   yitempos += (int)xv_get(item, XV_HEIGHT) + 10;
   apply_item = xv_create(panel,	PANEL_CHOICE_STACK,
		XV_X,		xitempos,
		XV_Y,		yitempos,
		PANEL_LABEL_STRING,	"Operands:",
	        PANEL_CHOICE_STRINGS,	"Image <op> Image",
			  		"Image <op> Constant",
					NULL,
		PANEL_NOTIFY_PROC,	&Win_arith::apply_proc,
		NULL);

   xitempos += (int)xv_get(apply_item, XV_WIDTH) + 5;
   yitempos += 5;
   constant_item = xv_create(panel,	PANEL_TEXT,
		XV_X,		xitempos,
		XV_Y,		yitempos,
		PANEL_LABEL_STRING,	"",
		PANEL_VALUE,		"0",
		PANEL_VALUE_DISPLAY_LENGTH, 6,
		PANEL_SHOW_ITEM, FALSE,
		NULL);

   window_fit(panel);
   window_fit(popup);
   window_fit(frame);
   xv_set(popup, XV_SHOW, TRUE, NULL);
}
Exemple #28
0
/************************************************************************
*									*
*  Execute user selcted menu.						*
*									*/
void
Zoom_routine::menu_handler(Menu, Menu_item i)
{
   Zoom_props props = (Zoom_props)xv_get(i, MENU_CLIENT_DATA);
   switch (props)
   {
      case Z_ZOOM:
      case Z_UNZOOM:
	 Zoomf::zoom_image(props);
	 break;

      case Z_BIND:
	 if (Zoomf::bind){
	     xv_set(i, MENU_STRING, "Bind", NULL);
	     Zoomf::bind = FALSE;
	 }else{
	     xv_set(i, MENU_STRING, "Unbind", NULL);
	     Zoomf::bind = TRUE;
	 }
	 break;

      case Z_COLOR:
	 inputwin_show((int)Z_COLOR, &Zoomf::set_attr,
	    "Zoom-Line-Color (Range: 0 - 255)");
         break;

      case Z_APERTURE:
	 inputwin_show((int)Z_APERTURE, &Zoomf::set_attr, 
	    "Zoom Cursor Tolerance (Range: 1 - 20)");
         break;

      case Z_TRACKING:
	 inputwin_show((int)Z_TRACKING, &Zoomf::set_attr, 
	    "Max Tracking Zooms (Range: 0 - 200)");
         break;

      case Z_FACTOR:
	 inputwin_show((int)Z_FACTOR, &Zoomf::set_attr, 
	    "Zoom mag. factor (Range: 1 < f <= 5)");
         break;

      case Z_REPLICATE:
	 xv_set(i,
		MENU_STRING, "Pixel Interpolation",
		MENU_CLIENT_DATA, Z_INTERPOLATE,
		NULL);
	 dont_smooth();
	 //smooth_zooms = FALSE ;
         break;

      case Z_INTERPOLATE:
	 xv_set(i,
		MENU_STRING, "Pixel Replication",
		MENU_CLIENT_DATA, Z_REPLICATE,
		NULL);
	 smooth();
	 //smooth_zooms = TRUE ;
         break;
	   
      case Z_FULLSCREEN:		// These cases should not occur
      case Z_UNFULLSCREEN:
      default:
	 break;
   }
}
static void in_notify_proc()
{
    char *s= (char *)xv_get(in_text, PANEL_VALUE);
    strncpy(in_buf, s, in_numch);
    if (in_loop) xv_window_return(0);
}
Exemple #30
0
/************************************************************************
*									*
*  User has entered part of the filename, and this routine tries to     *
*  complete a filename from the current directory.  If it finds more    *
*  than one filename to complete,  it will list them in the panel list
*  window.								*
*									*/
static void
file_complete_name(void)
{
    char fractname[128];		/* fraction user name */
    int fractnamlen;			/* fraction user name length */
    register struct dirent *dp; /* directory info pointer for each file */
    DIR *dirptr;			/* directory file pointer */
    struct stat statbuf;		/* status of a file */
    int nfile;				/* number of files */
    char *filename[MAX_FILE];		/* pointer to a filename */
    int i;				/* loop counter */

    (void) strcpy(fractname, (char *) xv_get(fhdl->filename, PANEL_VALUE));
    if ((fractnamlen = strlen(fractname)) == 0)
	return;

    /* open the directory */
    if ((dirptr = opendir(dirname)) == NULL){
	char dirbuf[MAXPATHLEN];

	err_msg("Cannot open %s", short_path(getcwd(dirbuf,MAXPATHLEN)));
	return;
    }
    nfile = 0;
    for (dp = readdir(dirptr); dp != NULL; dp = readdir(dirptr)){
	if (strncmp(dp->d_name, fractname, fractnamlen) == 0){
	    (void) stat(dp->d_name, &statbuf);
	    if ((statbuf.st_mode & S_IFMT) == S_IFDIR){
		if ((filename[nfile] = (char *) malloc(strlen(dp->d_name) + 2))
		    == NULL) {
		    PERROR("file_complte_name:malloc");
		    file_free(filename, nfile);
		    closedir(dirptr);
		    return;
		}
		(void) sprintf(filename[nfile], "%s/", dp->d_name);
	    }else{
		if ((filename[nfile] = strdup(dp->d_name)) == NULL){
		    PERROR("file_complte_name:strdup");
		    file_free(filename, nfile);
		    closedir(dirptr);
		    return;
		}
	    }
	    if (nfile++ == (MAX_FILE - 2)){
		err_msg("Only can list %d maximum files", MAX_FILE);
		break;
	    }
	}
    }

    if (nfile == 0){			/* NO such fractional filename */
	err_msg("No such fractional filename: %s", fractname);
	return;
    }
    if (nfile == 1){			/* We can complete filename */
	xv_set(fhdl->filename, PANEL_VALUE, filename[0], NULL);
    }else{				/* More than one filename found */
	char c0;			/* the first filename character */
	char ch;			/* the rest of the filename
					   character */

	/* Try to complete the fractional filename as many characters  */
	/* as possible.  The idea is to compare all the filenames      */
	/* starting at the position of the 'fractnamlen'.              */
	while (1){
	    /* A character to be checked (for the first filename) */
	    if ((c0 = *(filename[0] + fractnamlen)) == 0)
		break;

	    for (i = 1; i < nfile; i++){
		ch = *(filename[i] + fractnamlen);
		if ((ch == 0) || (ch != c0))
		    goto STOP_COMPLETE;
	    }

	    /* All filenames have the same character at 'fractnamlen' */
	    fractname[fractnamlen++] = c0;
	    fractname[fractnamlen] = 0;
	}

STOP_COMPLETE:

	/* Update the user fractional filename */
	xv_set(fhdl->filename, PANEL_VALUE, fractname, NULL);

	/* Update the panel list to all matching filenames */
	file_list_update(filename, nfile);
    }

    /* Free the filenames */
    file_free(filename, nfile);
}