gerbvhtdocs/doxygen/main_8c-source.html

955 lines
97 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: src/main.c Source File</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&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="classes.html"><span>Data&nbsp;Structures</span></a></li>
<li class="current"><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 class="navpath"><a class="el" href="dir_0fba06f62092f0c8d9ff47b96507f331.html">src</a>
</div>
</div>
<div class="contents">
<h1>main.c</h1><a href="main_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * gEDA - GNU Electronic Design Automation</span>
<a name="l00003"></a>00003 <span class="comment"> * This file is a part of gerbv.</span>
<a name="l00004"></a>00004 <span class="comment"> *</span>
<a name="l00005"></a>00005 <span class="comment"> * Copyright (C) 2008 Julian Lamb</span>
<a name="l00006"></a>00006 <span class="comment"> *</span>
<a name="l00007"></a>00007 <span class="comment"> * $Id$</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00010"></a>00010 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00011"></a>00011 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00012"></a>00012 <span class="comment"> * (at your option) any later version.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00015"></a>00015 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00016"></a>00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00017"></a>00017 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00020"></a>00020 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00021"></a>00021 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA</span>
<a name="l00022"></a>00022 <span class="comment"> */</span>
<a name="l00023"></a>00023
<a name="l00029"></a>00029 <span class="preprocessor">#ifdef HAVE_CONFIG_H</span>
<a name="l00030"></a>00030 <span class="preprocessor"></span><span class="preprocessor">#include "config.h"</span>
<a name="l00031"></a>00031 <span class="preprocessor">#endif</span>
<a name="l00032"></a>00032 <span class="preprocessor"></span>
<a name="l00033"></a>00033 <span class="preprocessor">#include &lt;assert.h&gt;</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00036"></a>00036 <span class="preprocessor">#include &lt;errno.h&gt;</span>
<a name="l00037"></a>00037
<a name="l00038"></a>00038 <span class="preprocessor">#ifdef HAVE_STRING_H</span>
<a name="l00039"></a>00039 <span class="preprocessor"></span><span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00040"></a>00040 <span class="preprocessor">#endif</span>
<a name="l00041"></a>00041 <span class="preprocessor"></span>
<a name="l00042"></a>00042 <span class="preprocessor">#ifdef HAVE_UNISTD_H</span>
<a name="l00043"></a>00043 <span class="preprocessor"></span><span class="preprocessor">#include &lt;unistd.h&gt;</span>
<a name="l00044"></a>00044 <span class="preprocessor">#endif</span>
<a name="l00045"></a>00045 <span class="preprocessor"></span>
<a name="l00046"></a>00046 <span class="preprocessor">#include &lt;glib.h&gt;</span>
<a name="l00047"></a>00047 <span class="preprocessor">#include &lt;gtk/gtk.h&gt;</span>
<a name="l00048"></a>00048 <span class="preprocessor">#include &lt;gdk/gdk.h&gt;</span>
<a name="l00049"></a>00049 <span class="preprocessor">#include &lt;gdk/gdkkeysyms.h&gt;</span>
<a name="l00050"></a>00050
<a name="l00051"></a>00051 <span class="preprocessor">#ifdef HAVE_GETOPT_H</span>
<a name="l00052"></a>00052 <span class="preprocessor"></span><span class="preprocessor"> #include &lt;getopt.h&gt;</span>
<a name="l00053"></a>00053 <span class="preprocessor">#endif</span>
<a name="l00054"></a>00054 <span class="preprocessor"></span>
<a name="l00055"></a>00055 <span class="preprocessor">#include &lt;locale.h&gt;</span>
<a name="l00056"></a>00056
<a name="l00057"></a>00057 <span class="preprocessor">#include "<a class="code" href="gerbv_8h.html" title="The main header file for the libgerbv library.">gerbv.h</a>"</span>
<a name="l00058"></a>00058 <span class="preprocessor">#include "<a class="code" href="main_8h.html" title="Header info for common structs and functions used for the GUI application.">main.h</a>"</span>
<a name="l00059"></a>00059 <span class="preprocessor">#include "<a class="code" href="callbacks_8h.html" title="Header info for the GUI callback functions.">callbacks.h</a>"</span>
<a name="l00060"></a>00060 <span class="preprocessor">#include "<a class="code" href="interface_8h.html" title="Header info for the GUI building functions for Gerber Viewer.">interface.h</a>"</span>
<a name="l00061"></a>00061 <span class="preprocessor">#include "<a class="code" href="render_8h.html" title="Header info for the rendering support functions for libgerbv.">render.h</a>"</span>
<a name="l00062"></a>00062 <span class="preprocessor">#include "<a class="code" href="project_8h.html" title="routines for loading and saving project files">project.h</a>"</span>
<a name="l00063"></a>00063
<a name="l00064"></a>00064 <span class="comment">/* DEBUG printing. #define DEBUG 1 in config.h to use this fcn. */</span>
<a name="l00065"></a>00065 <span class="preprocessor">#define dprintf if(DEBUG) printf</span>
<a name="l00066"></a>00066 <span class="preprocessor"></span>
<a name="l00067"></a>00067 <span class="preprocessor">#define NUMBER_OF_DEFAULT_COLORS 18</span>
<a name="l00068"></a>00068 <span class="preprocessor"></span><span class="preprocessor">#define NUMBER_OF_DEFAULT_TRANSFORMATIONS 20</span>
<a name="l00069"></a>00069 <span class="preprocessor"></span>
<a name="l00070"></a>00070 <span class="keyword">static</span> <a class="code" href="structgerbv__layer__color.html">gerbv_layer_color</a> mainDefaultColors[NUMBER_OF_DEFAULT_COLORS] = {
<a name="l00071"></a>00071 {115,115,222,177},
<a name="l00072"></a>00072 {255,127,115,177},
<a name="l00073"></a>00073 {193,0,224,177},
<a name="l00074"></a>00074 {117,242,103,177},
<a name="l00075"></a>00075 {0,195,195,177},
<a name="l00076"></a>00076 {213,253,51,177},
<a name="l00077"></a>00077 {209,27,104,177},
<a name="l00078"></a>00078 {255,197,51,177},
<a name="l00079"></a>00079 {186,186,186,177},
<a name="l00080"></a>00080 {211,211,255,177},
<a name="l00081"></a>00081 {253,210,206,177},
<a name="l00082"></a>00082 {236,194,242,177},
<a name="l00083"></a>00083 {208,249,204,177},
<a name="l00084"></a>00084 {183,255,255,177},
<a name="l00085"></a>00085 {241,255,183,177},
<a name="l00086"></a>00086 {255,202,225,177},
<a name="l00087"></a>00087 {253,238,197,177},
<a name="l00088"></a>00088 {226,226,226,177}
<a name="l00089"></a>00089 };
<a name="l00090"></a>00090
<a name="l00091"></a>00091 <span class="keyword">static</span> <a class="code" href="structgerbv__user__transformation__t.html">gerbv_user_transformation_t</a> mainDefaultTransformations[NUMBER_OF_DEFAULT_TRANSFORMATIONS] = {
<a name="l00092"></a>00092 {0,0,0,0,FALSE},
<a name="l00093"></a>00093 {0,0,0,0,FALSE},
<a name="l00094"></a>00094 {0,0,0,0,FALSE},
<a name="l00095"></a>00095 {0,0,0,0,FALSE},
<a name="l00096"></a>00096 {0,0,0,0,FALSE},
<a name="l00097"></a>00097 {0,0,0,0,FALSE},
<a name="l00098"></a>00098 {0,0,0,0,FALSE},
<a name="l00099"></a>00099 {0,0,0,0,FALSE},
<a name="l00100"></a>00100 {0,0,0,0,FALSE},
<a name="l00101"></a>00101 {0,0,0,0,FALSE},
<a name="l00102"></a>00102 {0,0,0,0,FALSE},
<a name="l00103"></a>00103 {0,0,0,0,FALSE},
<a name="l00104"></a>00104 {0,0,0,0,FALSE},
<a name="l00105"></a>00105 {0,0,0,0,FALSE},
<a name="l00106"></a>00106 {0,0,0,0,FALSE},
<a name="l00107"></a>00107 {0,0,0,0,FALSE},
<a name="l00108"></a>00108 {0,0,0,0,FALSE},
<a name="l00109"></a>00109 {0,0,0,0,FALSE},
<a name="l00110"></a>00110 {0,0,0,0,FALSE},
<a name="l00111"></a>00111 {0,0,0,0,FALSE},
<a name="l00112"></a>00112 };
<a name="l00113"></a>00113
<a name="l00114"></a>00114 <span class="preprocessor">#ifdef HAVE_GETOPT_LONG</span>
<a name="l00115"></a>00115 <span class="preprocessor"></span><span class="keywordtype">int</span> longopt_val = 0;
<a name="l00116"></a>00116 <span class="keywordtype">int</span> longopt_idx = 0;
<a name="l00117"></a>00117 <span class="keyword">const</span> <span class="keyword">struct </span>option longopts[] = {
<a name="l00118"></a>00118 <span class="comment">/* name has_arg flag val */</span>
<a name="l00119"></a>00119 {<span class="stringliteral">"border"</span>, required_argument, NULL, <span class="charliteral">'B'</span>},
<a name="l00120"></a>00120 {<span class="stringliteral">"dpi"</span>, required_argument, NULL, <span class="charliteral">'D'</span>},
<a name="l00121"></a>00121 {<span class="stringliteral">"version"</span>, no_argument, NULL, <span class="charliteral">'V'</span>},
<a name="l00122"></a>00122 {<span class="stringliteral">"origin"</span>, required_argument, NULL, <span class="charliteral">'O'</span>},
<a name="l00123"></a>00123 {<span class="stringliteral">"window_inch"</span>, required_argument, NULL, <span class="charliteral">'W'</span>},
<a name="l00124"></a>00124 {<span class="stringliteral">"antialias"</span>, no_argument, NULL, <span class="charliteral">'a'</span>},
<a name="l00125"></a>00125 {<span class="stringliteral">"background"</span>, required_argument, NULL, <span class="charliteral">'b'</span>},
<a name="l00126"></a>00126 {<span class="stringliteral">"dump"</span>, no_argument, NULL, <span class="charliteral">'d'</span>},
<a name="l00127"></a>00127 {<span class="stringliteral">"foreground"</span>, required_argument, NULL, <span class="charliteral">'f'</span>},
<a name="l00128"></a>00128 {<span class="stringliteral">"help"</span>, no_argument, NULL, <span class="charliteral">'h'</span>},
<a name="l00129"></a>00129 {<span class="stringliteral">"log"</span>, required_argument, NULL, <span class="charliteral">'l'</span>},
<a name="l00130"></a>00130 {<span class="stringliteral">"output"</span>, required_argument, NULL, <span class="charliteral">'o'</span>},
<a name="l00131"></a>00131 {<span class="stringliteral">"project"</span>, required_argument, NULL, <span class="charliteral">'p'</span>},
<a name="l00132"></a>00132 {<span class="stringliteral">"tools"</span>, required_argument, NULL, <span class="charliteral">'t'</span>},
<a name="l00133"></a>00133 {<span class="stringliteral">"translate"</span>, required_argument, NULL, <span class="charliteral">'T'</span>},
<a name="l00134"></a>00134 {<span class="stringliteral">"window"</span>, required_argument, NULL, <span class="charliteral">'w'</span>},
<a name="l00135"></a>00135 {<span class="stringliteral">"export"</span>, required_argument, NULL, <span class="charliteral">'x'</span>},
<a name="l00136"></a>00136 {<span class="stringliteral">"geometry"</span>, required_argument, &amp;longopt_val, 1},
<a name="l00137"></a>00137 <span class="comment">/* GDK/GDK debug flags to be "let through" */</span>
<a name="l00138"></a>00138 {<span class="stringliteral">"gtk-module"</span>, required_argument, &amp;longopt_val, 2},
<a name="l00139"></a>00139 {<span class="stringliteral">"g-fatal-warnings"</span>,no_argument, &amp;longopt_val, 2},
<a name="l00140"></a>00140 {<span class="stringliteral">"gtk-debug"</span>, required_argument, &amp;longopt_val, 2},
<a name="l00141"></a>00141 {<span class="stringliteral">"gtk-no-debug"</span>, required_argument, &amp;longopt_val, 2},
<a name="l00142"></a>00142 {<span class="stringliteral">"gdk-debug"</span>, required_argument, &amp;longopt_val, 2},
<a name="l00143"></a>00143 {<span class="stringliteral">"gdk-no-debug"</span>, required_argument, &amp;longopt_val, 2},
<a name="l00144"></a>00144 {<span class="stringliteral">"display"</span>, required_argument, &amp;longopt_val, 2},
<a name="l00145"></a>00145 {<span class="stringliteral">"sync"</span>, no_argument, &amp;longopt_val, 2},
<a name="l00146"></a>00146 {<span class="stringliteral">"no-xshm"</span>, no_argument, &amp;longopt_val, 2},
<a name="l00147"></a>00147 {<span class="stringliteral">"name"</span>, required_argument, &amp;longopt_val, 2},
<a name="l00148"></a>00148 {<span class="stringliteral">"class"</span>, required_argument, &amp;longopt_val, 2},
<a name="l00149"></a>00149 {0, 0, 0, 0},
<a name="l00150"></a>00150 };
<a name="l00151"></a>00151 <span class="preprocessor">#endif </span><span class="comment">/* HAVE_GETOPT_LONG*/</span>
<a name="l00152"></a>00152 <span class="keyword">const</span> <span class="keywordtype">char</span> *opt_options = <span class="stringliteral">"Vadh:B:D:O:W:b:f:l:o:p:t:T:w:x:"</span>;
<a name="l00153"></a>00153
<a name="l00157"></a><a class="code" href="main_8h.html#8d078d012e6d279c43966b2121226c43">00157</a> <a class="code" href="structgerbv__project__t.html">gerbv_project_t</a> *<a class="code" href="main_8c.html#8d078d012e6d279c43966b2121226c43" title="Global state variable to keep track of what&amp;#39;s happening on the screen.">mainProject</a>;
<a name="l00158"></a><a class="code" href="render_8c.html#1ec55bca5ad7868d265ee62fe10a29bc">00158</a> gerbv_screen_t <a class="code" href="callbacks_8c.html#1ec55bca5ad7868d265ee62fe10a29bc" title="Global variable to keep track of what&amp;#39;s happening on the screen.">screen</a>;
<a name="l00159"></a>00159
<a name="l00160"></a>00160 gboolean logToFileOption;
<a name="l00161"></a>00161 gchar *logToFileFilename;
<a name="l00162"></a>00162
<a name="l00163"></a>00163 <span class="comment">/* ------------------------------------------------------------------ */</span>
<a name="l00164"></a>00164 <span class="keywordtype">void</span>
<a name="l00165"></a>00165 main_open_project_from_filename(<a class="code" href="structgerbv__project__t.html">gerbv_project_t</a> *gerbvProject, gchar *filename)
<a name="l00166"></a>00166 {
<a name="l00167"></a>00167 project_list_t *project_list = NULL;
<a name="l00168"></a>00168
<a name="l00169"></a>00169 dprintf(<span class="stringliteral">"Opening project = %s\n"</span>, (gchar *) filename);
<a name="l00170"></a>00170 project_list = <a class="code" href="project_8c.html#92cb12e248aded047a0e4f3187808420" title="Reads the content of a project file.">read_project_file</a>(filename);
<a name="l00171"></a>00171
<a name="l00172"></a>00172 <span class="keywordflow">if</span> (project_list) {
<a name="l00173"></a>00173 project_list_t *pl_tmp;
<a name="l00174"></a>00174
<a name="l00175"></a>00175 <span class="keywordflow">while</span> (project_list) {
<a name="l00176"></a>00176 GdkColor colorTemplate = {0,project_list-&gt;rgb[0],
<a name="l00177"></a>00177 project_list-&gt;rgb[1],project_list-&gt;rgb[2]};
<a name="l00178"></a>00178 <span class="keywordflow">if</span> (project_list-&gt;layerno == -1) {
<a name="l00179"></a>00179 gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#545040772fbe22865784f8ddca0a3d5d">background</a> = colorTemplate;
<a name="l00180"></a>00180 } <span class="keywordflow">else</span> {
<a name="l00181"></a>00181 <span class="keywordtype">int</span> idx = project_list-&gt;layerno;
<a name="l00182"></a>00182 gchar *fullName = NULL;
<a name="l00183"></a>00183 gchar *dirName = NULL;
<a name="l00184"></a>00184
<a name="l00185"></a>00185 <span class="keywordflow">if</span> (!g_path_is_absolute (project_list-&gt;filename)) {
<a name="l00186"></a>00186 <span class="comment">/* build the full pathname to the layer */</span>
<a name="l00187"></a>00187 dirName = g_path_get_dirname (filename);
<a name="l00188"></a>00188 fullName = g_build_filename (dirName, project_list-&gt;filename, NULL);
<a name="l00189"></a>00189 } <span class="keywordflow">else</span> {
<a name="l00190"></a>00190 fullName = g_strdup (project_list-&gt;filename);
<a name="l00191"></a>00191 }
<a name="l00192"></a>00192 <span class="keywordflow">if</span> (gerbv_open_image(gerbvProject, fullName, idx, FALSE,
<a name="l00193"></a>00193 project_list-&gt;attr_list,
<a name="l00194"></a>00194 project_list-&gt;n_attr, TRUE) == -1) {
<a name="l00195"></a>00195 GERB_MESSAGE(<span class="stringliteral">"could not read %s[%d]"</span>, fullName, idx);
<a name="l00196"></a>00196 <span class="keywordflow">goto</span> next_layer;
<a name="l00197"></a>00197 }
<a name="l00198"></a>00198 g_free (dirName);
<a name="l00199"></a>00199 g_free (fullName);
<a name="l00200"></a>00200 <span class="comment">/* </span>
<a name="l00201"></a>00201 <span class="comment"> * Change color from default to from the project list</span>
<a name="l00202"></a>00202 <span class="comment"> */</span>
<a name="l00203"></a>00203 gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[idx]-&gt;<a class="code" href="structgerbv__fileinfo__t.html#412c5aa0e56866c1d0d10edfd09a5a1d">color</a> = colorTemplate;
<a name="l00204"></a>00204 gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[idx]-&gt;<a class="code" href="structgerbv__fileinfo__t.html#145b4c98b74e7b07d262e5ecad32199e">transform</a>.<a class="code" href="structgerbv__user__transformation__t.html#4c5d3155d0f4aa77896b1f88535cbb4e">inverted</a> = project_list-&gt;inverted;
<a name="l00205"></a>00205 gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[idx]-&gt;<a class="code" href="structgerbv__fileinfo__t.html#fc59b2ffc535696e81b3086d025370c5">isVisible</a> = project_list-&gt;visible;
<a name="l00206"></a>00206 }
<a name="l00207"></a>00207 next_layer:
<a name="l00208"></a>00208 pl_tmp = project_list;
<a name="l00209"></a>00209 project_list = project_list-&gt;next;
<a name="l00210"></a>00210 g_free(pl_tmp-&gt;filename);
<a name="l00211"></a>00211 g_free(pl_tmp);
<a name="l00212"></a>00212 }
<a name="l00213"></a>00213
<a name="l00214"></a>00214 <span class="comment">/*</span>
<a name="l00215"></a>00215 <span class="comment"> * Save project filename for later use</span>
<a name="l00216"></a>00216 <span class="comment"> */</span>
<a name="l00217"></a>00217 <span class="keywordflow">if</span> (gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#4594ebb553168b1ba1d8fd1357194ac3">project</a>) {
<a name="l00218"></a>00218 g_free(gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#4594ebb553168b1ba1d8fd1357194ac3">project</a>);
<a name="l00219"></a>00219 gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#4594ebb553168b1ba1d8fd1357194ac3">project</a> = NULL;
<a name="l00220"></a>00220 }
<a name="l00221"></a>00221 gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#4594ebb553168b1ba1d8fd1357194ac3">project</a> = g_strdup (filename);
<a name="l00222"></a>00222 <span class="keywordflow">if</span> (gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#4594ebb553168b1ba1d8fd1357194ac3">project</a> == NULL)
<a name="l00223"></a>00223 GERB_FATAL_ERROR(<span class="stringliteral">"malloc gerbvProject-&gt;project failed\n"</span>);
<a name="l00224"></a>00224 } <span class="keywordflow">else</span> {
<a name="l00225"></a>00225 GERB_MESSAGE(<span class="stringliteral">"could not read %s[%d]\n"</span>, (gchar *) filename,
<a name="l00226"></a>00226 gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#e46aefcf0d2e857be2d4c3c2370ede82">last_loaded</a>);
<a name="l00227"></a>00227 }
<a name="l00228"></a>00228 } <span class="comment">/* gerbv_open_project_from_filename */</span>
<a name="l00229"></a>00229
<a name="l00230"></a>00230 <span class="comment">/* ------------------------------------------------------------------ */</span>
<a name="l00231"></a>00231 <span class="keywordtype">void</span>
<a name="l00232"></a>00232 main_save_project_from_filename(<a class="code" href="structgerbv__project__t.html">gerbv_project_t</a> *gerbvProject, gchar *filename)
<a name="l00233"></a>00233 {
<a name="l00234"></a>00234 project_list_t *project_list = NULL, *tmp;
<a name="l00235"></a>00235 <span class="keywordtype">int</span> idx;
<a name="l00236"></a>00236 gchar *dirName = g_path_get_dirname (filename);
<a name="l00237"></a>00237
<a name="l00238"></a>00238 project_list = g_new0 (project_list_t, 1);
<a name="l00239"></a>00239 project_list-&gt;next = project_list;
<a name="l00240"></a>00240 project_list-&gt;layerno = -1;
<a name="l00241"></a>00241 project_list-&gt;filename = gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#8b8fc06714c48c6282639412d964ad9a">path</a>;
<a name="l00242"></a>00242 project_list-&gt;rgb[0] = gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#545040772fbe22865784f8ddca0a3d5d">background</a>.red;
<a name="l00243"></a>00243 project_list-&gt;rgb[1] = gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#545040772fbe22865784f8ddca0a3d5d">background</a>.green;
<a name="l00244"></a>00244 project_list-&gt;rgb[2] = gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#545040772fbe22865784f8ddca0a3d5d">background</a>.blue;
<a name="l00245"></a>00245 project_list-&gt;next = NULL;
<a name="l00246"></a>00246
<a name="l00247"></a>00247 <span class="comment">/* loop over all layer files */</span>
<a name="l00248"></a>00248 <span class="keywordflow">for</span> (idx = 0; idx &lt; gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#bab05758e52aca9b2b2c171ec923a4bf">max_files</a>; idx++) {
<a name="l00249"></a>00249 <span class="keywordflow">if</span> (gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[idx]) {
<a name="l00250"></a>00250 tmp = g_new0 (project_list_t, 1);
<a name="l00251"></a>00251 tmp-&gt;next = project_list;
<a name="l00252"></a>00252 tmp-&gt;layerno = idx;
<a name="l00253"></a>00253
<a name="l00254"></a>00254 <span class="comment">/* figure out the relative path to the layer from the project</span>
<a name="l00255"></a>00255 <span class="comment"> directory */</span>
<a name="l00256"></a>00256 <span class="keywordflow">if</span> (strncmp (dirName, gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[idx]-&gt;<a class="code" href="structgerbv__fileinfo__t.html#32bf3fed3f7a68bbd855a86839b52532">name</a>, strlen(dirName)) == 0) {
<a name="l00257"></a>00257 <span class="comment">/* skip over the common dirname and the separator */</span>
<a name="l00258"></a>00258 tmp-&gt;filename = (gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[idx]-&gt;<a class="code" href="structgerbv__fileinfo__t.html#32bf3fed3f7a68bbd855a86839b52532">name</a> + strlen(dirName) + 1);
<a name="l00259"></a>00259 } <span class="keywordflow">else</span> {
<a name="l00260"></a>00260 <span class="comment">/* if we can't figure out a relative path, just save the </span>
<a name="l00261"></a>00261 <span class="comment"> * absolute one */</span>
<a name="l00262"></a>00262 tmp-&gt;filename = gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[idx]-&gt;<a class="code" href="structgerbv__fileinfo__t.html#32bf3fed3f7a68bbd855a86839b52532">name</a>;
<a name="l00263"></a>00263 }
<a name="l00264"></a>00264 tmp-&gt;rgb[0] = gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[idx]-&gt;<a class="code" href="structgerbv__fileinfo__t.html#412c5aa0e56866c1d0d10edfd09a5a1d">color</a>.red;
<a name="l00265"></a>00265 tmp-&gt;rgb[1] = gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[idx]-&gt;<a class="code" href="structgerbv__fileinfo__t.html#412c5aa0e56866c1d0d10edfd09a5a1d">color</a>.green;
<a name="l00266"></a>00266 tmp-&gt;rgb[2] = gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[idx]-&gt;<a class="code" href="structgerbv__fileinfo__t.html#412c5aa0e56866c1d0d10edfd09a5a1d">color</a>.blue;
<a name="l00267"></a>00267 tmp-&gt;inverted = gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[idx]-&gt;<a class="code" href="structgerbv__fileinfo__t.html#145b4c98b74e7b07d262e5ecad32199e">transform</a>.<a class="code" href="structgerbv__user__transformation__t.html#4c5d3155d0f4aa77896b1f88535cbb4e">inverted</a>;
<a name="l00268"></a>00268 tmp-&gt;visible = gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[idx]-&gt;<a class="code" href="structgerbv__fileinfo__t.html#fc59b2ffc535696e81b3086d025370c5">isVisible</a>;
<a name="l00269"></a>00269 <span class="comment">/* save individual layers as part of saving project */</span>
<a name="l00270"></a>00270 gerbv_save_layer_from_index(gerbvProject, idx, tmp-&gt;filename);
<a name="l00271"></a>00271
<a name="l00272"></a>00272 project_list = tmp;
<a name="l00273"></a>00273 }
<a name="l00274"></a>00274 }
<a name="l00275"></a>00275
<a name="l00276"></a>00276 <span class="keywordflow">if</span> (write_project_file(gerbvProject, gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#4594ebb553168b1ba1d8fd1357194ac3">project</a>, project_list)) {
<a name="l00277"></a>00277 GERB_MESSAGE(<span class="stringliteral">"Failed to write project\n"</span>);
<a name="l00278"></a>00278 }
<a name="l00279"></a>00279 g_free (dirName);
<a name="l00280"></a>00280 } <span class="comment">/* gerbv_save_project_from_filename */</span>
<a name="l00281"></a>00281
<a name="l00282"></a>00282 <span class="comment">/* ------------------------------------------------------------------ */</span>
<a name="l00283"></a>00283 <span class="keywordtype">void</span>
<a name="l00284"></a>00284 main_save_as_project_from_filename(<a class="code" href="structgerbv__project__t.html">gerbv_project_t</a> *gerbvProject, gchar *filename)
<a name="l00285"></a>00285 {
<a name="l00286"></a>00286
<a name="l00287"></a>00287 <span class="comment">/*</span>
<a name="l00288"></a>00288 <span class="comment"> * Save project filename for later use</span>
<a name="l00289"></a>00289 <span class="comment"> */</span>
<a name="l00290"></a>00290 <span class="keywordflow">if</span> (gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#4594ebb553168b1ba1d8fd1357194ac3">project</a>) {
<a name="l00291"></a>00291 g_free(gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#4594ebb553168b1ba1d8fd1357194ac3">project</a>);
<a name="l00292"></a>00292 gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#4594ebb553168b1ba1d8fd1357194ac3">project</a> = NULL;
<a name="l00293"></a>00293 }
<a name="l00294"></a>00294 gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#4594ebb553168b1ba1d8fd1357194ac3">project</a> = g_strdup(filename);
<a name="l00295"></a>00295 <span class="keywordflow">if</span> (gerbvProject-&gt;<a class="code" href="structgerbv__project__t.html#4594ebb553168b1ba1d8fd1357194ac3">project</a> == NULL)
<a name="l00296"></a>00296 GERB_FATAL_ERROR(<span class="stringliteral">"malloc gerbvProject-&gt;project failed\n"</span>);
<a name="l00297"></a>00297 main_save_project_from_filename (gerbvProject, filename);
<a name="l00298"></a>00298 } <span class="comment">/* gerbv_save_as_project_from_filename */</span>
<a name="l00299"></a>00299
<a name="l00300"></a>00300
<a name="l00301"></a>00301 <span class="comment">/* ------------------------------------------------------------------ */</span>
<a name="l00302"></a>00302 <span class="keywordtype">int</span>
<a name="l00303"></a>00303 main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])
<a name="l00304"></a>00304 {
<a name="l00305"></a>00305 <span class="keywordtype">int</span> read_opt;
<a name="l00306"></a>00306 <span class="keywordtype">int</span> i,r,g,b,a;
<a name="l00307"></a>00307 <span class="keywordtype">int</span> req_width = -1, req_height = -1;
<a name="l00308"></a>00308 <span class="preprocessor">#ifdef HAVE_GETOPT_LONG</span>
<a name="l00309"></a>00309 <span class="preprocessor"></span> <span class="keywordtype">int</span> req_x = 0, req_y = 0;
<a name="l00310"></a>00310 <span class="keywordtype">char</span> *rest;
<a name="l00311"></a>00311 <span class="preprocessor">#endif</span>
<a name="l00312"></a>00312 <span class="preprocessor"></span> <span class="keywordtype">char</span> *project_filename = NULL;
<a name="l00313"></a>00313 gboolean exportFromCommandline = FALSE, userSuppliedOrigin=FALSE, userSuppliedWindow=FALSE,
<a name="l00314"></a>00314 userSuppliedAntiAlias=FALSE, userSuppliedWindowInPixels=FALSE, userSuppliedDpi=FALSE;
<a name="l00315"></a>00315 gint layerctr =0, transformCount = 0, exportType = 0;
<a name="l00316"></a>00316 gchar *exportFilename = NULL;
<a name="l00317"></a>00317 gfloat userSuppliedOriginX=0.0,userSuppliedOriginY=0.0,userSuppliedDpiX=72.0, userSuppliedDpiY=72.0,
<a name="l00318"></a>00318 userSuppliedWidth=0, userSuppliedHeight=0, userSuppliedBorder=0.05;
<a name="l00319"></a>00319
<a name="l00320"></a>00320
<a name="l00321"></a>00321 <span class="comment">/*</span>
<a name="l00322"></a>00322 <span class="comment"> * Setup the screen info. Must do this before getopt, since getopt</span>
<a name="l00323"></a>00323 <span class="comment"> * eventually will set some variables in screen.</span>
<a name="l00324"></a>00324 <span class="comment"> */</span>
<a name="l00325"></a>00325 memset((<span class="keywordtype">void</span> *)&amp;<a class="code" href="callbacks_8c.html#1ec55bca5ad7868d265ee62fe10a29bc" title="Global variable to keep track of what&amp;#39;s happening on the screen.">screen</a>, 0, <span class="keyword">sizeof</span>(gerbv_screen_t));
<a name="l00326"></a>00326 screen.state = NORMAL;
<a name="l00327"></a>00327
<a name="l00328"></a>00328 mainProject = <a class="code" href="gerbv_8c.html#5320e4f59b98078e635681ef0c5454c8" title="Create a new project structure and initialize some important variables.">gerbv_create_project</a>();
<a name="l00329"></a>00329 mainProject-&gt;<a class="code" href="structgerbv__project__t.html#b4caee5b70fab59e0f3f9ce84c0fc854">execpath</a> = g_path_get_dirname(argv[0]);
<a name="l00330"></a>00330
<a name="l00331"></a>00331 logToFileOption = FALSE;
<a name="l00332"></a>00332 logToFileFilename = NULL;
<a name="l00333"></a>00333 <span class="comment">/*</span>
<a name="l00334"></a>00334 <span class="comment"> * Now process command line flags</span>
<a name="l00335"></a>00335 <span class="comment"> */</span>
<a name="l00336"></a>00336 <span class="keywordflow">while</span> (
<a name="l00337"></a>00337 #ifdef HAVE_GETOPT_LONG
<a name="l00338"></a>00338 (read_opt = getopt_long(argc, argv, opt_options,
<a name="l00339"></a>00339 longopts, &amp;longopt_idx))
<a name="l00340"></a>00340 #<span class="keywordflow">else</span>
<a name="l00341"></a>00341 (read_opt = getopt(argc, argv, opt_options))
<a name="l00342"></a>00342 #endif <span class="comment">/* HAVE_GETOPT_LONG */</span>
<a name="l00343"></a>00343 != -1) {
<a name="l00344"></a>00344
<a name="l00345"></a>00345 <span class="keywordflow">switch</span> (read_opt) {
<a name="l00346"></a>00346 <span class="preprocessor">#ifdef HAVE_GETOPT_LONG</span>
<a name="l00347"></a>00347 <span class="preprocessor"></span> <span class="keywordflow">case</span> 0:
<a name="l00348"></a>00348 <span class="comment">/* Only long options like GDK/GTK debug */</span>
<a name="l00349"></a>00349 <span class="keywordflow">switch</span> (longopt_val) {
<a name="l00350"></a>00350 <span class="keywordflow">case</span> 0: <span class="comment">/* default value if nothing is set */</span>
<a name="l00351"></a>00351 fprintf(stderr, <span class="stringliteral">"Not handled option %s\n"</span>, longopts[longopt_idx].name);
<a name="l00352"></a>00352 <span class="keywordflow">break</span>;
<a name="l00353"></a>00353 <span class="keywordflow">case</span> 1: <span class="comment">/* geometry */</span>
<a name="l00354"></a>00354 errno = 0;
<a name="l00355"></a>00355 req_width = (int)strtol(optarg, &amp;rest, 10);
<a name="l00356"></a>00356 <span class="keywordflow">if</span> (errno) {
<a name="l00357"></a>00357 perror(<span class="stringliteral">"Width"</span>);
<a name="l00358"></a>00358 <span class="keywordflow">break</span>;
<a name="l00359"></a>00359 }
<a name="l00360"></a>00360 <span class="keywordflow">if</span> (rest[0] != <span class="charliteral">'x'</span>){
<a name="l00361"></a>00361 fprintf(stderr, <span class="stringliteral">"Split X and Y parameters with an x\n"</span>);
<a name="l00362"></a>00362 <span class="keywordflow">break</span>;
<a name="l00363"></a>00363 }
<a name="l00364"></a>00364 rest++;
<a name="l00365"></a>00365 errno = 0;
<a name="l00366"></a>00366 req_height = (int)strtol(rest, &amp;rest, 10);
<a name="l00367"></a>00367 <span class="keywordflow">if</span> (errno) {
<a name="l00368"></a>00368 perror(<span class="stringliteral">"Height"</span>);
<a name="l00369"></a>00369 <span class="keywordflow">break</span>;
<a name="l00370"></a>00370 }
<a name="l00371"></a>00371 <span class="keywordflow">if</span> ((rest[0] == 0) || ((rest[0] != <span class="charliteral">'-'</span>) &amp;&amp; (rest[0] != <span class="charliteral">'+'</span>)))
<a name="l00372"></a>00372 <span class="keywordflow">break</span>;
<a name="l00373"></a>00373 errno = 0;
<a name="l00374"></a>00374 req_x = (int)strtol(rest, &amp;rest, 10);
<a name="l00375"></a>00375 <span class="keywordflow">if</span> (errno) {
<a name="l00376"></a>00376 perror(<span class="stringliteral">"X"</span>);
<a name="l00377"></a>00377 <span class="keywordflow">break</span>;
<a name="l00378"></a>00378 }
<a name="l00379"></a>00379 <span class="keywordflow">if</span> ((rest[0] == 0) || ((rest[0] != <span class="charliteral">'-'</span>) &amp;&amp; (rest[0] != <span class="charliteral">'+'</span>)))
<a name="l00380"></a>00380 <span class="keywordflow">break</span>;
<a name="l00381"></a>00381 errno = 0;
<a name="l00382"></a>00382 req_y = (int)strtol(rest, &amp;rest, 10);
<a name="l00383"></a>00383 <span class="keywordflow">if</span> (errno) {
<a name="l00384"></a>00384 perror(<span class="stringliteral">"Y"</span>);
<a name="l00385"></a>00385 <span class="keywordflow">break</span>;
<a name="l00386"></a>00386 }
<a name="l00387"></a>00387 <span class="keywordflow">break</span>;
<a name="l00388"></a>00388 <span class="keywordflow">default</span>:
<a name="l00389"></a>00389 <span class="keywordflow">break</span>;
<a name="l00390"></a>00390 }
<a name="l00391"></a>00391 <span class="keywordflow">break</span>;
<a name="l00392"></a>00392 <span class="preprocessor">#endif </span><span class="comment">/* HAVE_GETOPT_LONG */</span>
<a name="l00393"></a>00393 <span class="keywordflow">case</span> <span class="charliteral">'B'</span> :
<a name="l00394"></a>00394 <span class="keywordflow">if</span> (optarg == NULL) {
<a name="l00395"></a>00395 fprintf(stderr, <span class="stringliteral">"You must specify the border in the format &lt;alpha&gt;.\n"</span>);
<a name="l00396"></a>00396 exit(1);
<a name="l00397"></a>00397 }
<a name="l00398"></a>00398 <span class="keywordflow">if</span> (strlen (optarg) &gt; 10) {
<a name="l00399"></a>00399 fprintf(stderr, <span class="stringliteral">"Specified border is not recognized.\n"</span>);
<a name="l00400"></a>00400 exit(1);
<a name="l00401"></a>00401 }
<a name="l00402"></a>00402 sscanf (optarg,<span class="stringliteral">"%f"</span>,&amp;userSuppliedBorder);
<a name="l00403"></a>00403 <span class="keywordflow">if</span> (userSuppliedBorder &lt; 0) {
<a name="l00404"></a>00404 fprintf(stderr, <span class="stringliteral">"Specified border is smaller than zero!\n"</span>);
<a name="l00405"></a>00405 exit(1);
<a name="l00406"></a>00406 }
<a name="l00407"></a>00407 userSuppliedBorder/=100.0;
<a name="l00408"></a>00408 <span class="keywordflow">break</span>;
<a name="l00409"></a>00409 <span class="keywordflow">case</span> <span class="charliteral">'D'</span> :
<a name="l00410"></a>00410 <span class="keywordflow">if</span> (optarg == NULL) {
<a name="l00411"></a>00411 fprintf(stderr, <span class="stringliteral">"You must give an resolution in the format &lt;DPI X,DPI Y&gt; or &lt;DPI_X_and_Y&gt;.\n"</span>);
<a name="l00412"></a>00412 exit(1);
<a name="l00413"></a>00413 }
<a name="l00414"></a>00414 <span class="keywordflow">if</span> (strlen (optarg) &gt; 20) {
<a name="l00415"></a>00415 fprintf(stderr, <span class="stringliteral">"Specified resolution is not recognized.\n"</span>);
<a name="l00416"></a>00416 exit(1);
<a name="l00417"></a>00417 }
<a name="l00418"></a>00418 <span class="keywordflow">if</span>(strchr(optarg, <span class="charliteral">'x'</span>)!=NULL){
<a name="l00419"></a>00419 sscanf (optarg,<span class="stringliteral">"%fx%f"</span>,&amp;userSuppliedDpiX,&amp;userSuppliedDpiY);
<a name="l00420"></a>00420 }<span class="keywordflow">else</span>{
<a name="l00421"></a>00421 sscanf (optarg,<span class="stringliteral">"%f"</span>,&amp;userSuppliedDpiX);
<a name="l00422"></a>00422 userSuppliedDpiY = userSuppliedDpiX;
<a name="l00423"></a>00423 }
<a name="l00424"></a>00424 <span class="keywordflow">if</span> ((userSuppliedDpiX &lt;= 0) || (userSuppliedDpiY &lt;= 0)) {
<a name="l00425"></a>00425 fprintf(stderr, <span class="stringliteral">"Specified resolution should be greater than 0.\n"</span>);
<a name="l00426"></a>00426 exit(1);
<a name="l00427"></a>00427 }
<a name="l00428"></a>00428 userSuppliedDpi=TRUE;
<a name="l00429"></a>00429 <span class="keywordflow">break</span>;
<a name="l00430"></a>00430 <span class="keywordflow">case</span> <span class="charliteral">'O'</span> :
<a name="l00431"></a>00431 <span class="keywordflow">if</span> (optarg == NULL) {
<a name="l00432"></a>00432 fprintf(stderr, <span class="stringliteral">"You must give an origin in the format &lt;lower_left_X x lower_left_Y&gt;.\n"</span>);
<a name="l00433"></a>00433 exit(1);
<a name="l00434"></a>00434 }
<a name="l00435"></a>00435 <span class="keywordflow">if</span> (strlen (optarg) &gt; 20) {
<a name="l00436"></a>00436 fprintf(stderr, <span class="stringliteral">"Specified origin is not recognized.\n"</span>);
<a name="l00437"></a>00437 exit(1);
<a name="l00438"></a>00438 }
<a name="l00439"></a>00439 sscanf (optarg,<span class="stringliteral">"%fx%f"</span>,&amp;userSuppliedOriginX,&amp;userSuppliedOriginY);
<a name="l00440"></a>00440 userSuppliedOrigin=TRUE;
<a name="l00441"></a>00441 <span class="keywordflow">break</span>;
<a name="l00442"></a>00442 <span class="keywordflow">case</span> <span class="charliteral">'V'</span> :
<a name="l00443"></a>00443 printf(<span class="stringliteral">"gerbv version %s\n"</span>, VERSION);
<a name="l00444"></a>00444 printf(<span class="stringliteral">"(C) Stefan Petersen (spe@stacken.kth.se)\n"</span>);
<a name="l00445"></a>00445 exit(0);
<a name="l00446"></a>00446 <span class="keywordflow">case</span> <span class="charliteral">'a'</span> :
<a name="l00447"></a>00447 userSuppliedAntiAlias = TRUE;
<a name="l00448"></a>00448 <span class="keywordflow">break</span>;
<a name="l00449"></a>00449 <span class="keywordflow">case</span> <span class="charliteral">'b'</span> : <span class="comment">// Set background to this color</span>
<a name="l00450"></a>00450 <span class="keywordflow">if</span> (optarg == NULL) {
<a name="l00451"></a>00451 fprintf(stderr, <span class="stringliteral">"You must give an background color in the hex-format &lt;#RRGGBB&gt;.\n"</span>);
<a name="l00452"></a>00452 exit(1);
<a name="l00453"></a>00453 }
<a name="l00454"></a>00454 <span class="keywordflow">if</span> ((strlen (optarg) != 7)||(optarg[0]!=<span class="charliteral">'#'</span>)) {
<a name="l00455"></a>00455 fprintf(stderr, <span class="stringliteral">"Specified color format is not recognized.\n"</span>);
<a name="l00456"></a>00456 exit(1);
<a name="l00457"></a>00457 }
<a name="l00458"></a>00458 r=g=b=-1;
<a name="l00459"></a>00459 sscanf (optarg,<span class="stringliteral">"#%2x%2x%2x"</span>,&amp;r,&amp;g,&amp;b);
<a name="l00460"></a>00460 <span class="keywordflow">if</span> ( (r&lt;0)||(r&gt;255)||(g&lt;0)||(g&gt;255)||(b&lt;0)||(b&gt;255)) {
<a name="l00461"></a>00461
<a name="l00462"></a>00462 fprintf(stderr, <span class="stringliteral">"Specified color values should be between 00 and FF.\n"</span>);
<a name="l00463"></a>00463 exit(1);
<a name="l00464"></a>00464 }
<a name="l00465"></a>00465 mainProject-&gt;<a class="code" href="structgerbv__project__t.html#545040772fbe22865784f8ddca0a3d5d">background</a>.red = r*257;
<a name="l00466"></a>00466 mainProject-&gt;<a class="code" href="structgerbv__project__t.html#545040772fbe22865784f8ddca0a3d5d">background</a>.green = g*257;
<a name="l00467"></a>00467 mainProject-&gt;<a class="code" href="structgerbv__project__t.html#545040772fbe22865784f8ddca0a3d5d">background</a>.blue = b*257;
<a name="l00468"></a>00468 <span class="keywordflow">break</span>;
<a name="l00469"></a>00469 <span class="keywordflow">case</span> <span class="charliteral">'f'</span> : <span class="comment">// Set layer colors to this color (foreground color)</span>
<a name="l00470"></a>00470 <span class="keywordflow">if</span> (optarg == NULL) {
<a name="l00471"></a>00471 <span class="preprocessor">#ifdef RENDER_USING_GDK</span>
<a name="l00472"></a>00472 <span class="preprocessor"></span> fprintf(stderr, <span class="stringliteral">"You must give an foreground color in the hex-format &lt;#RRGGBB&gt;.\n"</span>);
<a name="l00473"></a>00473 <span class="preprocessor">#else</span>
<a name="l00474"></a>00474 <span class="preprocessor"></span> fprintf(stderr, <span class="stringliteral">"You must give an foreground color in the hex-format &lt;#RRGGBB&gt; or &lt;#RRGGBBAA&gt;.\n"</span>);
<a name="l00475"></a>00475 <span class="preprocessor">#endif</span>
<a name="l00476"></a>00476 <span class="preprocessor"></span> exit(1);
<a name="l00477"></a>00477 }
<a name="l00478"></a>00478 <span class="keywordflow">if</span> (((strlen (optarg) != 7)&amp;&amp;(strlen (optarg) != 9))||(optarg[0]!=<span class="charliteral">'#'</span>)) {
<a name="l00479"></a>00479 fprintf(stderr, <span class="stringliteral">"Specified color format is not recognized.\n"</span>);
<a name="l00480"></a>00480 exit(1);
<a name="l00481"></a>00481 }
<a name="l00482"></a>00482 r=g=b=a=-1;
<a name="l00483"></a>00483 <span class="keywordflow">if</span>(strlen(optarg)==7){
<a name="l00484"></a>00484 sscanf (optarg,<span class="stringliteral">"#%2x%2x%2x"</span>,&amp;r,&amp;g,&amp;b);
<a name="l00485"></a>00485 a=177;
<a name="l00486"></a>00486 }
<a name="l00487"></a>00487 <span class="keywordflow">else</span>{
<a name="l00488"></a>00488 sscanf (optarg,<span class="stringliteral">"#%2x%2x%2x%2x"</span>,&amp;r,&amp;g,&amp;b,&amp;a);
<a name="l00489"></a>00489 }
<a name="l00490"></a>00490
<a name="l00491"></a>00491 <span class="keywordflow">if</span> ( (r&lt;0)||(r&gt;255)||(g&lt;0)||(g&gt;255)||(b&lt;0)||(b&gt;255)||(a&lt;0)||(a&gt;255) ) {
<a name="l00492"></a>00492
<a name="l00493"></a>00493 fprintf(stderr, <span class="stringliteral">"Specified color values should be between 0x00 (0) and 0xFF (255).\n"</span>);
<a name="l00494"></a>00494 exit(1);
<a name="l00495"></a>00495 }
<a name="l00496"></a>00496 mainDefaultColors[layerctr].<a class="code" href="structgerbv__layer__color.html#dabfffba7088a6824dce09b25cb4a7ce">red</a> = r;
<a name="l00497"></a>00497 mainDefaultColors[layerctr].<a class="code" href="structgerbv__layer__color.html#6621fb6bf3d3dca2463d00d671cb683f">green</a> = g;
<a name="l00498"></a>00498 mainDefaultColors[layerctr].<a class="code" href="structgerbv__layer__color.html#4c4e5a9e5832cca1e9381ccb6287677f">blue</a> = b;
<a name="l00499"></a>00499 mainDefaultColors[layerctr].<a class="code" href="structgerbv__layer__color.html#3d03fbd669ad1784fbde7308b618cca9">alpha</a> = a;
<a name="l00500"></a>00500 layerctr++;
<a name="l00501"></a>00501 <span class="comment">/* just reset the counter back to 0 if we read too many */</span>
<a name="l00502"></a>00502 <span class="keywordflow">if</span> (layerctr == NUMBER_OF_DEFAULT_COLORS)
<a name="l00503"></a>00503 layerctr = 0;
<a name="l00504"></a>00504 <span class="keywordflow">break</span>;
<a name="l00505"></a>00505 <span class="keywordflow">case</span> <span class="charliteral">'l'</span> :
<a name="l00506"></a>00506 <span class="keywordflow">if</span> (optarg == NULL) {
<a name="l00507"></a>00507 fprintf(stderr, <span class="stringliteral">"You must give a filename to send log to\n"</span>);
<a name="l00508"></a>00508 exit(1);
<a name="l00509"></a>00509 }
<a name="l00510"></a>00510 logToFileOption = TRUE;
<a name="l00511"></a>00511 logToFileFilename = optarg;
<a name="l00512"></a>00512 <span class="keywordflow">break</span>;
<a name="l00513"></a>00513 <span class="keywordflow">case</span> <span class="charliteral">'o'</span> :
<a name="l00514"></a>00514 <span class="keywordflow">if</span> (optarg == NULL) {
<a name="l00515"></a>00515 fprintf(stderr, <span class="stringliteral">"You must give a filename to export to.\n"</span>);
<a name="l00516"></a>00516 exit(1);
<a name="l00517"></a>00517 }
<a name="l00518"></a>00518 exportFilename = optarg;
<a name="l00519"></a>00519 <span class="keywordflow">break</span>;
<a name="l00520"></a>00520 <span class="keywordflow">case</span> <span class="charliteral">'p'</span> :
<a name="l00521"></a>00521 <span class="keywordflow">if</span> (optarg == NULL) {
<a name="l00522"></a>00522 fprintf(stderr, <span class="stringliteral">"You must give a project filename\n"</span>);
<a name="l00523"></a>00523 exit(1);
<a name="l00524"></a>00524 }
<a name="l00525"></a>00525 project_filename = optarg;
<a name="l00526"></a>00526 <span class="keywordflow">break</span>;
<a name="l00527"></a>00527 <span class="keywordflow">case</span> <span class="charliteral">'t'</span> :
<a name="l00528"></a>00528 <span class="keywordflow">if</span> (optarg == NULL) {
<a name="l00529"></a>00529 fprintf(stderr, <span class="stringliteral">"You must give a filename to read the tools from.\n"</span>);
<a name="l00530"></a>00530 exit(1);
<a name="l00531"></a>00531 }
<a name="l00532"></a>00532 <span class="keywordflow">if</span> (!gerbv_process_tools_file(optarg)) {
<a name="l00533"></a>00533 fprintf(stderr, <span class="stringliteral">"*** ERROR processing tools file \"%s\".\n"</span>, optarg);
<a name="l00534"></a>00534 fprintf(stderr, <span class="stringliteral">"Make sure all lines of the file are formatted like this:\n"</span>);
<a name="l00535"></a>00535 fprintf(stderr, <span class="stringliteral">"T01 0.024\nT02 0.032\nT03 0.040\n...\n"</span>);
<a name="l00536"></a>00536 fprintf(stderr, <span class="stringliteral">"*** EXITING to prevent erroneous display.\n"</span>);
<a name="l00537"></a>00537 exit(1);
<a name="l00538"></a>00538 }
<a name="l00539"></a>00539 <span class="keywordflow">break</span>;
<a name="l00540"></a>00540 <span class="keywordflow">case</span> <span class="charliteral">'T'</span> : <span class="comment">// Translate the layer</span>
<a name="l00541"></a>00541 <span class="keywordflow">if</span> (optarg == NULL) {
<a name="l00542"></a>00542 fprintf(stderr, <span class="stringliteral">"You must give a translation in the format &lt;X,Y&gt;.\n"</span>);
<a name="l00543"></a>00543 exit(1);
<a name="l00544"></a>00544 }
<a name="l00545"></a>00545 <span class="keywordflow">if</span> (strlen (optarg) &gt; 30) {
<a name="l00546"></a>00546 fprintf(stderr, <span class="stringliteral">"The translation format is not recognized.\n"</span>);
<a name="l00547"></a>00547 exit(1);
<a name="l00548"></a>00548 }
<a name="l00549"></a>00549 <span class="keywordtype">float</span> transX=0, transY=0;
<a name="l00550"></a>00550
<a name="l00551"></a>00551 sscanf (optarg,<span class="stringliteral">"%f,%f"</span>,&amp;transX,&amp;transY);
<a name="l00552"></a>00552 mainDefaultTransformations[transformCount].<a class="code" href="structgerbv__user__transformation__t.html#4e3b3a2a90019950374d5f969c176140">translateX</a> = transX;
<a name="l00553"></a>00553 mainDefaultTransformations[transformCount].<a class="code" href="structgerbv__user__transformation__t.html#d60fd2201908a685667656981f708522">translateY</a> = transY;
<a name="l00554"></a>00554 transformCount++;
<a name="l00555"></a>00555 <span class="comment">/* just reset the counter back to 0 if we read too many */</span>
<a name="l00556"></a>00556 <span class="keywordflow">if</span> (transformCount == NUMBER_OF_DEFAULT_TRANSFORMATIONS)
<a name="l00557"></a>00557 transformCount = 0;
<a name="l00558"></a>00558 <span class="keywordflow">break</span>;
<a name="l00559"></a>00559 <span class="keywordflow">case</span> <span class="charliteral">'w'</span>:
<a name="l00560"></a>00560 userSuppliedWindowInPixels = TRUE;
<a name="l00561"></a>00561 <span class="keywordflow">case</span> <span class="charliteral">'W'</span> :
<a name="l00562"></a>00562 <span class="keywordflow">if</span> (optarg == NULL) {
<a name="l00563"></a>00563 fprintf(stderr, <span class="stringliteral">"You must give a window size in the format &lt;width x height&gt;.\n"</span>);
<a name="l00564"></a>00564 exit(1);
<a name="l00565"></a>00565 }
<a name="l00566"></a>00566 <span class="keywordflow">if</span> (strlen (optarg) &gt; 20) {
<a name="l00567"></a>00567 fprintf(stderr, <span class="stringliteral">"Specified window size is not recognized.\n"</span>);
<a name="l00568"></a>00568 exit(1);
<a name="l00569"></a>00569 }
<a name="l00570"></a>00570 sscanf (optarg, <span class="stringliteral">"%fx%f"</span>, &amp;userSuppliedWidth, &amp;userSuppliedHeight);
<a name="l00571"></a>00571 <span class="keywordflow">if</span> (((userSuppliedWidth &lt; 0.001) || (userSuppliedHeight &lt; 0.001)) ||
<a name="l00572"></a>00572 ((userSuppliedWidth &gt; 2000) || (userSuppliedHeight &gt; 2000))) {
<a name="l00573"></a>00573 fprintf(stderr, <span class="stringliteral">"Specified window size is out of bounds.\n"</span>);
<a name="l00574"></a>00574 exit(1);
<a name="l00575"></a>00575 }
<a name="l00576"></a>00576 userSuppliedWindow = TRUE;
<a name="l00577"></a>00577 <span class="keywordflow">break</span>;
<a name="l00578"></a>00578 <span class="keywordflow">case</span> <span class="charliteral">'x'</span> :
<a name="l00579"></a>00579 <span class="keywordflow">if</span> (optarg == NULL) {
<a name="l00580"></a>00580 fprintf(stderr, <span class="stringliteral">"You must supply an export type.\n"</span>);
<a name="l00581"></a>00581 exit(1);
<a name="l00582"></a>00582 }
<a name="l00583"></a>00583 <span class="keywordflow">if</span> (strcmp (optarg,<span class="stringliteral">"png"</span>) == 0) {
<a name="l00584"></a>00584 exportType = 1;
<a name="l00585"></a>00585 exportFromCommandline = TRUE;
<a name="l00586"></a>00586 }
<a name="l00587"></a>00587 <span class="preprocessor">#ifndef RENDER_USING_GDK</span>
<a name="l00588"></a>00588 <span class="preprocessor"></span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp (optarg,<span class="stringliteral">"pdf"</span>) == 0) {
<a name="l00589"></a>00589 exportType = 2;
<a name="l00590"></a>00590 exportFromCommandline = TRUE;
<a name="l00591"></a>00591 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp (optarg,<span class="stringliteral">"svg"</span>) == 0) {
<a name="l00592"></a>00592 exportType = 3;
<a name="l00593"></a>00593 exportFromCommandline = TRUE;
<a name="l00594"></a>00594 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp (optarg,<span class="stringliteral">"ps"</span>) == 0) {
<a name="l00595"></a>00595 exportType = 4;
<a name="l00596"></a>00596 exportFromCommandline = TRUE;
<a name="l00597"></a>00597 }
<a name="l00598"></a>00598 <span class="preprocessor">#endif</span>
<a name="l00599"></a>00599 <span class="preprocessor"></span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp (optarg,<span class="stringliteral">"rs274x"</span>) == 0) {
<a name="l00600"></a>00600 exportType = 5;
<a name="l00601"></a>00601 exportFromCommandline = TRUE;
<a name="l00602"></a>00602 }
<a name="l00603"></a>00603 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp (optarg,<span class="stringliteral">"drill"</span>) == 0) {
<a name="l00604"></a>00604 exportType = 6;
<a name="l00605"></a>00605 exportFromCommandline = TRUE;
<a name="l00606"></a>00606 }
<a name="l00607"></a>00607 <span class="keywordflow">else</span> {
<a name="l00608"></a>00608 fprintf(stderr, <span class="stringliteral">"Unrecognized export type.\n"</span>);
<a name="l00609"></a>00609 exit(1);
<a name="l00610"></a>00610 }
<a name="l00611"></a>00611 <span class="keywordflow">break</span>;
<a name="l00612"></a>00612 <span class="keywordflow">case</span> <span class="charliteral">'d'</span>:
<a name="l00613"></a>00613 screen.dump_parsed_image = 1;
<a name="l00614"></a>00614 <span class="keywordflow">break</span>;
<a name="l00615"></a>00615 <span class="keywordflow">case</span> <span class="charliteral">'?'</span>:
<a name="l00616"></a>00616 <span class="keywordflow">case</span> <span class="charliteral">'h'</span>:
<a name="l00617"></a>00617 <span class="preprocessor">#ifdef HAVE_GETOPT_LONG</span>
<a name="l00618"></a>00618 <span class="preprocessor"></span> printf(<span class="stringliteral">"Usage: gerbv [OPTIONS...] [FILE...]\n\n"</span>);
<a name="l00619"></a>00619 printf(<span class="stringliteral">"Available options:\n"</span>);
<a name="l00620"></a>00620 printf(<span class="stringliteral">" -B, --border=&lt;b&gt; Border around the image in percent of the\n"</span>);
<a name="l00621"></a>00621 printf(<span class="stringliteral">" width/height. Defaults to 5%%.\n"</span>);
<a name="l00622"></a>00622 <span class="preprocessor">#ifdef RENDER_USING_GDK</span>
<a name="l00623"></a>00623 <span class="preprocessor"></span> printf(<span class="stringliteral">" -D, --dpi=&lt;R&gt; Resolution (Dots per inch) for the output\n"</span>);
<a name="l00624"></a>00624 printf(<span class="stringliteral">" bitmap.\n"</span>);
<a name="l00625"></a>00625 <span class="preprocessor">#else</span>
<a name="l00626"></a>00626 <span class="preprocessor"></span> printf(<span class="stringliteral">" -D, --dpi=&lt;XxY&gt;or&lt;R&gt; Resolution (Dots per inch) for the output\n"</span>);
<a name="l00627"></a>00627 printf(<span class="stringliteral">" bitmap. With the format &lt;XxY&gt;, different\n"</span>);
<a name="l00628"></a>00628 printf(<span class="stringliteral">" resolutions for X- and Y-direction are used.\n"</span>);
<a name="l00629"></a>00629 printf(<span class="stringliteral">" With the format &lt;R&gt;, both are the same.\n"</span>);
<a name="l00630"></a>00630 <span class="preprocessor">#endif</span>
<a name="l00631"></a>00631 <span class="preprocessor"></span> printf(<span class="stringliteral">" -O, --origin=&lt;XxY&gt; Use the specified coordinates (in inches)\n"</span>);
<a name="l00632"></a>00632 printf(<span class="stringliteral">" for the lower left corner.\n"</span>);
<a name="l00633"></a>00633 printf(<span class="stringliteral">" -V, --version Print version of gerbv.\n"</span>);
<a name="l00634"></a>00634 printf(<span class="stringliteral">" -a, --antialias Use antialiasing for generated bitmap output.\n"</span>);
<a name="l00635"></a>00635 printf(<span class="stringliteral">" -b, --background=&lt;hex&gt; Use background color &lt;hex&gt; (like #RRGGBB).\n"</span>);
<a name="l00636"></a>00636 <span class="preprocessor">#ifdef RENDER_USING_GDK</span>
<a name="l00637"></a>00637 <span class="preprocessor"></span> printf(<span class="stringliteral">" -f, --foreground=&lt;hex&gt; Use foreground color &lt;hex&gt; (like #RRGGBB)\n"</span>);
<a name="l00638"></a>00638 <span class="preprocessor">#else</span>
<a name="l00639"></a>00639 <span class="preprocessor"></span> printf(<span class="stringliteral">" -f, --foreground=&lt;hex&gt; Use foreground color &lt;hex&gt; (like #RRGGBB or\n"</span>);
<a name="l00640"></a>00640 printf(<span class="stringliteral">" #RRGGBBAA for setting the alpha).\n"</span>);
<a name="l00641"></a>00641 <span class="preprocessor">#endif</span>
<a name="l00642"></a>00642 <span class="preprocessor"></span> printf(<span class="stringliteral">" Use multiple -f flags to set the color for\n"</span>);
<a name="l00643"></a>00643 printf(<span class="stringliteral">" multiple layers.\n"</span>);
<a name="l00644"></a>00644 printf(<span class="stringliteral">" -h, --help Print this help message.\n"</span>);
<a name="l00645"></a>00645 printf(<span class="stringliteral">" -l, --log=&lt;logfile&gt; Send error messages to &lt;logfile&gt;.\n"</span>);
<a name="l00646"></a>00646 printf(<span class="stringliteral">" -o, --output=&lt;filename&gt; Export to &lt;filename&gt;\n"</span>);
<a name="l00647"></a>00647 printf(<span class="stringliteral">" -p, --project=&lt;prjfile&gt; Load project file &lt;prjfile&gt;\n"</span>);
<a name="l00648"></a>00648 printf(<span class="stringliteral">" -W, --window_inch=&lt;WxH&gt; Window size in inches &lt;WxH&gt; for the\n"</span>);
<a name="l00649"></a>00649 printf(<span class="stringliteral">" exported image.\n"</span>);
<a name="l00650"></a>00650 printf(<span class="stringliteral">" -w, --window=&lt;WxH&gt; Window size in pixels &lt;WxH&gt; for the\n"</span>);
<a name="l00651"></a>00651 printf(<span class="stringliteral">" exported image. Autoscales to fit\n"</span>);
<a name="l00652"></a>00652 printf(<span class="stringliteral">" if no resolution is specified. If a\n"</span>);
<a name="l00653"></a>00653 printf(<span class="stringliteral">" resolution is specified, it will clip.\n"</span>);
<a name="l00654"></a>00654 printf(<span class="stringliteral">" -t, --tools=&lt;toolfile&gt; Read Excellon tools from file &lt;toolfile&gt;.\n"</span>);
<a name="l00655"></a>00655 printf(<span class="stringliteral">" -T, --translate=&lt;X,Y&gt; Translate the image by &lt;X,Y&gt; (useful for\n"</span>);
<a name="l00656"></a>00656 printf(<span class="stringliteral">" arranging panels). Use multiple -T flags\n"</span>);
<a name="l00657"></a>00657 printf(<span class="stringliteral">" for multiple layers.\n"</span>);
<a name="l00658"></a>00658 <span class="preprocessor">#ifdef RENDER_USING_GDK</span>
<a name="l00659"></a>00659 <span class="preprocessor"></span> printf(<span class="stringliteral">" -x, --export=&lt;png&gt; Export a rendered picture to a PNG file.\n"</span>);
<a name="l00660"></a>00660 <span class="preprocessor">#else</span>
<a name="l00661"></a>00661 <span class="preprocessor"></span> printf(<span class="stringliteral">" -x, --export=&lt;png/pdf/ps/svg/ Export a rendered picture to a file with\n"</span>);
<a name="l00662"></a>00662 printf(<span class="stringliteral">" rs274x/drill&gt; the specified format.\n"</span>);
<a name="l00663"></a>00663 <span class="preprocessor">#endif</span>
<a name="l00664"></a>00664 <span class="preprocessor"></span>
<a name="l00665"></a>00665
<a name="l00666"></a>00666 <span class="preprocessor">#else</span>
<a name="l00667"></a>00667 <span class="preprocessor"></span> printf(<span class="stringliteral">"Usage: gerbv [OPTIONS...] [FILE...]\n\n"</span>);
<a name="l00668"></a>00668 printf(<span class="stringliteral">"Available options:\n"</span>);
<a name="l00669"></a>00669 printf(<span class="stringliteral">" -B&lt;b&gt; Border around the image in percent of the\n"</span>);
<a name="l00670"></a>00670 printf(<span class="stringliteral">" width/height. Defaults to 5%%.\n"</span>);
<a name="l00671"></a>00671 <span class="preprocessor">#ifdef RENDER_USING_GDK</span>
<a name="l00672"></a>00672 <span class="preprocessor"></span> printf(<span class="stringliteral">" -D&lt;R&gt; Resolution (Dots per inch) for the output\n"</span>);
<a name="l00673"></a>00673 printf(<span class="stringliteral">" bitmap\n"</span>);
<a name="l00674"></a>00674 <span class="preprocessor">#else</span>
<a name="l00675"></a>00675 <span class="preprocessor"></span> printf(<span class="stringliteral">" -D&lt;XxY&gt;or&lt;R&gt; Resolution (Dots per inch) for the output\n"</span>);
<a name="l00676"></a>00676 printf(<span class="stringliteral">" bitmap. With the format &lt;XxY&gt;, different\n"</span>);
<a name="l00677"></a>00677 printf(<span class="stringliteral">" resolutions for X- and Y-direction are used.\n"</span>);
<a name="l00678"></a>00678 printf(<span class="stringliteral">" With the format &lt;R&gt;, both are the same.\n"</span>);
<a name="l00679"></a>00679 <span class="preprocessor">#endif</span>
<a name="l00680"></a>00680 <span class="preprocessor"></span> printf(<span class="stringliteral">" -O&lt;XxY&gt; Use the specified coordinates (in inches)\n"</span>);
<a name="l00681"></a>00681 printf(<span class="stringliteral">" for the lower left corner.\n"</span>);
<a name="l00682"></a>00682 printf(<span class="stringliteral">" -V Print version of gerbv.\n"</span>);
<a name="l00683"></a>00683 printf(<span class="stringliteral">" -a Use antialiasing for generated bitmap output.\n"</span>);
<a name="l00684"></a>00684 printf(<span class="stringliteral">" -b&lt;hexcolor&gt; Use background color &lt;hexcolor&gt; (like #RRGGBB)\n"</span>);
<a name="l00685"></a>00685 <span class="preprocessor">#ifdef RENDER_USING_GDK</span>
<a name="l00686"></a>00686 <span class="preprocessor"></span> printf(<span class="stringliteral">" -f&lt;hexcolor&gt; Use foreground color &lt;hexcolor&gt; (like #RRGGBB)\n"</span>);
<a name="l00687"></a>00687 <span class="preprocessor">#else</span>
<a name="l00688"></a>00688 <span class="preprocessor"></span> printf(<span class="stringliteral">" -f&lt;hexcolor&gt; Use foreground color &lt;hexcolor&gt; (like #RRGGBB or\n"</span>);
<a name="l00689"></a>00689 printf(<span class="stringliteral">" #RRGGBBAA for setting the alpha).\n"</span>);
<a name="l00690"></a>00690 <span class="preprocessor">#endif</span>
<a name="l00691"></a>00691 <span class="preprocessor"></span> printf(<span class="stringliteral">" Use multiple -f flags to set the color for\n"</span>);
<a name="l00692"></a>00692 printf(<span class="stringliteral">" multiple layers.\n"</span>);
<a name="l00693"></a>00693 printf(<span class="stringliteral">" -h Print this help message.\n"</span>);
<a name="l00694"></a>00694 printf(<span class="stringliteral">" -l&lt;logfile&gt; Send error messages to &lt;logfile&gt;\n"</span>);
<a name="l00695"></a>00695 printf(<span class="stringliteral">" -o&lt;filename&gt; Export to &lt;filename&gt;\n"</span>);
<a name="l00696"></a>00696 printf(<span class="stringliteral">" -p&lt;prjfile&gt; Load project file &lt;prjfile&gt;\n"</span>);
<a name="l00697"></a>00697 printf(<span class="stringliteral">" -W&lt;WxH&gt; Window size in inches &lt;WxH&gt; for the\n"</span>);
<a name="l00698"></a>00698 printf(<span class="stringliteral">" exported image\n"</span>);
<a name="l00699"></a>00699 printf(<span class="stringliteral">" -w&lt;WxH&gt; Window size in pixels &lt;WxH&gt; for the\n"</span>);
<a name="l00700"></a>00700 printf(<span class="stringliteral">" exported image. Autoscales to fit\n"</span>);
<a name="l00701"></a>00701 printf(<span class="stringliteral">" if no resolution is specified. If a\n"</span>);
<a name="l00702"></a>00702 printf(<span class="stringliteral">" resolution is specified, it will clip.\n"</span>);
<a name="l00703"></a>00703 printf(<span class="stringliteral">" exported image\n"</span>);
<a name="l00704"></a>00704 printf(<span class="stringliteral">" -t&lt;toolfile&gt; Read Excellon tools from file &lt;toolfile&gt;\n"</span>);
<a name="l00705"></a>00705 printf(<span class="stringliteral">" -T&lt;X,Y&gt; Translate the image by &lt;X,Y&gt; (useful for\n"</span>);
<a name="l00706"></a>00706 printf(<span class="stringliteral">" arranging panels). Use multiple -T flags\n"</span>);
<a name="l00707"></a>00707 printf(<span class="stringliteral">" for multiple layers.\n"</span>);
<a name="l00708"></a>00708 <span class="preprocessor">#ifdef RENDER_USING_GDK</span>
<a name="l00709"></a>00709 <span class="preprocessor"></span> printf(<span class="stringliteral">" -x&lt;png&gt; Export a rendered picture to a PNG file\n"</span>);
<a name="l00710"></a>00710 <span class="preprocessor">#else</span>
<a name="l00711"></a>00711 <span class="preprocessor"></span> printf(<span class="stringliteral">" -x &lt;png/pdf/ps/svg/ Export a rendered picture to a file with\n"</span>);
<a name="l00712"></a>00712 printf(<span class="stringliteral">" rs274x/drill&gt; the specified format\n"</span>);
<a name="l00713"></a>00713 <span class="preprocessor">#endif</span>
<a name="l00714"></a>00714 <span class="preprocessor"></span>
<a name="l00715"></a>00715 <span class="preprocessor">#endif </span><span class="comment">/* HAVE_GETOPT_LONG */</span>
<a name="l00716"></a>00716 exit(1);
<a name="l00717"></a>00717 <span class="keywordflow">break</span>;
<a name="l00718"></a>00718 <span class="keywordflow">default</span> :
<a name="l00719"></a>00719 printf(<span class="stringliteral">"Not handled option [%d=%c]\n"</span>, read_opt, read_opt);
<a name="l00720"></a>00720 }
<a name="l00721"></a>00721 }
<a name="l00722"></a>00722
<a name="l00723"></a>00723 <span class="comment">/*</span>
<a name="l00724"></a>00724 <span class="comment"> * If project is given, load that one and use it for files and colors.</span>
<a name="l00725"></a>00725 <span class="comment"> * Else load files (eventually) given on the command line.</span>
<a name="l00726"></a>00726 <span class="comment"> * This limits you to either give files on the commandline or just load</span>
<a name="l00727"></a>00727 <span class="comment"> * a project.</span>
<a name="l00728"></a>00728 <span class="comment"> */</span>
<a name="l00729"></a>00729 <span class="keywordflow">if</span> (project_filename) {
<a name="l00730"></a>00730 <span class="comment">/* calculate the absolute pathname to the project if the user</span>
<a name="l00731"></a>00731 <span class="comment"> used a relative path */</span>
<a name="l00732"></a>00732 g_free (mainProject-&gt;<a class="code" href="structgerbv__project__t.html#8b8fc06714c48c6282639412d964ad9a">path</a>);
<a name="l00733"></a>00733 <span class="keywordflow">if</span> (!g_path_is_absolute(project_filename)) {
<a name="l00734"></a>00734 gchar *fullName = g_build_filename (g_get_current_dir (),
<a name="l00735"></a>00735 project_filename, NULL);
<a name="l00736"></a>00736 main_open_project_from_filename (mainProject, fullName);
<a name="l00737"></a>00737 mainProject-&gt;<a class="code" href="structgerbv__project__t.html#8b8fc06714c48c6282639412d964ad9a">path</a> = g_path_get_dirname (fullName);
<a name="l00738"></a>00738 g_free (fullName);
<a name="l00739"></a>00739 } <span class="keywordflow">else</span> {
<a name="l00740"></a>00740 main_open_project_from_filename (mainProject, project_filename);
<a name="l00741"></a>00741 mainProject-&gt;<a class="code" href="structgerbv__project__t.html#8b8fc06714c48c6282639412d964ad9a">path</a> = g_path_get_dirname (project_filename);
<a name="l00742"></a>00742 }
<a name="l00743"></a>00743
<a name="l00744"></a>00744 } <span class="keywordflow">else</span> {
<a name="l00745"></a>00745 gint loadedIndex = 0;
<a name="l00746"></a>00746 <span class="keywordflow">for</span>(i = optind ; i &lt; argc; i++) {
<a name="l00747"></a>00747 g_free (mainProject-&gt;<a class="code" href="structgerbv__project__t.html#8b8fc06714c48c6282639412d964ad9a">path</a>);
<a name="l00748"></a>00748 <span class="keywordflow">if</span> (!g_path_is_absolute(argv[i])) {
<a name="l00749"></a>00749 gchar *fullName = g_build_filename (g_get_current_dir (),
<a name="l00750"></a>00750 argv[i], NULL);
<a name="l00751"></a>00751 <a class="code" href="gerbv_8c.html#62a43082bcb669b8fb3fe3da0769eff0" title="Open a file, parse the contents, and add a new layer to an existing project while...">gerbv_open_layer_from_filename_with_color</a> (mainProject, fullName,
<a name="l00752"></a>00752 mainDefaultColors[loadedIndex % NUMBER_OF_DEFAULT_COLORS].red*257,
<a name="l00753"></a>00753 mainDefaultColors[loadedIndex % NUMBER_OF_DEFAULT_COLORS].green*257,
<a name="l00754"></a>00754 mainDefaultColors[loadedIndex % NUMBER_OF_DEFAULT_COLORS].blue*257,
<a name="l00755"></a>00755 mainDefaultColors[loadedIndex % NUMBER_OF_DEFAULT_COLORS].alpha*257);
<a name="l00756"></a>00756 mainProject-&gt;<a class="code" href="structgerbv__project__t.html#8b8fc06714c48c6282639412d964ad9a">path</a> = g_path_get_dirname (fullName);
<a name="l00757"></a>00757 g_free (fullName);
<a name="l00758"></a>00758 } <span class="keywordflow">else</span> {
<a name="l00759"></a>00759 <a class="code" href="gerbv_8c.html#62a43082bcb669b8fb3fe3da0769eff0" title="Open a file, parse the contents, and add a new layer to an existing project while...">gerbv_open_layer_from_filename_with_color</a> (mainProject, argv[i],
<a name="l00760"></a>00760 mainDefaultColors[loadedIndex % NUMBER_OF_DEFAULT_COLORS].red*257,
<a name="l00761"></a>00761 mainDefaultColors[loadedIndex % NUMBER_OF_DEFAULT_COLORS].green*257,
<a name="l00762"></a>00762 mainDefaultColors[loadedIndex % NUMBER_OF_DEFAULT_COLORS].blue*257,
<a name="l00763"></a>00763 mainDefaultColors[loadedIndex % NUMBER_OF_DEFAULT_COLORS].alpha*257);
<a name="l00764"></a>00764 mainProject-&gt;<a class="code" href="structgerbv__project__t.html#8b8fc06714c48c6282639412d964ad9a">path</a> = g_path_get_dirname (argv[i]);
<a name="l00765"></a>00765 }
<a name="l00766"></a>00766 loadedIndex++;
<a name="l00767"></a>00767 }
<a name="l00768"></a>00768 }
<a name="l00769"></a>00769
<a name="l00770"></a>00770 screen.unit = GERBV_DEFAULT_UNIT;
<a name="l00771"></a>00771 <span class="preprocessor">#ifdef RENDER_USING_GDK</span>
<a name="l00772"></a>00772 <span class="preprocessor"></span> <span class="comment">/* GDK renderer needs gtk started up even for png export */</span>
<a name="l00773"></a>00773 gtk_init (&amp;argc, &amp;argv);
<a name="l00774"></a>00774 <span class="preprocessor">#endif</span>
<a name="l00775"></a>00775 <span class="preprocessor"></span>
<a name="l00776"></a>00776 <span class="keywordflow">if</span> (exportFromCommandline) {
<a name="l00777"></a>00777 <span class="comment">/* load the info struct with the default values */</span>
<a name="l00778"></a>00778
<a name="l00779"></a>00779 gboolean freeFilename = FALSE;
<a name="l00780"></a>00780
<a name="l00781"></a>00781 <span class="keywordflow">if</span> (!exportFilename) {
<a name="l00782"></a>00782 <span class="keywordflow">if</span> (exportType == 1) {
<a name="l00783"></a>00783 exportFilename = g_strdup (<span class="stringliteral">"output.png"</span>);
<a name="l00784"></a>00784 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (exportType == 2) {
<a name="l00785"></a>00785 exportFilename = g_strdup (<span class="stringliteral">"output.pdf"</span>);
<a name="l00786"></a>00786 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (exportType == 3) {
<a name="l00787"></a>00787 exportFilename = g_strdup (<span class="stringliteral">"output.svg"</span>);
<a name="l00788"></a>00788 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (exportType == 4){
<a name="l00789"></a>00789 exportFilename = g_strdup (<span class="stringliteral">"output.ps"</span>);
<a name="l00790"></a>00790 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (exportType == 5){
<a name="l00791"></a>00791 exportFilename = g_strdup (<span class="stringliteral">"output.gbx"</span>);
<a name="l00792"></a>00792 } <span class="keywordflow">else</span> {
<a name="l00793"></a>00793 exportFilename = g_strdup (<span class="stringliteral">"output.cnc"</span>);
<a name="l00794"></a>00794 }
<a name="l00795"></a>00795 freeFilename = TRUE;
<a name="l00796"></a>00796 }
<a name="l00797"></a>00797
<a name="l00798"></a>00798 gerbv_render_size_t bb;
<a name="l00799"></a>00799 gerbv_render_get_boundingbox(mainProject, &amp;bb);
<a name="l00800"></a>00800 <span class="comment">// Set origin to the left-bottom corner if it is not specified</span>
<a name="l00801"></a>00801 <span class="keywordflow">if</span>(!userSuppliedOrigin){
<a name="l00802"></a>00802 userSuppliedOriginX = bb.left;
<a name="l00803"></a>00803 userSuppliedOriginY = bb.top;
<a name="l00804"></a>00804 }
<a name="l00805"></a>00805
<a name="l00806"></a>00806 <span class="keywordtype">float</span> width = bb.right - userSuppliedOriginX + 0.001; <span class="comment">// Plus a little extra to prevent from </span>
<a name="l00807"></a>00807 <span class="keywordtype">float</span> height = bb.bottom - userSuppliedOriginY + 0.001; <span class="comment">// missing items due to round-off errors</span>
<a name="l00808"></a>00808 <span class="comment">// If the user did not specify a height and width, autoscale w&amp;h till full size from origin.</span>
<a name="l00809"></a>00809 <span class="keywordflow">if</span>(!userSuppliedWindow){
<a name="l00810"></a>00810 userSuppliedWidth = width;
<a name="l00811"></a>00811 userSuppliedHeight = height;
<a name="l00812"></a>00812 }<span class="keywordflow">else</span>{
<a name="l00813"></a>00813 <span class="comment">// If size was specified in pixels, and no resolution was specified, autoscale resolution till fit</span>
<a name="l00814"></a>00814 <span class="keywordflow">if</span>( (!userSuppliedDpi)&amp;&amp; userSuppliedWindowInPixels){
<a name="l00815"></a>00815 userSuppliedDpiX = MIN(((userSuppliedWidth-0.5) / width),((userSuppliedHeight-0.5) / height));
<a name="l00816"></a>00816 userSuppliedDpiY = userSuppliedDpiX;
<a name="l00817"></a>00817 userSuppliedOriginX -= 0.5/userSuppliedDpiX;
<a name="l00818"></a>00818 userSuppliedOriginY -= 0.5/userSuppliedDpiY;
<a name="l00819"></a>00819 }
<a name="l00820"></a>00820 }
<a name="l00821"></a>00821
<a name="l00822"></a>00822
<a name="l00823"></a>00823 <span class="comment">// Add the border size (if there is one)</span>
<a name="l00824"></a>00824 <span class="keywordflow">if</span>(userSuppliedBorder!=0){
<a name="l00825"></a>00825 <span class="comment">// If supplied in inches, add a border around the image</span>
<a name="l00826"></a>00826 <span class="keywordflow">if</span>(!userSuppliedWindowInPixels){
<a name="l00827"></a>00827 userSuppliedWidth += userSuppliedWidth*userSuppliedBorder;
<a name="l00828"></a>00828 userSuppliedHeight += userSuppliedHeight*userSuppliedBorder;
<a name="l00829"></a>00829 userSuppliedOriginX -= (userSuppliedWidth*userSuppliedBorder)/2.0;
<a name="l00830"></a>00830 userSuppliedOriginY -= (userSuppliedHeight*userSuppliedBorder)/2.0;
<a name="l00831"></a>00831 }
<a name="l00832"></a>00832 <span class="comment">// If supplied in pixels, shrink image content for border_size</span>
<a name="l00833"></a>00833 <span class="keywordflow">else</span>{
<a name="l00834"></a>00834 userSuppliedDpiX -= (userSuppliedDpiX*userSuppliedBorder);
<a name="l00835"></a>00835 userSuppliedDpiY -= (userSuppliedDpiY*userSuppliedBorder);
<a name="l00836"></a>00836 userSuppliedOriginX -= ((userSuppliedWidth/userSuppliedDpiX)*userSuppliedBorder)/2.0;
<a name="l00837"></a>00837 userSuppliedOriginY -= ((userSuppliedHeight/userSuppliedDpiX)*userSuppliedBorder)/2.0;
<a name="l00838"></a>00838 }
<a name="l00839"></a>00839 }
<a name="l00840"></a>00840
<a name="l00841"></a>00841 <span class="keywordflow">if</span>(!userSuppliedWindowInPixels){
<a name="l00842"></a>00842 userSuppliedWidth *= userSuppliedDpiX;
<a name="l00843"></a>00843 userSuppliedHeight *= userSuppliedDpiY;
<a name="l00844"></a>00844 }
<a name="l00845"></a>00845
<a name="l00846"></a>00846 <span class="comment">// Make sure there is something valid in it. It could become negative if </span>
<a name="l00847"></a>00847 <span class="comment">// the userSuppliedOrigin is further than the bb.right or bb.top.</span>
<a name="l00848"></a>00848 <span class="keywordflow">if</span>(userSuppliedWidth &lt;=0)
<a name="l00849"></a>00849 userSuppliedWidth = 1;
<a name="l00850"></a>00850 <span class="keywordflow">if</span>(userSuppliedHeight &lt;=0)
<a name="l00851"></a>00851 userSuppliedHeight = 1;
<a name="l00852"></a>00852
<a name="l00853"></a>00853
<a name="l00854"></a>00854 <span class="preprocessor">#ifdef RENDER_USING_GDK</span>
<a name="l00855"></a>00855 <span class="preprocessor"></span> <a class="code" href="structgerbv__render__info__t.html">gerbv_render_info_t</a> renderInfo = {MIN(userSuppliedDpiX, userSuppliedDpiY), MIN(userSuppliedDpiX, userSuppliedDpiY),
<a name="l00856"></a>00856 userSuppliedOriginX, userSuppliedOriginY,1,
<a name="l00857"></a>00857 userSuppliedWidth,userSuppliedHeight };
<a name="l00858"></a>00858 <span class="preprocessor">#else </span>
<a name="l00859"></a>00859 <span class="preprocessor"></span> <a class="code" href="structgerbv__render__info__t.html">gerbv_render_info_t</a> renderInfo = {userSuppliedDpiX, userSuppliedDpiY,
<a name="l00860"></a>00860 userSuppliedOriginX, userSuppliedOriginY, userSuppliedAntiAlias?3:2,
<a name="l00861"></a>00861 userSuppliedWidth,userSuppliedHeight };
<a name="l00862"></a>00862 <span class="preprocessor">#endif</span>
<a name="l00863"></a>00863 <span class="preprocessor"></span>
<a name="l00864"></a>00864 <span class="keywordflow">if</span> (exportType == 1) {
<a name="l00865"></a>00865 <span class="preprocessor">#ifdef EXPORT_PNG</span>
<a name="l00866"></a>00866 <span class="preprocessor"></span> <a class="code" href="exportimage_8c.html#0f4275e99b0b5e083dbfca807ceee584" title="Render a project to a PNG file using user-specified render info.">gerbv_export_png_file_from_project</a> (mainProject, &amp;renderInfo, exportFilename);
<a name="l00867"></a>00867 <span class="preprocessor">#endif</span>
<a name="l00868"></a>00868 <span class="preprocessor"></span> } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (exportType == 2) {
<a name="l00869"></a>00869 <a class="code" href="exportimage_8c.html#bd459f30af80b3fbd4fb59fb6adf7de9" title="Render a project to a PDF file using user-specified render info.">gerbv_export_pdf_file_from_project</a> (mainProject, &amp;renderInfo, exportFilename);
<a name="l00870"></a>00870 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (exportType == 3) {
<a name="l00871"></a>00871 <a class="code" href="exportimage_8c.html#367c889e9f661b4502394a3e1b2f3e9e" title="Render a project to a file using user-specified render info.">gerbv_export_svg_file_from_project</a> (mainProject, &amp;renderInfo, exportFilename);
<a name="l00872"></a>00872 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (exportType == 4) {
<a name="l00873"></a>00873 <a class="code" href="exportimage_8c.html#78a0c7a0568ed284975fc84a84bf2b67" title="Render a project to a Postscript file using user-specified render info.">gerbv_export_postscript_file_from_project</a> (mainProject, &amp;renderInfo, exportFilename);
<a name="l00874"></a>00874 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (exportType == 5) {
<a name="l00875"></a>00875 <span class="keywordflow">if</span> (mainProject-&gt;<a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[0]-&gt;<a class="code" href="structgerbv__fileinfo__t.html#0aec7123b754ed7cb0adc9c98e985f84">image</a>) {
<a name="l00876"></a>00876 <span class="comment">/* if we have more than one file, we need to merge them before exporting */</span>
<a name="l00877"></a>00877 <span class="keywordflow">if</span> (mainProject-&gt;<a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[1]) {
<a name="l00878"></a>00878 <a class="code" href="structgerbv__image__t.html">gerbv_image_t</a> *exportImage;
<a name="l00879"></a>00879 exportImage = <a class="code" href="gerb__image_8c.html#dc5939e771877c0a4f62427b0a63bf64" title="Duplicate an existing image and return the new copy.">gerbv_image_duplicate_image</a> (mainProject-&gt;<a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[0]-&gt;<a class="code" href="structgerbv__fileinfo__t.html#0aec7123b754ed7cb0adc9c98e985f84">image</a>, &amp;mainProject-&gt;<a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[0]-&gt;<a class="code" href="structgerbv__fileinfo__t.html#145b4c98b74e7b07d262e5ecad32199e">transform</a>);
<a name="l00880"></a>00880 <span class="keywordflow">for</span>(i = mainProject-&gt;<a class="code" href="structgerbv__project__t.html#bab05758e52aca9b2b2c171ec923a4bf">max_files</a>-1; i &gt; 0; i--) {
<a name="l00881"></a>00881 <span class="keywordflow">if</span> (mainProject-&gt;<a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[i]) {
<a name="l00882"></a>00882 <a class="code" href="gerb__image_8c.html#8cd82de2992fbdc1b44b8fb1963214c9" title="Copy an image into an existing image, effectively merging the two together.">gerbv_image_copy_image</a> (mainProject-&gt;<a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[i]-&gt;<a class="code" href="structgerbv__fileinfo__t.html#0aec7123b754ed7cb0adc9c98e985f84">image</a>, &amp;mainProject-&gt;<a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[i]-&gt;<a class="code" href="structgerbv__fileinfo__t.html#145b4c98b74e7b07d262e5ecad32199e">transform</a>, exportImage);
<a name="l00883"></a>00883 }
<a name="l00884"></a>00884 }
<a name="l00885"></a>00885 <a class="code" href="export-rs274x_8c.html#49e264bfff8ce4ae783c173b48bba31d" title="Export an image to a new file in RS274X format.">gerbv_export_rs274x_file_from_image</a> (exportFilename, exportImage);
<a name="l00886"></a>00886 <a class="code" href="gerb__image_8c.html#2394060b1868594b1ae8b8edcca793e9" title="Free an image structure.">gerbv_destroy_image</a> (exportImage);
<a name="l00887"></a>00887 }
<a name="l00888"></a>00888 <span class="comment">/* otherwise, just export the single image file as it is */</span>
<a name="l00889"></a>00889 <span class="keywordflow">else</span> {
<a name="l00890"></a>00890 <a class="code" href="export-rs274x_8c.html#49e264bfff8ce4ae783c173b48bba31d" title="Export an image to a new file in RS274X format.">gerbv_export_rs274x_file_from_image</a> (exportFilename, mainProject-&gt;<a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[0]-&gt;<a class="code" href="structgerbv__fileinfo__t.html#0aec7123b754ed7cb0adc9c98e985f84">image</a>);
<a name="l00891"></a>00891 }
<a name="l00892"></a>00892 }
<a name="l00893"></a>00893 <span class="keywordflow">else</span> {
<a name="l00894"></a>00894 fprintf(stderr, <span class="stringliteral">"A valid file was not loaded.\n"</span>);
<a name="l00895"></a>00895 exit(1);
<a name="l00896"></a>00896 }
<a name="l00897"></a>00897 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (exportType == 6) {
<a name="l00898"></a>00898 <span class="keywordflow">if</span> (mainProject-&gt;<a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[0]-&gt;<a class="code" href="structgerbv__fileinfo__t.html#0aec7123b754ed7cb0adc9c98e985f84">image</a>) {
<a name="l00899"></a>00899 <span class="comment">/* if we have more than one file, we need to merge them before exporting */</span>
<a name="l00900"></a>00900 <span class="keywordflow">if</span> (mainProject-&gt;<a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[1]) {
<a name="l00901"></a>00901 <a class="code" href="structgerbv__image__t.html">gerbv_image_t</a> *exportImage;
<a name="l00902"></a>00902 exportImage = <a class="code" href="gerb__image_8c.html#dc5939e771877c0a4f62427b0a63bf64" title="Duplicate an existing image and return the new copy.">gerbv_image_duplicate_image</a> (mainProject-&gt;<a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[0]-&gt;<a class="code" href="structgerbv__fileinfo__t.html#0aec7123b754ed7cb0adc9c98e985f84">image</a>, &amp;mainProject-&gt;<a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[0]-&gt;<a class="code" href="structgerbv__fileinfo__t.html#145b4c98b74e7b07d262e5ecad32199e">transform</a>);
<a name="l00903"></a>00903 <span class="keywordflow">for</span>(i = mainProject-&gt;<a class="code" href="structgerbv__project__t.html#bab05758e52aca9b2b2c171ec923a4bf">max_files</a>-1; i &gt; 0; i--) {
<a name="l00904"></a>00904 <span class="keywordflow">if</span> (mainProject-&gt;<a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[i]) {
<a name="l00905"></a>00905 <a class="code" href="gerb__image_8c.html#8cd82de2992fbdc1b44b8fb1963214c9" title="Copy an image into an existing image, effectively merging the two together.">gerbv_image_copy_image</a> (mainProject-&gt;<a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[i]-&gt;<a class="code" href="structgerbv__fileinfo__t.html#0aec7123b754ed7cb0adc9c98e985f84">image</a>, &amp;mainProject-&gt;<a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[i]-&gt;<a class="code" href="structgerbv__fileinfo__t.html#145b4c98b74e7b07d262e5ecad32199e">transform</a>, exportImage);
<a name="l00906"></a>00906 }
<a name="l00907"></a>00907 }
<a name="l00908"></a>00908 <a class="code" href="export-drill_8c.html#1c57c267a10404d6fb15fd987f9052f6" title="Export an image to a new file in Excellon drill format.">gerbv_export_drill_file_from_image</a> (exportFilename, exportImage);
<a name="l00909"></a>00909 <a class="code" href="gerb__image_8c.html#2394060b1868594b1ae8b8edcca793e9" title="Free an image structure.">gerbv_destroy_image</a> (exportImage);
<a name="l00910"></a>00910 }
<a name="l00911"></a>00911 <span class="comment">/* otherwise, just export the single image file as it is */</span>
<a name="l00912"></a>00912 <span class="keywordflow">else</span> {
<a name="l00913"></a>00913 <a class="code" href="export-drill_8c.html#1c57c267a10404d6fb15fd987f9052f6" title="Export an image to a new file in Excellon drill format.">gerbv_export_drill_file_from_image</a> (exportFilename, mainProject-&gt;<a class="code" href="structgerbv__project__t.html#3ecaa11fbc1cef45f458e2b88445ac35">file</a>[0]-&gt;<a class="code" href="structgerbv__fileinfo__t.html#0aec7123b754ed7cb0adc9c98e985f84">image</a>);
<a name="l00914"></a>00914 }
<a name="l00915"></a>00915 }
<a name="l00916"></a>00916 <span class="keywordflow">else</span> {
<a name="l00917"></a>00917 fprintf(stderr, <span class="stringliteral">"A valid file was not loaded.\n"</span>);
<a name="l00918"></a>00918 exit(1);
<a name="l00919"></a>00919 }
<a name="l00920"></a>00920 }
<a name="l00921"></a>00921
<a name="l00922"></a>00922 <span class="keywordflow">if</span> (freeFilename)
<a name="l00923"></a>00923 free (exportFilename);
<a name="l00924"></a>00924 <span class="comment">/* exit now and don't start up gtk if this is a command line export */</span>
<a name="l00925"></a>00925 exit(1);
<a name="l00926"></a>00926 }
<a name="l00927"></a>00927 <span class="preprocessor">#ifndef RENDER_USING_GDK</span>
<a name="l00928"></a>00928 <span class="preprocessor"></span> gtk_init (&amp;argc, &amp;argv);
<a name="l00929"></a>00929 <span class="preprocessor">#endif</span>
<a name="l00930"></a>00930 <span class="preprocessor"></span> interface_create_gui (req_width, req_height);
<a name="l00931"></a>00931
<a name="l00932"></a>00932 <span class="keywordflow">return</span> 0;
<a name="l00933"></a>00933 } <span class="comment">/* main */</span>
<a name="l00934"></a>00934
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Tue Aug 19 00:14:49 2008 for gerbv by&nbsp;
<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>