Beispiel #1
0
void CodDirsCanvas::modified()
{
    if (visible()) {
        update_msgs();
        package_modified();
    }
}
void CPlayerBase::update(float elapsed) {
	PROFILE_FUNCTION("update base");
	if (camera.isValid()) {
		if (onCinematic) {
			UpdateCinematic(elapsed);
		}
		else if (controlEnabled || only_sense) {
			bool alive = !checkDead();
			if (alive && inputEnabled) {
				energy_decrease = energy_default_decrease; // Default if nobody change that this frame
				UpdateSenseVision();
				if (!only_sense) {
					UpdateMoves();
					UpdateInputActions();
				}
				setLife(getLife() - getDeltaTime() * energy_decrease);
			}
			Recalc();
			if (alive) {
				//UpdateMoves();
				myUpdate();
				update_msgs();
			}
		}
		//UpdateAnimation();
	}
}
Beispiel #3
0
void ColDiagramView::menu(const QPoint &)
{
    Q3PopupMenu m(0);

    MenuFactory::createTitle(m, TR("Communication diagram menu"));

    if ((((UmlCanvas *) canvas())->browser_diagram())->is_writable()) {
        m.insertSeparator();
        m.insertItem(TR("Edit all the messages"), 29);
    }

    switch (default_menu(m, 30)) {
    case EDIT_DRAWING_SETTING_CMD:
        ((BrowserColDiagram *) the_canvas()->browser_diagram())->edit_settings();
        break;

    case RELOAD_CMD:
        // pure drawing modifications are lost
        // mark the diagram modified because the undid modifications
        // may be saved in the file are not saved in memory
        load("Communication");
        update_msgs();
        window()->package_modified();
        break;

    case 29:
        CodEditMsgDialog::exec(this, msgs);
        break;
    }
}
Beispiel #4
0
bool CodDirsCanvas::edit_drawing_settings()
{
    for (;;) {
        StateSpecVector st;

        settings.complete_msg(st);

        SettingsDialog dialog(&st, 0, FALSE);

        dialog.raise();

        if (dialog.exec() != QDialog::Accepted)
            return FALSE;

        update_msgs();

        if (!dialog.redo())
            return TRUE;
    }
}
Beispiel #5
0
/*-------------------------- zoom ---------------------------------*/
int zoom(caddr_t data)
{
  int 	w, h, up;

  up = *((int *) data);
    
  if (up) {
    w = zWidth*2;
    h = zHeight*2;
  }
  else {
    w = zWidth/2;
    h = zHeight/2;
  }

  Resize(w,h);
  XResizeWindow(theDisp,mainW,
		w+(color_bar?color_bar_width:0),
		h+info_height);
  Window_Level(Lower,Upper);
  update_sliders();
  update_msgs();
}
Beispiel #6
0
ColDiagramView::ColDiagramView(QWidget * parent, UmlCanvas * canvas, int id)
    : DiagramView(parent, canvas, id)
{
    load("Communication");
    update_msgs();
}
Beispiel #7
0
/*----------------------- Reorient_Volume -------------------------------*/
int Reorient_Volume()
{
  int 	i, old_h, old_w, old_i, num_volumes;
  short 	*volume;
  int         vol_step;

  /* check that we have a volume */
  if ((num_images==1)||(!load_all_images)) {
    fprintf(stderr,"Only one image found!\n");
    return;
  }

  /* define new cursors */
  XDefineCursor(theDisp,mainW,waitCursor);
  XDefineCursor(theDisp,cmdW,waitCursor);
  XFlush(theDisp);
  if (Verbose) fprintf(stderr,"Volume reorientation in progress...\n");

  /* perform the reorientation */
  num_volumes = 1;
  for(i=0; i<ndimensions-3; i++){
    num_volumes *= slider_length[i];
  }
  vol_step = Width*Height*slider_length[ndimensions-3];
  for(i=0; i<num_volumes; i++){
    fprintf(stderr,"Reorienting volume: %d\r", i);
    volume = &(short_Image[i*vol_step]);
    _Reorient_Volume(volume, slider_length[ndimensions-3], 
		     Width, Height);
  }

  /* resize the color bar */
  Resize_ColorBar(color_bar_width,slider_length[ndimensions-3]);

  /* swap the width, height, and num_images variables */
  old_h=Height;
  old_w=Width;
  old_i=slider_length[ndimensions-3];
  zHeight=Height=old_i;
  zWidth=Width=old_h;
  slider_length[ndimensions-3]=old_w;
  num_images=old_w*num_volumes;
  theImage->width = theImage->bytes_per_line = zWidth;
  theImage->height = zHeight;

  /* Scale Image and Resize if necessary */
  Scale_Image(P_Min,P_Max);
  image_number=num_images/2;
  Resize(Width,Height);
  XResizeWindow(theDisp,mainW,
		Width+(color_bar?color_bar_width:0),
		Height+info_height);

  /* redraw image and clean up */
  DrawWindow(0,0,Width,Height);
  update_msgs();
  update_sliders();

  /* don't bother attempting to keep track of rotations */
  RW_valid = False;

  /* define new cursors */
  XDefineCursor(theDisp,mainW,mainCursor);
  XDefineCursor(theDisp,cmdW,cmdCursor);
  XFlush(theDisp);
}
Beispiel #8
0
/*----------------------- Rotate_Image -------------------------------*/
int Rotate_Image()
{
  int 	i, im, im_index, j, tmp;
  short	*tmp_short;
  byte	*tmp_byte;

  /* define new cursors */
  XDefineCursor(theDisp,mainW,waitCursor);
  XDefineCursor(theDisp,cmdW,waitCursor);
  XFlush(theDisp);
  if (Verbose) fprintf(stderr,"Clockwise image rotate in progress...\n");

  /* resize the color bar */
  Resize_ColorBar(color_bar_width,zWidth);

  /* malloc space */
  tmp_short = (short *) malloc(Width*Height*2);
  tmp_byte = (byte *) malloc(zWidth*zHeight*(bitmap_pad/8));

  /* Swap the width and height */
  tmp=Height;  Height=Width;  Width=tmp;
  tmp=zHeight;  zHeight=zWidth; zWidth=tmp;
  theImage->width  = zWidth;
  theImage->height = zHeight;
  theImage->bytes_per_line = zWidth*(bitmap_pad/8);

  /* perform the rotation */
  for (im=0; im<(load_all_images?num_images:1); im++) {
    if ((num_images>1)&&load_all_images) fprintf(stderr,"Rotating image %d\r",im);
    memcpy(tmp_short,&short_Image[Width*Height*im],Width*Height*2);
    memcpy(tmp_byte,&byte_Image[zWidth*zHeight*im*(bitmap_pad/8)],
	   zWidth*zHeight*(bitmap_pad/8));
    im_index=zWidth*zHeight*im*(bitmap_pad/8);
    if (bitmap_pad == 8) {
      for (i=0; i<zHeight; i++) {
	for (j=0; j<zWidth; j++) {
	  byte_Image[i*zWidth+j+im_index] = tmp_byte[(zWidth-j-1)*zHeight+i];
	}
      }
    }
    else {
      for (i=0; i<zHeight; i++) {
	for (j=0; j<zWidth; j++) {
	  byte_Image[i*zWidth*4+j*4+im_index]   = 
	    tmp_byte[(zWidth-j-1)*zHeight*4+i*4];
	  byte_Image[i*zWidth*4+j*4+im_index+1] = 
	    tmp_byte[(zWidth-j-1)*zHeight*4+i*4+1];
	  byte_Image[i*zWidth*4+j*4+im_index+2] = 
	    tmp_byte[(zWidth-j-1)*zHeight*4+i*4+2];
	  byte_Image[i*zWidth*4+j*4+im_index+3] = 
	    tmp_byte[(zWidth-j-1)*zHeight*4+i*4+3];
	}
      }
    }
    im_index=Width*Height*im;
    for (i=0; i<Height; i++) {
      for (j=0; j<Width; j++) {
	short_Image[i*Width+j+im_index] = 
	  tmp_short[(Width-j-1)*Height+i];
      }
    }
  }
  if ((num_images>1)&&load_all_images) fprintf(stderr,"                     \r");

  /* Scale Image and Resize if necessary */
  Resize(zWidth,zHeight);
  XResizeWindow(theDisp,mainW,
		zWidth+(color_bar?color_bar_width:0),
		zHeight+info_height);

  /* redraw image and clean up */
  free(tmp_short);
  free(tmp_byte);
  DrawWindow(0,0,zWidth,zHeight);
  update_msgs();

  /* don't bother attempting to keep track of rotations */
  RW_valid = False;

  /* define new cursors */
  XDefineCursor(theDisp,mainW,mainCursor);
  XDefineCursor(theDisp,cmdW,cmdCursor);
  XFlush(theDisp);
}
Beispiel #9
0
/*----------------------------- Resize -----------------------------*/
int Resize(int w, int h)
{
  byte 	*tmp_byte;
  short	*tmp_short;
  int	i;

  /* define new cursors */
  XDefineCursor(theDisp,mainW,waitCursor);
  XDefineCursor(theDisp,cmdW,waitCursor);
  XFlush(theDisp);
  if (Verbose) fprintf(stderr,"Resizing image to %dx%d\n",w,h);

  /* place reasonable bounds on the width and height */
  w = w<1 ? 1 : w;
  h = h<1 ? 1 : h;
    
  /* first resize the color bar */
  Resize_ColorBar(color_bar_width,h);  
    
  /* special case */
  if (w==zWidth && h==zHeight) {
    theImage->data=&byte_Image[zWidth*zHeight*(bitmap_pad/8)*
			      (load_all_images?image_number:0)];
  }
  else {
    /* perform the interpolation on the byte_image */
    if (Verbose) fprintf(stderr,"Interpolating image from %dx%d to %dx%d\n",
			 zWidth,zHeight,w,h);
    tmp_byte =  (byte *) malloc((bitmap_pad/8)*zWidth*zHeight*
				(load_all_images?num_images:1));
    memcpy(tmp_byte,byte_Image,
	   (bitmap_pad/8)*zWidth*zHeight*(load_all_images?num_images:1));
    free(byte_Image);
    byte_Image=(byte *) malloc((bitmap_pad/8)*w*h*(load_all_images?num_images:1));

    for (i=0; i<(load_all_images?num_images:1); i++) {
      if ((num_images>1)&&(load_all_images)) {
	fprintf(stderr,"Resizing image %d \r",i+1);
      }
      if (bitmap_pad==8) {
	if (Interpolation_Type==BILINEAR) {
	  bilinear_byte_to_byte ( &tmp_byte[zWidth*zHeight*i], zWidth, zHeight,
				  &byte_Image[w*h*i], w, h );
	}
	else {
	  nneighbour_byte_to_byte ( &tmp_byte[zWidth*zHeight*i], zWidth, zHeight,
				    &byte_Image[w*h*i], w, h );
	}
      }
      else {
	if (Interpolation_Type==BILINEAR) {
	  bilinear_rgbp_to_rgbp ( &tmp_byte[(bitmap_pad/8)*zWidth*zHeight*i], 
				  zWidth, zHeight,
				  &byte_Image[(bitmap_pad/8)*w*h*i], w, h );
	}
	else {
	  nneighbour_rgbp_to_rgbp ( &tmp_byte[(bitmap_pad/8)*zWidth*zHeight*i], 
				    zWidth, zHeight,
				    &byte_Image[(bitmap_pad/8)*w*h*i], w, h );
	}
      }
    }
    if ((num_images>1)&&(load_all_images)) {
      fprintf(stderr,"                    \r");
    }
    
    /* set theImage variables */
    theImage->data=&byte_Image[(bitmap_pad/8)*w*h*
			      (load_all_images?image_number:0)];

    /* clean up */
    free(tmp_byte);

    /* update dimensions */
    zWidth=w;
    zHeight=h;

    /* reset step size for window and level adjustment */
    steps=((P_Max-P_Min)/(2*Width)>=1) ? (P_Max-P_Min)/(2*Width): 1;
    XFlush(theDisp);                             
  }

  /* show result */
  theImage->width=w;
  theImage->height=h;
  theImage->bytes_per_line=w*(bitmap_pad/8);
  DrawWindow(0,0,zWidth,zHeight);
  Window_Level(Lower,Upper);

  /* define new cursors */
  zoom_factor_x = (float)zWidth/oWidth;
  zoom_factor_y = (float)zHeight/oHeight;
  update_msgs();
  XClearArea(theDisp, mainW, 0, zHeight,
	     zWidth,zHeight+info_height, False);
  XDefineCursor(theDisp,mainW,mainCursor);
  XDefineCursor(theDisp,cmdW,cmdCursor);
  XFlush(theDisp);    
}
Beispiel #10
0
/*---------------------------- Crop ------------------------------*/
int Crop(caddr_t data)
{
  int	i, j, index, im, im_index, w, h, x1, x2, y1, y2;

  /* check that an roi is defined */
  if (roi_present != 1) {
    fprintf(stderr,"An ROI must be drawn before cropping\n");
    return;
  }

  /* define new cursors */
  XDefineCursor(theDisp,mainW,waitCursor);
  XDefineCursor(theDisp,cmdW,waitCursor);
  XFlush(theDisp);
  fprintf(stderr,"Cropping image at (%d,%d) to (%d,%d)\n",
	  roi_x1,roi_y1,roi_x2,roi_y2);

  /* get roi corners in original image coordinates */
  if (roi_x2 < roi_x1) {
    i  = roi_x1;
    roi_x1 = roi_x2;
    roi_x2 = i;
  }
  if (roi_y2 < roi_y1) {
    i  = roi_y1;
    roi_y1 = roi_y2;
    roi_y2 = i;
  }
  x1 = roi_x1*(Width-1)/(zWidth-1);
  x2 = roi_x2*(Width-1)/(zWidth-1);
  y1 = roi_y1*(Height-1)/(zHeight-1);
  y2 = roi_y2*(Height-1)/(zHeight-1);
  crop_x = crop_x + x1;
  crop_y = crop_y + y1;

  /* perform cropping in-place */
  index=0;
  for (im=0; im<(load_all_images?num_images:1); im++) {
    if ((num_images>1)&&load_all_images) fprintf(stderr,"Cropping short image %d\r",im);
    im_index=Width*Height*im;
    for (j=y1; j<=y2; j++) {
      for (i=x1; i<=x2; i++, index++) {
	short_Image[index]=short_Image[j*Width+i+im_index];
      }
    }
  }
  if ((num_images>1)&&load_all_images) 
    fprintf(stderr,"                                          \r");

  index=0;
  for (im=0; im<(load_all_images?num_images:1); im++) {
    if ((num_images>1)&&load_all_images) fprintf(stderr,"Cropping X image %d\r",im);
    im_index=(bitmap_pad/8)*zWidth*zHeight*im;
    if (bitmap_pad==8) {
      for (j=roi_y1; j<=roi_y2; j++) {
	for (i=roi_x1; i<=roi_x2; i++) {
	  byte_Image[index++]=byte_Image[j*zWidth+i+im_index];
	}
      }
    }
    else {
      for (j=roi_y1; j<=roi_y2; j++) {
	for (i=roi_x1; i<=roi_x2; i++) {
	  byte_Image[index++]=byte_Image[j*zWidth*4+i*4+im_index];
	  byte_Image[index++]=byte_Image[j*zWidth*4+i*4+im_index+1];
	  byte_Image[index++]=byte_Image[j*zWidth*4+i*4+im_index+2];
	  byte_Image[index++]=byte_Image[j*zWidth*4+i*4+im_index+3];
	}
      }
    }

  }
  if ((num_images>1)&&load_all_images) 
    fprintf(stderr,"                                          \r");

  /* resize the color bar */
  Resize_ColorBar(color_bar_width,abs(roi_y2-roi_y1)+1);

  /* define new image dimensions */
  zWidth = theImage->width = abs(roi_x2 - roi_x1) + 1;
  theImage->bytes_per_line = (bitmap_pad/8)* (abs(roi_x2 - roi_x1) + 1);
  zHeight = theImage->height = abs(roi_y2 - roi_y1) + 1;
  theImage->data = &byte_Image[(bitmap_pad/8)*zWidth*zHeight*
			      (load_all_images?image_number:0)];
  Width = abs(x2 - x1) + 1;
  Height = abs(y2 - y1) + 1;

  /* resize window and image */
  XResizeWindow(theDisp,mainW,
		zWidth+(color_bar?color_bar_width:0),
		zHeight+info_height);
  DrawWindow(0,0,zWidth,zHeight);

  /* reset window/level step size */
  cropped = True;
  RW_valid = False;
  steps=((P_Max-P_Min)/(2*zWidth)>=1) ? (P_Max-P_Min)/(2*zWidth): 1;
  update_msgs();
  update_sliders();
    
  /* define new cursors */
  XDefineCursor(theDisp,mainW,mainCursor);
  XDefineCursor(theDisp,cmdW,cmdCursor);
  XFlush(theDisp);
}
Beispiel #11
0
/*---------------------------- HandleEvent --------------------------*/
int HandleEvent(XEvent *event)
{
  int	i;
    
  if(theEvent.xany.window==mainW) {

    switch (event->type) {
    case Expose: {
      XExposeEvent *exp_event = (XExposeEvent *) event;
 
      if (exp_event->window==mainW) {
	DrawWindow(exp_event->x,exp_event->y,
		   exp_event->width, exp_event->height);
      }
    }
    break;

    case EnterNotify: {
      if (Selected_Visual_Class==DirectColor)
	XStoreColors(theDisp,NewCmap,newC,ColorMapSize);
      if (Selected_Visual_Class!=TrueColor)
	XInstallColormap(theDisp,NewCmap);
    }
    break;
    
    case LeaveNotify: {
      if (Selected_Visual_Class==DirectColor)
	XStoreColors(theDisp,NewCmap,rootC,ColorMapSize); 
    }
    break;

    case KeyPress: {	/* allow a quit from the image window */
      Handle_KeyPress(event);
    }
    break;

    case MotionNotify: {
      Handle_Motion(event);
    }
    break;

    case ConfigureNotify: {
      XConfigureEvent *conf_event = (XConfigureEvent *) event;

      if (conf_event->window == cmdW && 
	  (conf_event->width != cmd_width ||
	   conf_event->height != cmd_height))
	XResizeWindow(theDisp,cmdW,cmd_width,cmd_height);
      if (conf_event->window == mainW && 
	  (conf_event->width != zWidth+(color_bar?color_bar_width:0) ||
	   conf_event->height != zHeight+info_height))
	Resize(conf_event->width-(color_bar?color_bar_width:0),
	       conf_event->height-info_height);
    }
    break;

    case ButtonPress: {
      if (theEvent.xbutton.button==Button1) {
	if (selzoom_active) {
	  Selective_Zoom((caddr_t)&one);
	  break;
	}
	XDefineCursor(theDisp,mainW,roiCursor);
	XFlush(theDisp);
	if (roi_present) draw_roi(roi_x1, roi_y1, roi_x2, roi_y2);
	roi_active = 1;
	roi_x1 = theEvent.xmotion.x < zWidth ?
	  (theEvent.xmotion.x>0 ?
	   theEvent.xmotion.x : 0) : zWidth-1;
	roi_y1 = theEvent.xmotion.y < zHeight ?
	  (theEvent.xmotion.y>0 ?
	   theEvent.xmotion.y : 0) : zHeight-1;
	roi_x2 = roi_x1;
	roi_y2 = roi_y1;
	draw_roi(roi_x1, roi_y1, roi_x2, roi_y2);
	break;
      } 
      if (theEvent.xbutton.button==Button2) {
	XDefineCursor(theDisp,mainW,wlCursor);
	XClearArea(theDisp,mainW,0,zHeight,
		   zWidth,zHeight+info_height,False);
	XDrawImageString(theDisp,mainW,theMGC,
			 zWidth-XTextWidth(ol_text_finfo,
					   wl_msg,strlen(wl_msg))-4,
			 zHeight+info_height-4,wl_msg,strlen(wl_msg));
	XDrawImageString(theDisp,mainW,theMGC,4,
			 zHeight+info_height-4,loc_msg,strlen(loc_msg));
	XFlush(theDisp);
	break;
      } 
      if (theEvent.xbutton.button==Button3) {
	/* note: not really 'iconic' anymore, simply map or unmap */
	if (cmdW_State==NormalState) {
	  XUnmapWindow(theDisp,cmdW);
	  cmdW_State = IconicState;
	}
	else {
	  XMapWindow(theDisp,cmdW);
	  cmdW_State = NormalState;
	}
	break;
      } 
    }
    break;

    case ButtonRelease: {
      int xa, xb, ya, yb;
      if (theEvent.xbutton.button==Button1 && roi_active) {
	roi_active = 0;
	xa = roi_x1*(Width-1)/(zWidth-1);
	xb = roi_x2*(Width-1)/(zWidth-1);
	ya = roi_y1*(Height-1)/(zHeight-1);
	yb = roi_y2*(Height-1)/(zHeight-1);
	roi_stats(xa, ya, xb, yb, 0);
	XDefineCursor(theDisp,mainW,mainCursor);
	XFlush(theDisp);
      }
      if (theEvent.xbutton.button==Button2) {
	XDefineCursor(theDisp,mainW,mainCursor);
	XFlush(theDisp);               
	if (Scale_Data && (oUpper != Upper || oLower != Lower)) {
	  Rescale();
	  Window_Level(Lower,Upper); 
	  oLower=Lower; oUpper=Upper; 
	}
	XClearArea(theDisp,mainW,0,zHeight,
		   zWidth,zHeight+info_height,False);
	if (wl_display) 
	  XDrawImageString(theDisp,mainW,theMGC,
			   zWidth-XTextWidth(ol_text_finfo,wl_msg,strlen(wl_msg))-4,
			   zHeight+info_height-4,wl_msg,strlen(wl_msg));
	XDrawImageString(theDisp,mainW,theMGC,4,
			 zHeight+info_height-4,loc_msg,strlen(loc_msg));
	update_sliders();
	update_msgs();
      }
    }
    break;

    case UnmapNotify: {
      if (bitmap_pad==8) {
	if (Interpolation_Type==BILINEAR) {
	  bilinear_byte_to_byte(byte_Image, Width, Height,
				icon_byte_image, ICON_WIDTH, ICON_HEIGHT);
	}
	else {
	  nneighbour_byte_to_byte(byte_Image, Width, Height,
				  icon_byte_image, ICON_WIDTH, ICON_HEIGHT);
	}
      }
      else {
	if (Interpolation_Type==BILINEAR) {
	  bilinear_rgbp_to_rgbp(byte_Image, Width, Height,
				icon_byte_image, ICON_WIDTH, ICON_HEIGHT);
	}
	else {
	  nneighbour_rgbp_to_rgbp(byte_Image, Width, Height,
				  icon_byte_image, ICON_WIDTH, ICON_HEIGHT);
	}
      }
      XPutImage(theDisp,iconW,theMGC,iconImage,0,0,0,0,
		ICON_WIDTH, ICON_HEIGHT);
    }
    break;
                
    case CirculateNotify:
    case MapNotify:
    case DestroyNotify:
    case GravityNotify:
    case ReparentNotify:
    default: 
    break;
    }  /* end of switch */
  }

  /* other command Window events */
  if(theEvent.xany.window==cmdW) {

    switch (event->type) {
    case Expose: {
      update_msgs();
    }
    break;

    case EnterNotify: {
      if (Selected_Visual_Class==DirectColor)
	XStoreColors(theDisp,NewCmap,newC,ColorMapSize); 
      if (Selected_Visual_Class!=TrueColor)
	XInstallColormap(theDisp,NewCmap);
    }
    break;

    case LeaveNotify: {
      if (Selected_Visual_Class==DirectColor)
	XStoreColors(theDisp,NewCmap,rootC,ColorMapSize); 
    }
    break;

    case UnmapNotify: {
      cmdW_State = IconicState;
    }
    break;
            
    case MapNotify: {
      cmdW_State = NormalState;
    }
    break;

    case ConfigureNotify: {
      XConfigureEvent *conf_event = (XConfigureEvent *) event;

      if (conf_event->window == cmdW && 
	  (conf_event->width != cmd_width ||
	   conf_event->height != cmd_height))
	XResizeWindow(theDisp,cmdW,cmd_width,cmd_height);
    }
    break;

    default: break;
    }
  }

  /* button press events */
  if (XFindContext(theDisp, theEvent.xany.window, xwin_context,
		   (caddr_t *) &which_xwin)==0) {
    if(*(which_xwin->event_handler)!=NULL)
      (*(which_xwin->event_handler))(which_xwin);
    if (Scale_Data && (oUpper != Upper || oLower != Lower)) {
      Rescale();
      oLower=Lower; oUpper=Upper;
    }
  }
}