Esempio n. 1
0
static void
gegl_introspect_load_cache (GeglProperties *op_introspect)
{
  GeglBuffer *new_buffer   = NULL;
  GeglNode   *png_load     = NULL;
  GeglNode   *buffer_sink  = NULL;
  gchar      *dot_string   = NULL;
  gchar      *png_filename = NULL;
  gchar      *dot_filename = NULL;
  gchar      *dot_cmd      = NULL;

  if (op_introspect->user_data || op_introspect->node == NULL)
    return;

  /* Construct temp filenames */
  dot_filename = g_build_filename (g_get_tmp_dir (), "gegl-introspect.dot", NULL);
  png_filename = g_build_filename (g_get_tmp_dir (), "gegl-introspect.png", NULL);

  /* Construct the .dot source */
  dot_string = gegl_to_dot (GEGL_NODE (op_introspect->node));
  g_file_set_contents (dot_filename, dot_string, -1, NULL);

  /* Process the .dot to a .png */
  dot_cmd = g_strdup_printf ("dot -o %s -Tpng %s", png_filename, dot_filename);
  if (system (dot_cmd) == -1)
    g_warning ("Error executing GraphViz dot program");

  /* Create a graph that loads the png into a GeglBuffer and process
   * it
   */
  png_load = gegl_node_new_child (NULL,
                                  "operation", "gegl:png-load",
                                  "path",      png_filename,
                                  NULL);
  buffer_sink = gegl_node_new_child (NULL,
                                     "operation", "gegl:buffer-sink",
                                     "buffer",    &new_buffer,
                                     NULL);
  gegl_node_link_many (png_load, buffer_sink, NULL);
  gegl_node_process (buffer_sink);

  op_introspect->user_data= new_buffer;

  /* Cleanup */
  g_object_unref (buffer_sink);
  g_object_unref (png_load);
  g_free (dot_string);
  g_free (dot_cmd);
  g_free (dot_filename);
  g_free (png_filename);
}
Esempio n. 2
0
/**
 * gegl_dot_node_to_png:
 * @node: Node to depict graph for.
 * @png_path: Path of the png to write.
 *
 * This is for debug purposes, meant to be invoked directly from a
 * debugger.
 **/
void
gegl_dot_node_to_png (GeglNode    *node,
                      const gchar *png_path)
{
  gchar      *dot_string   = NULL;
  gchar      *dot_filename = NULL;
  gchar      *dot_cmd      = NULL;

  /* Get dot string */
  dot_string = gegl_to_dot (node);

  /* Write it to a file */
  dot_filename = g_build_filename (g_get_tmp_dir (), "gegl-dot.dot", NULL);
  g_file_set_contents (dot_filename, dot_string, -1, NULL);

  /* Create a png from it */
  dot_cmd = g_strdup_printf ("dot -o %s -Tpng %s", png_path, dot_filename);
  if (system (dot_cmd) == -1)
    g_warning ("Error executing GraphViz dot program");
}