1 /*****************************************************************************
5 ** Purpose: PlotFile class header
6 ** Programmer: Kevin Rosenberg
7 ** Date Started: Dec 2000
9 ** This is part of the CTSim program
10 ** Copyright (C) 1983-2000 Kevin Rosenberg
12 ** $Id: plotfile.h,v 1.2 2000/12/20 14:39:09 kevin Exp $
14 ** This program is free software; you can redistribute it and/or modify
15 ** it under the terms of the GNU General Public License (version 2) as
16 ** published by the Free Software Foundation.
18 ** This program is distributed in the hope that it will be useful,
19 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ** GNU General Public License for more details.
23 ** You should have received a copy of the GNU General Public License
24 ** along with this program; if not, write to the Free Software
25 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 ******************************************************************************/
35 #include <sys/types.h>
43 #include "ctsupport.h"
46 // Plotfile structure:
47 // 1. Lines that begin with # are comments
48 // 2. ASCII file format
49 // 3. Header lines begin with <tags> and end with </tags>
51 // <header> (signifies beginning of headers)
52 // <description> (multiple instances may be present)
57 // <filetype>plotfile</filetype> (required)
58 // <ncolumns> (required)
59 // <nrecords> (required)
60 // </header> (required, signifies end of headers)
61 // 5. Data is ASCII file format, one record per line
62 // Number of columns is variable and is set by ncolumns header
63 // 6. Data begins with <plotdata> and ends with </plotdata>
69 std::string m_strFilename;
70 std::string m_strTitle;
71 std::string m_strXLabel;
72 std::string m_strYLabel;
73 std::string m_strDate;
74 std::vector<std::string> m_vecStrDescriptions;
75 std::vector<double> m_vecCurves;
79 bool headerRead (std::iostream& os);
80 bool headerWrite (std::iostream& os);
81 bool columnsRead (std::iostream& os);
82 bool columnsWrite (std::iostream& os);
86 PlotFile (const PlotFile& rhs); // copy constructor
87 PlotFile& operator= (const PlotFile&); // assignment operator
90 PlotFile (int iNColumns, int iNRecords);
94 void setTitle (const std::string& title)
95 { m_strTitle = title; }
97 void setTitle (const char* const title)
\r
98 { m_strTitle = title; }
\r
100 void setXLabel (const std::string& label)
101 { m_strXLabel = label; }
103 void setXLabel (const char* const label)
\r
104 { m_strXLabel = label; }
\r
106 void setYLabel (const std::string& label)
107 { m_strYLabel = label; }
109 void setYLabel (const char* const label)
\r
110 { m_strYLabel = label; }
\r
112 void setCurveSize (int iNCurves, int iNRecords);
114 void addDescription (const char* const pszDesc)
115 { m_vecStrDescriptions.push_back (pszDesc); }
117 bool addColumn (int iCol, const double* const pdColumn);
119 bool addColumn (int iCol, const float* const pdColumn);
\r
121 void getColumn (int iCol, double *pdColumnData) const;
\r
123 const std::string& getTitle () const
124 { return m_strTitle; }
126 const std::string& getXLabel () const
127 { return m_strXLabel; }
129 const std::string& getYLabel () const
130 { return m_strXLabel; }
132 const std::string& getDate () const
133 { return m_strDate; }
135 int getNumColumns () const
136 { return m_iNumColumns; }
138 int getNumRecords () const
139 { return m_iNumRecords; }
141 unsigned int getNumDescriptions (void) const
142 { return m_vecStrDescriptions.size(); }
144 const std::string& getDescription (int iDescIndex) const
145 { return m_vecStrDescriptions[iDescIndex]; }
147 bool fileRead (const char* const filename);
149 bool fileWrite (const char* const filename);
151 const std::string& getFilename (void) const
152 { return m_strFilename; }
154 void printHeaders (std::ostream& os) const;