Beispiel #1
0
gboolean button_pressed_ACTION_ROTATE (GtkWidget *widget, GdkEventButton *event, gpointer data)
  {
  project_OP *project_options = (project_OP *)data ;
  QCADDesignObject *htobj = NULL ;
  GdkRegion *rgn = NULL ;

  if (NULL != (htobj = QCAD_DESIGN_OBJECT (design_hit_test (project_options->design, event->x, event->y))))
    if (QCAD_IS_CELL (htobj))
      {
      GdkRectangle rcReal ;
      selection_renderer_draw (project_options->srSelection, project_options->design, widget->window, GDK_XOR) ;
      qcad_cell_rotate_dots (QCAD_CELL (htobj), PI / 4.0) ;
      selection_renderer_update (project_options->srSelection, project_options->design) ;
      selection_renderer_draw (project_options->srSelection, project_options->design, widget->window, GDK_XOR) ;

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

      rgn = gdk_region_new () ;
      gdk_region_union_with_rect (rgn, &rcReal) ;

      // redraw_async takes care of destroying rgn
      redraw_async (rgn) ;
      }

  return FALSE ;
  }
Beispiel #2
0
static gboolean qcad_layer_do_container_add (QCADDOContainer *container, QCADDesignObject *obj)
  {
  GList *lstIter = NULL ;
  OBJECT_TRACK_STRUCT *ots = NULL ;
  QCADLayer *layer = NULL ;
  QCADDesignObject *obj_child = NULL ;

  if (!QCAD_IS_LAYER (container)) return FALSE ;
  layer = QCAD_LAYER (container) ;
  if (NULL == obj) return FALSE ;
  ots = g_object_get_data (G_OBJECT (obj), "ots") ;

  if (NULL != ots)
    {
    if (NULL != ots->parent)
      if (QCAD_IS_DO_CONTAINER (ots->parent))
        return qcad_do_container_add (QCAD_DO_CONTAINER (ots->parent), obj) ;

    // If the layers don't match, we need to move the object to this layer
    if (ots->layer == layer)
      {
      // If we're re-adding the object to its layer, then we merely simulate its (de)selection
      if (NULL != ots->layer)
        {
/*        DBG_REFS (fprintf (stderr, "qcad_layer_add_object:refin-inf object 0x%08X so as to re-add to layer\n", (int)obj)) ;*/
        g_object_ref (G_OBJECT (obj)) ;
        if (NULL != ots->llDeSel)
          ots->llDeSel->data = obj ;
/*        qcad_design_object_selected (obj, ots) ;*/
        return TRUE ;
        }
      }
    }

  // Rules for cells
  if (QCAD_IS_CELL (obj))
    {
    if (layer->type != LAYER_TYPE_CELLS)
      return FALSE ;
/*    else*/
    // If the object is selected, we don't care that it overlaps, because it's floating
/*    if (!(obj->bSelected))*/
/*      {*/
/*#ifdef ALLOW_UNSERIALIZE_OVERLAP*/
/*      if (!(layer->bAllowOverlap))*/
//#endif  def ALLOW_UNSERIALIZE_OVERLAP 
/*      for (lstIter = layer->lstObjs ; lstIter != NULL ; lstIter = lstIter->next)*/
/*        if (qcad_design_object_overlaps (obj, QCAD_DESIGN_OBJECT (lstIter->data)))*/
/*          return FALSE ;*/
/*      }*/
    }
  else
  if (QCAD_IS_SUBSTRATE (obj))
    {
    if (layer->type != LAYER_TYPE_SUBSTRATE)
      return FALSE ;
/*    else*/
    // If the object is selected, we don't care that it overlaps, because it's floating
/*    if (!(obj->bSelected))*/
/*      {*/
/*      for (lstIter = layer->lstObjs ; lstIter != NULL ; lstIter = lstIter->next)*/
/*        if (qcad_design_object_overlaps (obj, QCAD_DESIGN_OBJECT (lstIter->data)))*/
/*          return FALSE ;*/
/*      }*/
    }
  else
  if (IS_QCAD_LABEL (obj) &&
      (!(LAYER_TYPE_DRAWING == layer->type && obj->bounding_box.cxWorld > 10 && obj->bounding_box.cyWorld > 10)))
    return FALSE ;

  qcad_layer_track_new_object (layer, obj, layer->lstObjs = g_list_prepend (layer->lstObjs, obj), NULL) ;
  if (QCAD_IS_COMPOUND_DO (obj))
    {
    g_signal_connect (G_OBJECT (obj), "added", (GCallback)qcad_layer_compound_do_added, layer) ;
    g_signal_connect (G_OBJECT (obj), "removed", (GCallback)qcad_layer_compound_do_removed, layer) ;
    for (obj_child = qcad_compound_do_first (QCAD_COMPOUND_DO (obj)) ; ; obj_child = qcad_compound_do_next (QCAD_COMPOUND_DO (obj)))
      {
      if (NULL != obj_child)
        qcad_layer_track_new_object (layer, obj_child, NULL, obj) ;
      if (qcad_compound_do_last (QCAD_COMPOUND_DO (obj))) break ;
      }
    }

  return TRUE ;
  }