示例#1
0
void add_positions(void)
{
  int k;
  for (k=0; k<NCELLS; k++) {
    int i;
    cell* p;
    p = CELLPTR(k);
    for (i=0; i<p->n; i++) {
        AV_POS(p,i,X) += ORT(p,i,X) + SHEET(p,i,X);
        AV_POS(p,i,Y) += ORT(p,i,Y) + SHEET(p,i,Y);
#ifndef TWOD
        AV_POS(p,i,Z) += ORT(p,i,Z) + SHEET(p,i,Z);
#endif
        AV_EPOT(p,i)  += POTENG(p,i);
    }
  }

#ifdef NPT
  av_box_x.x += box_x.x;
  av_box_x.y += box_x.y;
  av_box_y.x += box_y.x;
  av_box_y.y += box_y.y;
#ifndef TWOD
  av_box_x.z += box_x.z;  
  av_box_y.z += box_y.z;
  av_box_z.x += box_z.x;
  av_box_z.y += box_z.y;  
  av_box_z.z += box_z.z;  
#endif
#endif
  avpos_cnt++;

}
示例#2
0
Sheet *sheet_item_get_sheet (SheetItem *item)
{
	g_return_val_if_fail (item != NULL, NULL);
	g_return_val_if_fail (IS_SHEET_ITEM (item), NULL);

	return SHEET (goo_canvas_item_get_canvas (GOO_CANVAS_ITEM (item)));
}
示例#3
0
static void
wire_changed_callback (Wire *wire, WireItem *item)
{
	Coords start_pos, length;
	GooCanvasPoints *points;

	g_return_if_fail (wire != NULL);
	g_return_if_fail (IS_ITEM_DATA (wire));
	g_return_if_fail (item != NULL);
	g_return_if_fail (IS_WIRE_ITEM (item));


	wire_get_pos_and_length (wire, &start_pos, &length);

	Sheet *sheet = SHEET (goo_canvas_item_get_canvas (GOO_CANVAS_ITEM (item)));
	if (G_UNLIKELY(!sheet)) {
		g_warning ("Failed to determine the Sheet the item is glued to. This should never happen. Ever!");
	} else {
		item_data_snap (ITEM_DATA (wire), sheet->grid);
	}

	// Move the canvas item and invalidate the bbox cache.
	goo_canvas_item_set_simple_transform (GOO_CANVAS_ITEM (item),
	                                      start_pos.x,
	                                      start_pos.y,
	                                      1.0,
	                                      0.0);
	item->priv->cache_valid = FALSE;

	points = goo_canvas_points_new (2);
	points->coords[0] = 0;
	points->coords[1] = 0;
	points->coords[2] = length.x;
	points->coords[3] = length.y;

	// this does handle cleanup of previous points internally
	g_object_set (item->priv->line,
	              "points", points,
	              NULL);
	goo_canvas_points_unref (points);

	g_object_set (item->priv->resize1,
	              "x", -RESIZER_SIZE,
	              "y", -RESIZER_SIZE,
	              "width", 2 * RESIZER_SIZE,
	              "height", 2 * RESIZER_SIZE,
	              NULL);

	g_object_set (item->priv->resize2,
	              "x", length.x-RESIZER_SIZE,
	              "y", length.y-RESIZER_SIZE,
	              "width", 2 * RESIZER_SIZE,
	              "height", 2 * RESIZER_SIZE,
	              NULL);

	goo_canvas_item_request_update (GOO_CANVAS_ITEM (item->priv->line));
}
示例#4
0
static void sheet_set_property (GObject *object, guint prop_id, const GValue *value,
                                GParamSpec *spec)
{
	const Sheet *sheet = SHEET (object);

	switch (prop_id) {
	case ARG_ZOOM:
		sheet_set_zoom (sheet, g_value_get_double (value));
		break;
	}
}
示例#5
0
static void
sheet_finalize (GObject *object)
{	
	Sheet *sheet = SHEET (object);

	if (sheet->priv) {
		g_hash_table_destroy (sheet->priv->node_dots);
		g_free (sheet->priv);
	}
	if (G_OBJECT_CLASS (sheet_parent_class)->finalize)
		(* G_OBJECT_CLASS (sheet_parent_class)->finalize) (object);
}
示例#6
0
static void sheet_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *spec)
{
	const Sheet *sheet = SHEET (object);

	switch (prop_id) {
	case ARG_ZOOM:
		g_value_set_double (value, sheet->priv->zoom);
		break;

	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (sheet, prop_id, spec);
		break;
	}
}
示例#7
0
// This function defines the drawing sheet on which schematic will be drawn 
GtkWidget *
sheet_new (int width, int height)
{
	GooCanvas *sheet_canvas;
	GooCanvasGroup *sheet_group;
	GooCanvasPoints *points;
	Sheet *sheet;
	GtkWidget *sheet_widget;
  	GooCanvasItem *root;
	
	// Creation of the Canvas
	sheet = SHEET (g_object_new (TYPE_SHEET, NULL));

	sheet_canvas = GOO_CANVAS (sheet);
	g_object_set (G_OBJECT (sheet_canvas), 
	              "bounds-from-origin", FALSE,
	              "bounds-padding", 4.0,
	              "background-color-rgb", 0xFFFFFF,
	              NULL);

  	root = goo_canvas_get_root_item (sheet_canvas);
	
	sheet_group = GOO_CANVAS_GROUP (goo_canvas_group_new (
	                                root,
	                                NULL));
	sheet_widget = GTK_WIDGET (sheet);

	goo_canvas_set_bounds (GOO_CANVAS (sheet_canvas), 0, 0, 
	    width + 20, height + 20);

	// Define vicinity around GooCanvasItem
	//sheet_canvas->close_enough = 6.0;

	sheet->priv->width = width;
	sheet->priv->height = height;

	// Create the dot grid.
	sheet->grid = grid_create (GOO_CANVAS_ITEM (sheet_group),
	                           width,
	                           height);

	// Everything outside the sheet should be gray.
	// top //
	goo_canvas_rect_new (GOO_CANVAS_ITEM (sheet_group), 
	                     0.0, 
	                     0.0, 
	                     (double) width + 20.0, 
	                     20.0, 
	                     "fill_color", "gray", 
	                     "line-width", 0.0, 
	                     NULL);

	goo_canvas_rect_new (GOO_CANVAS_ITEM (sheet_group), 
	                     0.0, 
	                     (double) height, 
	                     (double) width + 20.0, 
	                     (double) height + 20.0, 
	                     "fill_color", "gray", 
	                     "line-width", 0.0, 
	                     NULL);

	// right //
	goo_canvas_rect_new (GOO_CANVAS_ITEM (sheet_group), 
	                     0.0, 
	                     0.0, 
	                     20.0, 
	                     (double) height + 20.0, 
	                     "fill_color", "gray", 
	                     "line-width", 0.0, 
	                     NULL);

	goo_canvas_rect_new (GOO_CANVAS_ITEM (sheet_group), 
	                     (double) width, 
	                     0.0, 
	                     (double) width + 20.0, 
	                     (double) height + 20.0, 
	                     "fill_color", "gray", 
	                     "line-width", 0.0, 
	                     NULL);

	//  Draw a thin black border around the sheet.
	points = goo_canvas_points_new (5);
	points->coords[0] = 20.0;
	points->coords[1] = 20.0;
	points->coords[2] = width;
	points->coords[3] = 20.0;
	points->coords[4] = width;
	points->coords[5] = height;
	points->coords[6] = 20.0;
	points->coords[7] = height;
	points->coords[8] = 20.0;
	points->coords[9] = 20.0;
	
	goo_canvas_polyline_new (GOO_CANVAS_ITEM (sheet_group),
	      FALSE, 0,
	      "line-width", 1.0, 
	      "points", points, 
	      NULL);

	goo_canvas_points_unref (points);

	// Finally, create the object group that holds all objects.
	sheet->object_group = GOO_CANVAS_GROUP (goo_canvas_group_new (
	                     root,
	                     "x", 0.0,
	                     "y", 0.0,
	                     NULL));
	NG_DEBUG ("root group %p", sheet->object_group);

	sheet->priv->selected_group = GOO_CANVAS_GROUP (goo_canvas_group_new (
	     GOO_CANVAS_ITEM (sheet->object_group),
	     "x", 0.0,
	     "y", 0.0,
	     NULL));
	NG_DEBUG ("selected group %p", sheet->priv->selected_group);

	sheet->priv->floating_group = GOO_CANVAS_GROUP (goo_canvas_group_new (
	     GOO_CANVAS_ITEM (sheet->object_group),
	     "x", 0.0,
	     "y", 0.0,
	     NULL));
	NG_DEBUG ("floating group %p", sheet->priv->floating_group);

	// Hash table that keeps maps coordinate to a specific dot.
	sheet->priv->node_dots = g_hash_table_new_full (dot_hash, dot_equal, g_free, NULL);

	//this requires object_group to be setup properly
	sheet->priv->rubberband_info = rubberband_info_new (sheet);
	sheet->priv->create_wire_info = create_wire_info_new (sheet);

	return sheet_widget;
}