home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / libgimp / gimppaths_pdb.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-08-25  |  15.6 KB  |  507 lines

  1. /* LIBGIMP - The GIMP Library
  2.  * Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
  3.  *
  4.  * gimppaths_pdb.c
  5.  *
  6.  * This library is free software; you can redistribute it and/or
  7.  * modify it under the terms of the GNU Lesser General Public
  8.  * License as published by the Free Software Foundation; either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * This library is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.  * Lesser General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU Lesser General Public
  17.  * License along with this library; if not, write to the
  18.  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19.  * Boston, MA 02111-1307, USA.
  20.  */
  21.  
  22. /* NOTE: This file is autogenerated by pdbgen.pl */
  23.  
  24. #include "gimp.h"
  25.  
  26. /**
  27.  * gimp_path_list:
  28.  * @image_ID: The ID of the image to list the paths from.
  29.  * @num_paths: The number of paths returned.
  30.  *
  31.  * List the paths associated with the passed image.
  32.  *
  33.  * List the paths associated with the passed image.
  34.  *
  35.  * Returns: List of the paths belonging to this image.
  36.  */
  37. gchar **
  38. gimp_path_list (gint32  image_ID,
  39.         gint   *num_paths)
  40. {
  41.   GimpParam *return_vals;
  42.   gint nreturn_vals;
  43.   gchar **path_list = NULL;
  44.   gint i;
  45.  
  46.   return_vals = gimp_run_procedure ("gimp_path_list",
  47.                     &nreturn_vals,
  48.                     GIMP_PDB_IMAGE, image_ID,
  49.                     GIMP_PDB_END);
  50.  
  51.   *num_paths = 0;
  52.  
  53.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  54.     {
  55.       *num_paths = return_vals[1].data.d_int32;
  56.       path_list = g_new (gchar *, *num_paths);
  57.       for (i = 0; i < *num_paths; i++)
  58.     path_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
  59.     }
  60.  
  61.   gimp_destroy_params (return_vals, nreturn_vals);
  62.  
  63.   return path_list;
  64. }
  65.  
  66. /**
  67.  * gimp_path_get_points:
  68.  * @image_ID: The ID of the image to list the paths from.
  69.  * @pathname: the name of the path whose points should be listed.
  70.  * @path_closed: Return if the path is closed. {0=path open, 1= path closed}.
  71.  * @num_path_point_details: The number of points returned. Each point is made up of (x,y,pnt_type) of floats.
  72.  * @points_pairs: The points in the path represented as 3 floats. The first is the x pos, next is the y pos, last is the type of the pnt. The type field is dependant on the path type. For beziers (type 1 paths) the type can either be {1.0= BEZIER_ANCHOR, 2.0= BEZIER_CONTROL}. Note all points are returned in pixel resolution.
  73.  *
  74.  * List the points associated with the named path.
  75.  *
  76.  * List the points associated with the named path.
  77.  *
  78.  * Returns: The type of the path. Currently only one type (1 = Bezier) is supported.
  79.  */
  80. gint
  81. gimp_path_get_points (gint32    image_ID,
  82.               gchar    *pathname,
  83.               gint     *path_closed,
  84.               gint     *num_path_point_details,
  85.               gdouble **points_pairs)
  86. {
  87.   GimpParam *return_vals;
  88.   gint nreturn_vals;
  89.   gint path_type = 0;
  90.  
  91.   return_vals = gimp_run_procedure ("gimp_path_get_points",
  92.                     &nreturn_vals,
  93.                     GIMP_PDB_IMAGE, image_ID,
  94.                     GIMP_PDB_STRING, pathname,
  95.                     GIMP_PDB_END);
  96.  
  97.   *num_path_point_details = 0;
  98.  
  99.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  100.     {
  101.       path_type = return_vals[1].data.d_int32;
  102.       *path_closed = return_vals[2].data.d_int32;
  103.       *num_path_point_details = return_vals[3].data.d_int32;
  104.       *points_pairs = g_new (gdouble, *num_path_point_details);
  105.       memcpy (*points_pairs, return_vals[4].data.d_floatarray,
  106.           *num_path_point_details * sizeof (gdouble));
  107.     }
  108.  
  109.   gimp_destroy_params (return_vals, nreturn_vals);
  110.  
  111.   return path_type;
  112. }
  113.  
  114. /**
  115.  * gimp_path_get_current:
  116.  * @image_ID: The ID of the image to get the current paths from.
  117.  *
  118.  * The name of the current path. Error if no paths.
  119.  *
  120.  * The name of the current path. Error if no paths.
  121.  *
  122.  * Returns: The name of the current path.
  123.  */
  124. gchar *
  125. gimp_path_get_current (gint32 image_ID)
  126. {
  127.   GimpParam *return_vals;
  128.   gint nreturn_vals;
  129.   gchar *current_path_name = NULL;
  130.  
  131.   return_vals = gimp_run_procedure ("gimp_path_get_current",
  132.                     &nreturn_vals,
  133.                     GIMP_PDB_IMAGE, image_ID,
  134.                     GIMP_PDB_END);
  135.  
  136.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  137.     current_path_name = g_strdup (return_vals[1].data.d_string);
  138.  
  139.   gimp_destroy_params (return_vals, nreturn_vals);
  140.  
  141.   return current_path_name;
  142. }
  143.  
  144. /**
  145.  * gimp_path_set_current:
  146.  * @image_ID: The ID of the image to list set the paths in.
  147.  * @set_current_path_name: The name of the path to set the current path to.
  148.  *
  149.  * List the paths associated with the passed image.
  150.  *
  151.  * List the paths associated with the passed image.
  152.  *
  153.  * Returns: TRUE on success.
  154.  */
  155. gboolean
  156. gimp_path_set_current (gint32  image_ID,
  157.                gchar  *set_current_path_name)
  158. {
  159.   GimpParam *return_vals;
  160.   gint nreturn_vals;
  161.   gboolean success = TRUE;
  162.  
  163.   return_vals = gimp_run_procedure ("gimp_path_set_current",
  164.                     &nreturn_vals,
  165.                     GIMP_PDB_IMAGE, image_ID,
  166.                     GIMP_PDB_STRING, set_current_path_name,
  167.                     GIMP_PDB_END);
  168.  
  169.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  170.  
  171.   gimp_destroy_params (return_vals, nreturn_vals);
  172.  
  173.   return success;
  174. }
  175.  
  176. /**
  177.  * gimp_path_set_points:
  178.  * @image_ID: The ID of the image to set the paths in.
  179.  * @pathname: The name of the path to create (if it exists then a unique name will be created - query the list of paths if you want to make sure that the name of the path you create is unique. This will be set as the current path.
  180.  * @ptype: The type of the path. Currently only one type (1 = Bezier) is supported.
  181.  * @num_path_points: The number of points in the path. Each point is made up of (x,y,type) of floats. Currently only the creation of bezier curves is allowed. The type parameter must be set to (1) to indicate a BEZIER type curve. For BEZIERS. Note the that points must be given in the following order... ACCACCAC ... If the path is not closed the last control point is missed off. Points consist of three control points (control/anchor/control) so for a curve that is not closed there must be at least two points passed (2 x,y pairs). If num_path_pnts % 3 = 0 then the path is assumed to be closed and the points are ACCACCACCACC.
  182.  * @points_pairs: The points in the path represented as 3 floats. The first is the x pos, next is the y pos, last is the type of the pnt. The type field is dependant on the path type. For beziers (type 1 paths) the type can either be {1.0= BEZIER_ANCHOR, 2.0= BEZIER_CONTROL}. Note all points are returned in pixel resolution.
  183.  *
  184.  * Set the points associated with the named path.
  185.  *
  186.  * Set the points associated with the named path.
  187.  *
  188.  * Returns: TRUE on success.
  189.  */
  190. gboolean
  191. gimp_path_set_points (gint32   image_ID,
  192.               gchar   *pathname,
  193.               gint     ptype,
  194.               gint     num_path_points,
  195.               gdouble *points_pairs)
  196. {
  197.   GimpParam *return_vals;
  198.   gint nreturn_vals;
  199.   gboolean success = TRUE;
  200.  
  201.   return_vals = gimp_run_procedure ("gimp_path_set_points",
  202.                     &nreturn_vals,
  203.                     GIMP_PDB_IMAGE, image_ID,
  204.                     GIMP_PDB_STRING, pathname,
  205.                     GIMP_PDB_INT32, ptype,
  206.                     GIMP_PDB_INT32, num_path_points,
  207.                     GIMP_PDB_FLOATARRAY, points_pairs,
  208.                     GIMP_PDB_END);
  209.  
  210.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  211.  
  212.   gimp_destroy_params (return_vals, nreturn_vals);
  213.  
  214.   return success;
  215. }
  216.  
  217. /**
  218.  * gimp_path_stroke_current:
  219.  * @image_ID: The ID of the image which contains the path to stroke.
  220.  *
  221.  * Stroke the current path in the passed image.
  222.  *
  223.  * Stroke the current path in the passed image.
  224.  *
  225.  * Returns: TRUE on success.
  226.  */
  227. gboolean
  228. gimp_path_stroke_current (gint32 image_ID)
  229. {
  230.   GimpParam *return_vals;
  231.   gint nreturn_vals;
  232.   gboolean success = TRUE;
  233.  
  234.   return_vals = gimp_run_procedure ("gimp_path_stroke_current",
  235.                     &nreturn_vals,
  236.                     GIMP_PDB_IMAGE, image_ID,
  237.                     GIMP_PDB_END);
  238.  
  239.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  240.  
  241.   gimp_destroy_params (return_vals, nreturn_vals);
  242.  
  243.   return success;
  244. }
  245.  
  246. /**
  247.  * gimp_path_get_point_at_dist:
  248.  * @image_ID: The ID of the image the paths belongs to.
  249.  * @distance: The distance along the path.
  250.  * @y_point: The y position of the point.
  251.  * @gradient: The gradient at the specified point.
  252.  *
  253.  * Get point on a path at a specified distance along the path.
  254.  *
  255.  * This will return the x,y position of a point at a given distance
  256.  * along the bezier curve. The distance will the obtained by first
  257.  * digitizing the curve internally an then walking along the curve. For
  258.  * a closed curve the start of the path is the first point on the path
  259.  * that was created. This might not be obvious. Note the current path
  260.  * is used.
  261.  *
  262.  * Returns: The x position of the point.
  263.  */
  264. gint
  265. gimp_path_get_point_at_dist (gint32   image_ID,
  266.                  gdouble  distance,
  267.                  gint    *y_point,
  268.                  gdouble *gradient)
  269. {
  270.   GimpParam *return_vals;
  271.   gint nreturn_vals;
  272.   gint x_point = 0;
  273.  
  274.   return_vals = gimp_run_procedure ("gimp_path_get_point_at_dist",
  275.                     &nreturn_vals,
  276.                     GIMP_PDB_IMAGE, image_ID,
  277.                     GIMP_PDB_FLOAT, distance,
  278.                     GIMP_PDB_END);
  279.  
  280.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  281.     {
  282.       x_point = return_vals[1].data.d_int32;
  283.       *y_point = return_vals[2].data.d_int32;
  284.       *gradient = return_vals[3].data.d_float;
  285.     }
  286.  
  287.   gimp_destroy_params (return_vals, nreturn_vals);
  288.  
  289.   return x_point;
  290. }
  291.  
  292. /**
  293.  * gimp_path_get_tattoo:
  294.  * @image_ID: The image.
  295.  * @pathname: the name of the path whose tattoo should be obtained.
  296.  *
  297.  * Returns the tattoo associated with the name path.
  298.  *
  299.  * This procedure returns the tattoo associated with the specified
  300.  * path. A tattoo is a unique and permanent identifier attached to a
  301.  * path that can be used to uniquely identify a path within an image
  302.  * even between sessions.
  303.  *
  304.  * Returns: The tattoo associated with the name path.
  305.  */
  306. gint
  307. gimp_path_get_tattoo (gint32  image_ID,
  308.               gchar  *pathname)
  309. {
  310.   GimpParam *return_vals;
  311.   gint nreturn_vals;
  312.   gint tattoo = 0;
  313.  
  314.   return_vals = gimp_run_procedure ("gimp_path_get_tattoo",
  315.                     &nreturn_vals,
  316.                     GIMP_PDB_IMAGE, image_ID,
  317.                     GIMP_PDB_STRING, pathname,
  318.                     GIMP_PDB_END);
  319.  
  320.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  321.     tattoo = return_vals[1].data.d_int32;
  322.  
  323.   gimp_destroy_params (return_vals, nreturn_vals);
  324.  
  325.   return tattoo;
  326. }
  327.  
  328. /**
  329.  * gimp_get_path_by_tattoo:
  330.  * @image_ID: The image.
  331.  * @tattoo: The tattoo of the required path.
  332.  *
  333.  * Return the name of the path with the given tattoo.
  334.  *
  335.  * The procedure returns the name of the path in the specified image
  336.  * which has the passed tattoo. The tattoos are unique within the image
  337.  * and will be preserved across sessions and through renaming of the
  338.  * path. An error is returned if no path woth the specified tattoo can
  339.  * be found.
  340.  *
  341.  * Returns: The name of the path with the specified tattoo.
  342.  */
  343. gchar *
  344. gimp_get_path_by_tattoo (gint32 image_ID,
  345.              gint   tattoo)
  346. {
  347.   GimpParam *return_vals;
  348.   gint nreturn_vals;
  349.   gchar *path_name = NULL;
  350.  
  351.   return_vals = gimp_run_procedure ("gimp_get_path_by_tattoo",
  352.                     &nreturn_vals,
  353.                     GIMP_PDB_IMAGE, image_ID,
  354.                     GIMP_PDB_INT32, tattoo,
  355.                     GIMP_PDB_END);
  356.  
  357.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  358.     path_name = g_strdup (return_vals[1].data.d_string);
  359.  
  360.   gimp_destroy_params (return_vals, nreturn_vals);
  361.  
  362.   return path_name;
  363. }
  364.  
  365. /**
  366.  * gimp_path_delete:
  367.  * @image_ID: The ID of the image to list delete the paths from.
  368.  * @path_name_to_del: The name of the path to delete.
  369.  *
  370.  * Delete the named paths associated with the passed image.
  371.  *
  372.  * Delete the named path.
  373.  *
  374.  * Returns: TRUE on success.
  375.  */
  376. gboolean
  377. gimp_path_delete (gint32  image_ID,
  378.           gchar  *path_name_to_del)
  379. {
  380.   GimpParam *return_vals;
  381.   gint nreturn_vals;
  382.   gboolean success = TRUE;
  383.  
  384.   return_vals = gimp_run_procedure ("gimp_path_delete",
  385.                     &nreturn_vals,
  386.                     GIMP_PDB_IMAGE, image_ID,
  387.                     GIMP_PDB_STRING, path_name_to_del,
  388.                     GIMP_PDB_END);
  389.  
  390.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  391.  
  392.   gimp_destroy_params (return_vals, nreturn_vals);
  393.  
  394.   return success;
  395. }
  396.  
  397. /**
  398.  * gimp_path_get_locked:
  399.  * @image_ID: The image.
  400.  * @pathname: the name of the path whose locked status should be obtained.
  401.  *
  402.  * Returns the locked status associated with the name path.
  403.  *
  404.  * This procedure returns the lock status associated with the specified
  405.  * path. A path can be \"locked\" which means that the transformation
  406.  * tool operations will also apply to the path.
  407.  *
  408.  * Returns: The lock status associated with the name path. 0 returned if the path is not locked. 1 is returned if the path is locked.
  409.  */
  410. gint
  411. gimp_path_get_locked (gint32  image_ID,
  412.               gchar  *pathname)
  413. {
  414.   GimpParam *return_vals;
  415.   gint nreturn_vals;
  416.   gint lockstatus = 0;
  417.  
  418.   return_vals = gimp_run_procedure ("gimp_path_get_locked",
  419.                     &nreturn_vals,
  420.                     GIMP_PDB_IMAGE, image_ID,
  421.                     GIMP_PDB_STRING, pathname,
  422.                     GIMP_PDB_END);
  423.  
  424.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  425.     lockstatus = return_vals[1].data.d_int32;
  426.  
  427.   gimp_destroy_params (return_vals, nreturn_vals);
  428.  
  429.   return lockstatus;
  430. }
  431.  
  432. /**
  433.  * gimp_path_set_locked:
  434.  * @image_ID: The image.
  435.  * @pathname: the name of the path whose locked status should be set.
  436.  * @lockstatus: The lock status associated with the name path. 0 if the path is not locked. 1 if the path is to be locked.
  437.  *
  438.  * Set the locked status associated with the name path.
  439.  *
  440.  * This procedure sets the lock status associated with the specified
  441.  * path. A path can be \"locked\" which means that the transformation
  442.  * tool operations will also apply to the path.
  443.  *
  444.  * Returns: TRUE on success.
  445.  */
  446. gboolean
  447. gimp_path_set_locked (gint32  image_ID,
  448.               gchar  *pathname,
  449.               gint    lockstatus)
  450. {
  451.   GimpParam *return_vals;
  452.   gint nreturn_vals;
  453.   gboolean success = TRUE;
  454.  
  455.   return_vals = gimp_run_procedure ("gimp_path_set_locked",
  456.                     &nreturn_vals,
  457.                     GIMP_PDB_IMAGE, image_ID,
  458.                     GIMP_PDB_STRING, pathname,
  459.                     GIMP_PDB_INT32, lockstatus,
  460.                     GIMP_PDB_END);
  461.  
  462.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  463.  
  464.   gimp_destroy_params (return_vals, nreturn_vals);
  465.  
  466.   return success;
  467. }
  468.  
  469. /**
  470.  * gimp_path_set_tattoo:
  471.  * @image_ID: The image.
  472.  * @pathname: the name of the path whose tattoo should be set.
  473.  * @tattovalue: The tattoo associated with the name path. Only values returned from 'path_get_tattoo' should be used here.
  474.  *
  475.  * Sets the tattoo associated with the name path.
  476.  *
  477.  * This procedure sets the tattoo associated with the specified path. A
  478.  * tattoo is a unique and permenant identifier attached to a path that
  479.  * can be used to uniquely identify a path within an image even between
  480.  * sessions. Note that the value passed to this function must have been
  481.  * obtained from a previous call to path_get_tattoo.
  482.  *
  483.  * Returns: TRUE on success.
  484.  */
  485. gboolean
  486. gimp_path_set_tattoo (gint32  image_ID,
  487.               gchar  *pathname,
  488.               gint    tattovalue)
  489. {
  490.   GimpParam *return_vals;
  491.   gint nreturn_vals;
  492.   gboolean success = TRUE;
  493.  
  494.   return_vals = gimp_run_procedure ("gimp_path_set_tattoo",
  495.                     &nreturn_vals,
  496.                     GIMP_PDB_IMAGE, image_ID,
  497.                     GIMP_PDB_STRING, pathname,
  498.                     GIMP_PDB_INT32, tattovalue,
  499.                     GIMP_PDB_END);
  500.  
  501.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  502.  
  503.   gimp_destroy_params (return_vals, nreturn_vals);
  504.  
  505.   return success;
  506. }
  507.