Sophie

Sophie

distrib > Fedora > 13 > i386 > by-pkgid > eebc325dc36bd6e3b09b9b45133e42f8 > files > 976

HippoDraw-devel-docs-1.21.1-10.fc13.i686.rpm

<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>HippoDraw Class Library</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
<link rel="shortcut icon" href="hippoApp.ico">
</head><body>
<!-- Generated by Doxygen 1.6.2 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</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>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
  <div class="navpath"><a class="el" href="dir_f31ced79fa1bf97bbae7cff793d8fdf1.html">fits</a>
  </div>
</div>
<div class="contents">
<h1>FitsController.cxx</h1><a href="FitsController_8cxx.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00012"></a>00012 <span class="preprocessor">#include &quot;<a class="code" href="FitsController_8h.html" title="hippodraw::FitsController class interface.">FitsController.h</a>&quot;</span>
<a name="l00013"></a>00013 
<a name="l00014"></a>00014 <span class="preprocessor">#include &quot;<a class="code" href="FitsFile_8h.html" title="hippodraw::FitsFile interface">FitsFile.h</a>&quot;</span>
<a name="l00015"></a>00015 <span class="preprocessor">#include &quot;<a class="code" href="FitsNTuple_8h.html" title="hippodraw::FitsNTuple class interface.">FitsNTuple.h</a>&quot;</span>
<a name="l00016"></a>00016 
<a name="l00017"></a>00017 <span class="preprocessor">#include &quot;<a class="code" href="CutController_8h.html" title="hippodraw::CutController class interface">controllers/CutController.h</a>&quot;</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &quot;<a class="code" href="DataSourceController_8h.html" title="DataSourceController class interface.">datasrcs/DataSourceController.h</a>&quot;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &quot;<a class="code" href="TupleCut_8h.html" title="hippodraw::TupleCut class interface">datasrcs/TupleCut.h</a>&quot;</span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &quot;<a class="code" href="string__convert_8h.html" title="The namespace for conversion to string.">pattern/string_convert.h</a>&quot;</span>
<a name="l00021"></a>00021 <span class="preprocessor">#include &quot;<a class="code" href="PlotterBase_8h.html" title="hippodraw::PlotterBase class interface.">plotters/PlotterBase.h</a>&quot;</span>
<a name="l00022"></a>00022 
<a name="l00023"></a>00023 <span class="preprocessor">#include &lt;algorithm&gt;</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include &lt;fstream&gt;</span>
<a name="l00025"></a>00025 
<a name="l00026"></a>00026 
<a name="l00027"></a>00027 <span class="preprocessor">#include &lt;cassert&gt;</span>
<a name="l00028"></a>00028 
<a name="l00029"></a>00029 <span class="keyword">using</span> std::ifstream;
<a name="l00030"></a>00030 <span class="keyword">using</span> std::runtime_error;
<a name="l00031"></a>00031 <span class="keyword">using</span> std::string;
<a name="l00032"></a>00032 <span class="keyword">using</span> std::vector;
<a name="l00033"></a>00033 
<a name="l00034"></a>00034 <span class="keyword">using namespace </span>hippodraw;
<a name="l00035"></a>00035 
<a name="l00038"></a><a class="code" href="FitsController_8cxx.html#a4d81cda31a5e7f9d2ffc2f969718f496">00038</a> <span class="keyword">typedef</span> std::map &lt; std::string, FitsFile * &gt;::iterator <a class="code" href="FitsController_8cxx.html#a4d81cda31a5e7f9d2ffc2f969718f496" title="Short cut to iterator type.">FileMapIterator</a>;
<a name="l00039"></a>00039 
<a name="l00040"></a>00040 <a class="code" href="classhippodraw_1_1FitsController.html" title="A Controller class for FITS files.">FitsController</a> * FitsController::s_instance = 0;
<a name="l00041"></a>00041 
<a name="l00042"></a>00042 <a class="code" href="classhippodraw_1_1FitsController.html" title="A Controller class for FITS files.">FitsController</a> *
<a name="l00043"></a>00043 FitsController::
<a name="l00044"></a><a class="code" href="classhippodraw_1_1FitsController.html#a127637b93f8a5e52504b68e98126219e">00044</a> instance ()
<a name="l00045"></a>00045 {
<a name="l00046"></a>00046   <span class="keywordflow">if</span> ( <a class="code" href="classhippodraw_1_1FitsController.html#a1188499e4445e516d40d5a3f7a89079c" title="The singleton instance of the FitsController.">s_instance</a> == 0 ) {
<a name="l00047"></a>00047     <a class="code" href="classhippodraw_1_1FitsController.html#a1188499e4445e516d40d5a3f7a89079c" title="The singleton instance of the FitsController.">s_instance</a> = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1FitsController.html" title="A Controller class for FITS files.">FitsController</a> ();
<a name="l00048"></a>00048   }
<a name="l00049"></a>00049   <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1FitsController.html#a1188499e4445e516d40d5a3f7a89079c" title="The singleton instance of the FitsController.">s_instance</a>;
<a name="l00050"></a>00050 }
<a name="l00051"></a>00051 
<a name="l00052"></a>00052 <a class="code" href="classhippodraw_1_1FitsController.html#a49b9acebf75b4145e24015a7f30d39bb" title="The destructor.">FitsController::</a>
<a name="l00053"></a><a class="code" href="classhippodraw_1_1FitsController.html#a49b9acebf75b4145e24015a7f30d39bb">00053</a> <a class="code" href="classhippodraw_1_1FitsController.html#a49b9acebf75b4145e24015a7f30d39bb" title="The destructor.">~FitsController</a>()
<a name="l00054"></a>00054 {
<a name="l00055"></a>00055 }
<a name="l00056"></a>00056 
<a name="l00057"></a>00057 <span class="keyword">const</span> std::string &amp;
<a name="l00058"></a>00058 <a class="code" href="classhippodraw_1_1FitsController.html#a8395fc086f9cfe5d544d04cae22dd059" title="Returns the version of cfitsio being used.">FitsController::</a>
<a name="l00059"></a><a class="code" href="classhippodraw_1_1FitsController.html#a8395fc086f9cfe5d544d04cae22dd059">00059</a> <a class="code" href="classhippodraw_1_1FitsController.html#a8395fc086f9cfe5d544d04cae22dd059" title="Returns the version of cfitsio being used.">version</a> ()<span class="keyword"> const</span>
<a name="l00060"></a>00060 <span class="keyword"></span>{
<a name="l00061"></a>00061   <span class="keywordtype">float</span> <a class="code" href="classhippodraw_1_1FitsController.html#a8395fc086f9cfe5d544d04cae22dd059" title="Returns the version of cfitsio being used.">version</a> = 0.0;
<a name="l00062"></a>00062   fits_get_version ( &amp; version );
<a name="l00063"></a>00063 
<a name="l00064"></a>00064   <a class="code" href="classhippodraw_1_1FitsController.html#a5ebb5240c11541d46b3bfe086e4a8b87" title="The version of cfitsio being used.">m_version</a> = <a class="code" href="namespacehippodraw_1_1Axes.html#ae2337bddf33bc8b17dd5c08e665422cd" title="Converts from string representation ot Axes::Type representation.">String::convert</a> ( version );
<a name="l00065"></a>00065 
<a name="l00066"></a>00066   <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1FitsController.html#a5ebb5240c11541d46b3bfe086e4a8b87" title="The version of cfitsio being used.">m_version</a>;
<a name="l00067"></a>00067 }
<a name="l00068"></a>00068 
<a name="l00069"></a>00069 <a class="code" href="classhippodraw_1_1FitsFile.html" title="Wrapper class to CFITSIO.">FitsFile</a> *
<a name="l00070"></a>00070 <a class="code" href="classhippodraw_1_1FitsController.html#a8736169b024b9bde1077c6a9fcea3efd" title="Opens the named file, if not already opened.">FitsController::</a>
<a name="l00071"></a><a class="code" href="classhippodraw_1_1FitsController.html#a8736169b024b9bde1077c6a9fcea3efd">00071</a> <a class="code" href="classhippodraw_1_1FitsController.html#a8736169b024b9bde1077c6a9fcea3efd" title="Opens the named file, if not already opened.">openFile</a> ( <span class="keyword">const</span> std::string &amp; name )
<a name="l00072"></a>00072 {
<a name="l00073"></a>00073   <a class="code" href="classhippodraw_1_1FitsFile.html" title="Wrapper class to CFITSIO.">FitsFile</a> * file = 0;
<a name="l00074"></a>00074   <a class="code" href="FitsController_8cxx.html#a4d81cda31a5e7f9d2ffc2f969718f496" title="Short cut to iterator type.">FileMapIterator</a> first = <a class="code" href="classhippodraw_1_1FitsController.html#aace5d8ec00ce1d9c555647f13aa90ff6" title="A map of open FITS files.">m_file_map</a>.find ( name );
<a name="l00075"></a>00075 
<a name="l00076"></a>00076   <span class="keywordflow">if</span> ( first == <a class="code" href="classhippodraw_1_1FitsController.html#aace5d8ec00ce1d9c555647f13aa90ff6" title="A map of open FITS files.">m_file_map</a>.end() ) {
<a name="l00077"></a>00077     ifstream test ( name.c_str (), std::ios::in );
<a name="l00078"></a>00078     <span class="keywordflow">if</span> ( test.is_open () == false ) {
<a name="l00079"></a>00079       <span class="keywordtype">string</span> what ( <span class="stringliteral">&quot;FitsController: File `&quot;</span> );
<a name="l00080"></a>00080       what += name;
<a name="l00081"></a>00081       what += <span class="stringliteral">&quot;&#39; not found&quot;</span>;
<a name="l00082"></a>00082       <span class="keywordflow">throw</span> std::runtime_error ( what );
<a name="l00083"></a>00083     }
<a name="l00084"></a>00084 
<a name="l00085"></a>00085     file = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1FitsFile.html" title="Wrapper class to CFITSIO.">FitsFile</a> ( name );
<a name="l00086"></a>00086     <span class="keywordtype">int</span> status = file -&gt; status();
<a name="l00087"></a>00087 
<a name="l00088"></a>00088     <span class="keywordflow">if</span> ( status != 0 ) {
<a name="l00089"></a>00089       <span class="keywordtype">string</span> what ( <span class="stringliteral">&quot;cfitsio: Error opening file `&quot;</span> );
<a name="l00090"></a>00090       what += name;
<a name="l00091"></a>00091       what += <span class="stringliteral">&quot;&#39;&quot;</span>;
<a name="l00092"></a>00092       <span class="keyword">delete</span> file;
<a name="l00093"></a>00093       <span class="keywordflow">throw</span> runtime_error ( what );
<a name="l00094"></a>00094     }
<a name="l00095"></a>00095     <a class="code" href="classhippodraw_1_1FitsController.html#aace5d8ec00ce1d9c555647f13aa90ff6" title="A map of open FITS files.">m_file_map</a> [ name ] = file;
<a name="l00096"></a>00096   }
<a name="l00097"></a>00097   <span class="keywordflow">else</span> {
<a name="l00098"></a>00098     file = first -&gt; second;
<a name="l00099"></a>00099   }
<a name="l00100"></a>00100 
<a name="l00101"></a>00101   <span class="keywordflow">return</span> file;
<a name="l00102"></a>00102 }
<a name="l00103"></a>00103 
<a name="l00106"></a>00106 <span class="keywordtype">void</span>
<a name="l00107"></a>00107 <a class="code" href="classhippodraw_1_1FitsController.html#a917c528adccaa019ab4a003046e7f21c" title="Closed the named file, if found in list of opened files.">FitsController::</a>
<a name="l00108"></a><a class="code" href="classhippodraw_1_1FitsController.html#a917c528adccaa019ab4a003046e7f21c">00108</a> <a class="code" href="classhippodraw_1_1FitsController.html#a917c528adccaa019ab4a003046e7f21c" title="Closed the named file, if found in list of opened files.">closeFile</a> ( <span class="keyword">const</span> std::string &amp; )
<a name="l00109"></a>00109 {
<a name="l00110"></a>00110 <span class="comment">//   FileMapIterator where = m_file_map.find ( name );</span>
<a name="l00111"></a>00111 <span class="comment">//   if ( where != m_file_map.end () ) {</span>
<a name="l00112"></a>00112 <span class="comment">//     m_file_map.erase ( where );</span>
<a name="l00113"></a>00113 <span class="comment">//     fitsfile * file = where -&gt; second;</span>
<a name="l00114"></a>00114 <span class="comment">//     fits_close_file ( file, &amp; status );</span>
<a name="l00115"></a>00115 <span class="comment">//   }</span>
<a name="l00116"></a>00116 }
<a name="l00117"></a>00117 
<a name="l00118"></a>00118 <span class="keyword">const</span> vector &lt; string &gt; &amp;
<a name="l00119"></a>00119 <a class="code" href="classhippodraw_1_1FitsController.html#a46c43f94e12641000a506c5cdb12e694" title="Returns a temporarily list of the names of the DataSource objects in the FITS file...">FitsController::</a>
<a name="l00120"></a><a class="code" href="classhippodraw_1_1FitsController.html#a46c43f94e12641000a506c5cdb12e694">00120</a> <a class="code" href="classhippodraw_1_1FitsController.html#a46c43f94e12641000a506c5cdb12e694" title="Returns a temporarily list of the names of the DataSource objects in the FITS file...">getNTupleNames</a> ( <span class="keyword">const</span> std::string &amp; file_name )
<a name="l00121"></a>00121 {
<a name="l00122"></a>00122   <a class="code" href="classhippodraw_1_1FitsController.html#a4d277b66ef016a78b2d85f29d164273b" title="A list of possible DataSource names in the FITS file.">m_ntuple_names</a>.clear ();
<a name="l00123"></a>00123   <a class="code" href="classhippodraw_1_1FitsFile.html" title="Wrapper class to CFITSIO.">FitsFile</a> * file = <a class="code" href="classhippodraw_1_1FitsController.html#a8736169b024b9bde1077c6a9fcea3efd" title="Opens the named file, if not already opened.">openFile</a> ( file_name );
<a name="l00124"></a>00124   <span class="keywordflow">if</span> ( file != 0 ) {
<a name="l00125"></a>00125     file -&gt; fillHDUNames ( <a class="code" href="classhippodraw_1_1FitsController.html#a4d277b66ef016a78b2d85f29d164273b" title="A list of possible DataSource names in the FITS file.">m_ntuple_names</a> );
<a name="l00126"></a>00126   }
<a name="l00127"></a>00127 
<a name="l00128"></a>00128   <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1FitsController.html#a4d277b66ef016a78b2d85f29d164273b" title="A list of possible DataSource names in the FITS file.">m_ntuple_names</a>;
<a name="l00129"></a>00129 }
<a name="l00130"></a>00130 
<a name="l00131"></a>00131 
<a name="l00132"></a>00132 <a class="code" href="classhippodraw_1_1DataSource.html" title="Base class for DataSource.">DataSource</a> *
<a name="l00133"></a>00133 <a class="code" href="classhippodraw_1_1FitsController.html#a1be245083fda2e52c2d2bd96a8a7d610" title="Creates a FitsNTuple from a ASCII or binary table in a FITS file.">FitsController::</a>
<a name="l00134"></a><a class="code" href="classhippodraw_1_1FitsController.html#a1be245083fda2e52c2d2bd96a8a7d610">00134</a> <a class="code" href="classhippodraw_1_1FitsController.html#a1be245083fda2e52c2d2bd96a8a7d610" title="Creates a FitsNTuple from a ASCII or binary table in a FITS file.">createNTuple</a> ( <span class="keyword">const</span> std::string &amp; filename,
<a name="l00135"></a>00135                <span class="keyword">const</span> std::string &amp; name )
<a name="l00136"></a>00136 {
<a name="l00137"></a>00137   <span class="keywordtype">int</span> index = -1;
<a name="l00138"></a>00138 
<a name="l00139"></a>00139   <span class="keyword">const</span> vector &lt; string &gt; &amp; names 
<a name="l00140"></a>00140     = <a class="code" href="classhippodraw_1_1FitsController.html#a46c43f94e12641000a506c5cdb12e694" title="Returns a temporarily list of the names of the DataSource objects in the FITS file...">getNTupleNames</a> ( filename );
<a name="l00141"></a>00141   <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="namespacenum__util.html#a137f48a49d12a7dae8ba7c86db2a0c01">size</a> = names.size ();
<a name="l00142"></a>00142 
<a name="l00143"></a>00143   <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i &lt; size; i++ ) {
<a name="l00144"></a>00144     <span class="keywordflow">if</span> ( name == names[i] ) {
<a name="l00145"></a>00145       index = i;
<a name="l00146"></a>00146       <span class="keywordflow">break</span>;
<a name="l00147"></a>00147     }
<a name="l00148"></a>00148   }
<a name="l00149"></a>00149 
<a name="l00150"></a>00150   <span class="keywordflow">if</span> ( index == -1 ) {
<a name="l00151"></a>00151     <span class="keywordtype">string</span> what ( <span class="stringliteral">&quot;FitsController: File `&quot;</span> );
<a name="l00152"></a>00152     what += filename; 
<a name="l00153"></a>00153     what += <span class="stringliteral">&quot;&#39; &quot;</span>;
<a name="l00154"></a>00154     what += <span class="stringliteral">&quot;does not have extensison with name `&quot;</span>;
<a name="l00155"></a>00155     what += name;
<a name="l00156"></a>00156     what  += <span class="stringliteral">&quot;&#39;&quot;</span>;
<a name="l00157"></a>00157     <span class="keywordflow">throw</span> runtime_error ( what );
<a name="l00158"></a>00158   }
<a name="l00159"></a>00159 
<a name="l00160"></a>00160   <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1FitsController.html#a1be245083fda2e52c2d2bd96a8a7d610" title="Creates a FitsNTuple from a ASCII or binary table in a FITS file.">createNTuple</a> ( filename, name, index );
<a name="l00161"></a>00161 }
<a name="l00162"></a>00162 
<a name="l00163"></a>00163 <a class="code" href="classhippodraw_1_1DataSource.html" title="Base class for DataSource.">DataSource</a> *
<a name="l00164"></a>00164 <a class="code" href="classhippodraw_1_1FitsController.html#a1be245083fda2e52c2d2bd96a8a7d610" title="Creates a FitsNTuple from a ASCII or binary table in a FITS file.">FitsController::</a>
<a name="l00165"></a><a class="code" href="classhippodraw_1_1FitsController.html#a817cbdd26f468e2b1904a9b6c563e2b0">00165</a> <a class="code" href="classhippodraw_1_1FitsController.html#a1be245083fda2e52c2d2bd96a8a7d610" title="Creates a FitsNTuple from a ASCII or binary table in a FITS file.">createNTuple</a> ( <span class="keyword">const</span> std::string &amp; filename, 
<a name="l00166"></a>00166                <span class="keyword">const</span> std::string &amp; name,
<a name="l00167"></a>00167                <span class="keywordtype">int</span> index )
<a name="l00168"></a>00168 {
<a name="l00169"></a>00169   <a class="code" href="classhippodraw_1_1DataSource.html" title="Base class for DataSource.">DataSource</a>  * ntuple = 0;
<a name="l00170"></a>00170 
<a name="l00171"></a>00171   <span class="keywordtype">string</span> ds_name = filename;
<a name="l00172"></a>00172   ds_name += <span class="stringliteral">&quot;: &quot;</span>;
<a name="l00173"></a>00173   ds_name += name;
<a name="l00174"></a>00174 
<a name="l00175"></a>00175   <a class="code" href="classhippodraw_1_1FitsFile.html" title="Wrapper class to CFITSIO.">FitsFile</a> * file =  <a class="code" href="classhippodraw_1_1FitsController.html#a8736169b024b9bde1077c6a9fcea3efd" title="Opens the named file, if not already opened.">openFile</a> ( filename );
<a name="l00176"></a>00176   <span class="keywordflow">if</span> ( file == NULL ) <span class="keywordflow">return</span> NULL;
<a name="l00177"></a>00177 
<a name="l00178"></a>00178   <span class="keywordtype">int</span> retval = file -&gt; moveToHDU ( index );
<a name="l00179"></a>00179   <span class="keywordflow">if</span> ( retval == 0 ) {
<a name="l00180"></a>00180     <span class="keywordflow">try</span> {
<a name="l00181"></a>00181       ntuple = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1FitsNTuple.html" title="A DataSource class implemented with a vector &amp;lt; DataColumn * &amp;gt; objects.">FitsNTuple</a> ( file );
<a name="l00182"></a>00182     }
<a name="l00183"></a>00183     <span class="keywordflow">catch</span> ( <span class="keyword">const</span> runtime_error &amp; e ) {
<a name="l00184"></a>00184       <span class="keywordflow">throw</span> e;
<a name="l00185"></a>00185     }
<a name="l00186"></a>00186 
<a name="l00187"></a>00187     ntuple -&gt; setTitle ( name );
<a name="l00188"></a>00188     ntuple -&gt; setName ( ds_name );
<a name="l00189"></a>00189     <a class="code" href="classhippodraw_1_1DataSourceController.html" title="A singleton class that is the interface between GUI and the DataSource objects.">DataSourceController</a> * controller = <a class="code" href="classhippodraw_1_1FitsController.html#a127637b93f8a5e52504b68e98126219e" title="Returns the singleton instance of the FitsController.">DataSourceController::instance</a>();
<a name="l00190"></a>00190     controller -&gt; registerNTuple ( ds_name, ntuple );
<a name="l00191"></a>00191     controller -&gt; registerDataSourceFile ( ntuple );
<a name="l00192"></a>00192   }
<a name="l00193"></a>00193 
<a name="l00194"></a>00194   <span class="keywordflow">return</span> ntuple;
<a name="l00195"></a>00195 }
<a name="l00196"></a>00196 
<a name="l00197"></a>00197 <span class="keywordtype">void</span>
<a name="l00198"></a>00198 <a class="code" href="classhippodraw_1_1FitsController.html#a4439ba6c350f285a082ae19613784966" title="Check and fix plotter for FITS image data source.">FitsController::</a>
<a name="l00199"></a><a class="code" href="classhippodraw_1_1FitsController.html#a4439ba6c350f285a082ae19613784966">00199</a> <a class="code" href="classhippodraw_1_1FitsController.html#a4439ba6c350f285a082ae19613784966" title="Check and fix plotter for FITS image data source.">checkForImage</a> ( <a class="code" href="classhippodraw_1_1PlotterBase.html" title="The base class for the PlotterBase hierarchy.">PlotterBase</a> * plotter, <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1DataSource.html" title="Base class for DataSource.">DataSource</a> &amp; source )
<a name="l00200"></a>00200 {
<a name="l00201"></a>00201   <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1FitsFile.html" title="Wrapper class to CFITSIO.">FitsFile</a> * file = 0;
<a name="l00202"></a>00202   <span class="keywordflow">try</span> {
<a name="l00203"></a>00203     <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1FitsNTuple.html" title="A DataSource class implemented with a vector &amp;lt; DataColumn * &amp;gt; objects.">FitsNTuple</a> &amp; ntuple 
<a name="l00204"></a>00204       = dynamic_cast &lt; <span class="keyword">const</span>  <a class="code" href="classhippodraw_1_1FitsNTuple.html" title="A DataSource class implemented with a vector &amp;lt; DataColumn * &amp;gt; objects.">FitsNTuple</a> &amp; &gt; ( source );
<a name="l00205"></a>00205     file = ntuple.<a class="code" href="classhippodraw_1_1FitsNTuple.html#af98fcfecd7b16f3afff21e87a7eda308" title="Returns the FITS file used to create this object.">getFile</a> ();
<a name="l00206"></a>00206   }
<a name="l00207"></a>00207   <span class="keywordflow">catch</span> ( ... ) {
<a name="l00208"></a>00208     <span class="comment">// do nothing</span>
<a name="l00209"></a>00209   }
<a name="l00210"></a>00210   <span class="keywordflow">if</span> ( file == 0 ) <span class="keywordflow">return</span>;
<a name="l00211"></a>00211 
<a name="l00212"></a>00212   <a class="code" href="classhippodraw_1_1FitsFileBase.html#a09204037a28bb5e9ae491bc1b7b78c96" title="The type of HDU.">FitsFileBase::HduType</a> <a class="code" href="namespacenum__util.html#af7e893a8c6a5f6a426480fc85cda4fa1">type</a> = file -&gt; getHduType ();
<a name="l00213"></a>00213   <span class="keywordflow">if</span> ( type != <a class="code" href="classhippodraw_1_1FitsFileBase.html#a09204037a28bb5e9ae491bc1b7b78c96a41675d4fa29c99fe7e2e71b07889ae98" title="Image.">FitsFileBase::Image</a> ) <span class="keywordflow">return</span>;
<a name="l00214"></a>00214 
<a name="l00215"></a>00215   vector &lt; long &gt; sizes;
<a name="l00216"></a>00216   file -&gt; fillAxisSizes ( sizes );
<a name="l00217"></a>00217   <span class="keywordflow">if</span> ( sizes.size () &gt; 3 ) {
<a name="l00218"></a>00218     <span class="keywordtype">string</span> what ( <span class="stringliteral">&quot;FitsController: greater then 3D images not supported&quot;</span> );
<a name="l00219"></a>00219     <span class="keywordflow">throw</span> std::runtime_error ( what );
<a name="l00220"></a>00220   }
<a name="l00221"></a>00221 
<a name="l00222"></a>00222   plotter -&gt; setNumberOfBins ( <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a58833a3110c570fb05130d40c365d1e4" title="X axis.">Axes::X</a>, sizes[0] );
<a name="l00223"></a>00223   plotter -&gt; setNumberOfBins ( <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a5596231eabd6cf29050967d5ac83ad84" title="Y axis.">Axes::Y</a>, sizes[1] );
<a name="l00224"></a>00224 
<a name="l00225"></a>00225   vector &lt; double &gt; deltas;
<a name="l00226"></a>00226   file -&gt; fillImageDeltas ( deltas );
<a name="l00227"></a>00227   plotter -&gt; setBinWidth ( <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a58833a3110c570fb05130d40c365d1e4" title="X axis.">Axes::X</a>, deltas[0] );
<a name="l00228"></a>00228   plotter -&gt; setBinWidth ( <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a5596231eabd6cf29050967d5ac83ad84" title="Y axis.">Axes::Y</a>, deltas[1] );
<a name="l00229"></a>00229 
<a name="l00230"></a>00230   vector &lt; double &gt; ref_values;
<a name="l00231"></a>00231   file -&gt; fillRefPixelValues ( ref_values );
<a name="l00232"></a>00232   vector &lt; int &gt; ref_indices;
<a name="l00233"></a>00233   file -&gt; fillRefPixelIndices ( ref_indices );
<a name="l00234"></a>00234 
<a name="l00235"></a>00235   <span class="comment">// Process fits file with PIXCENT keyword.</span>
<a name="l00236"></a>00236   <span class="keywordtype">double</span> pixToRef;
<a name="l00237"></a>00237   <span class="keywordflow">if</span> ((file -&gt;pixCenter ())==<span class="keyword">true</span>) pixToRef=0.5;
<a name="l00238"></a>00238   <span class="keywordflow">else</span> pixToRef=0.0;
<a name="l00239"></a>00239 
<a name="l00240"></a>00240   <span class="keywordtype">double</span> x_orig = - deltas[0] * ( ref_indices[0]-1+pixToRef ) + ref_values[0];
<a name="l00241"></a>00241   <span class="keywordtype">double</span> y_orig = - deltas[1] * ( ref_indices[1]-1+pixToRef ) + ref_values[1];
<a name="l00242"></a>00242   plotter -&gt;<a class="code" href="classhippodraw_1_1PlotterBase.html#aabcc71f2884f3667c1410685d5a887fa" title="Sets the offset.">setOffset</a> ( <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a58833a3110c570fb05130d40c365d1e4" title="X axis.">Axes::X</a>, x_orig );
<a name="l00243"></a>00243   plotter -&gt;<a class="code" href="classhippodraw_1_1PlotterBase.html#aabcc71f2884f3667c1410685d5a887fa" title="Sets the offset.">setOffset</a> ( <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a5596231eabd6cf29050967d5ac83ad84" title="Y axis.">Axes::Y</a>, y_orig );
<a name="l00244"></a>00244 
<a name="l00245"></a>00245 
<a name="l00246"></a>00246   <span class="comment">// Fix out of range bug.</span>
<a name="l00247"></a>00247   <a class="code" href="classhippodraw_1_1Range.html" title="Expresses a range of values.">Range</a> range;
<a name="l00248"></a>00248   <span class="keywordflow">if</span> ( deltas[0] &lt; 0. ) {
<a name="l00249"></a>00249     range.<a class="code" href="classhippodraw_1_1Range.html#addffd7d4904f8f6261dae4e2cb51b734" title="Changes the current Range.">setRange</a> ( x_orig +  sizes[0]  * deltas[0], x_orig, -deltas[0] );
<a name="l00250"></a>00250   }
<a name="l00251"></a>00251   <span class="keywordflow">else</span> {
<a name="l00252"></a>00252     range.<a class="code" href="classhippodraw_1_1Range.html#addffd7d4904f8f6261dae4e2cb51b734" title="Changes the current Range.">setRange</a> ( x_orig, x_orig + (sizes[0] ) * deltas[0], 1. );
<a name="l00253"></a>00253   }
<a name="l00254"></a>00254   plotter -&gt; setRange ( <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a58833a3110c570fb05130d40c365d1e4" title="X axis.">Axes::X</a>, range, <span class="keyword">false</span>, <span class="keyword">true</span> );
<a name="l00255"></a>00255   range.<a class="code" href="classhippodraw_1_1Range.html#a2618a41860251089e4ab57a83429c27f" title="Sets the minimum of the range object.">setLow</a> ( y_orig );
<a name="l00256"></a>00256   range.<a class="code" href="classhippodraw_1_1Range.html#a351c05149e0c2de1ad130b9c13bd2cb3" title="Sets the length of the range.">setLength</a> ( ( sizes[1]  ) * deltas[1] );
<a name="l00257"></a>00257   plotter -&gt; setRange ( <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a5596231eabd6cf29050967d5ac83ad84" title="Y axis.">Axes::Y</a>, range, <span class="keyword">false</span>, <span class="keyword">true</span> );
<a name="l00258"></a>00258 
<a name="l00259"></a>00259   plotter -&gt; matrixTranspose ( <span class="keyword">true</span> );
<a name="l00260"></a>00260 
<a name="l00261"></a>00261   <span class="keywordtype">bool</span> yes = file -&gt; isHammerAitoff ();
<a name="l00262"></a>00262   <span class="keywordflow">if</span> ( yes ) {
<a name="l00263"></a>00263     plotter -&gt;<a class="code" href="classhippodraw_1_1PlotterBase.html#a2702277fba29397e6d437872a381dd21" title="Sets the aspect ratio.">setAspectRatio</a> ( 2.0 );
<a name="l00264"></a>00264     plotter -&gt;<a class="code" href="classhippodraw_1_1PlotterBase.html#a9307172f633cda713dd356a1f2cf0cbb" title="Set the fits transform object.">setFitsTransform</a> (<span class="stringliteral">&quot;HammerAito&quot;</span>);
<a name="l00265"></a>00265   }
<a name="l00266"></a>00266 }
<a name="l00267"></a>00267 
<a name="l00270"></a>00270 <span class="keywordtype">void</span>
<a name="l00271"></a>00271 <a class="code" href="classhippodraw_1_1FitsController.html#abed090ca9deca879293a70ca867d7f19" title="Write a DataSource to a FITS file as binary table.">FitsController::</a>
<a name="l00272"></a><a class="code" href="classhippodraw_1_1FitsController.html#abed090ca9deca879293a70ca867d7f19">00272</a> <a class="code" href="classhippodraw_1_1FitsController.html#abed090ca9deca879293a70ca867d7f19" title="Write a DataSource to a FITS file as binary table.">writeNTupleToFile</a> ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1DataSource.html" title="Base class for DataSource.">DataSource</a> * ntuple,
<a name="l00273"></a>00273                     <span class="keyword">const</span> std::string &amp; filename )
<a name="l00274"></a>00274 {
<a name="l00275"></a>00275   <a class="code" href="classhippodraw_1_1FitsFile.html" title="Wrapper class to CFITSIO.">FitsFile</a> * file = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1FitsFile.html" title="Wrapper class to CFITSIO.">FitsFile</a> ( filename, <span class="keyword">true</span> );
<a name="l00276"></a>00276 
<a name="l00277"></a>00277   <span class="keywordtype">long</span> row = <span class="keyword">static_cast&lt;</span><span class="keywordtype">long</span><span class="keyword">&gt;</span> ( ntuple -&gt; rows() );
<a name="l00278"></a>00278   <span class="keywordtype">int</span> <a class="code" href="namespacehippodraw_1_1DataPoint2DTuple.html#ae78e6e11a40e6dba1bae097358f97d15" title="The column indices for 2 dimension data point tuple.">column</a> = <span class="keyword">static_cast&lt;</span><span class="keywordtype">int</span><span class="keyword">&gt;</span> (ntuple -&gt; columns());
<a name="l00279"></a>00279   <span class="keyword">const</span> vector &lt;string&gt; labels = ntuple -&gt; getLabels();
<a name="l00280"></a>00280   vector &lt; vector &lt; int &gt; &gt; shapes;
<a name="l00281"></a>00281 
<a name="l00282"></a>00282   <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i &lt; column; i++ ){
<a name="l00283"></a>00283     vector &lt; int &gt; <a class="code" href="namespacenum__util.html#a8570d9b34e8e9d714823c1b1986764f7">shape</a>;
<a name="l00284"></a>00284     ntuple -&gt; fillShape ( shape, i );
<a name="l00285"></a>00285     shapes.push_back ( shape );
<a name="l00286"></a>00286   }
<a name="l00287"></a>00287   <span class="keywordtype">string</span> extname;
<a name="l00288"></a>00288   <span class="keyword">const</span> <span class="keywordtype">string</span> fullname = ntuple -&gt; getName();
<a name="l00289"></a>00289   string::size_type pos1 = fullname.find_last_of ( <span class="stringliteral">&quot;:&quot;</span> );
<a name="l00290"></a>00290   string::size_type pos2 = fullname.find_last_of ( <span class="stringliteral">&quot;/&quot;</span> );
<a name="l00291"></a>00291  
<a name="l00292"></a>00292   <span class="keywordflow">if</span> ( pos1 != string::npos &amp;&amp; pos1!=1 ) {
<a name="l00293"></a>00293     extname = fullname.substr ( pos1+2 );
<a name="l00294"></a>00294   }
<a name="l00295"></a>00295   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (pos2 != string::npos) {   <span class="comment">// only filename</span>
<a name="l00296"></a>00296     extname = <span class="stringliteral">&quot;&lt;no name&gt;&quot;</span>;
<a name="l00297"></a>00297   }
<a name="l00298"></a>00298   <span class="keywordflow">else</span> {  <span class="comment">// only title</span>
<a name="l00299"></a>00299     extname = fullname; 
<a name="l00300"></a>00300   } 
<a name="l00301"></a>00301   
<a name="l00302"></a>00302   file -&gt; writeHDU ( row, column, labels, shapes, extname );
<a name="l00303"></a>00303   <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i &lt; column; i++ ) {
<a name="l00304"></a>00304       <span class="keyword">const</span> vector &lt; double &gt; &amp; col = ntuple -&gt; getColumn (i );
<a name="l00305"></a>00305     file -&gt; writeColumn ( i, col );
<a name="l00306"></a>00306   }
<a name="l00307"></a>00307 
<a name="l00308"></a>00308   file -&gt; writeCloseFile ();
<a name="l00309"></a>00309   
<a name="l00310"></a>00310   <span class="keyword">delete</span> file;
<a name="l00311"></a>00311 
<a name="l00312"></a>00312 }
<a name="l00313"></a>00313 
<a name="l00314"></a>00314 <span class="keywordtype">void</span>
<a name="l00315"></a>00315 <a class="code" href="classhippodraw_1_1FitsController.html#abed090ca9deca879293a70ca867d7f19" title="Write a DataSource to a FITS file as binary table.">FitsController::</a>
<a name="l00316"></a><a class="code" href="classhippodraw_1_1FitsController.html#aac63e69a4d959a3d63fbfa95565bfe6c">00316</a> <a class="code" href="classhippodraw_1_1FitsController.html#abed090ca9deca879293a70ca867d7f19" title="Write a DataSource to a FITS file as binary table.">writeNTupleToFile</a> ( <span class="keyword">const</span> std::string &amp; name, <span class="keyword">const</span> std::string &amp; filename )
<a name="l00317"></a>00317 {
<a name="l00318"></a>00318   <a class="code" href="classhippodraw_1_1DataSourceController.html" title="A singleton class that is the interface between GUI and the DataSource objects.">DataSourceController</a> * controller = <a class="code" href="classhippodraw_1_1FitsController.html#a127637b93f8a5e52504b68e98126219e" title="Returns the singleton instance of the FitsController.">DataSourceController::instance</a> ();
<a name="l00319"></a>00319   <a class="code" href="classhippodraw_1_1DataSource.html" title="Base class for DataSource.">DataSource</a> * ntuple 
<a name="l00320"></a>00320     = controller -&gt; findDataSource ( name ); <span class="comment">// throws exception if not found</span>
<a name="l00321"></a>00321   <span class="keywordflow">if</span> ( ntuple == 0 ) <span class="keywordflow">return</span>;
<a name="l00322"></a>00322 
<a name="l00323"></a>00323   <a class="code" href="classhippodraw_1_1FitsController.html#abed090ca9deca879293a70ca867d7f19" title="Write a DataSource to a FITS file as binary table.">writeNTupleToFile</a> ( ntuple, filename );  
<a name="l00324"></a>00324 }
<a name="l00325"></a>00325 
<a name="l00326"></a>00326 <span class="keywordtype">void</span>
<a name="l00327"></a>00327 <a class="code" href="classhippodraw_1_1FitsController.html#adde36a25fcc411493fd407f559a8d50d" title="Write a image to a FITS image.">FitsController::</a>
<a name="l00328"></a><a class="code" href="classhippodraw_1_1FitsController.html#adde36a25fcc411493fd407f559a8d50d">00328</a> <a class="code" href="classhippodraw_1_1FitsController.html#adde36a25fcc411493fd407f559a8d50d" title="Write a image to a FITS image.">writeImageToFile</a> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> x, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> y,
<a name="l00329"></a>00329                    <span class="keyword">const</span> std::vector &lt;double&gt; &amp; <a class="code" href="namespacenum__util.html#a0c664ca7e08d03a2b3275f4f35efa933">data</a>,
<a name="l00330"></a>00330                    <span class="keyword">const</span> std::string &amp; filename )
<a name="l00331"></a>00331 {
<a name="l00332"></a>00332 
<a name="l00333"></a>00333   <a class="code" href="classhippodraw_1_1FitsFile.html" title="Wrapper class to CFITSIO.">FitsFile</a> * file = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1FitsFile.html" title="Wrapper class to CFITSIO.">FitsFile</a> ( filename, <span class="keyword">true</span> );
<a name="l00334"></a>00334 
<a name="l00335"></a>00335   <span class="keywordtype">long</span> xx = <span class="keyword">static_cast&lt;</span><span class="keywordtype">long</span><span class="keyword">&gt;</span> ( x );
<a name="l00336"></a>00336   <span class="keywordtype">long</span> yy = <span class="keyword">static_cast&lt;</span><span class="keywordtype">long</span><span class="keyword">&gt;</span> ( y );
<a name="l00337"></a>00337 
<a name="l00338"></a>00338   <span class="keywordtype">double</span> xlow = 0.0 - <span class="keyword">static_cast&lt;</span><span class="keywordtype">double</span><span class="keyword">&gt;</span> (x) / 2 ;
<a name="l00339"></a>00339   <span class="keywordtype">double</span> ylow = 0.0 - <span class="keyword">static_cast&lt;</span><span class="keywordtype">double</span><span class="keyword">&gt;</span> (y) / 2;
<a name="l00340"></a>00340 
<a name="l00341"></a>00341   file -&gt; writeImageHDU ( xx,yy );
<a name="l00342"></a>00342   file -&gt; writeRefPixelValues ( xlow, ylow );
<a name="l00343"></a>00343   file -&gt; writePix ( xx, yy, data );
<a name="l00344"></a>00344   
<a name="l00345"></a>00345   file -&gt; writeCloseFile ();
<a name="l00346"></a>00346 
<a name="l00347"></a>00347   <span class="keyword">delete</span> file;
<a name="l00348"></a>00348   
<a name="l00349"></a>00349 }
<a name="l00350"></a>00350 
<a name="l00351"></a>00351 <span class="keywordtype">size_t</span>
<a name="l00352"></a>00352 <a class="code" href="classhippodraw_1_1FitsController.html#a92ffc044118bb6a430998e2d19e40439" title="Returns the number of elements in a column.">FitsController::</a>
<a name="l00353"></a><a class="code" href="classhippodraw_1_1FitsController.html#a92ffc044118bb6a430998e2d19e40439">00353</a> <a class="code" href="classhippodraw_1_1FitsController.html#a92ffc044118bb6a430998e2d19e40439" title="Returns the number of elements in a column.">calcColumnWidth</a> ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1DataSource.html" title="Base class for DataSource.">DataSource</a> * source, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="namespacehippodraw_1_1DataPoint2DTuple.html#ae78e6e11a40e6dba1bae097358f97d15" title="The column indices for 2 dimension data point tuple.">column</a> )<span class="keyword"> const</span>
<a name="l00354"></a>00354 <span class="keyword"></span>{
<a name="l00355"></a>00355   vector &lt; int &gt; <a class="code" href="namespacenum__util.html#a8570d9b34e8e9d714823c1b1986764f7">shape</a>;
<a name="l00356"></a>00356   source -&gt; fillShape ( shape, column );
<a name="l00357"></a>00357   <span class="keywordtype">size_t</span> <a class="code" href="namespacenum__util.html#a59851d76f9624ac3de899f818f9e0a6b">rank</a> = shape.size ();
<a name="l00358"></a>00358   <span class="keywordtype">size_t</span> count = 1;
<a name="l00359"></a>00359 
<a name="l00360"></a>00360   <span class="keywordflow">for</span> ( <span class="keywordtype">size_t</span> i = 1; i &lt; rank; i++ ) {
<a name="l00361"></a>00361     count *= shape[i];
<a name="l00362"></a>00362   }
<a name="l00363"></a>00363   <span class="keywordflow">return</span> count;
<a name="l00364"></a>00364 }
<a name="l00365"></a>00365 
<a name="l00366"></a>00366 <span class="keywordtype">int</span>
<a name="l00367"></a>00367 <a class="code" href="classhippodraw_1_1FitsController.html#abed090ca9deca879293a70ca867d7f19" title="Write a DataSource to a FITS file as binary table.">FitsController::</a>
<a name="l00368"></a><a class="code" href="classhippodraw_1_1FitsController.html#a85660c0a5376e3f8537b2eea1caa70b9">00368</a> <a class="code" href="classhippodraw_1_1FitsController.html#abed090ca9deca879293a70ca867d7f19" title="Write a DataSource to a FITS file as binary table.">writeNTupleToFile</a> ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1DataSource.html" title="Base class for DataSource.">DataSource</a> * ds,
<a name="l00369"></a>00369                     <span class="keyword">const</span> std::string &amp; filename,
<a name="l00370"></a>00370                     <span class="keyword">const</span> std::string &amp; dsname, 
<a name="l00371"></a>00371                     <span class="keyword">const</span> std::vector &lt; std::string &gt; &amp; column_list,
<a name="l00372"></a>00372                     <span class="keyword">const</span> std::vector &lt; const TupleCut * &gt; &amp; cut_list)
<a name="l00373"></a>00373 {
<a name="l00374"></a>00374   <span class="keywordflow">if</span> ( column_list.empty() ) <span class="keywordflow">return</span> 1;
<a name="l00375"></a>00375 
<a name="l00376"></a>00376   <a class="code" href="classhippodraw_1_1FitsFile.html" title="Wrapper class to CFITSIO.">FitsFile</a> * file = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1FitsFile.html" title="Wrapper class to CFITSIO.">FitsFile</a> ( filename, <span class="keyword">true</span> );
<a name="l00377"></a>00377 
<a name="l00378"></a>00378   <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> columnNumber = column_list.size();
<a name="l00379"></a>00379   <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="namespacenum__util.html#a137f48a49d12a7dae8ba7c86db2a0c01">size</a> = ds-&gt;<a class="code" href="classhippodraw_1_1DataSource.html#a1d2abe9c739bf78a94515f803cf926e7" title="Returns the number of rows.">rows</a>();
<a name="l00380"></a>00380 
<a name="l00381"></a>00381   vector &lt; bool &gt; acceptArray;
<a name="l00382"></a>00382   <a class="code" href="classhippodraw_1_1CutController.html#a7fd3044b7e3ce94fc29992cc9f126bf6">CutController::fillAcceptedRows</a> ( acceptArray, ds, cut_list );
<a name="l00383"></a>00383 
<a name="l00384"></a>00384   <span class="keywordtype">long</span> rows = std::count ( acceptArray.begin(), acceptArray.end(), true );
<a name="l00385"></a>00385   <span class="keywordtype">int</span> columns = <span class="keyword">static_cast&lt;</span><span class="keywordtype">int</span><span class="keyword">&gt;</span> (columnNumber);
<a name="l00386"></a>00386 
<a name="l00387"></a>00387   <span class="comment">// Following collected to create FITS table before writing.</span>
<a name="l00388"></a>00388 
<a name="l00389"></a>00389   vector &lt; int &gt; col_indices ( columnNumber );
<a name="l00390"></a>00390   
<a name="l00391"></a>00391   <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i &lt; columnNumber; i++ ) {
<a name="l00392"></a>00392     <span class="keyword">const</span> <span class="keywordtype">string</span> &amp; label = column_list [ i ];
<a name="l00393"></a>00393     <span class="keywordtype">int</span> index = ds -&gt; indexOf ( label );
<a name="l00394"></a>00394     <span class="keywordflow">if</span> ( index &lt; 0 ) { 
<a name="l00395"></a>00395      ds -&gt; throwIfInvalidLabel ( label );
<a name="l00396"></a>00396     }
<a name="l00397"></a>00397     col_indices [i] = index;
<a name="l00398"></a>00398   }
<a name="l00399"></a>00399 
<a name="l00400"></a>00400   vector &lt; size_t &gt; sizes;
<a name="l00401"></a>00401   vector &lt; vector &lt; int &gt; &gt; shapes;
<a name="l00402"></a>00402   <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i &lt; columns; i++ ) {
<a name="l00403"></a>00403     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> size = <a class="code" href="classhippodraw_1_1FitsController.html#a92ffc044118bb6a430998e2d19e40439" title="Returns the number of elements in a column.">calcColumnWidth</a> ( ds, col_indices[i] );
<a name="l00404"></a>00404     sizes.push_back ( size );
<a name="l00405"></a>00405     vector &lt; int &gt; <a class="code" href="namespacenum__util.html#a8570d9b34e8e9d714823c1b1986764f7">shape</a>;
<a name="l00406"></a>00406     ds -&gt; fillShape ( shape, col_indices[i] );
<a name="l00407"></a>00407     shapes.push_back ( shape );
<a name="l00408"></a>00408   }
<a name="l00409"></a>00409 
<a name="l00410"></a>00410   file -&gt; writeHDU ( rows, columns, column_list,
<a name="l00411"></a>00411                      shapes, dsname );
<a name="l00412"></a>00412 
<a name="l00413"></a>00413 
<a name="l00414"></a>00414   <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> k = 0; k &lt; columnNumber; k++ ) {
<a name="l00415"></a>00415     std::vector &lt; double &gt; tempColumn;
<a name="l00416"></a>00416     <span class="keywordflow">if</span> ( sizes [ k ] == 1 ) {
<a name="l00417"></a>00417       tempColumn.reserve (size );
<a name="l00418"></a>00418     }
<a name="l00419"></a>00419     <span class="keywordflow">else</span> {
<a name="l00420"></a>00420       tempColumn.reserve ( size * sizes[k] );
<a name="l00421"></a>00421     }
<a name="l00422"></a>00422     <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i&lt;size; i++ ) {
<a name="l00423"></a>00423       <span class="keywordflow">if</span> ( acceptArray[i]==<span class="keyword">true</span> ) {
<a name="l00424"></a>00424         <span class="keywordtype">int</span> index = col_indices[k];
<a name="l00425"></a>00425         <span class="keywordflow">if</span> ( sizes [ k ] == 1 ) {
<a name="l00426"></a>00426           tempColumn.push_back ( ds -&gt; valueAtNoCache (i, index) );
<a name="l00427"></a>00427         }
<a name="l00428"></a>00428         <span class="keywordflow">else</span> { <span class="comment">// array variable</span>
<a name="l00429"></a>00429           <span class="keywordtype">double</span> * array = ds -&gt; doubleArrayAt ( i, index );
<a name="l00430"></a>00430           <span class="keywordflow">for</span> ( std::size_t l = 0; l &lt; sizes [ k ]; l++ ) {
<a name="l00431"></a>00431             tempColumn.push_back ( array[l] );
<a name="l00432"></a>00432           }
<a name="l00433"></a>00433         }
<a name="l00434"></a>00434       }
<a name="l00435"></a>00435     }
<a name="l00436"></a>00436     file -&gt; writeColumn ( k, tempColumn );
<a name="l00437"></a>00437       
<a name="l00438"></a>00438     tempColumn.clear();
<a name="l00439"></a>00439   }
<a name="l00440"></a>00440  
<a name="l00441"></a>00441   file -&gt; writeCloseFile ();
<a name="l00442"></a>00442   
<a name="l00443"></a>00443   <span class="keyword">delete</span> file;
<a name="l00444"></a>00444   
<a name="l00445"></a>00445   <span class="keywordflow">return</span> 0;
<a name="l00446"></a>00446 }
</pre></div></div>
<hr size="1"><address style="align: right;"><small>
Generated for HippoDraw Class Library by <a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0>
</a> </small></address>
</body>
</html>