Minsky
CSVDialog.h
Go to the documentation of this file.
1 /*
2  @copyright Steve Keen 2018
3  @author Russell Standish
4  This file is part of Minsky.
5 
6  Minsky is free software: you can redistribute it and/or modify it
7  under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Minsky is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with Minsky. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
24 #ifndef CSVDIALOG_H
25 #define CSVDIALOG_H
26 #include "CSVParser.h"
27 #include "renderNativeWindow.h"
28 #include <cairoSurfaceImage.h>
29 
30 #include <vector>
31 #include <string>
32 
33 namespace minsky
34 {
36  {
37  std::vector<std::string> initialLines;
38  double rowHeight=0;
39  double m_tableWidth;
41  bool redraw(int, int, int width, int height) override;
42 
43  public:
44  static const unsigned numInitialLines=100;
45  double xoffs=80;
46  double colWidth=50;
47  bool flashNameRow=false;
50  std::string url;
52  double tableWidth() const {return m_tableWidth;}
53 
57  void loadFile();
59  void guessSpecAndLoadFile();
61  void loadFileFromName(const std::string& fname);
62  void reportFromFile(const std::string& input, const std::string& output) const;
63  void requestRedraw() {if (surface.get()) surface->requestRedraw();}
65  std::size_t columnOver(double x) const;
67  std::size_t rowOver(double y) const;
68  std::vector<std::vector<std::string> > parseLines(size_t maxColumn=std::numeric_limits<size_t>::max());
70  void populateHeaders();
72  void populateHeader(size_t col);
74  void classifyColumns();
78  std::vector<size_t> correctedUniqueValues();
79  };
80 
81  bool isNumerical(const std::string& s);
82 }
83 
84 #include "CSVDialog.cd"
85 #include "CSVDialog.xcd"
86 #endif
Definition: input.py:1
std::vector< std::vector< std::string > > parseLines(size_t maxColumn=std::numeric_limits< size_t >::max())
Definition: CSVDialog.cc:300
std::size_t rowOver(double y) const
return row mouse is over
Definition: CSVDialog.cc:295
void classifyColumns()
try to classify axis,data,ignore columns based on read in data
Definition: CSVDialog.cc:344
std::vector< size_t > correctedUniqueValues()
unique values in each column, ignoring initial header lines could slightly underestimate the value...
Definition: CSVDialog.cc:385
void loadFile()
loads an initial sequence of lines from url. If fname contains "://", is is treated as a URL...
Definition: CSVDialog.cc:97
void populateHeaders()
populate all column names from the headers row
Definition: CSVDialog.cc:327
double tableWidth() const
width of table (in pixels)
Definition: CSVDialog.h:52
void reportFromFile(const std::string &input, const std::string &output) const
Definition: CSVDialog.cc:50
double rowHeight
Definition: CSVDialog.h:38
void guessSpecAndLoadFile()
guess the spec, then load an initial sequence of like loadFile()
Definition: CSVDialog.cc:102
void populateHeader(size_t col)
populate the name of column col with the data from the header row
Definition: CSVDialog.cc:335
bool isNumerical(const std::string &s)
Definition: CSVParser.cc:338
std::string url
filename, or web url
Definition: CSVDialog.h:50
Creation and access to the minskyTCL_obj object, which has code to record whenever Minsky&#39;s state cha...
Definition: constMap.h:22
DataSpec spec
Definition: CSVDialog.h:48
void loadFileFromName(const std::string &fname)
common implementation of loading the initial sequence of lines
Definition: CSVDialog.cc:111
std::size_t columnOver(double x) const
return column mouse is over
Definition: CSVDialog.cc:290
CLASSDESC_ACCESS(DataSpec)
bool redraw(int, int, int width, int height) override
Definition: CSVDialog.cc:168
double m_tableWidth
Definition: CSVDialog.h:39
std::vector< std::string > initialLines
initial lines of file
Definition: CSVDialog.h:37
static const unsigned numInitialLines
Definition: CSVDialog.h:44
void requestRedraw()
Definition: CSVDialog.h:63