コード例 #1
0
ファイル: geda_circle_object.c プロジェクト: SayCV/geda-gaf
/*! \brief Create a character string representation of a circle OBJECT.
 *  \par Function Description
 *  This function formats a string in the buffer <B>*buff</B> to describe the
 *  circle object <B>*object</B>.
 *  It follows the post-20000704 release file format that handle the line
 *  type and fill options.
 *
 *  \param [in] object  Circle OBJECT to create string from.
 *  \return A pointer to the circle OBJECT character string.
 *
 *  \note
 *  Caller must g_free returned character string.
 *
 */
gchar*
geda_circle_object_to_buffer (const GedaObject *object)
{
  g_return_val_if_fail (object != NULL, NULL);
  g_return_val_if_fail (object->circle != NULL, NULL);
  g_return_val_if_fail (object->type == OBJ_CIRCLE, NULL);

  return g_strdup_printf ("%c %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d",
                          OBJ_CIRCLE,
                          geda_circle_object_get_center_x (object),
                          geda_circle_object_get_center_y (object),
                          geda_circle_object_get_radius (object),
                          geda_object_get_color (object),
                          object->line_width,
                          object->line_end,
                          object->line_type,
                          object->line_length,
                          object->line_space,
                          object->fill_type,
                          object->fill_width,
                          object->fill_angle1,
                          object->fill_pitch1,
                          object->fill_angle2,
                          object->fill_pitch2);
}
コード例 #2
0
ファイル: geda_text_object.c プロジェクト: peter-b/geda-gaf
/*! \brief Create a string representation of the text object
 *  \par Function Description
 *  This function takes a text \a object and return a string
 *  according to the file format definition.
 *
 *  \param [in] object the text object
 *  \return the string representation of the text object
 */
gchar*
geda_text_object_to_buffer (const GedaObject *object)
{
  const gchar *string;

  g_return_val_if_fail (object != NULL, NULL);
  g_return_val_if_fail (object->text != NULL, NULL);
  g_return_val_if_fail (object->type == OBJ_TEXT, NULL);

  string = geda_text_object_get_string (object);

  g_return_val_if_fail (string != NULL, NULL);

  return g_strdup_printf ("%c %d %d %d %d %d %d %d %d %d\n%s",
                          OBJ_TEXT,
                          geda_text_object_get_x (object),
                          geda_text_object_get_y (object),
                          geda_object_get_color (object),
                          geda_text_object_get_size (object),
                          geda_object_get_visible (object),
                          object->show_name_value,
                          geda_text_object_get_angle (object),
                          geda_text_object_get_alignment (object),
                          o_text_num_lines (string),
                          string);
}
コード例 #3
0
ファイル: geda_box_object.c プロジェクト: SayCV/geda-gaf
/*! \brief Create a character string representation of a BOX.
 *  \par Function Description
 *  This function formats a string in the buffer <B>*buff</B> to describe the
 *  box object <B>*object</B>.
 *  It follows the post-20000704 release file format that handle the line type
 *  and fill options.
 *
 *  \param [in] object  The BOX OBJECT to create string from.
 *  \return A pointer to the BOX character string.
 *
 *  \warning
 *  Caller must g_free returned character string.
 */
gchar*
geda_box_object_to_buffer (const GedaObject *object)
{
  int x1, y1;
  int width, height;
  int box_width, box_space, box_length;
  int fill_width, angle1, pitch1, angle2, pitch2;
  OBJECT_END box_end;
  OBJECT_TYPE box_type;
  OBJECT_FILLING box_fill;
  char *buf;

  /*! \note
   *  A box is internally represented by its lower right and upper left corner
   *  whereas it is described in the file format as its lower left corner and
   *  its width and height.
   */

  /* calculate the width and height of the box */
  width  = abs(object->box->lower_x - object->box->upper_x);
  height = abs(object->box->upper_y - object->box->lower_y);

  /* calculate the lower left corner of the box */
  x1 = object->box->upper_x;
  y1 = object->box->upper_y - height; /* move the origin to 0, 0*/

#if DEBUG
  printf("box: %d %d %d %d\n", x1, y1, width, height);
#endif

  /* description of the line type for the outline */
  box_end    = object->line_end;
  box_width  = object->line_width;
  box_type   = object->line_type;
  box_length = object->line_length;
  box_space  = object->line_space;

  /* description of the filling of the box */
  box_fill   = object->fill_type;
  fill_width = object->fill_width;
  angle1     = object->fill_angle1;
  pitch1     = object->fill_pitch1;
  angle2     = object->fill_angle2;
  pitch2     = object->fill_pitch2;

  buf = g_strdup_printf("%c %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d",
			object->type,
			x1, y1, width, height, geda_object_get_color (object),
			box_width, box_end, box_type, box_length, box_space,
			box_fill,
			fill_width, angle1, pitch1, angle2, pitch2);

  return(buf);
}
コード例 #4
0
ファイル: geda_net_object.c プロジェクト: SayCV/geda-gaf
/*! \brief Create a string representation of the net object
 *  \par Function Description
 *  This function takes a net \a object and return a string
 *  according to the file format definition.
 *
 *  \param [in] object  a net OBJECT
 *  \return the string representation of the net OBJECT
 */
