1 /* Panorama_Tools	-	Generate, Edit and Convert Panoramic Images
2    Copyright (C) 1998,1999 - Helmut Dersch  der@fh-furtwangen.de
3 
4    This program 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 2, or (at your option)
7    any later version.
8 
9    This program 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 this software; see the file COPYING.  If not, a copy
16    can be downloaded from http://www.gnu.org/licenses/gpl.html, or
17    obtained by writing to the Free Software Foundation, Inc.,
18    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
19 
20 /*------------------------------------------------------------*/
21 
22 #include "filter.h"
23 
24 #ifdef __Mac__
25   #include "sys_mac.h"
26 #endif
27 
28 // Jim Watters 2008/01/11  need sys_win.h for dialogs to work in Windows
29 //                         need sys_ansi.h for command prompt to work
30 #ifdef __Ansi__
31   #include "sys_ansi.h"
32 #elif defined (__Win__)
33   #include "sys_win.h"
34 #endif
35 
36 
37 #if !__Mac__ && !__Win__ && !__Ansi__
38   #include "sys_X11.h"
39 #endif
40 
41 #if _MSC_VER > 1000
42 #pragma warning(disable: 4100) // disable unreferenced formal parameter warning
43 #endif
44 
45 // Please do not change the way these dialogs work. You will certainly mess
46 // up one of the platform specific versions.
47 
48 //----------------------- Dialogs for remap  -------------------------------------------
49 
50 
51 
52 
SetRemapPrefs(rPrefs * thePrefs)53 int SetRemapPrefs(  rPrefs * thePrefs )
54 {
55 	GenDialog( rPrefs,
56 			   kSetRemapPrefs_dlg, "Remap Options",
57 			   {
58 			   		CheckButton( kSetRemapPrefs_InRect, 			localPrefs.from == _rectilinear);
59 					CheckButton( kSetRemapPrefs_InPano, 			localPrefs.from == _panorama);
60 					CheckButton( kSetRemapPrefs_InErect, 			localPrefs.from == _equirectangular);
61 					CheckButton( kSetRemapPrefs_InSphereCenter, 	localPrefs.from == _spherical_cp);
62 					CheckButton( kSetRemapPrefs_InSphereTop,		localPrefs.from == _spherical_tp);
63 					CheckButton( kSetRemapPrefs_InMirror, 			localPrefs.from == _mirror);
64 
65 					CheckButton( kSetRemapPrefs_OutRect, 			localPrefs.to == _rectilinear);
66 					CheckButton( kSetRemapPrefs_OutPano, 			localPrefs.to == _panorama);
67 					CheckButton( kSetRemapPrefs_OutErect, 			localPrefs.to == _equirectangular);
68 					CheckButton( kSetRemapPrefs_OutSphereCenter, 	localPrefs.to == _spherical_cp);
69 					CheckButton( kSetRemapPrefs_OutSphereTop, 		localPrefs.to == _spherical_tp);
70 					CheckButton( kSetRemapPrefs_OutMirror, 			localPrefs.to == _mirror);
71 				},
72 				{
73 					SetText( kSetRemapPrefs_Hfov, "%g", localPrefs.hfov );
74 					SetText( kSetRemapPrefs_Vfov, "%g", localPrefs.vfov );
75 				},
76 				{
77 					GetText( kSetRemapPrefs_Hfov, "%lf", &localPrefs.hfov );
78 					GetText( kSetRemapPrefs_Vfov, "%lf", &localPrefs.vfov );
79 				},
80 				{
81 					case kSetRemapPrefs_InRect:
82 						localPrefs.from = _rectilinear;
83 						break;
84 					case kSetRemapPrefs_InPano:
85 						localPrefs.from = _panorama;
86 						break;
87 					case kSetRemapPrefs_InErect:
88 						localPrefs.from = _equirectangular;
89 						break;
90 					case kSetRemapPrefs_InSphereCenter:
91 						localPrefs.from = _spherical_cp;
92 						break;
93 					case kSetRemapPrefs_InSphereTop:
94 						localPrefs.from = _spherical_tp;
95 						break;
96 					case kSetRemapPrefs_InMirror:
97 						localPrefs.from = _mirror;
98 						break;
99 					case kSetRemapPrefs_OutRect:
100 						localPrefs.to = _rectilinear;
101 						break;
102 					case kSetRemapPrefs_OutPano:
103 						localPrefs.to = _panorama;
104 						break;
105 					case kSetRemapPrefs_OutErect:
106 						localPrefs.to = _equirectangular;
107 						break;
108 					case kSetRemapPrefs_OutSphereCenter:
109 						localPrefs.to = _spherical_cp;
110 						break;
111 					case kSetRemapPrefs_OutSphereTop:
112 						localPrefs.to = _spherical_tp;
113 						break;
114 					case kSetRemapPrefs_OutMirror:
115 						localPrefs.to = _mirror;
116 						break;
117 					case kSetRemapPrefs_SetPrefs:
118 						if( setSizePrefs( gsPrPtr, gTrPtr->mode & _hostCanResize ))
119 						{
120 							writePrefs((char*) gsPrPtr, _sizep );
121 						}
122 						break;
123 				}, SetRem)
124 }
125 
126 //-------------------------- Dialogs for perspective  -------------------------------------------
127 
SetPerspectivePrefs(pPrefs * thePrefs)128 int SetPerspectivePrefs(  pPrefs * thePrefs )
129 {
130 	GenDialog( pPrefs,
131 			   kSetPerspectivePrefs_dlg	, "Perspective Options",
132 			   {
133 					CheckButton( kSetPerspectivePrefs_InRect, 		localPrefs.format == _rectilinear);
134 					CheckButton( kSetPerspectivePrefs_InSphere, 	localPrefs.format == _spherical_tp);
135 					CheckButton( kSetPerspectivePrefs_Degree, 		!localPrefs.unit_is_cart );
136 					CheckButton( kSetPerspectivePrefs_Points, 		localPrefs.unit_is_cart);
137 				},
138 				{
139 					SetText( kSetPerspectivePrefs_X, 		"%g", localPrefs.x_alpha );
140 					SetText( kSetPerspectivePrefs_Y, 		"%g", localPrefs.y_beta );
141 					SetText( kSetPerspectivePrefs_Hfov, 	"%g", localPrefs.hfov );
142 					SetText( kSetPerspectivePrefs_Gamma, 	"%g", localPrefs.gamma );
143 					SetText( kSetPerspectivePrefs_Width, 	"%ld", localPrefs.width );
144 					SetText( kSetPerspectivePrefs_Height, 	"%ld", localPrefs.height );
145 				},
146 				{
147 					GetText( kSetPerspectivePrefs_X, 		"%lf", &localPrefs.x_alpha );
148 					GetText( kSetPerspectivePrefs_Y, 		"%lf", &localPrefs.y_beta );
149 					GetText( kSetPerspectivePrefs_Hfov, 	"%lf", &localPrefs.hfov );
150 					GetText( kSetPerspectivePrefs_Gamma, 	"%lf", &localPrefs.gamma );
151 					GetText( kSetPerspectivePrefs_Width, 	"%ld", &localPrefs.width );
152 					GetText( kSetPerspectivePrefs_Height, 	"%ld", &localPrefs.height );
153 				},
154 				{
155 					case kSetPerspectivePrefs_InRect:
156 						localPrefs.format = _rectilinear;
157 						break;
158 					case kSetPerspectivePrefs_InSphere:
159 						localPrefs.format = _spherical_tp;
160 						break;
161 					case kSetPerspectivePrefs_Degree:
162 						localPrefs.unit_is_cart = FALSE;
163 						break;
164 					case kSetPerspectivePrefs_Points	:
165 						localPrefs.unit_is_cart = TRUE;
166 						break;
167 					case kSetPerspectivePrefs_Keep:
168 						SetText( kSetPerspectivePrefs_Width, "%ld", gTrPtr->src->width );
169 						SetText( kSetPerspectivePrefs_Height, "%ld", gTrPtr->src->height );
170 						break;
171 					case kSetPerspectivePrefs_SetPrefs:
172 						if( setSizePrefs( gsPrPtr, gTrPtr->mode & _hostCanResize ))
173 						{
174 							writePrefs((char*) gsPrPtr, _sizep );
175 						}
176 						break;
177 				}, SetPerspPrefs )
178 }
179 
180 
181 
182 // ---------------- Dialogs for correct ------------------------------------------------
183 
SetCorrectPrefs(cPrefs * thePrefs)184 int SetCorrectPrefs( cPrefs * thePrefs )
185 {
186 	GenDialog( cPrefs,
187 			   kSetCorrectPrefs_dlg, "Correction",
188 			   {
189 					CheckButton( kSetCorrectPrefs_Radial, 		localPrefs.radial);
190 					CheckButton( kSetCorrectPrefs_Horizontal, 	localPrefs.horizontal );
191 					CheckButton( kSetCorrectPrefs_Vertical, 	localPrefs.vertical);
192 					CheckButton( kSetCorrectPrefs_Shear, 		localPrefs.shear);
193 					CheckButton( kSetCorrectPrefs_Scale, 		localPrefs.resize);
194 					CheckButton( kSetCorrectPrefs_Lum, 			localPrefs.luminance);
195 					CheckButton( kSetCorrectPrefs_CutFrame, 	localPrefs.cutFrame);
196 					CheckButton( kSetCorrectPrefs_Fourier, 		localPrefs.fourier);
197 				},;,;,
198 				{
199 					case kSetCorrectPrefs_Save:
200 						SaveOptions( &localPrefs );
201 						break;
202 					case kSetCorrectPrefs_Load:
203 						LoadOptions( &localPrefs );
204 						break;
205 					case kSetCorrectPrefs_Radial:
206 						localPrefs.radial = !localPrefs.radial;
207 						break;
208 					case kSetCorrectPrefs_Horizontal:
209 						localPrefs.horizontal = !localPrefs.horizontal;
210 						break;
211 					case kSetCorrectPrefs_Vertical:
212 						localPrefs.vertical = !localPrefs.vertical;
213 						break;
214 					case kSetCorrectPrefs_Shear:
215 						localPrefs.shear = !localPrefs.shear;
216 						break;
217 					case kSetCorrectPrefs_Scale:
218 						localPrefs.resize = !localPrefs.resize;
219 						break;
220 					case kSetCorrectPrefs_RadialOption:
221 						SetRadialOptions(  &localPrefs );
222 						SetCorrectionRadius( &localPrefs );
223 						break;
224 					case kSetCorrectPrefs_HorizontalOption:
225 						SetHorizontalOptions(  &localPrefs );
226 						break;
227 					case kSetCorrectPrefs_VerticalOption:
228 						SetVerticalOptions(  &localPrefs );
229 						break;
230 					case kSetCorrectPrefs_ShearOption:
231 						SetShearOptions(  &localPrefs );
232 						break;
233 					case kSetCorrectPrefs_ScaleOption:
234 						SetScaleOptions(  &localPrefs );
235 						break;
236 					case kSetCorrectPrefs_Lum:
237 						localPrefs.luminance = !localPrefs.luminance;
238 						break;
239 					case kSetCorrectPrefs_LumOpt:
240 						SetLumOptions(  &localPrefs);
241 						break;
242 					case kSetCorrectPrefs_SetPrefs:
243 						if( setSizePrefs( gsPrPtr, gTrPtr->mode & _hostCanResize ))
244 						{
245 							writePrefs((char*) gsPrPtr, _sizep );
246 						}
247 						break;
248 					case kSetCorrectPrefs_CutFrame:
249 						localPrefs.cutFrame = !localPrefs.cutFrame;
250 						break;
251 					case kSetCorrectPrefs_CutOpt:
252 						SetCutOptions(  &localPrefs );
253 						break;
254 					case kSetCorrectPrefs_Fourier:
255 						localPrefs.fourier = !localPrefs.fourier;
256 						break;
257 					case kSetCorrectPrefs_FourierOpt:
258 						SetFourierOptions(  &localPrefs );
259 						break;
260 			}, SetCPrefs )
261 }
262 
263 #if !__Mac__ && !__Win__
SetFourierOptions(cPrefs * thePrefs)264 int SetFourierOptions( cPrefs * thePrefs )
265 {
266 	GenDialog( cPrefs,
267 			   kSetFourierOptions_dlg, "Fourier Filtering Options",
268 			   {
269 					CheckButton( kSetFourierOptions_addBlur, 	localPrefs.fourier_mode == _faddBlurr );
270 					CheckButton( kSetFourierOptions_remBlur, 	localPrefs.fourier_mode == _fremoveBlurr);
271 					CheckButton( kSetFourierOptions_internal, 	localPrefs.fourier_nf   == _nf_internal);
272 					CheckButton( kSetFourierOptions_custom, 	localPrefs.fourier_nf   == _nf_custom);
273 				},
274 				{
275 					SetText( kSetFourierOptions_filterfactor, 	"%g", localPrefs.filterfactor );
276 					SetText( kSetFourierOptions_fourier_frame,	"%g", localPrefs.fourier_frame);
277 				},
278 				{
279 					GetText( kSetFourierOptions_filterfactor, 	"%lf", &localPrefs.filterfactor );
280 					GetText( kSetFourierOptions_fourier_frame,	"%lf", &localPrefs.fourier_frame);
281 				},
282 				{
283 					case kSetFourierOptions_findPSD:
284 						FindFile( &(localPrefs.psf) );
285 						break;
286 					case kSetFourierOptions_addBlur:
287 						localPrefs.fourier_mode = _faddBlurr;
288 						break;
289 					case kSetFourierOptions_remBlur:
290 						localPrefs.fourier_mode = _fremoveBlurr;
291 						break;
292 					case kSetFourierOptions_internal:
293 						localPrefs.fourier_nf   = _nf_internal;
294 						break;
295 					case kSetFourierOptions_custom:
296 						localPrefs.fourier_nf   = _nf_custom;
297 						break;
298 					case kSetFourierOptions_findNFF:
299 						FindFile( &(localPrefs.nff) );
300 						break;
301 				}, SetFrPrefs )
302 }
303 #endif
304 
305 
306 #ifdef __Win__
SetFourierOptions(cPrefs * thePrefs)307 int SetFourierOptions( cPrefs * thePrefs )
308 {
309 	GenDialog( cPrefs,
310 			   kSetFourierOptions_dlg, "Fourier Filtering Options",
311 			   {
312 					CheckButton( kSetFourierOptions_addBlur, 	localPrefs.fourier_mode == _faddBlurr );
313 					CheckButton( kSetFourierOptions_remBlur, 	localPrefs.fourier_mode == _fremoveBlurr);
314 					CheckButton( kSetFourierOptions_internal, 	localPrefs.fourier_nf   == _nf_internal);
315 					CheckButton( kSetFourierOptions_custom, 	localPrefs.fourier_nf   == _nf_custom);
316 				},
317 				{
318 					SetLbl(  kSetFourierOptions_PSDname,  (char*)&(localPrefs.psf) );
319 					SetText( kSetFourierOptions_filterfactor, 	"%g", localPrefs.filterfactor );
320 					SetText( kSetFourierOptions_fourier_frame,	"%g", localPrefs.fourier_frame);
321 				},
322 				{
323 					GetLbl( kSetFourierOptions_PSDname, (char*)&(localPrefs.psf), 255 );
324 					GetText( kSetFourierOptions_filterfactor, 	"%lf", &localPrefs.filterfactor );
325 					GetText( kSetFourierOptions_fourier_frame,	"%lf", &localPrefs.fourier_frame);
326 				},
327 				{
328 					case kSetFourierOptions_findPSD:
329 						{
330 							fullPath path;
331 
332 							if( ! FindFile( &path ))
333 							{
334 								memcpy( &localPrefs.psf, &path, sizeof( fullPath ) );
335 								SetLbl(  kSetFourierOptions_PSDname,  (char*)&(localPrefs.psf) );
336 							}
337 						}
338 						break;
339 					case kSetFourierOptions_addBlur:
340 						localPrefs.fourier_mode = _faddBlurr;
341 						break;
342 					case kSetFourierOptions_remBlur:
343 						localPrefs.fourier_mode = _fremoveBlurr;
344 						break;
345 					case kSetFourierOptions_internal:
346 						localPrefs.fourier_nf   = _nf_internal;
347 						break;
348 					case kSetFourierOptions_custom:
349 						localPrefs.fourier_nf   = _nf_custom;
350 						break;
351 					case kSetFourierOptions_findNFF:
352 						FindFile( &(localPrefs.nff) );
353 						break;
354 				}, SetFrPrefs )
355 }
356 #endif
357 
358 
359 
360 #ifdef __Mac__
SetFourierOptions(cPrefs * thePrefs)361 int SetFourierOptions( cPrefs * thePrefs )
362 {
363 	GenDialog( cPrefs,
364 			   kSetFourierOptions_dlg, "Fourier Filtering Options",
365 			   {
366 					CheckButton( kSetFourierOptions_addBlur, 	localPrefs.fourier_mode == _faddBlurr );
367 					CheckButton( kSetFourierOptions_remBlur, 	localPrefs.fourier_mode == _fremoveBlurr);
368 					CheckButton( kSetFourierOptions_scale, 		localPrefs.fourier_mode == _fresize);
369 					CheckButton( kSetFourierOptions_internal, 	localPrefs.fourier_nf   == _nf_internal);
370 					CheckButton( kSetFourierOptions_custom, 	localPrefs.fourier_nf   == _nf_custom);
371 					ConvFileName( &(localPrefs.psf), &numString[120]);
372 					SetLbl(  kSetFourierOptions_PSDname, &numString[120]);
373 				},
374 				{
375 					SetText( kSetFourierOptions_filterfactor, 	"%g", localPrefs.filterfactor );
376 					SetText( kSetFourierOptions_fourier_frame,	"%g", localPrefs.fourier_frame);
377 				},
378 				{
379 					GetText( kSetFourierOptions_filterfactor, 	"%lf", &localPrefs.filterfactor );
380 					GetText( kSetFourierOptions_fourier_frame,	"%lf", &localPrefs.fourier_frame);
381 				},
382 				{
383 					case kSetFourierOptions_findPSD:
384 						FindFile( &(localPrefs.psf) );
385 						break;
386 					case kSetFourierOptions_addBlur:
387 						localPrefs.fourier_mode = _faddBlurr;
388 						break;
389 					case kSetFourierOptions_scale:
390 						localPrefs.fourier_mode = _fresize;
391 						break;
392 					case kSetFourierOptions_remBlur:
393 						localPrefs.fourier_mode = _fremoveBlurr;
394 						break;
395 					case kSetFourierOptions_internal:
396 						localPrefs.fourier_nf   = _nf_internal;
397 						break;
398 					case kSetFourierOptions_custom:
399 						localPrefs.fourier_nf   = _nf_custom;
400 						break;
401 					case kSetFourierOptions_findNFF:
402 						FindFile( &(localPrefs.nff) );
403 						break;
404 				}, SetFrPrefs )
405 }
406 #endif
407 
SetLumOptions(cPrefs * thePrefs)408 int SetLumOptions(  cPrefs * thePrefs )
409 {
410 	GenDialog( cPrefs,
411 			   kSetLumOptions_dlg, "Luminance Correction Options",;,
412 			   {
413 			   		switch( gTrPtr->src->dataformat )
414 					{
415 						case _RGB:	SetLbl( kSetLumOptions_RedText,  	"Red");
416 									SetLbl( kSetLumOptions_GreenText,  	"Green");
417 									SetLbl( kSetLumOptions_BlueText,  	"Blue");
418 									break;
419 						case _Lab:	SetLbl( kSetLumOptions_RedText,  	"Lightness");
420 									SetLbl( kSetLumOptions_GreenText,  	"Color a");
421 									SetLbl( kSetLumOptions_BlueText,  	"Color b");
422 									break;
423 					}
424 					SetText( kSetLumOptions_Red, 	"%g", localPrefs.lum_params[0] );
425 					SetText( kSetLumOptions_Green, 	"%g", localPrefs.lum_params[1] );
426 					SetText( kSetLumOptions_Blue, 	"%g", localPrefs.lum_params[2] );
427 				},
428 				{
429 					GetText( kSetLumOptions_Red, 	"%lf", &localPrefs.lum_params[0] );
430 					GetText( kSetLumOptions_Green, 	"%lf", &localPrefs.lum_params[1] );
431 					GetText( kSetLumOptions_Blue, 	"%lf", &localPrefs.lum_params[2] );
432 				},;,
433 				SetLumOpt)
434 }
435 
SetRadialOptions(cPrefs * thePrefs)436 int SetRadialOptions(  cPrefs * thePrefs )
437 {
438 	GenDialog(cPrefs,
439 			   kSetRadialOptions_dlg, /*"Radial Shift Options"*/"Set Polynomial Coefficients for Radial Shift" /*Changed by Kekus Digital August 14 2003*/,
440 			   {
441 					CheckButton( kSetRadialOptions_radial, 		localPrefs.correction_mode == correction_mode_radial );
442 					CheckButton( kSetRadialOptions_vertical, 	localPrefs.correction_mode == correction_mode_vertical  );
443 					CheckButton( kSetRadialOptions_horizontal, 	localPrefs.correction_mode == correction_mode_deregister );
444 				},
445 			   {
446 					SetText( kSetRadialOptions_Red0, 	"%g", localPrefs.radial_params[0][0] );
447 					SetText( kSetRadialOptions_Red1, 	"%g", localPrefs.radial_params[0][1] );
448 					SetText( kSetRadialOptions_Red2, 	"%g", localPrefs.radial_params[0][2] );
449 					SetText( kSetRadialOptions_Red3, 	"%g", localPrefs.radial_params[0][3] );
450 					SetText( kSetRadialOptions_Green0, 	"%g", localPrefs.radial_params[1][0] );
451 					SetText( kSetRadialOptions_Green1, 	"%g", localPrefs.radial_params[1][1] );
452 					SetText( kSetRadialOptions_Green2, 	"%g", localPrefs.radial_params[1][2] );
453 					SetText( kSetRadialOptions_Green3, 	"%g", localPrefs.radial_params[1][3] );
454 					SetText( kSetRadialOptions_Blue0, 	"%g", localPrefs.radial_params[2][0] );
455 					SetText( kSetRadialOptions_Blue1, 	"%g", localPrefs.radial_params[2][1] );
456 					SetText( kSetRadialOptions_Blue2, 	"%g", localPrefs.radial_params[2][2] );
457 					SetText( kSetRadialOptions_Blue3, 	"%g", localPrefs.radial_params[2][3] );
458 				},
459 				{
460 					GetText( kSetRadialOptions_Red0, 	"%lf", &localPrefs.radial_params[0][0] );
461 					GetText( kSetRadialOptions_Red1, 	"%lf", &localPrefs.radial_params[0][1] );
462 					GetText( kSetRadialOptions_Red2, 	"%lf", &localPrefs.radial_params[0][2] );
463 					GetText( kSetRadialOptions_Red3, 	"%lf", &localPrefs.radial_params[0][3] );
464 					GetText( kSetRadialOptions_Green0, 	"%lf", &localPrefs.radial_params[1][0] );
465 					GetText( kSetRadialOptions_Green1, 	"%lf", &localPrefs.radial_params[1][1] );
466 					GetText( kSetRadialOptions_Green2, 	"%lf", &localPrefs.radial_params[1][2] );
467 					GetText( kSetRadialOptions_Green3, 	"%lf", &localPrefs.radial_params[1][3] );
468 					GetText( kSetRadialOptions_Blue0, 	"%lf", &localPrefs.radial_params[2][0] );
469 					GetText( kSetRadialOptions_Blue1, 	"%lf", &localPrefs.radial_params[2][1] );
470 					GetText( kSetRadialOptions_Blue2, 	"%lf", &localPrefs.radial_params[2][2] );
471 					GetText( kSetRadialOptions_Blue3, 	"%lf", &localPrefs.radial_params[2][3] );
472 				},
473 				{
474 					case kSetRadialOptions_radial:
475 						localPrefs.correction_mode = correction_mode_radial;
476 						break;
477 					case kSetRadialOptions_vertical:
478 						localPrefs.correction_mode = correction_mode_vertical;
479 						break;
480 					case kSetRadialOptions_horizontal:
481 						localPrefs.correction_mode = correction_mode_deregister;
482 						break;
483 				},SetRadOpt)
484 }
485 
SetHorizontalOptions(cPrefs * thePrefs)486 int SetHorizontalOptions(  cPrefs * thePrefs )
487 {
488 	GenDialog( cPrefs,
489 			   kSetHorizontalOptions_dlg, "Horizontal Shift Options",;,
490 			   {
491 					SetText( kSetHorizontalOptions_Red, 	"%g", localPrefs.horizontal_params[0] );
492 					SetText( kSetHorizontalOptions_Green, 	"%g", localPrefs.horizontal_params[1] );
493 					SetText( kSetHorizontalOptions_Blue, 	"%g", localPrefs.horizontal_params[2] );
494 				},
495 				{
496 					GetText( kSetHorizontalOptions_Red, 	"%lf", &localPrefs.horizontal_params[0] );
497 					GetText( kSetHorizontalOptions_Green, 	"%lf", &localPrefs.horizontal_params[1] );
498 					GetText( kSetHorizontalOptions_Blue, 	"%lf", &localPrefs.horizontal_params[2] );
499 				}, ;,SetHorOpt)
500 }
501 
SetVerticalOptions(cPrefs * thePrefs)502 int SetVerticalOptions(  cPrefs * thePrefs )
503 {
504 	GenDialog(cPrefs,
505 			   kSetHorizontalOptions_dlg, "Vertical Shift Options",;,
506 			   {
507 					SetText( kSetHorizontalOptions_Red, 	"%g", localPrefs.vertical_params[0] );
508 					SetText( kSetHorizontalOptions_Green, 	"%g", localPrefs.vertical_params[1] );
509 					SetText( kSetHorizontalOptions_Blue, 	"%g", localPrefs.vertical_params[2] );
510 				},
511 				{
512 					GetText( kSetHorizontalOptions_Red, 	"%lf", &localPrefs.vertical_params[0] );
513 					GetText( kSetHorizontalOptions_Green, 	"%lf", &localPrefs.vertical_params[1] );
514 					GetText( kSetHorizontalOptions_Blue, 	"%lf", &localPrefs.vertical_params[2] );
515 				},; ,SetVerOpt)
516 }
517 
SetShearOptions(cPrefs * thePrefs)518 int SetShearOptions(  cPrefs * thePrefs )
519 {
520 	GenDialog(cPrefs,
521 			   kSetShearOptions_dlg, "Shear Options",;,
522 			   {
523 					SetLbl( kSetShearOptions_vname,  "Vertical");
524 					SetText( kSetShearOptions_vvar, "%g", localPrefs.shear_y);
525 					SetLbl( kSetShearOptions_hname,  "Horizontal");
526 					SetText( kSetShearOptions_hvar, "%g", localPrefs.shear_x);
527 				},
528 			   {
529 					GetText( kSetShearOptions_vvar, "%lf", &localPrefs.shear_y);
530 					GetText( kSetShearOptions_hvar, "%lf", &localPrefs.shear_x);
531 				}, ;, SetShOpt)
532 }
533 
SetScaleOptions(cPrefs * thePrefs)534 int SetScaleOptions(  cPrefs * thePrefs )
535 {
536 	GenDialog( cPrefs,
537 			   kSetShearOptions_dlg, "Resize Options",;,
538 			   {
539 					SetLbl( kSetShearOptions_vname,  "Width");
540 					SetText( kSetShearOptions_vvar, "%ld", localPrefs.width);
541 					SetLbl( kSetShearOptions_hname,  "Height");
542 					SetText( kSetShearOptions_hvar, "%ld", localPrefs.height);
543 				},
544 			   {
545 					GetText( kSetShearOptions_vvar, "%ld", &localPrefs.width);
546 					GetText( kSetShearOptions_hvar, "%ld", &localPrefs.height);
547 				}, ;,SetScOpt)
548 }
549 
550 
SetCutOptions(cPrefs * thePrefs)551 int SetCutOptions(  cPrefs * thePrefs )
552 {
553 	GenDialog(cPrefs,
554 			   kSetShearOptions_dlg, "Cut Frame Options",;,
555 			   {
556 					SetLbl( kSetShearOptions_vname,  "Width");
557 					SetText( kSetShearOptions_vvar, "%ld", localPrefs.fwidth);
558 					SetLbl( kSetShearOptions_hname,  "Height");
559 					SetText( kSetShearOptions_hvar, "%ld", localPrefs.fheight);
560 				},
561 			   {
562 					GetText( kSetShearOptions_vvar, "%ld", &localPrefs.fwidth);
563 					GetText( kSetShearOptions_hvar, "%ld", &localPrefs.fheight);
564 				},; ,SetCutOpt)
565 }
566 
567 
SetAdjustPrefs(aPrefs * thePrefs)568 int SetAdjustPrefs( aPrefs * thePrefs )
569 {
570 	GenDialog( aPrefs,
571 			   kSetAdjustPrefs_dlg, "Adjust Options",
572 			   {
573 					CheckButton( kSetAdjustPrefs_Insert, 		((localPrefs.mode & 7) == _insert ));
574 					CheckButton( kSetAdjustPrefs_Extract, 		((localPrefs.mode & 7) == _extract ));
575 					CheckButton( kSetAdjustPrefs_SetCtrlPts, 	((localPrefs.mode & 7) == _readControlPoints));
576 					CheckButton( kSetAdjustPrefs_RunOptimizer, 	((localPrefs.mode & 7) == _runOptimizer));
577 					CheckButton( kSetAdjustPrefs_Options, 		!(localPrefs.mode & _useScript));
578 					CheckButton( kSetAdjustPrefs_Script, 		localPrefs.mode & _useScript  );
579 				},; ,; ,
580 				{
581 					case kSetAdjustPrefs_Insert:
582 						localPrefs.mode = (localPrefs.mode & _useScript) + _insert;
583 						break;
584 					case kSetAdjustPrefs_Extract:
585 						localPrefs.mode = (localPrefs.mode & _useScript) + _extract;
586 						break;
587 					case kSetAdjustPrefs_SetCtrlPts:
588 						localPrefs.mode = (localPrefs.mode & _useScript) + _readControlPoints;
589 						break;
590 					case kSetAdjustPrefs_RunOptimizer:
591 						localPrefs.mode = (localPrefs.mode & _useScript) + _runOptimizer;
592 						break;
593 					case kSetAdjustPrefs_Options:
594 						localPrefs.mode &= (~_useScript);
595 						break;
596 					case kSetAdjustPrefs_Script:
597 						localPrefs.mode |= _useScript;
598 						break;
599 					case kSetAdjustPrefs_SetOpt:
600 						SetCreateOptions(  &localPrefs );
601 						break;
602 					case kSetAdjustPrefs_FindScript	:
603 						FindScript( &localPrefs );
604 						break;
605 					case kSetAdjustPrefs_SetPrefs:
606 						if( setSizePrefs( gsPrPtr, gTrPtr->mode & _hostCanResize ))
607 						{
608 							writePrefs((char*) gsPrPtr, _sizep );
609 						}
610 						break;
611 				},SetAdPrefs)
612 }
613 
614 
615 
616 
617 
618 //					CheckButton( kSetCreateOptions_PCu, 		FALSE);
619 
620 
SetCreateOptions(aPrefs * thePrefs)621 int SetCreateOptions(  aPrefs * thePrefs )
622 {
623 	GenDialog(aPrefs,
624 			   kSetCreateOptions_dlg, "Options for Insert/Extract",
625 			   {
626 					CheckButton( kSetCreateOptions_ImR, 		(localPrefs.im.format == _rectilinear ));
627 					CheckButton( kSetCreateOptions_ImP, 		(localPrefs.im.format == _panorama ));
628 					CheckButton( kSetCreateOptions_ImFf, 		(localPrefs.im.format == _fisheye_ff));
629 					CheckButton( kSetCreateOptions_ImFc, 		(localPrefs.im.format == _fisheye_circ));
630 					CheckButton( kSetCreateOptions_ImEq, 		(localPrefs.im.format == _equirectangular));
631 
632 					CheckButton( kSetCreateOptions_PRe, 		(localPrefs.pano.format == _rectilinear ));
633 					CheckButton( kSetCreateOptions_PPa, 		(localPrefs.pano.format == _panorama ));
634 					CheckButton( kSetCreateOptions_PSp, 		(localPrefs.pano.format == _equirectangular));
635 
636 					CheckButton( kSetCreateOptions_PSave, 		(*localPrefs.sBuf.destName != 0));
637 					CheckButton( kSetCreateOptions_SLoad, 		(*localPrefs.sBuf.srcName != 0));
638 
639 					CheckButton( kSetCreateOptions_SPaste, 		(localPrefs.sBuf.seam == _dest ));
640 					CheckButton( kSetCreateOptions_SBlend, 		(localPrefs.sBuf.seam == _middle ));
641 					CheckButton( kSetCreateOptions_SIm, 		(localPrefs.sBuf.colcorrect == 1 ));
642 					CheckButton( kSetCreateOptions_SBuf, 		(localPrefs.sBuf.colcorrect == 2 ));
643 					CheckButton( kSetCreateOptions_Sboth, 		(localPrefs.sBuf.colcorrect == 3 ));
644 					CheckButton( kSetCreateOptions_Snone, 		(localPrefs.sBuf.colcorrect == 0 ));
645 				},
646 				{
647 					SetText( kSetCreateOptions_ImHfov, 	"%g", 	localPrefs.im.hfov);
648 					SetText( kSetCreateOptions_ImW, 	"%ld", 	localPrefs.im.width);
649 					SetText( kSetCreateOptions_ImH, 	"%ld", 	localPrefs.im.height);
650 
651 					SetText( kSetCreateOptions_PHfov, 	"%g", 	localPrefs.pano.hfov);
652 					SetText( kSetCreateOptions_PWi, 	"%ld", 	localPrefs.pano.width);
653 					SetText( kSetCreateOptions_PHe, 	"%ld", 	localPrefs.pano.height);
654 					SetText( kSetCreateOptions_TY, 		"%g",	localPrefs.im.yaw);
655 					SetText( kSetCreateOptions_TP, 		"%g", 	localPrefs.im.pitch);
656 					SetText( kSetCreateOptions_TR, 		"%g", 	localPrefs.im.roll);
657 					SetText( kSetCreateOptions_SF, 		"%ld", 	localPrefs.sBuf.feather);
658 				},
659 				{
660 					GetText( kSetCreateOptions_ImHfov, 	"%lf", &localPrefs.im.hfov);
661 					GetText( kSetCreateOptions_ImW, 	"%ld", &localPrefs.im.width);
662 					GetText( kSetCreateOptions_ImH, 	"%ld", &localPrefs.im.height);
663 
664 					GetText( kSetCreateOptions_PHfov, 	"%lf", &localPrefs.pano.hfov);
665 					GetText( kSetCreateOptions_PWi, 	"%ld", &localPrefs.pano.width);
666 					GetText( kSetCreateOptions_PHe, 	"%ld", &localPrefs.pano.height);
667 					GetText( kSetCreateOptions_TY, 		"%lf", &localPrefs.im.yaw);
668 					GetText( kSetCreateOptions_TP, 		"%lf", &localPrefs.im.pitch);
669 					GetText( kSetCreateOptions_TR, 		"%lf", &localPrefs.im.roll);
670 					GetText( kSetCreateOptions_SF, 		"%ld", &localPrefs.sBuf.feather);
671 				},
672 				{
673 					case kSetCreateOptions_ImR:
674 						localPrefs.im.format = _rectilinear;
675 						break;
676 					case kSetCreateOptions_ImP:
677 						localPrefs.im.format = _panorama;
678 						break;
679 					case kSetCreateOptions_ImFf:
680 						localPrefs.im.format = _fisheye_ff;
681 						break;
682 					case kSetCreateOptions_ImFc:
683 						localPrefs.im.format = _fisheye_circ;
684 						break;
685 					case kSetCreateOptions_ImEq:
686 						localPrefs.im.format = _equirectangular;
687 						break;
688 					case kSetCreateOptions_Correct:
689 						SetCorrectPrefs(  &localPrefs.im.cP );
690 						break;
691 					case kSetCreateOptions_PRe:
692 						localPrefs.pano.format = _rectilinear;
693 						break;
694 					case kSetCreateOptions_PPa:
695 						localPrefs.pano.format = _panorama;
696 						break;
697 					case kSetCreateOptions_PSp:
698 						localPrefs.pano.format = _equirectangular;
699 						break;
700 					case kSetCreateOptions_PSave:
701 						if(*localPrefs.sBuf.destName != 0)
702 							*localPrefs.sBuf.destName = 0;
703 						else
704 							sprintf( localPrefs.sBuf.destName, "buf" );
705 						break;
706 					case kSetCreateOptions_SLoad:
707 						if(*localPrefs.sBuf.srcName != 0)
708 							*localPrefs.sBuf.srcName = 0;
709 						else
710 							sprintf( localPrefs.sBuf.srcName, "buf" );
711 						break;
712 					case kSetCreateOptions_SPaste:
713 						localPrefs.sBuf.seam = _dest;
714 						break;
715 					case kSetCreateOptions_SBlend:
716 						localPrefs.sBuf.seam = _middle;
717 						break;
718 					case kSetCreateOptions_SIm:
719 						localPrefs.sBuf.colcorrect = 1;
720 						break;
721 					case kSetCreateOptions_SBuf:
722 						localPrefs.sBuf.colcorrect = 2;
723 						break;
724 					case kSetCreateOptions_Sboth:
725 						localPrefs.sBuf.colcorrect = 3;
726 						break;
727 					case kSetCreateOptions_Snone:
728 						localPrefs.sBuf.colcorrect = 0;
729 						break;
730 					}, SetCrOpt)
731 }
732 
733 
734 
SetPanPrefs(panControls * thePrefs)735 int	SetPanPrefs(  panControls *thePrefs )
736 {
737 	GenDialog( panControls,
738 			   kSetShearOptions_dlg, "Pan Options",;,
739 			   {
740 					SetLbl( kSetShearOptions_vname,  "Pan Angle");
741 					SetLbl( kSetShearOptions_hname,  "Zoom (%)");
742 					SetText(  kSetShearOptions_vvar, "%g", localPrefs.panAngle);
743 					SetText(  kSetShearOptions_hvar, "%g", localPrefs.zoomFactor);
744 				},
745 			   {
746 					GetText( kSetShearOptions_vvar, "%lf", &localPrefs.panAngle);
747 					GetText( kSetShearOptions_hvar, "%lf", &localPrefs.zoomFactor);
748 				}, ;, SetPanOpt)
749 }
750 
751 
SetInterpolator(sPrefs * thePrefs)752 int SetInterpolator( sPrefs *thePrefs)
753 {
754   GenDialog( sPrefs,  kSetIntpPrefs_SetIntp, "Interpolation Options",
755       {
756         CheckButton( kSetIntpPrefs_Poly,        localPrefs.interpolator == _poly3 );
757         CheckButton( kSetIntpPrefs_Sp36,        localPrefs.interpolator == _spline36 );
758         CheckButton( kSetIntpPrefs_Sp64,        localPrefs.interpolator == _spline64 );
759         CheckButton( kSetIntpPrefs_Sinc256,     localPrefs.interpolator == _sinc256 );
760         CheckButton( kSetIntpPrefs_AAHammering, localPrefs.interpolator == _aahamming );
761         CheckButton( kSetIntpPrefs_AAGaussian,  localPrefs.interpolator == _aagaussian );
762         CheckButton( kSetIntpPrefs_AAQuadratic, localPrefs.interpolator == _aaquadratic );
763         CheckButton( kSetIntpPrefs_AAMitchell,  localPrefs.interpolator == _aamitchell );
764         CheckButton( kSetIntpPrefs_AALauczos2,  localPrefs.interpolator == _aalanczos2 );
765         CheckButton( kSetIntpPrefs_AALauczos3,  localPrefs.interpolator == _aalanczos3 );
766         CheckButton( kSetIntpPrefs_FastTNorm,   localPrefs.fastStep == FAST_TRANSFORM_STEP_NONE );
767         CheckButton( kSetIntpPrefs_FastTMed,    localPrefs.fastStep == FAST_TRANSFORM_STEP_MORPH );
768         CheckButton( kSetIntpPrefs_FastTFast,   localPrefs.fastStep == FAST_TRANSFORM_STEP_NORMAL );
769       },
770       {
771         SetText( kSetIntpPrefs_Gamma, 	"%g", 	localPrefs.gamma);
772       },
773       {
774         GetText( kSetIntpPrefs_Gamma, 	"%lf",  &localPrefs.gamma);
775       },
776       {
777         case kSetIntpPrefs_Poly:
778         localPrefs.interpolator = _poly3;
779         break;
780         case kSetIntpPrefs_Sp36:
781         localPrefs.interpolator = _spline36;
782         break;
783         case kSetIntpPrefs_Sp64:
784         localPrefs.interpolator = _spline64;
785         break;
786         case kSetIntpPrefs_Sinc256:
787         localPrefs.interpolator = _sinc256;
788         break;
789         case kSetIntpPrefs_AAHammering:
790         localPrefs.interpolator = _aahamming;
791         break;
792         case kSetIntpPrefs_AAGaussian:
793         localPrefs.interpolator = _aagaussian;
794         break;
795         case kSetIntpPrefs_AAQuadratic:
796         localPrefs.interpolator = _aaquadratic;
797         break;
798         case kSetIntpPrefs_AAMitchell:
799         localPrefs.interpolator = _aamitchell;
800         break;
801         case kSetIntpPrefs_AALauczos2:
802         localPrefs.interpolator = _aalanczos2;
803         break;
804         case kSetIntpPrefs_AALauczos3:
805         localPrefs.interpolator = _aalanczos3;
806         break;
807 
808         case kSetIntpPrefs_FastTNorm:
809         localPrefs.fastStep = FAST_TRANSFORM_STEP_NONE;
810         break;
811         case kSetIntpPrefs_FastTMed:
812         localPrefs.fastStep = FAST_TRANSFORM_STEP_MORPH;
813         break;
814         case kSetIntpPrefs_FastTFast:
815         localPrefs.fastStep = FAST_TRANSFORM_STEP_NORMAL;
816         break;
817       },
818       SetIntp )
819 }
820 
821 
822 #ifdef __Mac__
823 // can_resize = 0 if not.
824 
setSizePrefs(sPrefs * thePrefs,int can_resize)825 int setSizePrefs( sPrefs *thePrefs, int can_resize )
826 {
827 	GenDialog( sPrefs, kSetSizePrefs_dlg, "Preferences",
828 			{
829 				CheckButton( kSetSizePrefs_Crop,  localPrefs.displayPart );
830 				CheckButton( kSetSizePrefs_SFile,  localPrefs.saveFile );
831 				if(!can_resize)
832 				{
833 					CheckButton( kSetSizePrefs_OpenF,  localPrefs.launchApp );
834 					CheckButton( kSetSizePrefs_NoAlpha,  localPrefs.noAlpha );
835 				}
836 			},;,;,
837 			{
838 				case kSetSizePrefs_Crop:
839 					localPrefs.displayPart = !localPrefs.displayPart;
840 					break;
841 				case kSetSizePrefs_SFile:
842 					localPrefs.saveFile = !localPrefs.saveFile;
843 					break;
844 				case kSetSizePrefs_OpenF:
845 					localPrefs.launchApp = !localPrefs.launchApp;
846 					break;
847 				case kSetSizePrefs_BrFile:
848 					{
849 						fullPath path;
850 						if( SaveFileAs( &path, "Save Results as...", "ptools_result" ) == 0 )
851 						{
852 							memcpy( &(localPrefs.sFile), &path,  sizeof( fullPath ));
853 						}
854 					}
855 					break;
856 				case kSetSizePrefs_SetInt:
857 					SetInterpolator( &localPrefs );
858 					break;
859 				case kSetSizePrefs_NoAlpha:
860 					localPrefs.noAlpha = !localPrefs.noAlpha;
861 					break;
862 			 }, SetSiz )
863 }
864 
865 
866 #endif
867 
868 #ifdef __Win__
869 
setSizePrefs(sPrefs * thePrefs,int can_resize)870 int setSizePrefs( sPrefs *thePrefs, int can_resize )
871 {
872 	GenDialog( sPrefs, kSetSizePrefs_dlg, "Preferences",
873 			{
874 				CheckButton( kSetSizePrefs_Crop,  	localPrefs.displayPart );
875 				CheckButton( kSetSizePrefs_SFile,  	localPrefs.saveFile );
876 				CheckButton( kSetSizePrefs_OpenF,  	localPrefs.launchApp );
877 				CheckButton( kSetSizePrefs_NoAlpha,  	localPrefs.noAlpha );
878 			},
879 			{
880 				SetLbl( kSetSizePrefs_FileName,  (char*)&localPrefs.sFile);
881 				SetLbl( kSetSizePrefs_AppName,   (char*)&localPrefs.lApp);
882 			},
883 			{
884 				GetLbl( kSetSizePrefs_FileName, (char*)&(localPrefs.sFile), 255);
885 				GetLbl( kSetSizePrefs_AppName, (char*)&(localPrefs.lApp), 255);
886 			},
887 			{
888 				case kSetSizePrefs_Crop:
889 					localPrefs.displayPart = !localPrefs.displayPart;
890 					break;
891 				case kSetSizePrefs_SFile:
892 					localPrefs.saveFile = !localPrefs.saveFile;
893 					break;
894 				case kSetSizePrefs_OpenF:
895 					localPrefs.launchApp = !localPrefs.launchApp;
896 					break;
897 				case kSetSizePrefs_BrFile:
898 					{
899 						if( !SaveFileAs( &(localPrefs.sFile), "Save Results as...", "ptools_result" )  )
900 						{
901 							SetLbl( kSetSizePrefs_FileName,  (char*)&localPrefs.sFile);
902 						}
903 					}
904 					break;
905 				case kSetSizePrefs_SetInt:
906 					SetInterpolator( &localPrefs );
907 					break;
908 				case kSetSizePrefs_BrApp:
909 					{
910 						if( !FindFile( &(localPrefs.lApp )  ) )
911 						{
912 							SetLbl( kSetSizePrefs_AppName,   (char*)&localPrefs.lApp);
913 						}
914 					}
915 					break;
916 				case kSetSizePrefs_NoAlpha:
917 					localPrefs.noAlpha = !localPrefs.noAlpha;
918 					break;
919 			 }, SetSiz )
920 }
921 
922 #endif
923 
924 #if  !__Mac__  && !__Win__	// Gimp version
925 // can_resize  ignored
926 
setSizePrefs(sPrefs * thePrefs,int can_resize)927 int setSizePrefs( sPrefs *thePrefs, int can_resize )
928 {
929 	GenDialog( sPrefs, kSetSizePrefs_dlg, "Preferences",
930 			{
931 				CheckButton( kSetSizePrefs_Crop,  localPrefs.displayPart );
932 				CheckButton( kSetSizePrefs_SFile,  localPrefs.saveFile );
933 			},;,;,
934 			{
935 				case kSetSizePrefs_Crop:
936 					localPrefs.displayPart = !localPrefs.displayPart;
937 					break;
938 				case kSetSizePrefs_SFile:
939 					localPrefs.saveFile = !localPrefs.saveFile;
940 					break;
941 				case kSetSizePrefs_SetInt:
942 					SetInterpolator( &localPrefs );
943 					break;
944 			 }, SetSiz )
945 }
946 
947 #endif
948 
949 
950