Debian Codegraph @

src/HardSettings.cpp

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 #cxx . . $ `<file>/src/HardSettings.cpp`/include <stdio.h>
2
3 #if defined(_WIN32)
4 #include <strings.h>
5 #else
6 #include <string.h> // for strcmp
7 #endif
8 #include "HardSettings.h"cxx . . $ `<file>/src/HardSettings.h`/
9
10 void HardSettingscxx . . $ HardSettings#::SetDefaultscxx . . $ HardSettings#SetDefaults(49f6e7a06ebc5aa8).(){
11 TSIZEcxx . . $ HardSettings#TSIZE.=1024; // total texture size
12 MAX_TSIZEcxx . . $ HardSettings#MAX_TSIZE.=2048; /// MAX texture size
13
14
15 N_VIEW_DIRcxx . . $ HardSettings#N_VIEW_DIR.=128;
16
17 SHADOWMAP_SIZEcxx . . $ HardSettings#SHADOWMAP_SIZE.=1024; // texture size for shadowmap
18 AOSM_SIZEcxx . . $ HardSettings#AOSM_SIZE.=256; // texture size for shadowmmaps for AO comp[utation
19
20 // if true, use double ShadomMap optimization
21 doubleSMcxx . . $ HardSettings#doubleSM.=1;
22
23 NVIDIA_PATCHcxx . . $ HardSettings#NVIDIA_PATCH. = 0;
24
25 MOVING_QUALITYcxx . . $ HardSettings#MOVING_QUALITY.=100;
26 STILL_QUALITYcxx . . $ HardSettings#STILL_QUALITY.=200;
27
28 SNAP_SIZEcxx . . $ HardSettings#SNAP_SIZE.=1024; // snapshots size
29 SNAP_ANTIALIAScxx . . $ HardSettings#SNAP_ANTIALIAS.=1;
30 PNG_TRANSPARENTcxx . . $ HardSettings#PNG_TRANSPARENT.=0;
31
32
33 // GIF animation settings
34 GIF_SNAP_SIZEcxx . . $ HardSettings#GIF_SNAP_SIZE.=256;
35 GIF_INITIAL_PAUSEcxx . . $ HardSettings#GIF_INITIAL_PAUSE.=0;
36 GIF_ANIMATION_MODEcxx . . $ HardSettings#GIF_ANIMATION_MODE.=0;
37
38 GIF_ROT_N_FRAMEScxx . . $ HardSettings#GIF_ROT_N_FRAMES.=60;
39 GIF_ROT_MSECcxx . . $ HardSettings#GIF_ROT_MSEC.=3000;
40 GIF_ROT_SIDEVIEW_ANGLEcxx . . $ HardSettings#GIF_ROT_SIDEVIEW_ANGLE.=10;
41
42 GIF_INSP_N_FRAMEScxx . . $ HardSettings#GIF_INSP_N_FRAMES.=60;
43 GIF_INSP_MSECcxx . . $ HardSettings#GIF_INSP_MSEC.=3000;
44 GIF_INSP_ANGLEcxx . . $ HardSettings#GIF_INSP_ANGLE.=10;
45
46 GIF_6SIDES_N_FRAMEScxx . . $ HardSettings#GIF_6SIDES_N_FRAMES.=10;
47 GIF_6SIDES_MSECcxx . . $ HardSettings#GIF_6SIDES_MSEC.=400;
48 GIF_6SIDES_PAUSEcxx . . $ HardSettings#GIF_6SIDES_PAUSE.=1000;
49
50 };
51
52
•53 static const char* namescxx . . $ names.[NNAMEScxx . . $ NNAMES.]={
54 "TSIZE",
55 "MAX_TSIZE",
56 "N_VIEW_DIR",
57 "SHADOWMAP_SIZE",
58 "AOSM_SIZE",
59 "MOVING_QUALITY",
60 "STILL_QUALITY",
61 "doubleSM",
62 "NVIDIA_PATCH",
63
64 "SNAP_SIZE",
65 "SNAP_ANTIALIAS",
66
67 "PNG_TRANSPARENT",
68
69 "GIF_SNAP_SIZE",
70 "GIF_INITIAL_PAUSE",
71 "GIF_ANIMATION_MODE",
72
73 "GIF_ROT_N_FRAMES",
74 "GIF_GIF_ROT_MSEC",
75 "GIF_GIF_ROT_SIDEVIEW_ANGLE",
76
77 "GIF_INSP_N_FRAMES",
78 "GIF_INSP_MSEC",
79 "GIF_INSP_ANGLE",
80
81 "GIF_6SIDES_N_FRAMES",
82 "GIF_6SIDES_MSEC",
83 "GIF_6SIDES_PAUSE",
84 };
85
86
87 HardSettingscxx . . $ HardSettings#::HardSettingscxx . . $ HardSettings#HardSettings(49f6e7a06ebc5aa8).(){
88 int i=0;
89 datacxx . . $ HardSettings#data.[i++]=&TSIZEcxx . . $ HardSettings#TSIZE.;
90 datacxx . . $ HardSettings#data.[i++]=&MAX_TSIZEcxx . . $ HardSettings#MAX_TSIZE.;
91 datacxx . . $ HardSettings#data.[i++]=&N_VIEW_DIRcxx . . $ HardSettings#N_VIEW_DIR.;
92 datacxx . . $ HardSettings#data.[i++]=&SHADOWMAP_SIZEcxx . . $ HardSettings#SHADOWMAP_SIZE.;
93 datacxx . . $ HardSettings#data.[i++]=&AOSM_SIZEcxx . . $ HardSettings#AOSM_SIZE.;
94 datacxx . . $ HardSettings#data.[i++]=&MOVING_QUALITYcxx . . $ HardSettings#MOVING_QUALITY.;
95 datacxx . . $ HardSettings#data.[i++]=&STILL_QUALITYcxx . . $ HardSettings#STILL_QUALITY.;
96 datacxx . . $ HardSettings#data.[i++]=&doubleSMcxx . . $ HardSettings#doubleSM.;
97 datacxx . . $ HardSettings#data.[i++]=&NVIDIA_PATCHcxx . . $ HardSettings#NVIDIA_PATCH.;
98
99 datacxx . . $ HardSettings#data.[i++]=&SNAP_SIZEcxx . . $ HardSettings#SNAP_SIZE.;
100 datacxx . . $ HardSettings#data.[i++]=&SNAP_ANTIALIAScxx . . $ HardSettings#SNAP_ANTIALIAS.;
101
102 datacxx . . $ HardSettings#data.[i++]=&PNG_TRANSPARENTcxx . . $ HardSettings#PNG_TRANSPARENT.;
103
104 datacxx . . $ HardSettings#data.[i++]=&GIF_SNAP_SIZEcxx . . $ HardSettings#GIF_SNAP_SIZE.;
105 datacxx . . $ HardSettings#data.[i++]=&GIF_INITIAL_PAUSEcxx . . $ HardSettings#GIF_INITIAL_PAUSE.;
106 datacxx . . $ HardSettings#data.[i++]=&GIF_ANIMATION_MODEcxx . . $ HardSettings#GIF_ANIMATION_MODE.;
107
108 datacxx . . $ HardSettings#data.[i++]=&GIF_ROT_N_FRAMEScxx . . $ HardSettings#GIF_ROT_N_FRAMES.;
109 datacxx . . $ HardSettings#data.[i++]=&GIF_ROT_MSECcxx . . $ HardSettings#GIF_ROT_MSEC.;
110 datacxx . . $ HardSettings#data.[i++]=&GIF_ROT_SIDEVIEW_ANGLEcxx . . $ HardSettings#GIF_ROT_SIDEVIEW_ANGLE.;
111
112 datacxx . . $ HardSettings#data.[i++]=&GIF_INSP_N_FRAMEScxx . . $ HardSettings#GIF_INSP_N_FRAMES.;
113 datacxx . . $ HardSettings#data.[i++]=&GIF_INSP_MSECcxx . . $ HardSettings#GIF_INSP_MSEC.;
114 datacxx . . $ HardSettings#data.[i++]=&GIF_INSP_ANGLEcxx . . $ HardSettings#GIF_INSP_ANGLE.;
115
116 datacxx . . $ HardSettings#data.[i++]=&GIF_6SIDES_N_FRAMEScxx . . $ HardSettings#GIF_6SIDES_N_FRAMES.;
117 datacxx . . $ HardSettings#data.[i++]=&GIF_6SIDES_MSECcxx . . $ HardSettings#GIF_6SIDES_MSEC.;
118 datacxx . . $ HardSettings#data.[i++]=&GIF_6SIDES_PAUSEcxx . . $ HardSettings#GIF_6SIDES_PAUSE.;
119
120
121 }
122
123
•124 static const char* commentscxx . . $ comments.[NNAMEScxx . . $ NNAMES.]={
125 "favoured texture size for molecule",
126 "maximal texture size (used when molecule too large for TSIZE)",
127 "number of view directions ussed in AO computation",
128 "texture size for shadowmap",
129 "texture size for shadowmmaps for AO computation",
130 "Quality of image on screen when molecole moves (between 50..200)",
131 "Quality of image on screen when molecole is still (between 50..200)",
132 "if 1, use double ShadomMap optimization (two way lights)",
133 "use 1 - *AND* disable doubleSM - to patch a bug reported on some Nvidia cards (warning: lowers visual quality!)",
134
135 "snapshots resolution (per side)",
136 "if 1, antialias exported snapshots",
•137 "if 1, save PNG images with transparent background",
138
139
140 "resolution of exported GIF animations",
141 "initial pause in msec before each animation loop",
142 "if 0: full rotation. If 1: inspection mode (rotation around current viewpoint). If 2: six-views show.",
143
144 "number of frames of exported GIF animations (for full rotation)",
145 "total duration in msec of GIF animations loop (for full rotation)",
146 "angle (in -45 +45). If 0, perfect side rotation; if >0, look from above; if <0, look from below (for full rotation)",
147
148 "number of frames of exported GIF animations (for inspections)",
149 "total duration in msec of GIF animations loop (for inspections)",
150 "in (10..45). Animation is an inspection around current view point (for inspections)",
151
152 "number of frames of exported GIF animations (for six-views show)",
153 "duration in msec of each face shift (for six-views show)",
154 "pause in msec after each face shift (for six-views show)",
155 };
156
157
158
159
•160 bool HardSettingscxx . . $ HardSettings#::Loadcxx . . $ HardSettings#Load(c5f7da30cbc0f4e9).(const char *fn){
161 char buf[512];
162 strcpy(buf, PKGDATADIRcxx . . $ `<built-in>:481:9`!);
163 if (buf[strlen(buf)-1] != '/') {
164 strcat(buf,"/");
165 }
166 FILE *f=fopen(strcat(buf,fn),"rt");
167
168 bool present[NNAMEScxx . . $ NNAMES.];
169 for (int i=0; i<NNAMEScxx . . $ NNAMES.; i++) present[i]=false;
170 bool duplicated=false;
171 bool errors=false;
172
173 if (!f) return false;
174 char token[255];
175 char last[255];
•176 last[0]=0;
177 while (1){
178 if (fscanf(f,"%s",token)!=1) break;
179 if (token[0]=='=') {
180 int val;
181 if (fscanf(f,"%d",&val)==1) {
182 bool ok=false;
183 for (int i=0; i<NNAMEScxx . . $ NNAMES.; i++) {
184 if (strcmp(namescxx . . $ names.[i],last)==0) {
185 ok=true;
186 *(datacxx . . $ HardSettings#data.[i])=val;
187 if (present[i]) duplicated=true;
188 present[i]=true;
189 }
190 }
191 if (!ok) errors=true;
192 } else errors=true;
193 }
194 sprintf(last,"%s",token);
195 }
196 fclose(f);
197 for (int i=0; i<NNAMEScxx . . $ NNAMES.; i++) if (!present[i]) return false;
198
199 if (duplicated) return false;
200 if (errors) return false;
201 return true;
202 }
203
•204 bool HardSettingscxx . . $ HardSettings#::Savecxx . . $ HardSettings#Save(c5f7da30cbc0f4e9).(const char *fn){
205 FILE *f=fopen(fn,"wt");
206
207 static HardSettingscxx . . $ HardSettings# defaultscxx . . $ HardSettings#HardSettings(49f6e7a06ebc5aa8).;
208 defaults.SetDefaultscxx . . $ HardSettings#SetDefaults(49f6e7a06ebc5aa8).();
209
210 if (!f) return false;
211
212 for (int i=0; i<NNAMEScxx . . $ NNAMES.; i++) {
213 if (i==13) // quick hack
214 fprintf(f," \\\\ PARAMETERS FOR GIF ANIMATION \n \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n\n");
215
216 fprintf(f,"%s = %d\n \\\\ %s\n \\\\ (default: %d ) \n\n",
217 namescxx . . $ names.[i], *(datacxx . . $ HardSettings#data.[i]), commentscxx . . $ comments.[i] , *(defaults.datacxx . . $ HardSettings#data.[i]) );
218 }
219 fclose(f);
220 return true;
221 }
222
•223 void HardSettingscxx . . $ HardSettings#::OnStartcxx . . $ HardSettings#OnStart(49f6e7a06ebc5aa8).(){
224 SetDefaultscxx . . $ HardSettings#SetDefaults(49f6e7a06ebc5aa8).();
225 if (!Loadcxx . . $ HardSettings#Load(c5f7da30cbc0f4e9).("qutemol.cfg")) {
226 Savecxx . . $ HardSettings#Save(c5f7da30cbc0f4e9).("qutemol.cfg");
227 }
228 }
229
230
231
232
233
234 HardSettingscxx . . $ HardSettings# hardSettingscxx . . $ hardSettings.; // SINGLETON