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.1 2000/12/19 21:37:10 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 setXLabel (const std::string& label)
98 { m_strXLabel = label; }
100 void setYLabel (const std::string& label)
101 { m_strYLabel = label; }
103 void setCurveSize (int iNCurves, int iNRecords);
105 void addDescription (const char* const pszDesc)
106 { m_vecStrDescriptions.push_back (pszDesc); }
108 bool addColumn (int iCol, const double* const pdColumn);
110 bool addColumn (int iCol, const float* const pdColumn);
\r
112 const std::string& getTitle () const
113 { return m_strTitle; }
115 const std::string& getXLabel () const
116 { return m_strXLabel; }
118 const std::string& getYLabel () const
119 { return m_strXLabel; }
121 const std::string& getData () const
122 { return m_strDate; }
124 int getNumColumns () const
125 { return m_iNumColumns; }
127 int getNumRecords () const
128 { return m_iNumRecords; }
130 unsigned int getNumDescriptions (void) const
131 { return m_vecStrDescriptions.size(); }
133 const std::string& getDescription (int iDescIndex) const
134 { return m_vecStrDescriptions[iDescIndex]; }
136 bool fileRead (const char* const filename);
138 bool fileWrite (const char* const filename);
140 const std::string& getFilename (void) const
141 { return m_strFilename; }
143 void printHeaders (std::ostream& os) const;