~ubuntu-branches/ubuntu/trusty/3depict/trusty

« back to all changes in this revision

Viewing changes to src/configFile.h

  • Committer: Package Import Robot
  • Author(s): D Haley
  • Date: 2013-05-17 00:52:39 UTC
  • mfrom: (3.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20130517005239-7bl4mnhkvrhc2ba6
Tags: 0.0.13-1
Upload to unstable 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * configFile.h - Configuration file management header 
3
 
 * Copyright (C) 2011  D Haley
4
 
 * 
5
 
 * This program is free software: you can redistribute it and/or modify
6
 
 * it under the terms of the GNU General Public License as published by
7
 
 * the Free Software Foundation, either version 3 of the License, or
8
 
 * (at your option) any later version.
9
 
 * 
10
 
 * This program is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 * GNU General Public License for more details.
14
 
 * 
15
 
 * You should have received a copy of the GNU General Public License
16
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 
 */
18
 
 
19
 
#ifndef CONFIGFILE_H
20
 
#define CONFIGFILE_H
21
 
 
22
 
 
23
 
#include "filter.h"
24
 
 
25
 
#include <string>
26
 
#include <vector>
27
 
#include <deque>
28
 
 
29
 
//!Startup panel identifiers. 
30
 
enum {
31
 
        CONFIG_STARTUPPANEL_RAWDATA,
32
 
        CONFIG_STARTUPPANEL_CONTROL,
33
 
        CONFIG_STARTUPPANEL_PLOTLIST,
34
 
        CONFIG_STARTUPPANEL_END_ENUM
35
 
};
36
 
 
37
 
enum
38
 
{
39
 
        CONFIG_PANELMODE_NONE,
40
 
        CONFIG_PANELMODE_REMEMBER,
41
 
        CONFIG_PANELMODE_SPECIFY,
42
 
        CONFIG_PANELMODE_END_ENUM
43
 
};
44
 
 
45
 
enum
46
 
{
47
 
        CONFIG_ERR_NOFILE=1,
48
 
        CONFIG_ERR_BADFILE,
49
 
        CONFIG_ERR_NOPARSER
50
 
};
51
 
 
52
 
 
53
 
class ConfigFile 
54
 
{
55
 
        private:
56
 
                std::deque<std::string> recentFiles;
57
 
                vector<Filter *> filterDefaults;
58
 
                
59
 
                //!Did the configuration load from file OK?
60
 
                bool configLoadOK;
61
 
                
62
 
                //!Panel 
63
 
                vector<bool> startupPanelView;
64
 
 
65
 
                //!Any errors that occur during file IO. Set by class members during read()/write()
66
 
                std::string errMessage;
67
 
 
68
 
                //!Method for showing/hiding panel at startup
69
 
                unsigned int panelMode;
70
 
 
71
 
                //!Initial application window size in pixels
72
 
                unsigned int initialSizeX,initialSizeY;
73
 
                //!Do we have a valid initial app size?
74
 
                bool haveIntialAppSize;
75
 
 
76
 
                //!Percentile speeds for mouse zoom and move 
77
 
                unsigned int mouseZoomRatePercent,mouseMoveRatePercent;
78
 
 
79
 
                //!Master allow the program to do stuff online check. This is AND-ed, so cannot override disabled items
80
 
                bool allowOnline;
81
 
 
82
 
                //!Should the program perform online version number checking?
83
 
                bool allowOnlineVerCheck;       
84
 
 
85
 
                //!fractional initial positions of sashes in main UI
86
 
                float leftRightSashPos,topBottomSashPos,
87
 
                                filterSashPos,plotListSashPos;
88
 
                                        
89
 
                                        
90
 
        public:
91
 
                ConfigFile(); 
92
 
                ~ConfigFile(); 
93
 
                void addRecentFile(const std::string &str);
94
 
                void getRecentFiles(std::vector<std::string> &filenames) const; 
95
 
                void removeRecentFile(const std::string &str);
96
 
                
97
 
                unsigned int read();
98
 
                bool write();
99
 
                
100
 
                bool configLoadedOK() const { return configLoadOK;}
101
 
                        
102
 
                //Create the configuration folder, if needed.
103
 
                bool createConfigDir() const;
104
 
                //Get the configartion dir path
105
 
                std::string getConfigDir() const;
106
 
                
107
 
                std::string getErrMessage() const { return errMessage;};
108
 
 
109
 
                unsigned int getMaxHistory() const;
110
 
 
111
 
                //Get a vector of the default filter pointers
112
 
                void getFilterDefaults(vector<Filter* > &defs);
113
 
                //Set the default filter pointers (note this will take ownership of the poitner)
114
 
                void setFilterDefaults(const vector<Filter* > &defs);
115
 
 
116
 
                //Get a clone of the default filter for a given type,
117
 
                //even if it is not in the array (use hardcoded)
118
 
                Filter *getDefaultFilter(unsigned int type) const;
119
 
 
120
 
                //!Return startup status of UI panels
121
 
                bool getPanelEnabled(unsigned int panelID) const;
122
 
                
123
 
                //!Return startup status of UI panels
124
 
                void setPanelEnabled(unsigned int panelID,bool enabled, bool permanent=false);
125
 
 
126
 
                //!Get the mouse movement rate (for all but zoom)
127
 
                unsigned int getMouseMoveRate() const { return mouseMoveRatePercent; }
128
 
                //!Get the mouse movement rate for zoom
129
 
                unsigned int getMouseZoomRate() const { return mouseZoomRatePercent; }
130
 
 
131
 
                //Set the mouse zoom rate(percent)
132
 
                void setMouseZoomRate(unsigned int rate) { mouseZoomRatePercent=rate;};
133
 
                //Set the mouse move rate (percent)
134
 
                void setMouseMoveRate(unsigned int rate) { mouseMoveRatePercent=rate;};
135
 
 
136
 
                //!Return the current panelmode
137
 
                unsigned int getStartupPanelMode() const;
138
 
                //!Set the mode to use for recalling the startup panel layout
139
 
                void setStartupPanelMode(unsigned int panelM);
140
 
 
141
 
                //!Returns true if we have a suggested initial window size; with x & y being the suggestion
142
 
                bool getInitialAppSize(unsigned int &x, unsigned int &y) const;
143
 
                //!Set the inital window suggested size
144
 
                void setInitialAppSize(unsigned int x, unsigned int y);
145
 
 
146
 
                bool getAllowOnlineVersionCheck() const;
147
 
 
148
 
                //!Set if the program is allowed to access network resources
149
 
                void setAllowOnline(bool v);
150
 
                //!Set if the program is allowed to phone home to get latest version #s
151
 
                void setAllowOnlineVersionCheck(bool v);
152
 
 
153
 
                //!Set the position for the main window left/right sash 
154
 
                void setLeftRightSashPos(float fraction);
155
 
                //!Set the position for the top/bottom sash
156
 
                void setTopBottomSashPos(float fraction);
157
 
                //!Set the position for the filter property/tree sash
158
 
                void setFilterSashPos(float fraction);
159
 
                //!Set the position for the plot list panel
160
 
                void setPlotListSashPos(float fraction);
161
 
 
162
 
                //!Set the position for the main window left/right sash 
163
 
                float getLeftRightSashPos() const { return leftRightSashPos;};
164
 
                //!Set the position for the top/bottom sash
165
 
                float getTopBottomSashPos() const{ return topBottomSashPos;}
166
 
                //!Set the position for the filter property/tree sash
167
 
                float getFilterSashPos() const { return filterSashPos;};
168
 
                //!Set the position for the plot list panel
169
 
                float getPlotListSashPos()const { return plotListSashPos;};
170
 
 
171
 
 
172
 
};
173
 
 
174
 
#endif