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-2001 Kevin Rosenberg
12 ** $Id: plotfile.h,v 1.9 2001/03/10 23:14:15 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"
47 // Plotfile structure:
48 // 1. Lines that begin with # are comments
49 // 2. ASCII file format
50 // 3. Header lines begin with <tags> and end with </tags>
52 // <plotfile ncolumns nrecords> (signifies beginning of plotfile)
53 // <description> (beginning of description lines)
54 // <ezset> (signifies beginning of ezset commands)
55 // <columns> Beginning of data columns
56 // 5. Data is ASCII file format, one record per line
57 // Number of columns is variable and is set by ncolumns header
64 std::string m_strFilename;
65 std::string m_strDate;
66 std::vector<std::string> m_vecStrDescriptions;
67 std::vector<std::string> m_vecStrEzsetCommands;
68 std::vector<double> m_vecCurves;
73 bool headerRead (std::iostream& os);
74 bool headerWrite (std::iostream& os);
75 bool columnsRead (std::iostream& os);
76 bool columnsWrite (std::iostream& os);
80 PlotFile (const PlotFile& rhs); // copy constructor
81 PlotFile& operator= (const PlotFile&); // assignment operator
84 PlotFile (int iNColumns, int iNRecords);
88 void setCurveSize (int iNCurves, int iNRecords, bool bScatterPlot = false);
90 void addDescription (const char* const pszDesc)
91 { m_vecStrDescriptions.push_back (pszDesc); }
93 void addEzsetCommand (const char* const pszCmd)
94 { m_vecStrEzsetCommands.push_back (pszCmd); }
96 bool addColumn (int iCol, const double* const pdColumn);
98 bool addColumn (int iCol, const float* const pdColumn);
100 void getColumn (int iCol, double *pdColumnData) const;
102 const std::string& getDate () const
103 { return m_strDate; }
105 int getNumColumns () const
106 { return m_iNumColumns; }
108 int getNumRecords () const
109 { return m_iNumRecords; }
111 bool getIsScatterPlot() const
112 { return m_bScatterPlot; }
114 bool getMinMax (int startingCol, double& min, double& max) const;
116 bool statistics (int startingCol, double& min, double& max, double& mean, double& mode, double& median, double &stddev) const;
118 unsigned int getNumDescriptions (void) const
119 { return m_vecStrDescriptions.size(); }
121 const std::string& getDescription (int iDescIndex) const
122 { return m_vecStrDescriptions[iDescIndex]; }
124 unsigned int getNumEzsetCommands (void) const
125 { return m_vecStrEzsetCommands.size(); }
127 const std::string& getEzsetCommand (int iIndex) const
128 { return m_vecStrEzsetCommands[iIndex]; }
130 bool fileRead (const char* const filename);
132 bool fileWrite (const char* const filename);
134 const std::string& getFilename (void) const
135 { return m_strFilename; }
137 void printHeaders (std::ostream& os) const;
138 void printHeaders (std::ostringstream& os) const;
139 void printHeadersBrief (std::ostream& os) const;
140 void printHeadersBrief (std::ostringstream& os) const;