Re: Filling polygons using GTK-Extra.

"Adrian E. Feiguin" <[email protected]> Thu, 23 Sep 2004 15:51:39 -0700
Newsgroups gmane.comp.scigraphica.gtkextra
Message-ID <[email protected]>
Oi Fabio! This is what I would do:

1) Take a look at gtkplotbox.[ch] copy it into a new file gtkplotpoly.[ch].
2) Replace all the Box->Poly ; plot_box -> plot_poly
3) go to gtk_plot_poly_draw_symbol, and replace all the code for dawing 
your custom polygon. Example:

 GtkPlotPoint point[n];

 point[0].x = ...;
 point[0].y = ...;
....
 point[n-1].x = ...;
 point[n-1].y = ...;

 gtk_plot_pc_draw_polygon(plot->pc, TRUE,point, n);

and voila! compile together with your code.
BTW. to convert from actual (x,y) coordinates to GtkPlotPoint (pixel) 
coordinates, you should use:
 
gtk_plot_get_pixel(plot, x, y, &point.x, &point.y);

Good luck!,
Saludos,
<ADRIAN>


Fabio da Silva wrote

Hola, Adrian!

>
> I have an integrated circuit design that I will need to tweak to reach 
> its final version.
> The design has 25 parameters that I need to be able to change before I 
> generate the
> final CAD script. I have been doing this on a command line basis but 
> now I wanted
> to see the changes on a GUI before I submit the script file and not 
> launch the CAD
> program everytime I change a parameter.
>
> That's why I need to be able to draw polygons with some filling 
> capabilities. This is
> a simple drwaing capability I want to implement. Eventually, the GUI 
> will have a
> simulation capability that will use the ploting capabilities of 
> GTK-Extra.
>
> I have successfully integrated Glade and GTK-Extra in some other 
> ploting GUIs
> I built, but the polygon drawing is new to me now.
>
> Any suggestion will be of great help.
>
>    Muito obrigado!
>
>        Fabio.
>
> Adrian E. Feiguin wrote:
>
>> Can you tell me exactly what's the idea behind the polygons? What are 
>> you representing? You need different shapes for different points? Can 
>> you use a pixmap? You are plotting some data or you just want to draw 
>> shapes? Tell me more and I'll give you a couple of ideas.
>> Saludos.
>> <ADRIAN>
>>
>> Fabio da Silva wrote:
>>
>>> Hello again!
>>>
>>> I need to draw some figures in my application that will require the 
>>> creation and
>>> display of polygons on the screen. On the gtkplotdata.h file I found 
>>> a few basic
>>> shapes like, lines, rectangles and ellipses. Is there a similar 
>>> function for general
>>> polygons?
>>>
>>> I tried to fill the region defined by a set of points using 
>>> gtk_plot_data_fill_area, but
>>> the filling is done with respect to the x-axis... I also looked at 
>>> the gtkplotpc.h file,
>>> but I am not sure whether or not I could use those functions into a 
>>> canvas widget.
>>> I checked the CVS repository, but  couldn't find a testgtkplotpc.c 
>>> file for some
>>> enlightening hints either. I can try it if that's the answer, but I 
>>> want to check with
>>> you guys first.
>>>
>>> Any suggestion?
>>>
>>>    Thank you,
>>>
>>>        Fabio.
>>>
>>>
>>>
>>> -------------------------------------------------------
>>> This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
>>> Project Admins to receive an Apple iPod Mini FREE for your judgement on
>>> who ports your project to Linux PPC the best. Sponsored by IBM.
>>> Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
>>> _______________________________________________
>>> Scigraphica-gtkextra mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/scigraphica-gtkextra
>>>
>>> .
>>>
>>
>>
>>
>
>
>
> .
>



-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php