Julian,

thanks for that response. It looks like i was checking the wrong account and
didn't get your responses. I'm back to looking at this project and am still
having trouble drawing on an existing gerber file.

I've modified example6 to read in a gerber file of my own -- a solder mask.
i'm trying to draw a rectangle and a line on it. I output the min and max
(x,y) coordinates to make sure I'm within the image with the drawings, but
can't see my changes. Please see the attached file.

I know I must be missing something. Changing the color works for me, but the
drawn parts don't show up, either in this example or when i try to save the
modified image to file.

the image dimensions that I get from running the compiled executable are:
Image width min: 1.660000
Image height min: 4.225000

Image width max: 12.113500
Image height max: 8.175000

Anything obvious that i'm doing wrong?

am


On Tue, Jun 22, 2010 at 4:18 PM, Julian Lamb <thepurl...@gmail.com> wrote:

>  aM,
>     I sent 2 emails to you directly last week....did you not get them?  If
> not, here they are.  I'm guessing you may still have multiple libraries on
> your system (see last part).  Let me know if this doesn't help.
>
>
> aM,
>     Hmmm...it works fine here.  I'm guessing you still may be linking to
> the previous libgerbv library, since I just added the ability to pass NULL
> as the transform pointer.  You can try make clean, then make install on the
> gerbv source...you can also try manually deleting the library from your
> /usr/local directory (or wherever you're installing it to and try compiling
> the examples again).  Worst case, you can just replace the relevant code in
> the examples you're interested in to:
>
>
>         gerbv_user_transformation_t identityTransform =
> {0,0,1,1,0,FALSE,FALSE,FALSE};
>         thisTransform = &identityTransform;
>
>     /* export the first (and only) image in the project, which will be the
>        one we just loaded */
>     gerbv_export_rs274x_file_from_image ("example1-output.gbx",
>             mainProject->file[0]->image, thisTransform);
>
>
> Another possible culprit may be multiple libgerbv libraries on your
> system.  You can find out the library location by using:
>
> ldd /usr/local/bin/gerbv (or wherever the gerbv binary is installed)
>
> If you have also installed gerbv using a package on your system (ubuntu,
> fedora, etc), this may be causing multiple libraries to exist.  To fix this,
> and make the examples use the version you are installing, do this:
>
>         2. If you installed gerbv to "/usr/local" (the default), many
>             distributions don't correctly point pkgconfig to this target.
>             To fix this, add the following to your ~/.bashrc file:
>
>             export
> PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:/usr/lib/pkgconfig/
>
>
> Hope this helps--
>
>
>
> Julian
>
> On 06/22/2010 02:09 AM, a m wrote:
>
> Any idea about the segfaults? They seem to happen in the
> gerbv_export_rs274x_file_from_image () call.
>
> thanks
>
> On Fri, Jun 11, 2010 at 6:50 PM, a m <makha...@gmail.com> wrote:
>
>> That was quick. I did a [git pull] to grab the changes, ran [make], and
>> [make install].
>> All of the examples now compile for me. However, all of the previously
>> broken ones (1,2,4,5) now give me segmentation faults.
>>
>> thanks,
>> aM
>>
>>
>> On Fri, Jun 11, 2010 at 4:03 PM, Julian Lamb <thepurl...@gmail.com>wrote:
>>
>>>  aM,
>>>     Thanks for spotting this problem...I guess I missed updating the
>>> example files when we changed the API previously.  I went ahead and fixed it
>>> all in git, so please update your tree and check out the changes.
>>> Basically, pass NULL in for the transform and the function will just use the
>>> default identity transform.  I think I checked all 6 of the examples and
>>> they should work now.  Let me know if you find otherwise, and feel free to
>>> ask any questions regarding libgerbv...we're glad to help!
>>>
>>> Cheers--
>>>  Julian
>>>
>>> On 06/11/2010 02:55 AM, a m wrote:
>>>
>>> Julian,
>>>
>>> Thanks for the prompt reply. Ive finally installed all the dependencies
>>> and was able to build it from source.
>>>
>>> I ran into problems with examples 1, 2, 4, 5. All the same thing:
>>> example5.c:56: error: too few arguments to function
>>> ‘gerbv_export_rs274x_file_from_image’
>>>
>>>  looks like a transform is missing. Whatś a quick way to get this
>>> working?
>>>
>>> Thanks again, it looks like this library will be perfect.
>>>
>>> aM
>>>
>>> On Tue, Jun 8, 2010 at 5:37 PM, Julian Lamb <thepurl...@gmail.com>wrote:
>>>
>>>> Hi aM,
>>>>     It depends on how in-depth you want to go.  We have split out
>>>> "libgerbv" as a separate library you're welcome to use in your own
>>>> applications.  If you download the gerbv source from git (see webpage on 
>>>> how
>>>> to do this), look at the /doc/example-code/ directory for a bunch of
>>>> examples on making some command line apps using libgerbv.  The rendering
>>>> code is also accessible with libgerv, so you can make fully functional GUI
>>>> apps with it too.
>>>>     If you want to just use the regular gerbv program and add some
>>>> specialized functions of your own, that would be another option.  Go to
>>>> /src/interface.c to add any buttons or menu entries you want to add, and
>>>> then place the callbacks for those buttons in the /src/callback.c file.  
>>>> You
>>>> can then put whatever code you want in those callback stubs.  There's an
>>>> example in /doc/example-code on how to draw rectangles.  For zooming to
>>>> specific levels, you'll probably just want to look at the functions in
>>>> callbacks.c on how to do that.
>>>>
>>>> Hack away!
>>>> Julian
>>>>
>>>> On 06/08/2010 01:36 AM, a m wrote:
>>>>
>>>>  Hello,
>>>>
>>>> Im wondering how it would be possible for me to zoom in on a certain
>>>> region or a drawing that is specified by typing in (x, y, width, height)
>>>> parameters. Another use case would be to draw a box or circle based on the
>>>> above parameters.
>>>>
>>>> Where would i start to be able to do something like this?
>>>>
>>>> In general, how scriptable is gerbv? how can i start hacking?
>>>>
>>>> thanks,
>>>> aM
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> ThinkGeek and WIRED's GeekDad team up for the Ultimate
>>>> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
>>>> lucky parental unit.  See the prize list and enter to win: 
>>>> http://p.sf.net/sfu/thinkgeek-promo
>>>>
>>>>
>>>> _______________________________________________
>>>> Gerbv-devel mailing 
>>>> listgerbv-de...@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/gerbv-devel
>>>>
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> ThinkGeek and WIRED's GeekDad team up for the Ultimate
>>>> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
>>>> lucky parental unit.  See the prize list and enter to win:
>>>> http://p.sf.net/sfu/thinkgeek-promo
>>>> _______________________________________________
>>>> Gerbv-devel mailing list
>>>> Gerbv-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/gerbv-devel
>>>>
>>>>
>>>
>>> ------------------------------------------------------------------------------
>>> ThinkGeek and WIRED's GeekDad team up for the Ultimate
>>> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
>>> lucky parental unit.  See the prize list and enter to win: 
>>> http://p.sf.net/sfu/thinkgeek-promo
>>>
>>>
>>> _______________________________________________
>>> Gerbv-devel mailing 
>>> listgerbv-de...@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/gerbv-devel
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> ThinkGeek and WIRED's GeekDad team up for the Ultimate
>>> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
>>> lucky parental unit.  See the prize list and enter to win:
>>> http://p.sf.net/sfu/thinkgeek-promo
>>> _______________________________________________
>>> Gerbv-devel mailing list
>>> Gerbv-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/gerbv-devel
>>>
>>>
>>
>
> ------------------------------------------------------------------------------
> ThinkGeek and WIRED's GeekDad team up for the Ultimate
> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
> lucky parental unit.  See the prize list and enter to win: 
> http://p.sf.net/sfu/thinkgeek-promo
>
>
> _______________________________________________
> Gerbv-devel mailing 
> listgerbv-de...@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/gerbv-devel
>
>
>
> ------------------------------------------------------------------------------
> ThinkGeek and WIRED's GeekDad team up for the Ultimate
> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
> lucky parental unit.  See the prize list and enter to win:
> http://p.sf.net/sfu/thinkgeek-promo
> _______________________________________________
> Gerbv-devel mailing list
> Gerbv-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gerbv-devel
>
>
/*------------------------------------------------------------------------------
  Filename: example6.c
  
  Description: Demonstrate how to embed a libgerbv render window into a new
  application to create a custom viewer
  
  Instructions: Make sure you are in the example-code directory, and compile
  this program with the following command (assumes you are using a
  newer version of gtk which uses cairo):
  
  gcc -Wall -g `pkg-config --cflags libgerbv` `pkg-config --libs libgerbv` example6.c -o example6
  
  Run with the following command:
  
  ./example6
  
  Common compiling problems:
  1. If you are compiling gerbv from source, make sure you run
  "make install" before trying to compile this example. This
  ensures libgerbv is correctly installed and can be found.
  2. If you installed gerbv to "/usr/local" (the default), many
  distributions don't correctly point pkgconfig to this target.
  To fix this, add the following to your ~/.bashrc file:
  
  export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:/usr/lib/pkgconfig/ 
  ------------------------------------------------------------------------------*/

