rasdaman complete source
rviewPrefs.hh
Go to the documentation of this file.
1 /*
2 * This file is part of rasdaman community.
3 *
4 * Rasdaman community is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * Rasdaman community is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
18 rasdaman GmbH.
19 *
20 * For more information please see <http://www.rasdaman.org>
21 * or contact Peter Baumann via <baumann@rasdaman.com>.
22 /
23 
42 #ifndef _RVIEW_PREFS_H_
43 #define _RVIEW_PREFS_H_
44 
45 // #include "wx_scrol.h"
46 #include "wx/xrc/xh_scrol.h"
47 
48 #include "raslib/mddtypes.hh"
49 
50 #include "rviewUtils.hh"
51 #include "rviewDModes.hh"
52 
53 
54 
55 // Needed by rviewPrefsWindow. Full definition below.
56 class rviewPrefs;
57 
58 
59 
60 
61 /*
62  * The window for editing the preferences
63  */
64 class rviewPrefsWindow: public rviewFrame
65 {
66 public:
67 
68  rviewPrefsWindow(void);
69  rviewPrefsWindow(rviewPrefs *Prefs);
70  ~rviewPrefsWindow(void);
71 
72  void setPrefs(rviewPrefs *Prefs);
73 
74  void unlinkParent(void);
75 
76  void OnSize(int w, int h);
77 
78  void label(void);
79  int process(wxObject &obj, wxEvent &evt);
80  int userEvent(const user_event &ue);
81 
82  virtual const char *getFrameName(void) const;
83  virtual rviewFrameType getFrameType(void) const;
84 
85 
86 protected:
87 
88  void setupVariables(void);
89  void updatePrefs(void);
90  void updateAndDie(void);
91  int findInChoices(int value, const char **choices, int number);
92 
93  static rviewChoice *buildFormatMenu(wxPanel *parent, int fmtNum, const char *label);
94  static void textWindowToString(DynamicString &str, wxTextWindow *twin);
95 
96  rviewPrefs *editPrefs;
97  rviewPrefs *myParent;
98 
99  wxPanel *panel, *butPanel;
100  rviewButton *butOK, *butCancel, *butApply;
101  // wxGroupBox *miscGroup, *imgGroup, *renderGroup, *thumbGroup, *heightGroup;
102  // wxGroupBox *chartGroup, *tableGroup, *soundGroup, *commGroup, *orthoGroup;
103  wxWindowBase *miscGroup, *imgGroup, *renderGroup, *thumbGroup, *heightGroup;
104  wxWindowBase *chartGroup, *tableGroup, *soundGroup, *commGroup, *orthoGroup;
105  rviewText *filePath, *queryPath, *queryFont;
106  rviewText *vffParams;
107  rviewText *maxDWidth, *maxDHeight;
108  rviewCheckBox *imgDither, *ditherBest;
109  rviewChoice *imgMode, *chartMode, *tableMode, *rgbSpace, *movieMode;
110  rviewCheckBox *imgBBox;
111  rviewText *imgZpro, *imgClipz, *imgPixThreshLow, *imgPixThreshHigh, *imgWgtThresh, *imgWgtQuant;
112  rviewText *imgScale;
113  rviewCheckBox *imgRgbBrightness, *imgVoxForType;
114  rviewCheckBox *imgLight;
115  rviewText *imgLightAmbient, *imgLightGain, *imgLightAngle, *imgLightScintAngle;
116  rviewChoice *imgKernSize, *imgKernType;
117  rviewCheckBox *imgUseVCol;
118  rviewText *imgVoxColour;
119  rviewText *imgLightDir, *imgLightDist;
120  rviewCheckBox *imgOrthoBBox, *imgOrthoDragRel;
121  rviewText *imgOrthoThick;
122  rviewCheckBox *chartCosys;
123  rviewText *chartStep, *chartMarkx, *chartMarky;
124  rviewCheckBox *tableCosys;
125  rviewText *tableStepx, *tableStepy;
126  rviewText *thumbProjdim, *thumbProjstep, *thumbWidth, *thumbCols;
127  rviewChoice *soundFreq, *soundLatency;
128  rviewCheckBox *soundLoop;
129  rviewText *imgHeightGrid, *imgHeightScale;
130  rviewChoice *transferFmt, *storageFmt;
131  wxTextWindow *transferParm, *storageParm;
132  wxMessage *transferMsg, *storageMsg;
133  wxScrollBar *scroll;
134  rviewButton *cstrap;
135  colourspaceMapper *csmap;
136 
137  // constants
138  static const char *soundLatencyChoices[];
139  static const char *soundFrequencyChoices[];
140 
141  // Width and height of preferences window
142  static const int prefs_width;
143  static const int prefs_height;
144  // Borders used in prefs window
145  static const int prefs_border;
146  // Space at the bottom for button bar
147  static const int prefs_bottom;
148  // Button dimensions
149  static const int prefs_bwidth;
150  static const int prefs_bheight;
151  // Height of a text widget
152  static const int prefs_theight;
153  // Height of a checkbox
154  static const int prefs_chkheight;
155  // Height of a text widget's writable field
156  static const int prefs_eheight;
157  // ScrollBar width
158  static const int prefs_scrwidth;
159  // TextWindow height
160  static const int prefs_twheight;
161  // Message height
162  static const int prefs_mheight;
163  // Group boxes
164  static const int prefs_grpmsc_height;
165  static const int prefs_grpimg_height;
166  static const int prefs_grpren_height;
167  static const int prefs_grphgt_height;
168  static const int prefs_grport_height;
169  static const int prefs_grpthb_height;
170  static const int prefs_grpcht_height;
171  static const int prefs_grptab_height;
172  static const int prefs_grpsnd_height;
173  static const int prefs_grpcom_height;
174  // Height of panel
175  static const int prefs_pheight;
176 };
177 
178 
179 /*
180  * Object holding the preferences and the current setup.
181  */
182 class rviewPrefs
183 {
184 public:
185 
186  rviewPrefs(void);
187  rviewPrefs(const char *file);
188  rviewPrefs(const rviewPrefs &srcPrefs);
189  ~rviewPrefs(void);
190 
191  int load(const char *file);
192  int save(const char *file);
193  int edit(void);
194  void editorClosed(void);
195  void closeEditor(rviewPrefs *newPrefs);
196  void updatePrefs(rviewPrefs *newPrefs);
197  void markModified(void);
198 
199  static void copyPrefs(const rviewPrefs &src, rviewPrefs &dest);
200 
201  r_Data_Format getTransferFormat( void ) const;
202  r_Data_Format getStorageFormat( void ) const;
203 
204  DynamicString serverName;
205  int serverPort;
206  DynamicString databaseName;
207  DynamicString userName;
208  DynamicString lastColl;
209  DynamicString lastScColl;
210  DynamicString lastOrthoColl;
211  DynamicString filePath;
212  DynamicString queryPath;
213  DynamicString queryFont;
214  DynamicString vffParams;
215  int lastDisplay;
216  int maxDWidth, maxDHeight;
217  bool imgDither, ditherBest;
218  rviewImageMode imgMode;
219  rviewChartMode chartMode;
220  int movieMode, rgbSpace;
221  int tableMode;
222  bool imgBBox;
223  unsigned long imgZpro, imgClipz, imgWgtQuant;
224  double imgPixThreshLow, imgPixThreshHigh, imgWgtThresh;
225  double imgScale;
226  bool imgRgbBrightness, imgVoxForType;
227  bool imgLight;
228  double imgLightAmbient, imgLightGain, imgLightAngle, imgLightScintAngle;
229  int imgKernSize, imgKernType;
230  bool imgUseVCol;
231  double imgVoxColour;
232  DynamicString imgLightDir;
233  int imgLightDist;
234  int imgHeightGrid;
235  double imgHeightScale;
236  bool imgOrthoBBox, imgOrthoDragRel;
237  int imgOrthoThick;
238  bool chartCosys;
239  int chartStep, chartMarkx;
240  double chartMarky;
241  bool tableCosys;
242  int tableStepx, tableStepy;
243  int thumbProjdim, thumbProjstep, thumbWidth, thumbCols;
244  int soundFreq, soundLatency, soundLoop;
245  int transferFmt, storageFmt;
246  DynamicString transferParm, storageParm;
247  colourspace_params csp;
248 
249 
250 protected:
251 
252  void setupVariables(void);
253  // used for getting the value of an argument when reading the prefs file.
254  char *getValue(char *b);
255  // convert long strings (including newlines) from/to external representation
256  static char *toExternal(const DynamicString &str);
257  static void fromExternal(const char *ext, DynamicString &str);
258  // read a line into the internal buffer; return a pointer to the start if successful
259  char *readLine(FILE *fp);
260 
261  rviewPrefsWindow *pwin;
262  bool prefsModified;
263 
264  char *inbuff;
265  unsigned long buffSize;
266 
267  static const unsigned long buffExtendGranularity;
268  static const keyword_to_ident_c prefsVarDesc[];
269 };
270 
271 
272 
273 /*
274  * Global variables
275  */
276 
277 extern rviewPrefs *prefs;
278 
279 #endif