Example #1
0
/*----------------------------------------------------------------------
            Parameters:

           Description:
----------------------------------------------------------------------*/
static void
event_handler(Event *event, DIMAGE *dimage)
{
#if 0
  int    x, y ;
  float  scale, dx, dy ;

  x = event_x(event) ;
  y = event_y(event) ;

  scale = dimage->scale ;
  if (event_id(event) == MS_MIDDLE)
  {
    if (event_is_down(event))
    {
      if (processed)
      {
        dx = *HIPSFpix(offsetImage, x, y) ;
        dy = *HIPSFseq_pix(offsetImage, x, y, 1) ;
        XVprintf(xvf, 0, "offset at (%d, %d) = (%2.3f, %2.3f)", x, y, dx, dy) ;
      }
      else
        dx = dy = 0.0f ;

      showOffsetArea(x,y, dx, dy) ;
      switch (filter_type)
      {
      case FILTER_EXPONENTIAL:
        calculateExponentialKernel(gradImage, x, y, filter_size,
                                   filter_parm, kernelImage, dx, dy) ;
        break ;
      case FILTER_EXP_LAPLACIAN:
        calculateExponentialKernel(laplacianImage, x, y, filter_size,
                                   filter_parm, kernelImage, dx, dy) ;
        break ;
      case FILTER_EXP_SUM:
        tmpImage = HipsAdd(laplacianImage, gradImage, tmpImage) ;
        calculateExponentialKernel(tmpImage, x, y, filter_size,
                                   filter_parm, kernelImage, dx, dy) ;
        break ;
      default:
        return ;
      }

      XVshowImage(xvf, FILTER_IMAGE, kernelImage, 0) ;
      XVshowImageTitle(xvf, FILTER_IMAGE, "filter at (%d, %d)    ", x, y) ;
    }
  }
#endif
}
Example #2
0
void ShowDeadl(XButtonEvent *ie)
{
    struct p_i_l_type *from;
    struct p_i_object *pip;
    int             first = TRUE;
    char            string[LINEMAX];
	
    if (figure_modified)
		ClearDeadl();
    if (p_invars == NULL)
	{
		ShowInfoDialog("Sorry, no up-to-date Deadlocks available",mainwin);
		return;
    }
    DehighlightDeadl();
    fix_x = event_x(ie) / zoom_level;
    fix_y = event_y(ie) / zoom_level;
    if ((cur_place = near_place_obj(fix_x, fix_y)) == NULL) 
	{
		StatusPrintf("");
		ShowShowDialog("");
		return;
    }
    for (from = p_invars = p_invars->next; first || (p_invars != from);
	 first = FALSE, p_invars = p_invars->next) {
		for (pip = p_invars->i_l; pip != NULL; pip = pip->next)
			if (pip->p_p == cur_place)
				goto found;
    }
    sprintf(string,"place %s is not contained in any minimal deadlock",cur_place->tag);
	StatusPrintf(string);
	ShowShowDialog(string);
    return;
	found:
		DisplayDeadl();
}
Example #3
0
/************************************************************************
*                                                                       *
*  Mouse event Graphics-tool: Zoom.                                    	*
*  This function will be called if there is an event related to Zoom.	*
*                                                                       */
Routine_type
Zoom_routine::process(Event *e)
{
    static float left;		// Starting positions of zoom cursors
    static float right;
    static float top;
    static float bottom;
    static int prevx;
    static int prevy;
    static short firstx;	// first x mouse cursor value
    static short firsty;	// first y mouse cursor value
    static Imginfo *z_imginfo; // Hold the selected image information
    static Gframe *z_gframe;   // Hold the selected frame info
    Gframe *gframe;	// loop for selected frame
    int nth;		// loop counter
    Imginfo *iptr;	// image information pointer
    short x = event_x(e);
    short y = event_y(e);
    int nfrms;
    
    switch (event_action(e))   {
      case LOC_DRAG:
	// Execute only if there is a selected zoomed lines.
	if (Zoomf::zline == 0){
	    return(ROUTINE_FRAME_SELECT);
	}
	// Move the zoom-lines to which the cursor points
	z_imginfo->move_zlines(x - firstx, y - firsty,
			       left, right, top, bottom,
			       Zoomf::color, Zoomf::zline);
	if (Zoomf::bind){ // Move zoom-lines for all selected frames
	    nfrms = 0;
	    for (nth=1, gframe=Frame_select::get_selected_frame(nth); 
		 gframe;
		 nth++, gframe=Frame_select::get_selected_frame(nth))
	    {
		if ((iptr = gframe->imginfo)
		    && (iptr != z_imginfo)
		    && nfrms < Zoomf::max_tracks)
		{
		    iptr->replace_zlines(z_imginfo->zlinex1,
					 z_imginfo->zlinex2,
					 z_imginfo->zliney1,
					 z_imginfo->zliney2,
					 Zoomf::color);
		    nfrms++;
		}  
	    }  /* for */
	}  /* if (Zoomf::bind) */
	prevx = x;
	prevy = y;
	return(ROUTINE_DONE);
	
      case ACTION_SELECT:
	if (event_is_down(e)) {
	    // Move zoom-lines.  Note that we search for all frames
	    for (nth=1, gframe=Frame_select::get_selected_frame(nth); 
		 gframe;
		 nth++, gframe=Frame_select::get_selected_frame(nth))   {
		// A frame should contains an image and the cursor should be
		// within image boundary
		if ((iptr = gframe->imginfo)
		    && com_point_in_rect(x, y, iptr->pixstx - Zoomf::aperture,
					 iptr->pixsty - Zoomf::aperture,
					 iptr->pixstx + iptr->pixwd +
					 Zoomf::aperture,
					 iptr->pixsty + iptr->pixht +
					 Zoomf::aperture))
		{
		    // If no selected zoom-line, it means that it moves all
		    // zoom lines
		    if (!(Zoomf::zline=gframe->imginfo->select_zoom_lines(x, 
				 y, Zoomf::aperture, Zoomf::zline)))
		    {
			Zoomf::zline |= ZLINE_ALL;
		    }
		    prevx = firstx = x;
		    prevy = firsty = y;
		    z_gframe = gframe;
		    z_imginfo = gframe->imginfo;
		    left = z_imginfo->zlinex1;
		    right = z_imginfo->zlinex2;
		    top = z_imginfo->zliney1;
		    bottom = z_imginfo->zliney2;
		    return(ROUTINE_DONE);
		}  /* if com_point_in_rect(...) */
	    } /* for */
	    // Nothing to zoom
	    return(ROUTINE_FRAME_SELECT);
	} else {	// event_is_up(e)
	    // Execute only if there is a selected zoomed line.
	    if (Zoomf::zline == 0){
		return(ROUTINE_FRAME_SELECT);
	    }
	    
	    // Move the zoom-lines to which the cursor points
	    z_imginfo->move_zlines(x - firstx, y - firsty,
				   left, right, top, bottom,
				   Zoomf::color, Zoomf::zline);
	    /*z_imginfo->move_zlines(x, y, prevx, prevy, Zoomf::color, 
	      Zoomf::zline);*/
	    if (Zoomf::bind){
		// Move zoom-lines for all selected frames
		for (nth=1, gframe=Frame_select::get_selected_frame(nth); 
		     gframe;
		     nth++, gframe=Frame_select::get_selected_frame(nth))
		{
		    if ((iptr = gframe->imginfo)
			&& (iptr != z_imginfo))
		    {
			iptr->replace_zlines(z_imginfo->zlinex1,
					     z_imginfo->zlinex2,
					     z_imginfo->zliney1,
					     z_imginfo->zliney2,
					     Zoomf::color);
		    }  
		}  /* for */
	    }  /* if (Zoomf::bind) */
	    Zoomf::zline = 0;
	    return(ROUTINE_DONE);
	}  /* event_is_up */
	break;
	
	
      default:
	break;
	
    }  /* switch */
    
    return(ROUTINE_DONE);
}
Example #4
0
static void
canvas_event_proc(Xv_Window, Event *event)
{
    int i;
    register int x, y;		// location of mouse pointer on canvas
    float fx;			// Normalized location of mouse on canvas
    float fy;
    register int x0, y0;
    float dis;
    static int knot = -1;	// Which knot mouse controls (-1=>none)
    static float mctl = 0.5;	// Relative Y distance of ctl point from here
    static float fyother = 0;	// Y position of other line end

    x = (int) event_x(event);
    y = (int) event_y(event);
    fx = (float)x / (vsi.canvas_width - 1);
    fy = (float)(vsi.canvas_height - 1 - y) / (vsi.canvas_height - 1);

    switch (event_action(event)){
      case ACTION_SELECT:
      case ACTION_ADJUST:
	if (event_is_down(event)){
	    /*fprintf(stderr,"%.4f, %.4f, k=%.3f\n",
		    fx, fy, knot2logparm(fx, fy));/*CMP*/
	    /* Find out which knot we want to change */
	    /* See if mouse pointer <= 2 * G_APERTURE pixels from a knot. */
	    int tst = 4 * G_APERTURE * G_APERTURE;
	    knot = -1;
	    for (i=0; i<vsi.nknots[vsi.myknots]; i++){
		x0 = (int)(vsi.knotlists[vsi.myknots][i].x
			   * (vsi.canvas_width - 1) + 0.5);
		y0 = (int)(vsi.canvas_height
			   * (1-vsi.knotlists[vsi.myknots][i].y) + 0.5);
		if ((dis=(x-x0)*(x-x0) + (y-y0)*(y-y0)) <= tst){
		    knot = i;
		    tst = dis;
		}
	    }
	    if (vsi.myknots == LIN_KNOTS || vsi.myknots == SPL_KNOTS){
		if (event_action(event) == ACTION_SELECT){
		    if (knot < 0){
			knot = create_knot(fx, fy);
		    }
		}else{		// ACTION_ADJUST
		    // Cannot delete end points
		    if (knot > 0 && knot < vsi.nknots[vsi.myknots]-1){
			delete_knot(knot);
		    }
		    knot = -1;
		}
	    }else if (vsi.myknots == CRV_KNOTS){
		// Remember relative position of control knot
		if (knot == 0){
		    fyother = vsi.knotlists[vsi.myknots][2].y;
		}else if (knot == 2){
		    fyother = vsi.knotlists[vsi.myknots][0].y;
		}
		if (fabs(fyother - fy) > 5.0 / (1 + vsi.canvas_height)){
		    mctl = ((vsi.knotlists[vsi.myknots][1].y - fy)
			    / (fyother-fy));
		}
	    }
	}else{
	    /* (event_is_up) */
	    set_func_command();
	    func_update();
	    report_state();	// Notify client of new settings
	    knot = -1;
	    return;
	}
	break;

      case LOC_DRAG:
	if (knot == -1){
	    return;
	}
	break;

      default:
	return;
    }

    // Apply constraints to adjustment of knots
    if (fy < 0){ // Always stay on canvas
	fy = 0;
    }else if (fy > 1){
	fy = 1;
    }
    if (vsi.myknots == CRV_KNOTS){ // Special contraints for these
	if (knot == 0 || knot == 2){
	    // Keep control knot between end points
	    /*fprintf(stderr,"knot=%d, mctl=%f, fyother=%f, fy=%f\n",
		    knot, mctl, fyother, fy);/*CMP*/
	    vsi.knotlists[vsi.myknots][1].y = fy + mctl * (fyother - fy);
	}else if (knot == 1){
	    fy = bound(fy,
		       vsi.knotlists[vsi.myknots][0].y,
		       vsi.knotlists[vsi.myknots][2].y);
	}
    }
    if (knot > 0 && knot < vsi.nknots[vsi.myknots] - 1){
	// Knots cannot move past neighbors in x direction
	if (fx <= vsi.knotlists[vsi.myknots][knot-1].x){
	    fx = (vsi.knotlists[vsi.myknots][knot-1].x
		  + 1.0 / (vsi.canvas_width - 1));
	}else if (fx >= vsi.knotlists[vsi.myknots][knot+1].x){
	    fx = (vsi.knotlists[vsi.myknots][knot+1].x
		  - 1.0 / (vsi.canvas_width - 1));
	}
	vsi.knotlists[vsi.myknots][knot].x = fx;
	vsi.knotlists[vsi.myknots][knot].y = fy;
    }else if (knot == 0){	// First knot stays at left edge
	vsi.knotlists[vsi.myknots][knot].x = 0;
	vsi.knotlists[vsi.myknots][knot].y = fy;
    }else if (knot == vsi.nknots[vsi.myknots] - 1){ // Last knot at right edge
	vsi.knotlists[vsi.myknots][knot].x = 1;
	vsi.knotlists[vsi.myknots][knot].y = fy;
    }
    func_update();
}