/* gerbv.h pulls in all glib and gtk headers for you */
#include "gerbv.h"
#include <cairo.h>

/* this holds our rendering info like window size, scale factor, and translation */
gerbv_render_info_t screenRenderInfo;
/* this holds all our layers */
gerbv_project_t *mainProject;
/* store the drawing area widget globally to simplify the key event handling, to eliminate
   the need for an event box */
GtkWidget *drawingarea;

void
example_render_project_to_screen (GdkDrawable *drawable) {
  cairo_t *cr = gdk_cairo_create (drawable);
  
  /* this is by far the simplest method of rendering everything */
  gerbv_render_all_layers_to_cairo_target (mainProject, cr, &screenRenderInfo);
  
  /* if you know cairo well, feel free to incorporate your own method here,
     but this method shows you one possible idea.  With it, you have more flexibilty over
     the rendering
     int i;	
     // paint the background white before we draw anything
     cairo_set_source_rgba (cr, 1,1,1, 1);
     cairo_paint (cr);
     
     // step through all the files
     for(i = mainProject->max_files-1; i >= 0; i--) {
     if (mainProject->file[i]) {
     cairo_push_g
roup (cr);
     gerbv_render_layer_to_cairo_target (cr, mainProject->file[i], &screenRenderInfo);
     cairo_pop_group_to_source (cr);
     cairo_paint_with_alpha (cr, 0.70);
     }
     } */
  cairo_destroy (cr);
}
	
