예제 #1
0
static void draw (QCADDesignObject *obj, GdkDrawable *dst, GdkFunction rop, GdkRectangle *rcClip)
  {
  int Nix, Nix1 ;
  GdkGC *gc = NULL ;
  GdkRectangle rcReal ;
  GdkPoint ptSrc, ptDst ;
  QCADRectangleElectrode *rc_electrode = QCAD_RECTANGLE_ELECTRODE (obj) ;
  GdkColor *clr = NULL ;

  world_to_real_rect (&(obj->bounding_box), &rcReal) ;

  if (!RECT_INTERSECT_RECT (rcReal.x, rcReal.y, rcReal.width, rcReal.height, rcClip->x, rcClip->y, rcClip->width, rcClip->height))
    return ;

  clr = obj->bSelected ? clr_idx_to_clr_struct (RED) : &(obj->clr) ;
  gc = gdk_gc_new (dst) ;
  gdk_gc_set_foreground (gc, clr) ;
  gdk_gc_set_background (gc, clr) ;
  gdk_gc_set_function (gc, rop) ;
  gdk_gc_set_clip_rectangle (gc, rcClip) ;

  ptSrc.x = world_to_real_x (rc_electrode->precompute_params.pt[0].xWorld) ;
  ptSrc.y = world_to_real_y (rc_electrode->precompute_params.pt[0].yWorld) ;
  ptDst.x = world_to_real_x (rc_electrode->precompute_params.pt[1].xWorld) ;
  ptDst.y = world_to_real_y (rc_electrode->precompute_params.pt[1].yWorld) ;
  gdk_draw_line (dst, gc, ptSrc.x, ptSrc.y, ptDst.x, ptDst.y) ;
  ptSrc = ptDst ;
  ptDst.x = world_to_real_x (rc_electrode->precompute_params.pt[2].xWorld) ;
  ptDst.y = world_to_real_y (rc_electrode->precompute_params.pt[2].yWorld) ;
  gdk_draw_line (dst, gc, ptSrc.x, ptSrc.y, ptDst.x, ptDst.y) ;
  ptSrc = ptDst ;
  ptDst.x = world_to_real_x (rc_electrode->precompute_params.pt[3].xWorld) ;
  ptDst.y = world_to_real_y (rc_electrode->precompute_params.pt[3].yWorld) ;
  gdk_draw_line (dst, gc, ptSrc.x, ptSrc.y, ptDst.x, ptDst.y) ;
  ptSrc = ptDst ;
  ptDst.x = world_to_real_x (rc_electrode->precompute_params.pt[0].xWorld) ;
  ptDst.y = world_to_real_y (rc_electrode->precompute_params.pt[0].yWorld) ;
  gdk_draw_line (dst, gc, ptSrc.x, ptSrc.y, ptDst.x, ptDst.y) ;

  for (Nix = 0 ; Nix < rc_electrode->n_x_divisions ; Nix++)
    for (Nix1 = 0 ; Nix1 < rc_electrode->n_y_divisions ; Nix1++)
      {
      ptSrc.x = world_to_real_x (exp_array_index_2d (rc_electrode->precompute_params.pts, WorldPoint, Nix1, Nix).xWorld) ;
      ptSrc.y = world_to_real_y (exp_array_index_2d (rc_electrode->precompute_params.pts, WorldPoint, Nix1, Nix).yWorld) ;
      if (PT_IN_RECT (ptSrc.x, ptSrc.y, rcClip->x, rcClip->y, rcClip->width, rcClip->height))
        gdk_draw_point (dst, gc, ptSrc.x, ptSrc.y) ;
      }

  g_object_unref (gc) ;
  }
예제 #2
0
파일: Starmap.cpp 프로젝트: IcyX/bote
Sector CStarmap::GetClickedSector(const CPoint &pt)
{
	Sector result;
	result.x = result.y = -1;

	// wenn innerhalb der Karte geklickt, dann Koordinaten umrechnen
	if (PT_IN_RECT(pt, 0, 0, STARMAP_TOTALWIDTH, STARMAP_TOTALHEIGHT))
	{
		result.x = pt.x / STARMAP_SECTOR_WIDTH;
		result.y = pt.y / STARMAP_SECTOR_HEIGHT;
		AssertBotE(result.on_map());
	}

	return result;
}