home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / plug-ins / gimpressionist / orientation.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-08-31  |  9.4 KB  |  232 lines

  1. #ifdef HAVE_CONFIG_H
  2. #include "config.h"
  3. #else
  4. #define HAVE_DIRENT_H
  5. #define HAVE_UNISTD_H
  6. #endif
  7.  
  8. #include <stdio.h>
  9. #include <string.h>
  10. #include <gtk/gtk.h>
  11. #include <sys/types.h>
  12. #ifdef HAVE_UNISTD_H
  13. #include <unistd.h>
  14. #endif
  15. #include "gimpressionist.h"
  16. #include "ppmtool.h"
  17. #include <libgimp/stdplugins-intl.h>
  18.  
  19.  
  20. GtkObject *orientnumadjust = NULL;
  21. GtkObject *orientfirstadjust = NULL;
  22. GtkObject *orientlastadjust = NULL;
  23.  
  24. #define NUMORIENTRADIO 8
  25.  
  26. GtkWidget *orientradio[NUMORIENTRADIO];
  27.  
  28. void orientchange(GtkWidget *wg, void *d, int num)
  29. {
  30.   int n;
  31.   if(wg) {
  32.     n = (long)d;
  33.     pcvals.orienttype = n;
  34.   } else {
  35.     int i;
  36.     n = num;
  37.     for(i = 0; i < NUMORIENTRADIO; i++)
  38.       if(i != n)
  39.     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(orientradio[i]), FALSE);
  40.     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(orientradio[n]), TRUE);
  41.   }
  42. }
  43.  
  44. void create_orientationpage(GtkNotebook *notebook)
  45. {
  46.   GtkWidget *box1, *box2, *box3, *box4, *thispage;
  47.   GtkWidget *labelbox, *menubox;
  48.   GtkWidget *tmpw;
  49.   int i;
  50.  
  51.   labelbox = gtk_hbox_new (FALSE, 0);
  52.   tmpw = gtk_label_new (_("Orientation"));
  53.   gtk_box_pack_start(GTK_BOX(labelbox), tmpw, FALSE, FALSE, 0);
  54.   gtk_widget_show_all(labelbox);
  55.  
  56.   menubox = gtk_hbox_new (FALSE, 0);
  57.   tmpw = gtk_label_new (_("Orientation"));
  58.   gtk_box_pack_start(GTK_BOX(menubox), tmpw, FALSE, FALSE, 0);
  59.   gtk_widget_show_all(menubox);
  60.  
  61.   thispage = gtk_vbox_new(FALSE, 0);
  62.   gtk_container_set_border_width (GTK_CONTAINER (thispage), 5);
  63.   gtk_widget_show(thispage);
  64.  
  65.   box1 = gtk_hbox_new (FALSE, 0);
  66.   gtk_box_pack_start(GTK_BOX(thispage), box1,FALSE,FALSE,0);
  67.   gtk_widget_show (box1);
  68.  
  69.   box2 = gtk_vbox_new (TRUE, 0);
  70.   gtk_box_pack_start(GTK_BOX(box1), box2,FALSE,FALSE,0);
  71.   gtk_widget_show (box2);
  72.  
  73.   tmpw = gtk_label_new( _("Directions:"));
  74.   gtk_box_pack_start(GTK_BOX(box2), tmpw,FALSE,FALSE,0);
  75.   gtk_widget_show (tmpw);
  76.  
  77.   tmpw = gtk_label_new( _("Start angle:"));
  78.   gtk_box_pack_start(GTK_BOX(box2), tmpw,FALSE,FALSE,0);
  79.   gtk_widget_show (tmpw);
  80.  
  81.   tmpw = gtk_label_new( _("Angle span:"));
  82.   gtk_box_pack_start(GTK_BOX(box2), tmpw,FALSE,FALSE,0);
  83.   gtk_widget_show (tmpw);
  84.  
  85.  
  86.   box2 = gtk_vbox_new (TRUE, 0);
  87.   gtk_box_pack_start(GTK_BOX(box1), box2,FALSE,FALSE, 10);
  88.   gtk_widget_show (box2);
  89.  
  90.   orientnumadjust = gtk_adjustment_new(pcvals.orientnum, 1.0, 31.0, 1.0, 1.0, 1.0);
  91.   tmpw = gtk_hscale_new(GTK_ADJUSTMENT(orientnumadjust));
  92.   gtk_widget_set_usize (GTK_WIDGET(tmpw), 150, 30);
  93.   gtk_scale_set_draw_value (GTK_SCALE (tmpw), TRUE);
  94.   gtk_scale_set_digits(GTK_SCALE (tmpw), 0);
  95.   gtk_box_pack_start (GTK_BOX (box2), tmpw, FALSE, FALSE, 0);
  96.   gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), tmpw, _("The number of directions (i.e. brushes) to use"), NULL);
  97.   gtk_widget_show (tmpw);
  98.  
  99.   orientfirstadjust = gtk_adjustment_new(pcvals.orientfirst, 0.0, 361.0, 1.0, 1.0, 1.0);
  100.   tmpw = gtk_hscale_new(GTK_ADJUSTMENT(orientfirstadjust));
  101.   gtk_widget_set_usize (GTK_WIDGET(tmpw), 150, 30);
  102.   gtk_scale_set_draw_value (GTK_SCALE (tmpw), TRUE);
  103.   gtk_scale_set_digits(GTK_SCALE (tmpw), 2);
  104.   gtk_box_pack_start (GTK_BOX (box2), tmpw, FALSE, FALSE, 0);
  105.   gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), tmpw, _("The angle of the first brush to create"), NULL);
  106.   gtk_widget_show (tmpw);
  107.  
  108.   orientlastadjust = gtk_adjustment_new(pcvals.orientlast, 0.0, 361.0, 1.0, 1.0, 1.0);
  109.   tmpw = gtk_hscale_new(GTK_ADJUSTMENT(orientlastadjust));
  110.   gtk_widget_set_usize (GTK_WIDGET(tmpw), 150, 30);
  111.   gtk_scale_set_draw_value (GTK_SCALE (tmpw), TRUE);
  112.   gtk_scale_set_digits(GTK_SCALE (tmpw), 2);
  113.   gtk_box_pack_start (GTK_BOX (box2), tmpw, FALSE, FALSE, 0);
  114.   gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), tmpw, _("How large an angle-span to use (360 = full circle)"), NULL);
  115.   gtk_widget_show (tmpw);
  116.  
  117.   box2 = gtk_hbox_new (FALSE, 0);
  118.   gtk_box_pack_start(GTK_BOX(thispage), box2,FALSE,FALSE,0);
  119.   gtk_widget_show (box2);
  120.  
  121.   tmpw = gtk_label_new( _("Orientation:"));
  122.   gtk_box_pack_start(GTK_BOX(box2), tmpw,FALSE,FALSE,0);
  123.   gtk_widget_show (tmpw);
  124.  
  125.   box3 = gtk_vbox_new(FALSE,0);
  126.   gtk_box_pack_start(GTK_BOX(box2), box3,FALSE,FALSE, 10);
  127.   gtk_widget_show(box3);
  128.  
  129.   i = pcvals.orienttype;
  130.  
  131.   orientradio[0] = tmpw = gtk_radio_button_new_with_label(NULL, _("Value"));
  132.   gtk_box_pack_start(GTK_BOX(box3), tmpw, FALSE, FALSE, 0);
  133.   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tmpw), FALSE);
  134.   gtk_widget_show(tmpw);
  135.   gtk_signal_connect(GTK_OBJECT(tmpw), "clicked",
  136.              (GtkSignalFunc)orientchange, (void *)0);
  137.   gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), tmpw, _("Let the value (brightness) of the region determine the direction of the stroke"), NULL);
  138.   if(i == 0)
  139.     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tmpw), TRUE);
  140.  
  141.   orientradio[1] = tmpw = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(tmpw)), _("Radius"));
  142.   gtk_box_pack_start(GTK_BOX(box3), tmpw, FALSE, FALSE, 0);
  143.   gtk_widget_show(tmpw);
  144.   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tmpw), FALSE);
  145.   gtk_signal_connect(GTK_OBJECT(tmpw), "clicked",
  146.              (GtkSignalFunc)orientchange, (void *)1);
  147.   gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), tmpw, _("The distance from the center of the image determines the direction of the stroke"), NULL);
  148.   if(i == 1)
  149.     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tmpw), TRUE);
  150.     
  151.   orientradio[2] = tmpw = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(tmpw)), _("Random"));
  152.   gtk_box_pack_start(GTK_BOX(box3), tmpw, FALSE, FALSE, 0);
  153.   gtk_widget_show(tmpw);
  154.   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tmpw), FALSE);
  155.   gtk_signal_connect(GTK_OBJECT(tmpw), "clicked",
  156.              (GtkSignalFunc)orientchange, (void *)2);
  157.   gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), tmpw, _("Selects a random direction of each stroke"), NULL);
  158.   if(i == 2)
  159.     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tmpw), TRUE);
  160.  
  161.   orientradio[3] = tmpw = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(tmpw)), _("Radial"));
  162.   gtk_box_pack_start(GTK_BOX(box3), tmpw, FALSE, FALSE, 0);
  163.   gtk_widget_show(tmpw);
  164.   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tmpw), FALSE);
  165.   gtk_signal_connect(GTK_OBJECT(tmpw), "clicked",
  166.              (GtkSignalFunc)orientchange, (void *)3);
  167.   gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), tmpw, _("Let the direction from the center determine the direction of the stroke"), NULL);
  168.   if(i == 3)
  169.     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tmpw), TRUE);
  170.  
  171.   box3 = gtk_vbox_new(FALSE,0);
  172.   gtk_box_pack_start(GTK_BOX(box2), box3,FALSE,FALSE, 10);
  173.   gtk_widget_show(box3);
  174.  
  175.  
  176.   orientradio[4] = tmpw = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(tmpw)), _("Flowing"));
  177.   gtk_box_pack_start(GTK_BOX(box3), tmpw, FALSE, FALSE, 0);
  178.   gtk_widget_show(tmpw);
  179.   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tmpw), FALSE);
  180.   gtk_signal_connect(GTK_OBJECT(tmpw), "clicked",
  181.              (GtkSignalFunc)orientchange, (void *)4);
  182.   gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), tmpw, _("The strokes follow a \"flowing\" pattern"), NULL);
  183.   if(i == 4)
  184.     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tmpw), TRUE);
  185.  
  186.  
  187.  
  188.   orientradio[5] = tmpw = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(tmpw)), _("Hue"));
  189.   gtk_box_pack_start(GTK_BOX(box3), tmpw, FALSE, FALSE, 0);
  190.   gtk_widget_show(tmpw);
  191.   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tmpw), FALSE);
  192.   gtk_signal_connect(GTK_OBJECT(tmpw), "clicked",
  193.              (GtkSignalFunc)orientchange, (void *)5);
  194.   gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), tmpw, _("The hue of the region determines the direction of the stroke"), NULL);
  195.   if(i == 5)
  196.     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tmpw), TRUE);
  197.  
  198.   orientradio[6] = tmpw = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(tmpw)), _("Adaptive"));
  199.   gtk_box_pack_start(GTK_BOX(box3), tmpw, FALSE, FALSE, 0);
  200.   gtk_widget_show(tmpw);
  201.   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tmpw), FALSE);
  202.   gtk_signal_connect(GTK_OBJECT(tmpw), "clicked",
  203.              (GtkSignalFunc)orientchange, (void *)6);
  204.   gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), tmpw, _("The direction that matches the original image the closest is selected"), NULL);
  205.   if(i == 6)
  206.     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tmpw), TRUE);
  207.  
  208.  
  209.   box4 = gtk_hbox_new(FALSE, 0);
  210.   gtk_box_pack_start(GTK_BOX(box3), box4, FALSE, FALSE, 0);
  211.   gtk_widget_show(box4);
  212.  
  213.   orientradio[7] = tmpw = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(tmpw)), _("Manual"));
  214.   gtk_box_pack_start(GTK_BOX(box4), tmpw, FALSE, FALSE, 0);
  215.   gtk_widget_show(tmpw);
  216.   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tmpw), FALSE);
  217.   gtk_signal_connect(GTK_OBJECT(tmpw), "clicked",
  218.              (GtkSignalFunc)orientchange, (void *)7);
  219.   gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), tmpw, _("Manually specify the stroke orientation"), NULL);
  220.   if(i == 7)
  221.     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tmpw), TRUE);
  222.  
  223.   tmpw = gtk_button_new_with_label( _("Edit..."));
  224.   gtk_box_pack_start(GTK_BOX(box4), tmpw, FALSE, FALSE, 0);
  225.   gtk_widget_show(tmpw);
  226.   gtk_signal_connect(GTK_OBJECT(tmpw), "clicked",
  227.              (GtkSignalFunc)create_orientmap_dialog, NULL);
  228.   gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), tmpw, _("Opens up the Orientation Map Editor"), NULL);
  229.  
  230.   gtk_notebook_append_page_menu (notebook, thispage, labelbox, menubox);
  231. }
  232.