1 /*****************************************************************************
2 ** This is part of the CTSim program
3 ** Copyright (C) 1983-2000 Kevin Rosenberg
5 ** $Id: dialogs.cpp,v 1.1 2000/06/19 02:59:34 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 ******************************************************************************/
25 * phm_add_pelem_kb Let user specify pelem, and add it to the pic
28 * phm_add_pelem_kb (phm)
29 * Phantom& pic PHANTOM that we are to add pelem to
32 * true if user added an pelem to PHANTOM
33 * false if user decided not to add an pelem to the PHANTOM
37 phm_add_pelem_kb (Phantom& phm)
47 crt_put_str ("1 = Rectangle, 2 = Triangle, 3 = Ellipse, 4 = Sector, 5 = Segment");
49 crt_put_str ("Enter pelem type (1-5, 0 = no pelem) -- ");
50 scanf ("%d", &pelemtype);
57 double cx, cy, u, v, rot, dens;
61 crt_put_str ("Enter pelem specs (cx, cy, u, v, rot, density) -- ");
62 scanf ("%lf %lf %lf %lf %lf %lf %*c", &cx, &cy, &u, &v, &rot, &dens);
64 phm.addPelem (phm, pelemtype, cx, cy, u, v, rot, dens);
66 } while (retval == true);
71 const Phantom& phm_select (Phantom& phm)
76 printf ("Which phantom do you want to compile into pixels:\n");
77 printf (" 1 - Herman head phantom\n");
78 printf (" 2 - Rowland head phantom\n");
80 printf (" 4 - Rowland head phantom (Bordered)\n");
81 printf (" 6 - A Filter\n");
82 printf (" 7 - Unit pulse\n");
83 printf (" 8 - Enter PHANTOM from file\n");
84 printf (" 9 - Enter PHANTOM from keyboard\n");
85 printf ("Enter the number corresponding to your choice: ");
86 scanf ("%d%*c", &phmnum);
96 phm.std_rowland_bordered ();
99 phm.setComposition (P_FILTER);
102 phm.setComposition (P_UNIT_PULSE);
103 phm.addPelem (1, 0., 0., 100., 100., 0., 0.); /* outline */
104 phm.addPelem (3, 0., 0., 1., 1., 0., 1.); /* pulse */
107 printf ("Enter name of file: ");
108 scanf ("%s %*c", fname);
109 phm.setComposition (P_PELEMS);
110 if (phm.createFromFile (fname) == false)
111 cerr << "File " << fname << " doesn't contain valid Phantom declaration" << endl;
115 phm_add_pelem_kb (phm);
119 sys_error (ERR_FATAL, "Illegal Phantom number %d\n", phmnum);
127 * interpolation_select Let user select an interpolation method
130 * interpolation_type = interpolation_select()
131 * int interpolation_type Method of interpolation to use
134 int interpolation_select (void)
141 printf ("What interpolation method do you want to use:\n");
142 printf (" %2d - Nearest neighbor\n", I_NEAREST);
143 printf (" %2d - Linear\n", I_LINEAR);
144 printf (" %2d - B-Spline\n", I_BSPLINE);
145 printf ("Enter number corresponding to desired method: ");
146 scanf ("%d", &interp_type);
149 if (interp_name_of (interp_type) == NULL) {
157 return (interp_type);
162 * filter_select Let user select a filter
165 * filter_type = filt_select (filt_param)
166 * int filt_type Type of filter to use
167 * double *filt_param Returns parameter to filter
168 * Currently, only used with Hamming filters
172 filter_select (double *filt_param)
179 printf ("Which filter would you like to use:\n");
180 printf (" %2d - Bandlimiting\n", FILTER_BANDLIMIT);
181 printf (" %2d - Sinc\n", FILTER_SINC);
182 printf (" %2d - Hamming\n", FILTER_G_HAMMING);
183 printf (" %2d - Cosine\n", FILTER_COSINE);
184 printf (" %2d - Triangle\n", FILTER_TRIANGLE);
185 printf (" %2d - Abs * Bandlimit\n", FILTER_ABS_BANDLIMIT);
186 printf (" %2d - Abs * Sinc\n", FILTER_ABS_SINC);
187 printf (" %2d - Abs * Hamming \n", FILTER_ABS_G_HAMMING);
188 printf (" %2d - Abs * Cosine\n", FILTER_ABS_COSINE);
189 printf (" %2d - Shepp-Logan\n", FILTER_SHEPP);
190 printf ("Enter number corresponding to desired filter: ");
191 scanf ("%d", &filt_type);
193 if (filter_name_of (filt_type) == NULL) {
201 if (filt_type == FILTER_G_HAMMING || filt_type == FILTER_ABS_G_HAMMING) {
202 cout << "Enter alpha (0-1): " << flush;