summaryrefslogtreecommitdiffstats
path: root/applications/rview/rviewPrefs.hh
blob: 55acce02c278db0afa5c5153ab87433d15d800c2 (plain)
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
278
279
/*
* This file is part of rasdaman community.
*
* Rasdaman community 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 3 of the License, or
* (at your option) any later version.
*
* Rasdaman community 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 rasdaman community.  If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
rasdaman GmbH.
*
* For more information please see <http://www.rasdaman.org>
* or contact Peter Baumann via <baumann@rasdaman.com>.
/

/**
 *  PURPOSE:
 *
 *  Management of rView's preferences. This includes an object encapsulating
 *  the preferences and providing IO of these preferences (rviewPrefs) and a
 *  frame class that allows displaying / editing the current preferences
 *  (rviewPrefsWindow).
 *
 * COMMENTS:
 * 		none
 */

/**
*	@file rviewPrefs.hh
*
*	@ingroup Applications
*/

#ifndef _RVIEW_PREFS_H_
#define _RVIEW_PREFS_H_

// #include "wx_scrol.h"
#include "wx/xrc/xh_scrol.h"

#include "raslib/mddtypes.hh"

#include "rviewUtils.hh"
#include "rviewDModes.hh"



// Needed by rviewPrefsWindow. Full definition below.
class rviewPrefs;




/*
 *  The window for editing the preferences
 */
class rviewPrefsWindow: public rviewFrame
{
  public:

  rviewPrefsWindow(void);
  rviewPrefsWindow(rviewPrefs *Prefs);
  ~rviewPrefsWindow(void);

  void setPrefs(rviewPrefs *Prefs);

  void unlinkParent(void);

  void OnSize(int w, int h);

  void label(void);
  int process(wxObject &obj, wxEvent &evt);
  int userEvent(const user_event &ue);

  virtual const char *getFrameName(void) const;
  virtual rviewFrameType getFrameType(void) const;


  protected:

  void setupVariables(void);
  void updatePrefs(void);
  void updateAndDie(void);
  int  findInChoices(int value, const char **choices, int number);

  static rviewChoice *buildFormatMenu(wxPanel *parent, int fmtNum, const char *label);
  static void textWindowToString(DynamicString &str, wxTextWindow *twin);

  rviewPrefs *editPrefs;
  rviewPrefs *myParent;

  wxPanel *panel, *butPanel;
  rviewButton *butOK, *butCancel, *butApply;
  // wxGroupBox *miscGroup, *imgGroup, *renderGroup, *thumbGroup, *heightGroup;
  // wxGroupBox *chartGroup, *tableGroup, *soundGroup, *commGroup, *orthoGroup;
  wxWindowBase *miscGroup, *imgGroup, *renderGroup, *thumbGroup, *heightGroup;
  wxWindowBase *chartGroup, *tableGroup, *soundGroup, *commGroup, *orthoGroup;
  rviewText *filePath, *queryPath, *queryFont;
  rviewText *vffParams;
  rviewText *maxDWidth, *maxDHeight;
  rviewCheckBox *imgDither, *ditherBest;
  rviewChoice *imgMode, *chartMode, *tableMode, *rgbSpace, *movieMode;
  rviewCheckBox *imgBBox;
  rviewText *imgZpro, *imgClipz, *imgPixThreshLow, *imgPixThreshHigh, *imgWgtThresh, *imgWgtQuant;
  rviewText *imgScale;
  rviewCheckBox *imgRgbBrightness, *imgVoxForType;
  rviewCheckBox *imgLight;
  rviewText *imgLightAmbient, *imgLightGain, *imgLightAngle, *imgLightScintAngle;
  rviewChoice *imgKernSize, *imgKernType;
  rviewCheckBox *imgUseVCol;
  rviewText *imgVoxColour;
  rviewText *imgLightDir, *imgLightDist;
  rviewCheckBox *imgOrthoBBox, *imgOrthoDragRel;
  rviewText *imgOrthoThick;
  rviewCheckBox *chartCosys;
  rviewText *chartStep, *chartMarkx, *chartMarky;
  rviewCheckBox *tableCosys;
  rviewText *tableStepx, *tableStepy;
  rviewText *thumbProjdim, *thumbProjstep, *thumbWidth, *thumbCols;
  rviewChoice *soundFreq, *soundLatency;
  rviewCheckBox *soundLoop;
  rviewText *imgHeightGrid, *imgHeightScale;
  rviewChoice *transferFmt, *storageFmt;
  wxTextWindow *transferParm, *storageParm;
  wxMessage *transferMsg, *storageMsg;
  wxScrollBar *scroll;
  rviewButton *cstrap;
  colourspaceMapper *csmap;

