mirror of
git://git.geda-project.org/gerbvhtdocs
synced 2025-06-06 00:00:20 +08:00
79 lines
6.6 KiB
HTML
79 lines
6.6 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
|
<title>gerbv: example3.c</title>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
|
<link href="tabs.css" rel="stylesheet" type="text/css">
|
|
</head><body>
|
|
<!-- Generated by Doxygen 1.5.6 -->
|
|
<div class="navigation" id="top">
|
|
<div class="tabs">
|
|
<ul>
|
|
<li><a href="main.html"><span>Main Page</span></a></li>
|
|
<li><a href="modules.html"><span>Modules</span></a></li>
|
|
<li><a href="classes.html"><span>Data Structures</span></a></li>
|
|
<li><a href="files.html"><span>Files</span></a></li>
|
|
<li><a href="dirs.html"><span>Directories</span></a></li>
|
|
<li><a href="examples.html"><span>Examples</span></a></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="contents">
|
|
<h1>example3.c</h1><div class="fragment"><pre class="fragment"><span class="comment">/*------------------------------------------------------------------------------</span>
|
|
<span class="comment"> Filename: example3.c</span>
|
|
<span class="comment"> </span>
|
|
<span class="comment"> Description: Loads example3-input.gbx, duplicates it and offsets it to the</span>
|
|
<span class="comment"> right by the width of the layer, changed the rendered color of the</span>
|
|
<span class="comment"> second image, then exports a PNG rendering of the overlaid images.</span>
|
|
<span class="comment"></span>
|
|
<span class="comment"> Instructions: Make sure you are in the example-code directory, and compile</span>
|
|
<span class="comment"> this program with the following command:</span>
|
|
<span class="comment"></span>
|
|
<span class="comment"> gcc -Wall -g `pkg-config --cflags gtk+-2.0 glib-2.0 libgerbv` `pkg-config \</span>
|
|
<span class="comment">--libs gtk+-2.0 glib-2.0 libgerbv` example3.c -o example3</span>
|
|
<span class="comment"></span>
|
|
<span class="comment"> Run with the following command:</span>
|
|
<span class="comment"> </span>
|
|
<span class="comment"> ./example3</span>
|
|
<span class="comment"></span>
|
|
<span class="comment">------------------------------------------------------------------------------*/</span>
|
|
|
|
<span class="preprocessor">#include "<a class="code" href="gerbv_8h.html" title="The main header file for the libgerbv library.">gerbv.h</a>"</span>
|
|
|
|
<span class="keywordtype">int</span>
|
|
main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[]) {
|
|
<span class="comment">/* create a top level libgerbv structure */</span>
|
|
<a name="_a0"></a><a class="code" href="structgerbv__project__t.html">gerbv_project_t</a> *<a name="a1"></a><a class="code" href="main_8c.html#8d078d012e6d279c43966b2121226c43" title="Global state variable to keep track of what&#39;s happening on the screen.">mainProject</a> = <a name="a2"></a><a class="code" href="gerbv_8c.html#5320e4f59b98078e635681ef0c5454c8" title="Create a new project structure and initialize some important variables.">gerbv_create_project</a>();
|
|
|
|
<span class="comment">/* parse a Gerber file and store it in the gerbv_project_t struct, and</span>
|
|
<span class="comment"> then immediately parse a second copy */</span>
|
|
<a name="a3"></a><a class="code" href="gerbv_8c.html#99cc1512fb3e47976604fde92ae3ce8c" title="Open a file, parse the contents, and add a new layer to an existing project.">gerbv_open_layer_from_filename</a> (mainProject, <span class="stringliteral">"example3-input.gbx"</span>);
|
|
<a class="code" href="gerbv_8c.html#99cc1512fb3e47976604fde92ae3ce8c" title="Open a file, parse the contents, and add a new layer to an existing project.">gerbv_open_layer_from_filename</a> (mainProject, <span class="stringliteral">"example3-input.gbx"</span>);
|
|
|
|
<span class="comment">/* make sure we parsed the files */</span>
|
|
<span class="keywordflow">if</span> ((mainProject-><a name="a4"></a><a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[0] == NULL) || (mainProject-><a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[1] == NULL))
|
|
g_error (<span class="stringliteral">"There was an error parsing the files."</span>);
|
|
|
|
<span class="comment">/* translate the second image (file[1]) up and right by 0.02 inches */</span>
|
|
mainProject-><a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[1]-><a name="a5"></a><a class="code" href="structgerbv__fileinfo__t.html#145b4c98b74e7b07d262e5ecad32199e">transform</a>.<a name="a6"></a><a class="code" href="structgerbv__user__transformation__t.html#d60fd2201908a685667656981f708522">translateY</a> = 0.02;
|
|
mainProject-><a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[1]-><a class="code" href="structgerbv__fileinfo__t.html#145b4c98b74e7b07d262e5ecad32199e">transform</a>.<a name="a7"></a><a class="code" href="structgerbv__user__transformation__t.html#4e3b3a2a90019950374d5f969c176140">translateX</a> = 0.02;
|
|
|
|
<span class="comment">/* change the color of the first image (file[0]) to green */</span>
|
|
GdkColor greenishColor = {0, 10000, 65000, 10000};
|
|
mainProject-><a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[0]-><a name="a8"></a><a class="code" href="structgerbv__fileinfo__t.html#412c5aa0e56866c1d0d10edfd09a5a1d">color</a> = greenishColor;
|
|
|
|
<span class="comment">/* export a rendered PNG image of the project, using the autoscale version</span>
|
|
<span class="comment"> to automatically center the image */</span>
|
|
<a name="a9"></a><a class="code" href="exportimage_8c.html#9afeb20672420eaa4998a597c913c818" title="Render a project to a PNG file, autoscaling the layers to fit inside the specified...">gerbv_export_png_file_from_project_autoscaled</a> (mainProject, 640, 480,
|
|
<span class="stringliteral">"example3-output.png"</span>);
|
|
|
|
<span class="comment">/* destroy the project, which will in turn destroy all child images */</span>
|
|
<a name="a10"></a><a class="code" href="gerbv_8c.html#2e09480d52ed08f73975eec160946b0c" title="Free a project and all related variables.">gerbv_destroy_project</a> (mainProject);
|
|
<span class="keywordflow">return</span> 0;
|
|
}
|
|
</pre></div> </div>
|
|
<hr size="1"><address style="text-align: right;"><small>Generated on Tue Aug 19 00:14:47 2008 for gerbv by
|
|
<a href="http://www.doxygen.org/index.html">
|
|
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address>
|
|
</body>
|
|
</html>
|