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-2009 Kevin Rosenberg
12 ** This program is free software; you can redistribute it and/or modify
13 ** it under the terms of the GNU General Public License (version 2) as
14 ** published by the Free Software Foundation.
16 ** This program is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ** GNU General Public License for more details.
21 ** You should have received a copy of the GNU General Public License
22 ** along with this program; if not, write to the Free Software
23 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 ******************************************************************************/
33 #include <sys/types.h>
41 #include "ctsupport.h"
45 // Plotfile structure:
46 // 1. Lines that begin with # are comments
47 // 2. ASCII file format
48 // 3. Header lines begin with <tags> and end with </tags>
50 // <plotfile ncolumns nrecords> (signifies beginning of plotfile)
51 // <description> (beginning of description lines)
52 // <ezset> (signifies beginning of ezset commands)
53 // <columns> Beginning of data columns
54 // 5. Data is ASCII file format, one record per line
55 // Number of columns is variable and is set by ncolumns header
62 std::string m_strFilename;
63 std::string m_strDate;
64 std::vector<std::string> m_vecStrDescriptions;
65 std::vector<std::string> m_vecStrEzsetCommands;
66 std::vector<double> m_vecCurves;
71 bool headerRead (std::iostream& os);
72 bool headerWrite (std::iostream& os);
73 bool columnsRead (std::iostream& os);
74 bool columnsWrite (std::iostream& os);
78 PlotFile (const PlotFile& rhs); // copy constructor
79 PlotFile& operator= (const PlotFile&); // assignment operator
82 PlotFile (int iNColumns, int iNRecords);
86 void setCurveSize (int iNCurves, int iNRecords, bool bScatterPlot = false);
88 void addDescription (const char* const pszDesc)
89 { m_vecStrDescriptions.push_back (pszDesc); }
91 void addEzsetCommand (const char* const pszCmd)
92 { m_vecStrEzsetCommands.push_back (pszCmd); }
94 bool addColumn (int iCol, const double* const pdColumn);
95 bool addColumn (int iCol, const float* const pdColumn);
96 void getColumn (int iCol, double *pdColumnData) const;
98 const std::string& getDate () const
101 int getNumColumns () const
102 { return m_iNumColumns; }
104 int getNumRecords () const
105 { return m_iNumRecords; }
107 bool getIsScatterPlot() const
108 { return m_bScatterPlot; }
110 bool getMinMax (int startingCol, double& min, double& max) const;
112 bool statistics (int startingCol, double& min, double& max, double& mean, double& mode, double& median, double &stddev) const;
114 unsigned int getNumDescriptions (void) const
115 { return m_vecStrDescriptions.size(); }
117 const std::string& getDescription (int iDescIndex) const
118 { return m_vecStrDescriptions[iDescIndex]; }
120 unsigned int getNumEzsetCommands (void) const
121 { return m_vecStrEzsetCommands.size(); }
123 const std::string& getEzsetCommand (int iIndex) const
124 { return m_vecStrEzsetCommands[iIndex]; }
126 bool fileRead (const char* const filename);
128 bool fileWrite (const char* const filename);
130 const std::string& getFilename (void) const
131 { return m_strFilename; }
133 void printHeaders (std::ostream& os) const;
134 void printHeaders (std::ostringstream& os) const;
135 void printHeadersBrief (std::ostream& os) const;
136 void printHeadersBrief (std::ostringstream& os) const;