Esempio n. 1
0
static void
selection_changed_cb (GtkTreeSelection *selection, gpointer user_data)
{
    GtkTreeModel *model;
    GtkTreeIter iter;
    GhidDrcViolation *violation;
    int i;

    if (!gtk_tree_selection_get_selected (selection, &model, &iter))
    {
        if (ClearFlagOnAllObjects (true, FOUNDFLAG))
        {
            IncrementUndoSerialNumber ();
            Draw ();
        }
        return;
    }

    /* Check the selected node has children, if so; return. */
    if (gtk_tree_model_iter_has_child (model, &iter))
        return;

    gtk_tree_model_get (model, &iter, DRC_VIOLATION_OBJ_COL, &violation, -1);

    ClearFlagOnAllObjects (true, FOUNDFLAG);

    if (violation == NULL)
        return;

    /* Flag the objects listed against this DRC violation */
    for (i = 0; i < violation->object_count; i++)
    {
        int object_id = violation->object_id_list[i];
        int object_type = violation->object_type_list[i];
        int found_type;
        void *ptr1, *ptr2, *ptr3;

        found_type = SearchObjectByID (PCB->Data, &ptr1, &ptr2, &ptr3,
                                       object_id, object_type);
        if (found_type == NO_TYPE)
        {
            Message (_("Object ID %i identified during DRC was not found. Stale DRC window?\n"),
                     object_id);
            continue;
        }
        AddObjectToFlagUndoList (object_type, ptr1, ptr2, ptr3);
        SET_FLAG (FOUNDFLAG, (AnyObjectType *)ptr2);
        switch (violation->object_type_list[i])
        {
        case LINE_TYPE:
        case ARC_TYPE:
        case POLYGON_TYPE:
            ChangeGroupVisibility (GetLayerNumber (PCB->Data, (LayerType *) ptr1), true, true);
        }
        DrawObject (object_type, ptr1, ptr2);
    }
    SetChangedFlag (true);
    IncrementUndoSerialNumber ();
    Draw();
}
Esempio n. 2
0
int
MoveLayerAction (int argc, char **argv, Coord x, Coord y)
{
  int old_index, new_index;
  int new_top = -1;

  if (argc != 2)
    {
      Message ("Usage; MoveLayer(old,new)");
      return 1;
    }

  if (strcmp (argv[0], "c") == 0)
    old_index = INDEXOFCURRENT;
  else
    old_index = atoi (argv[0]);

  if (strcmp (argv[1], "c") == 0)
    {
      new_index = INDEXOFCURRENT;
      if (new_index < 0)
	new_index = 0;
    }
  else if (strcmp (argv[1], "up") == 0)
    {
      new_index = INDEXOFCURRENT - 1;
      if (new_index < 0)
	return 1;
      new_top = new_index;
    }
  else if (strcmp (argv[1], "down") == 0)
    {
      new_index = INDEXOFCURRENT + 1;
      if (new_index >= max_copper_layer)
	return 1;
      new_top = new_index;
    }
  else
    new_index = atoi (argv[1]);

  if (MoveLayer (old_index, new_index))
    return 1;

  if (new_index == -1)
    {
      new_top = old_index;
      if (new_top >= max_copper_layer)
	new_top--;
      new_index = new_top;
    }
  if (old_index == -1)
    new_top = new_index;

  if (new_top != -1)
    ChangeGroupVisibility (new_index, 1, 1);

  return 0;
}
Esempio n. 3
0
File: menu.c Progetto: thequux/pcb
static void
layerpick_button_callback (Widget w, int layer,
			   XmPushButtonCallbackStruct * pbcs)
{
  int l, i;
  char *name;
  PCB->RatDraw = (layer == LB_RATS);
  PCB->SilkActive = (layer == LB_SILK);
  if (layer < max_copper_layer)
    ChangeGroupVisibility (layer, 1, 1);
  for (l = 0; l < num_layer_buttons; l++)
    {
      LayerButtons *lb = layer_button_list + l;
      if (!lb->is_pick)
	continue;
      for (i = 0; i < LB_NUMPICK; i++)
	XmToggleButtonSetState (lb->w[i], layer == i, False);
    }
  switch (layer)
    {
    case LB_RATS:
      name = "Rats";
      break;
    case LB_SILK:
      name = "Silk";
      break;
    default:
      name = PCB->Data->Layer[layer].Name;
      break;
    }
  n = 0;
  stdarg (XmNbackground, fg_colors[layer]);
  stdarg (XmNforeground, bg_color);
  stdarg (XmNlabelString, XmStringCreateLocalized (name));
  XtSetValues (lesstif_m_layer, args, n);
  lesstif_invalidate_all ();
}