/* this is called when the window size changes, and also during startup */    
gboolean
example_callbacks_drawingarea_configure_event (GtkWidget *widget, GdkEventConfigure *event)
{
  GdkDrawable *drawable = widget->window;
  
  /* figure out how large the window is, and then fit the rendered images inside
     the specified window */
  gdk_drawable_get_size (drawable, &screenRenderInfo.displayWidth, &screenRenderInfo.displayHeight);
  gerbv_render_zoom_to_fit_display (mainProject, &screenRenderInfo);
  
  /* GTK should now automatically expose the window, so no need to do it manually */
  return TRUE;
}

/* this is called any time the window needs to redraw (another window moved in front of
   it, the window was un-minimized, etc) */
gboolean
example_callbacks_drawingarea_expose_event (GtkWidget *widget, GdkEventExpose *event)
{
  /* render all the layers */
  example_render_project_to_screen(widget->window);
  return TRUE;
}

/* do some simple translation based on the arrow keys and "Z" keys */
gboolean
example_callbacks_drawingarea_key_press_event (GtkWidget *widget, GdkEventKey *event)
{
  switch(event->keyval) {
  case GDK_Up:
    /* cairo renders positive Y as down, so keep the sign in mind */
    screenRenderInfo.lowerLeftY -= 0.1;
    break;
  case GDK_Down:
    screenRenderInfo.lowerLeftY += 0.1;
    break;
  case GDK_Left:
    screenRenderInfo.lowerLeftX += 0.1;
    break;
  case GDK_Right:
    screenRenderInfo.lowerLeftX -= 0.1;
    break;
  case GDK_z:
    /* notice the lower left corner doesn't move with this method...
       to do a "true" zoom in, refer to render.c and see how Gerber Viewer
       does it */
    screenRenderInfo.scaleFactorX += screenRenderInfo.scaleFactorX/3;
    screenRenderInfo.scaleFactorY += screenRenderInfo.scaleFactorY/3;
    break;
  case GDK_Z:
    screenRenderInfo.scaleFactorX -= screenRenderInfo.scaleFactorX/3;
    screenRenderInfo.scaleFactorY -= screenRenderInfo.scaleFactorY/3;
    break;
  default:
    break;
  }
  /* render everything again by forcing an expose event */
  GdkRectangle update_rect;
  
  update_rect.x = 0;
  update_rect.y = 0;
  update_rect.width = screenRenderInfo.displayWidth;
  update_rect.height = screenRenderInfo.displayHeight;
  
  /* force the drawing area to have an expose_event, thus redrawing the window */
  gdk_window_invalidate_rect (drawingarea->window, &update_rect, FALSE);
  return TRUE;
}

