1 /*****************************************************************************
2 ** This is part of the CTSim program
3 ** Copyright (C) 1983-2000 Kevin Rosenberg
5 ** $Id: dialogs.cpp,v 1.2 2000/06/22 10:42:39 kevin Exp $
7 ** This program is free software; you can redistribute it and/or modify
8 ** it under the terms of the GNU General Public License (version 2) as
9 ** published by the Free Software Foundation.
11 ** This program is distributed in the hope that it will be useful,
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ** GNU General Public License for more details.
16 ** You should have received a copy of the GNU General Public License
17 ** along with this program; if not, write to the Free Software
18 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ******************************************************************************/
23 /*************************************************************************
24 * FUNCTION DECLARATIONS
25 ************************************************************************/
28 bool phm_add_pelem_kb (Phantom& phm);
29 const Phantom& phm_select (Phantom& phm);
30 int interpolation_select (void);
31 int filter_select (double *filter_param);
35 * phm_add_pelem_kb Let user specify pelem, and add it to the pic
38 * phm_add_pelem_kb (phm)
39 * Phantom& pic PHANTOM that we are to add pelem to
42 * true if user added an pelem to PHANTOM
43 * false if user decided not to add an pelem to the PHANTOM
47 phm_add_pelem_kb (Phantom& phm)
57 crt_put_str ("1 = Rectangle, 2 = Triangle, 3 = Ellipse, 4 = Sector, 5 = Segment");
59 crt_put_str ("Enter pelem type (1-5, 0 = no pelem) -- ");
60 scanf ("%d", &pelemtype);
67 double cx, cy, u, v, rot, dens;
71 crt_put_str ("Enter pelem specs (cx, cy, u, v, rot, density) -- ");
72 scanf ("%lf %lf %lf %lf %lf %lf %*c", &cx, &cy, &u, &v, &rot, &dens);
74 phm.addPelem (phm, pelemtype, cx, cy, u, v, rot, dens);
76 } while (retval == true);
81 const Phantom& phm_select (Phantom& phm)
86 printf ("Which phantom do you want to compile into pixels:\n");
87 printf (" 1 - Herman head phantom\n");
88 printf (" 2 - Rowland head phantom\n");
90 printf (" 4 - Rowland head phantom (Bordered)\n");
91 printf (" 6 - A Filter\n");
92 printf (" 7 - Unit pulse\n");
93 printf (" 8 - Enter PHANTOM from file\n");
94 printf (" 9 - Enter PHANTOM from keyboard\n");
95 printf ("Enter the number corresponding to your choice: ");
96 scanf ("%d%*c", &phmnum);
106 phm.std_rowland_bordered ();
109 phm.setComposition (P_FILTER);
112 phm.setComposition (P_UNIT_PULSE);
113 phm.addPelem (1, 0., 0., 100., 100., 0., 0.); /* outline */
114 phm.addPelem (3, 0., 0., 1., 1., 0., 1.); /* pulse */
117 printf ("Enter name of file: ");
118 scanf ("%s %*c", fname);
119 phm.setComposition (P_PELEMS);
120 if (phm.createFromFile (fname) == false)
121 cerr << "File " << fname << " doesn't contain valid Phantom declaration" << endl;
125 phm_add_pelem_kb (phm);
129 sys_error (ERR_FATAL, "Illegal Phantom number %d\n", phmnum);
137 * interpolation_select Let user select an interpolation method
140 * interpolation_type = interpolation_select()
141 * int interpolation_type Method of interpolation to use
144 int interpolation_select (void)
151 printf ("What interpolation method do you want to use:\n");
152 printf (" %2d - Nearest neighbor\n", I_NEAREST);
153 printf (" %2d - Linear\n", I_LINEAR);
154 printf (" %2d - B-Spline\n", I_BSPLINE);
155 printf ("Enter number corresponding to desired method: ");
156 scanf ("%d", &interp_type);
159 if (interp_name_of (interp_type) == NULL) {
167 return (interp_type);
172 * filter_select Let user select a filter
175 * filter_type = filt_select (filt_param)
176 * int filt_type Type of filter to use
177 * double *filt_param Returns parameter to filter
178 * Currently, only used with Hamming filters
182 filter_select (double *filt_param)
189 printf ("Which filter would you like to use:\n");
190 printf (" %2d - Bandlimiting\n", FILTER_BANDLIMIT);
191 printf (" %2d - Sinc\n", FILTER_SINC);
192 printf (" %2d - Hamming\n", FILTER_G_HAMMING);
193 printf (" %2d - Cosine\n", FILTER_COSINE);
194 printf (" %2d - Triangle\n", FILTER_TRIANGLE);
195 printf (" %2d - Abs * Bandlimit\n", FILTER_ABS_BANDLIMIT);
196 printf (" %2d - Abs * Sinc\n", FILTER_ABS_SINC);
197 printf (" %2d - Abs * Hamming \n", FILTER_ABS_G_HAMMING);
198 printf (" %2d - Abs * Cosine\n", FILTER_ABS_COSINE);
199 printf (" %2d - Shepp-Logan\n", FILTER_SHEPP);
200 printf ("Enter number corresponding to desired filter: ");
201 scanf ("%d", &filt_type);
203 if (filter_name_of (filt_type) == NULL) {
211 if (filt_type == FILTER_G_HAMMING || filt_type == FILTER_ABS_G_HAMMING) {
212 cout << "Enter alpha (0-1): " << flush;