File: thconfig.h

package info (click to toggle)
therion 5.3.16-10
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 19,400 kB
  • ctags: 16,579
  • sloc: ansic: 126,508; cpp: 100,089; tcl: 25,682; perl: 2,002; makefile: 1,114; asm: 219; python: 121; sh: 4
file content (277 lines) | stat: -rw-r--r-- 5,376 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
/**
 * @file thconfig.h
 * Configuration module.
 */
  
/* Copyright (C) 2000 Stacho Mudrak
 * 
 * $Date: $
 * $RCSfile: $
 * $Revision: $
 *
 * -------------------------------------------------------------------- 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * --------------------------------------------------------------------
 */
 
#ifndef thconfig_h
#define thconfig_h

#include <list>

#include "thbuffer.h"
#include "thmbuffer.h"
#include "thinput.h"
#include "thexporter.h"
#include "thselector.h"
#include "thobjectsrc.h"

/**
 * What to do with configuration file?
 */

typedef enum {THCFG_GENERATE,  ///< Generate config file.
  THCFG_UPDATE,  ///< Update config file.
  THCFG_READ  ///< Read only config file.
  } thcfg_fstate;


struct thconfig_src {
  const char * fname;
  long startln, endln;
  thconfig_src() : fname(""), startln(-1), endln(-1) {}
};


typedef std::list<thconfig_src> thconfig_src_list;



/**
 * Configuration class.
 *
 * Provides functions for therion configuration.
 */

class thconfig {

  public:

  thbuffer fname,  ///< Configuration file name.
    search_path,  ///< Lib files search path.
    init_path,  ///< Initialization path.
    install_path,  ///< Installation path.
    bf1,  ///< TMP buffer.
    bf2;  ///< TMP buffer.
  thmbuffer strmbuff,  ///< String storage buffer.
    src_fnames,  ///< Source file name.
    cfg_dblines,  ///< Lines with database commands.
    mbf1;  ///< TMP buffer.
  bool skip_comments,  ///< Skip comments when writing config file.
    generate_xthcfg,  ///< Generate xtherion log file.
    install_tcltk, ///< Whether tcltk is installed with therion.
    install_tex, ///< Whether TeX is installed with therion.
    install_im, ///< Whether ImageMagick is installed with therion.
    auto_join;  ///< Whether scraps in one file should be automatically joined
  thcfg_fstate fstate;  ///< What to do with cfg file.
  thinput cfg_file;  ///< Configuration file input.
  int cfg_fenc;  ///< Configuration file encoding.

  int outcs;  ///< Output coordinate system.
  int lang; ///< Output language.
  int sketch_warp;  ///< Sketch warping method.
  thobjectsrc outcs_def;  ///< Where output coordinate system is defined.
  double outcs_sumx, outcs_sumy, outcs_sumz, outcs_sumn;
  
  thconfig_src_list src;

  double tmp3dSMP, tmp3dWALLSMP, tmp3dMAXDIMD;
  int sketch_colors;

  class thdatabase * dbptr;  ///< Associated db.
  thexporter exporter;  ///< Data exporter.
  thselector selector;  ///< Database selector.

  /**
   * Standard constructor.
   */
  
  thconfig();
  
  
  /**
   * Standard destructor.
   */
   
  ~thconfig();
  
  
  /**
   * Set config file name.
   */
 
  void set_file_name(char * fn);
  
  
  /**
   * Retrieve config file name.
   */
   
  char * get_file_name();
  
  
  /**
   * Set input file name.
   */
  
  void append_source(char * fname, long startln = -1, long endln = -1);
  
  
  /**
   * Retrieve input file name.
   */
   
  thconfig_src_list * get_sources();
  
  
  /**
   * Set/get skip comments state.
   */
   
  void set_comments_skip(bool state);
  
  void comments_skip_on();
  
  void comments_skip_off();
  
  bool get_comments_skip();


  /**
   * Set/get config file state.
   */
   
  void set_file_state(thcfg_fstate fs);
  
  thcfg_fstate get_file_state();


  /**
   * Set/get search path.
   */
   
  void set_search_path(char * pth);
  
  char * get_search_path();
  
  char * get_initialization_path();
  
  /**
   * Load input from configuration file.
   */
   
  void load();
  
  
  /**
   * Load database command.
   */
  
  void load_dbcommand(thmbuffer * valmb);
  
  /**
   * Save input into configuration file.
   */
   
  void save();

  /**
   * Write configuration to xth file.
   */
   
  void xth_save();
  
  
  /**
   * Return string storage buffer.
   */
   
  thmbuffer * get_str_buff() {return &(this->strmbuff);}
  
  
  /**
   * Assign db.
   */
   
  void assign_db(class thdatabase * dp);
  
  
  /**
   * Return assigned db.
   */
   
  class thdatabase * get_db() {return this->dbptr;}
  
  
  /**
   * Select objects in database.
   */
   
  void select_data();
  
  
  /**
   * Export data from database.
   */
   
  void export_data();
  
  
  /**
   * Return input ptr.
   */
   
  thinput * get_cfg_file() {return &(this->cfg_file);}
  

  /**
   * Return output coordinate system meridian convergence.
   */
  
  double get_outcs_convergence();

  double get_cs_convergence(int cs);

  bool get_outcs_center(double & x, double & y, double & z);

  bool get_outcs_mag_decl(double year, double & decl);

  void log_outcs(double decsyear, double deceyear);

  int get_lang();

};


/**
 * Configuration module.
 */
 
extern thconfig thcfg;


#endif