void
example_create_GUI (void){
  GtkWidget *mainWindow;
  
  mainWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size((GtkWindow *)mainWindow, 400, 400);
  
  gtk_window_set_title (GTK_WINDOW (mainWindow), "Example 6");
	
  /* a drawing area is the easiest way to make a custom cairo renderer */
  drawingarea = gtk_drawing_area_new();
  gtk_container_add (GTK_CONTAINER (mainWindow), drawingarea);

  /* hook up the signals we need to connect to */
  gtk_signal_connect(GTK_OBJECT(drawingarea), "expose_event",
		     GTK_SIGNAL_FUNC(example_callbacks_drawingarea_expose_event), NULL);
  gtk_signal_connect(GTK_OBJECT(drawingarea),"configure_event",
		     GTK_SIGNAL_FUNC(example_callbacks_drawingarea_configure_event), NULL);
  gtk_signal_connect(GTK_OBJECT(mainWindow), "key_press_event",
		     GTK_SIGNAL_FUNC(example_callbacks_drawingarea_key_press_event), NULL);
  gtk_signal_connect_after(GTK_OBJECT(mainWindow), "delete_event",
			   GTK_SIGNAL_FUNC(gtk_main_quit), NULL);

  gtk_widget_show_all (mainWindow);
}

int
main(int argc, char *argv[]) {
  /* create the top level libgerbv structure */
  mainProject = gerbv_create_project();
	
  /* make sure we change the render type to "cairo" instead of the GDK alternative */
  screenRenderInfo.renderType = GERBV_RENDER_TYPE_CAIRO_HIGH_QUALITY;
	
  /* parse 2 Gerber files */
  gerbv_open_layer_from_filename (mainProject, "/home/andrei/Desktop/test.gbx");
  /* gerbv_open_layer_from_filename (mainProject, "example2-input.gbx"); */
	
  /* make sure we parsed the files */
  if ((mainProject->file[0] == NULL) /* || (mainProject->file[1] == NULL) */)
    g_error ("There was an error parsing the files.");

  GdkColor greenishColor = {0, 10000, 65000, 10000};
  mainProject->file[0]->color = greenishColor;

  printf("\nImage width min: %f\n",mainProject->file[0]->image->info->min_x);
  printf("Image height min: %f\n",mainProject->file[0]->image->info->min_y);
  
  printf("\nImage width max: %f\n", mainProject->file[0]->image->info->max_x);
  printf("Image height max: %f\n",mainProject->file[0]->image->info->max_y);
  

  gerbv_image_create_line_object (mainProject->file[0]->image,
				  2.4, 5.3, 3.6, 5.3, 0.40,
				  GERBV_APTYPE_CIRCLE);

  gerbv_image_create_rectangle_object (mainProject->file[0]->image, /*!< the image to draw to */
				       9.0, /*!< the X coordinate of the lower left corner */
				       7.0, /*!< the Y coordinate of the lower left corner */
				       3.0, /*!< the width of the drawn rectangle */
		1.0 /*!< the height of the drawn rectangle */
);


	
  /* start up the gtk engine and create our GUI */
  gtk_init (&argc, &argv);
  example_create_GUI ();
	
  /* start the main GUI loop...it will stay in this function call until you exit */
  gtk_main();
	
  /* destroy the project, which will in turn destroy all child images */
  gerbv_destroy_project (mainProject);
  return 0;
}
------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share 
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
Gerbv-devel mailing list
Gerbv-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gerbv-devel

Reply via email to