gchar*
geda_net_object_to_buffer (const GedaObject *object)
{
  g_return_val_if_fail (object != NULL, NULL);
  g_return_val_if_fail (object->line != NULL, NULL);
  g_return_val_if_fail (object->type == OBJ_NET, NULL);

  return g_strdup_printf ("%c %d %d %d %d %d",
                          OBJ_NET,
                          geda_net_object_get_x0 (object),
                          geda_net_object_get_y0 (object),
                          geda_net_object_get_x1 (object),
                          geda_net_object_get_y1 (object),
                          geda_object_get_color (object));
}
コード例 #5
0
/*! \brief Create a copy of a picture.
 *  \par Function Description
 *  This function creates a verbatim copy of the object pointed by
 *  <B>o_current</B> describing a picture.
 *
 *  \param [in]  toplevel   The TOPLEVEL object.
 *  \param [in]  object     Picture OBJECT to copy.
 *  \return The new OBJECT
 */
OBJECT *o_picture_copy(TOPLEVEL *toplevel, OBJECT *object)
{
  OBJECT *new_node;
  PICTURE *picture;

  /* create the object */
  new_node = s_basic_new_object(object->type, "picture");

  picture = (PICTURE*) g_malloc (sizeof(PICTURE));
  new_node->picture = picture;

  new_node->color = geda_object_get_color (object);
  new_node->selectable = geda_object_get_selectable (object);

  /* describe the picture with its upper left and lower right corner */
  picture->upper_x = object->picture->upper_x;
  picture->upper_y = object->picture->upper_y;
  picture->lower_x = object->picture->lower_x;
  picture->lower_y = object->picture->lower_y;

  if (object->picture->file_content != NULL) {
    picture->file_content = (gchar*) g_memdup (object->picture->file_content,
                                               object->picture->file_length);
  } else {
    picture->file_content = NULL;
  }

  picture->file_length = object->picture->file_length;
  picture->filename    = g_strdup (object->picture->filename);
  picture->ratio       = object->picture->ratio;
  picture->angle       = object->picture->angle;
  picture->mirrored    = object->picture->mirrored;
  picture->embedded    = object->picture->embedded;

  /* Get the picture data */
  picture->pixbuf = o_picture_get_pixbuf (toplevel, object);

  /* compute the bounding picture */
  new_node->w_bounds_valid_for = NULL;

  return new_node;
}
コード例 #6
0
/*! \brief Create a character string representation of a path OBJECT.
 *  \par Function Description
 *  The function formats a string in the buffer <B>*buff</B> to describe
 *  the path object <B>*object</B>.
 *
 *  \param [in] object  path OBJECT to create string from.
 *  \return A pointer to the path OBJECT character string.
 *
 *  \note
 *  Caller must g_free returned character string.
 *
 */
gchar*
geda_path_object_to_buffer (const GedaObject *object)
{
  int line_width, line_space, line_length;
  char *buf;
  int num_lines;
  OBJECT_END line_end;
  OBJECT_TYPE line_type;
  OBJECT_FILLING fill_type;
  int fill_width, angle1, pitch1, angle2, pitch2;
  char *path_string;

  /* description of the line type */
  line_width  = object->line_width;
  line_end    = object->line_end;
  line_type   = object->line_type;
  line_length = object->line_length;
  line_space  = object->line_space;

  /* filling parameters */
  fill_type    = object->fill_type;
  fill_width   = object->fill_width;
  angle1       = object->fill_angle1;
  pitch1       = object->fill_pitch1;
  angle2       = object->fill_angle2;
  pitch2       = object->fill_pitch2;

  path_string = s_path_string_from_path (object->path);
  num_lines = o_text_num_lines (path_string);
  buf = g_strdup_printf ("%c %d %d %d %d %d %d %d %d %d %d %d %d %d\n%s",
                         object->type, geda_object_get_color (object), line_width, line_end,
                         line_type, line_length, line_space, fill_type,
                         fill_width, angle1, pitch1, angle2, pitch2,
                         num_lines, path_string);
  g_free (path_string);

  return buf;
}
コード例 #7
0
ファイル: geda_arc_object.c プロジェクト: gareth8118/geda-gaf
/*! \brief create the string representation of an arc object
 *
 *  This function converts the arc object to a string representation for
 *  seiralization. The arc object only uses a single line.
 *
 *  The end of the returned string does not have a newline.
 *
 *  When no longer needed, free the returned string using g_free().
 *
 *  \param [in] object the arc object to convert to string representation
 *  \return the string representation of the arc object
 */
gchar*
geda_arc_object_to_buffer (const GedaObject *object)
{
  g_return_val_if_fail (object != NULL, NULL);
  g_return_val_if_fail (object->arc != NULL, NULL);
  g_return_val_if_fail (object->type == OBJ_ARC, NULL);

  /* Describe a circle with post-20000704 file format */

  return g_strdup_printf ("%c %d %d %d %d %d %d %d %d %d %d %d",
                          OBJ_ARC,
                          geda_arc_object_get_center_x (object),
                          geda_arc_object_get_center_y (object),
                          geda_arc_object_get_radius (object),
                          geda_arc_object_get_start_angle (object),
                          geda_arc_object_get_sweep_angle (object),
                          geda_object_get_color (object),
                          object->line_width,
                          object->line_end,
                          object->line_type,
                          object->line_length,
                          object->line_space);
}