  // constants
  static const char *soundLatencyChoices[];
  static const char *soundFrequencyChoices[];

  // Width and height of preferences window
  static const int prefs_width;
  static const int prefs_height;
  // Borders used in prefs window
  static const int prefs_border;
  // Space at the bottom for button bar
  static const int prefs_bottom;
  // Button dimensions
  static const int prefs_bwidth;
  static const int prefs_bheight;
  // Height of a text widget
  static const int prefs_theight;
  // Height of a checkbox
  static const int prefs_chkheight;
  // Height of a text widget's writable field
  static const int prefs_eheight;
  // ScrollBar width
  static const int prefs_scrwidth;
  // TextWindow height
  static const int prefs_twheight;
  // Message height
  static const int prefs_mheight;
  // Group boxes
  static const int prefs_grpmsc_height;
  static const int prefs_grpimg_height;
  static const int prefs_grpren_height;
  static const int prefs_grphgt_height;
  static const int prefs_grport_height;
  static const int prefs_grpthb_height;
  static const int prefs_grpcht_height;
  static const int prefs_grptab_height;
  static const int prefs_grpsnd_height;
  static const int prefs_grpcom_height;
  // Height of panel
  static const int prefs_pheight;
};


/*
 *  Object holding the preferences and the current setup.
 */
class rviewPrefs
{
  public:

  rviewPrefs(void);
  rviewPrefs(const char *file);
  rviewPrefs(const rviewPrefs &srcPrefs);
  ~rviewPrefs(void);

  int load(const char *file);
  int save(const char *file);
  int edit(void);
  void editorClosed(void);
  void closeEditor(rviewPrefs *newPrefs);
  void updatePrefs(rviewPrefs *newPrefs);
  void markModified(void);

  static void copyPrefs(const rviewPrefs &src, rviewPrefs &dest);

  r_Data_Format getTransferFormat( void ) const;
  r_Data_Format getStorageFormat( void ) const;

  DynamicString serverName;
  int serverPort;
  DynamicString databaseName;
  DynamicString userName;
  DynamicString lastColl;
  DynamicString lastScColl;
  DynamicString lastOrthoColl;
  DynamicString filePath;
  DynamicString queryPath;
  DynamicString queryFont;
  DynamicString vffParams;
  int  lastDisplay;
  int maxDWidth, maxDHeight;
  bool imgDither, ditherBest;
  rviewImageMode imgMode;
  rviewChartMode chartMode;
  int movieMode, rgbSpace;
  int tableMode;
  bool imgBBox;
  unsigned long imgZpro, imgClipz, imgWgtQuant;
  double imgPixThreshLow, imgPixThreshHigh, imgWgtThresh;
  double imgScale;
  bool imgRgbBrightness, imgVoxForType;
  bool imgLight;
  double imgLightAmbient, imgLightGain, imgLightAngle, imgLightScintAngle;
  int imgKernSize, imgKernType;
  bool imgUseVCol;
  double imgVoxColour;
  DynamicString imgLightDir;
  int imgLightDist;
  int imgHeightGrid;
  double imgHeightScale;
  bool imgOrthoBBox, imgOrthoDragRel;
  int imgOrthoThick;
  bool chartCosys;
  int chartStep, chartMarkx;
  double chartMarky;
  bool tableCosys;
  int tableStepx, tableStepy;
  int thumbProjdim, thumbProjstep, thumbWidth, thumbCols;
  int soundFreq, soundLatency, soundLoop;
  int transferFmt, storageFmt;
  DynamicString transferParm, storageParm;
  colourspace_params csp;


  protected:

  void setupVariables(void);
  // used for getting the value of an argument when reading the prefs file.
  char *getValue(char *b);
  // convert long strings (including newlines) from/to external representation
  static char *toExternal(const DynamicString &str);
  static void fromExternal(const char *ext, DynamicString &str);
  // read a line into the internal buffer; return a pointer to the start if successful
  char *readLine(FILE *fp);
  
  rviewPrefsWindow *pwin;
  bool prefsModified;

  char *inbuff;
  unsigned long buffSize;

  static const unsigned long buffExtendGranularity;
  static const keyword_to_ident_c prefsVarDesc[];
};



/*
 *  Global variables
 */

extern rviewPrefs *prefs;

#endif