Ejemplo n.º 1
0
static void draw (QCADDesignObject *obj, GdkDrawable *dst, GdkFunction rop)
  {
  GdkGC *gc = NULL ;
  char *pszFont = NULL ;
  GdkRectangle rc = {0} ;
  GdkRectangle rcDst = {0} ;
  GdkRectangle rcDraw = {0} ;
  QCADLabel *label = NULL ;

  if ((label = QCAD_LABEL (obj))->bShrinkWrap)
    qcad_label_shrinkwrap (label) ;

  world_to_real_rect (&(obj->bounding_box), &rc) ;
  gdk_drawable_get_size (dst, &(rcDst.width), &(rcDst.height)) ;
  if (!gdk_rectangle_intersect (&rc, &rcDst, &rcDraw)) return ;

  gc = gdk_gc_new (dst) ;
  gdk_gc_set_function (gc, rop) ;
  gdk_gc_set_clip_rectangle (gc, &rc) ;
  if (GDK_COPY == rop)
    {
    gdk_gc_set_foreground (gc, obj->bSelected ? &(QCAD_DESIGN_OBJECT_GET_CLASS (obj)->clrSelected) : &(obj->clr)) ;
    draw_string (dst, gc, pszFont = g_strdup_printf ("Courier %d", world_to_real_cy (CYFONT)),
      rc.x + XTOP_LABEL_OFFSET, rc.y + YTOP_LABEL_OFFSET, label->psz) ;
    g_free (pszFont) ;
    }
  else
    {
    if (label->bNeedsEPMDraw)
      {
      GdkGC *gcEPM = NULL ;

      label->bNeedsEPMDraw = FALSE ;
      label->epm = exp_pixmap_cond_new (label->epm, dst, rcDraw.width, rcDraw.height, -1) ;
      exp_pixmap_clean (label->epm) ;
      gcEPM = gdk_gc_new (label->epm->pixmap) ;
      gdk_gc_set_foreground (gcEPM, obj->bSelected ? &(QCAD_DESIGN_OBJECT_GET_CLASS (obj)->clrSelected) : &(obj->clr)) ;
      draw_string (label->epm->pixmap, gcEPM, pszFont = g_strdup_printf ("Courier %d", world_to_real_cy (CYFONT)),
        XTOP_LABEL_OFFSET, YTOP_LABEL_OFFSET, label->psz) ;
      g_free (pszFont) ;
      g_object_unref (gcEPM) ;
      }
    gdk_draw_drawable (dst, gc, label->epm->pixmap, 0, 0, rc.x, rc.y, rcDraw.width, rcDraw.height) ;
    }

  if (obj->bSelected)
    gdk_draw_rectangle (dst, gc, FALSE, rc.x, rc.y, rc.width - 1, rc.height - 1) ;
  gdk_gc_unref (gc) ;
  }
Ejemplo n.º 2
0
static void move (QCADDesignObject *obj, double dxDelta, double dyDelta)
  {
  int Nix, Nix1 ;
  QCADRectangleElectrode *rc_electrode = QCAD_RECTANGLE_ELECTRODE (obj) ;

  QCAD_DESIGN_OBJECT_CLASS (g_type_class_peek_parent (QCAD_DESIGN_OBJECT_GET_CLASS (obj)))->move (obj, dxDelta, dyDelta) ;

  rc_electrode->precompute_params.pt[0].xWorld += dxDelta ;
  rc_electrode->precompute_params.pt[0].yWorld += dyDelta ;
  rc_electrode->precompute_params.pt[1].xWorld += dxDelta ;
  rc_electrode->precompute_params.pt[1].yWorld += dyDelta ;
  rc_electrode->precompute_params.pt[2].xWorld += dxDelta ;
  rc_electrode->precompute_params.pt[2].yWorld += dyDelta ;
  rc_electrode->precompute_params.pt[3].xWorld += dxDelta ;
  rc_electrode->precompute_params.pt[3].yWorld += dyDelta ;

  if (NULL != rc_electrode->precompute_params.pts)
    for (Nix = 0 ; Nix < rc_electrode->n_x_divisions ; Nix++)
      for (Nix1 = 0 ; Nix1 < rc_electrode->n_y_divisions ; Nix1++)
        {
        exp_array_index_2d (rc_electrode->precompute_params.pts, WorldPoint, Nix1, Nix).xWorld += dxDelta ;
        exp_array_index_2d (rc_electrode->precompute_params.pts, WorldPoint, Nix1, Nix).yWorld += dyDelta ;
        }
  }