1 /*****************************************************************************
5 ** Purpose: Dialog routines for CTSim program
6 ** Programmer: Kevin Rosenberg
7 ** Date Started: July 2000
9 ** This is part of the CTSim program
10 ** Copyright (C) 1983-2000 Kevin Rosenberg
12 ** $Id: dialogs.cpp,v 1.2 2000/07/18 14:51:06 kevin Exp $
14 ** This program is free software; you can redistribute it and/or modify
15 ** it under the terms of the GNU General Public License (version 2) as
16 ** published by the Free Software Foundation.
18 ** This program is distributed in the hope that it will be useful,
19 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ** GNU General Public License for more details.
23 ** You should have received a copy of the GNU General Public License
24 ** along with this program; if not, write to the Free Software
25 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 ******************************************************************************/
29 // #pragma implementation
32 // For compilers that support precompilation, includes "wx/wx.h".
33 #include "wx/wxprec.h"
43 #if !wxUSE_DOC_VIEW_ARCHITECTURE
44 #error You must set wxUSE_DOC_VIEW_ARCHITECTURE to 1 in setup.h!
47 #include "wx/statline.h"
51 #include "ctsupport.h"
54 DialogGetImageMinMax::DialogGetImageMinMax (wxFrame* pParent, const ImageFile& rImagefile, double dDefaultMin = 0., double dDefaultMax = 0.)
55 : wxDialog (pParent, -1, "Set Image Display Minimum & Maximum", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
57 wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
59 pTopSizer->Add (new wxStaticText (this, -1, "Set Image Display Minimum and Maximum"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
61 pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
65 m_pTextCtrlMin = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
68 m_pTextCtrlMax = new wxTextCtrl (this, -1, osMax.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
70 wxGridSizer *pGridSizer = new wxGridSizer (2, 2, 5);
71 pGridSizer->Add (new wxStaticText (this, -1, "Minimum"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
72 pGridSizer->Add (m_pTextCtrlMin, 0, wxALIGN_CENTER_VERTICAL);
73 pGridSizer->Add (new wxStaticText (this, -1, "Maximum"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
74 pGridSizer->Add (m_pTextCtrlMax, 0, wxALIGN_CENTER_VERTICAL);
75 pTopSizer->Add (pGridSizer, 1, wxALL, 10);
77 pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
79 wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
80 wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
81 wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
82 pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
83 pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
85 pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
89 pTopSizer->Fit (this);
90 pTopSizer->SetSizeHints (this);
93 DialogGetImageMinMax::~DialogGetImageMinMax (void)
96 delete m_pTextCtrlMin;
97 delete m_pTextCtrlMax;
102 DialogGetImageMinMax::getMinimum (void)
104 wxString strCtrl = m_pTextCtrlMin->GetValue();
106 if (strCtrl.ToDouble (&dValue))
109 return (m_dDefaultMin);
113 DialogGetImageMinMax::getMaximum (void)
115 wxString strCtrl = m_pTextCtrlMax->GetValue();
117 if (strCtrl.ToDouble (&dValue))
120 return (m_dDefaultMax);
124 /////////////////////////////////////////////////////////////////////
125 // CLASS IDENTIFICATION
127 // DialogGetRasterParameters
128 /////////////////////////////////////////////////////////////////////
130 DialogGetRasterParameters::DialogGetRasterParameters (wxFrame* pParent, int iDefaultXSize = 0, int iDefaultYSize = 0, int iDefaultNSamples = 1)
131 : wxDialog (pParent, -1, "Set Rasterization Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
133 wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
135 pTopSizer->Add (new wxStaticText (this, -1, "Set Rasterization Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
137 pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
141 m_pTextCtrlXSize = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
142 ostringstream osYSize;
143 osYSize << iDefaultYSize;
144 m_pTextCtrlYSize = new wxTextCtrl (this, -1, osYSize.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
145 ostringstream osNSamples;
146 osNSamples << iDefaultNSamples;
147 m_pTextCtrlNSamples = new wxTextCtrl (this, -1, osNSamples.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
149 wxGridSizer *pGridSizer = new wxGridSizer (2, 3, 5);
150 pGridSizer->Add (new wxStaticText (this, -1, "X Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
151 pGridSizer->Add (m_pTextCtrlXSize, 0, wxALIGN_CENTER_VERTICAL);
152 pGridSizer->Add (new wxStaticText (this, -1, "Y Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
153 pGridSizer->Add (m_pTextCtrlYSize, 0, wxALIGN_CENTER_VERTICAL);
154 pGridSizer->Add (new wxStaticText (this, -1, "Samples per Pixel"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
155 pGridSizer->Add (m_pTextCtrlNSamples, 0, wxALIGN_CENTER_VERTICAL);
156 pTopSizer->Add (pGridSizer, 1, wxALL, 10);
158 pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
160 wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
161 wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
162 wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
163 pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
164 pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
166 pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
168 SetAutoLayout (true);
169 SetSizer (pTopSizer);
170 pTopSizer->Fit (this);
171 pTopSizer->SetSizeHints (this);
174 DialogGetRasterParameters::~DialogGetRasterParameters (void)
180 DialogGetRasterParameters::getXSize (void)
182 wxString strCtrl = m_pTextCtrlXSize->GetValue();
183 unsigned long lValue;
184 if (strCtrl.ToULong (&lValue))
187 return (m_iDefaultXSize);
191 DialogGetRasterParameters::getYSize (void)
193 wxString strCtrl = m_pTextCtrlYSize->GetValue();
194 unsigned long lValue;
195 if (strCtrl.ToULong (&lValue))
198 return (m_iDefaultYSize);
203 DialogGetRasterParameters::getNSamples (void)
205 wxString strCtrl = m_pTextCtrlNSamples->GetValue();
206 unsigned long lValue;
207 if (strCtrl.ToULong (&lValue))
210 return (m_iDefaultNSamples);
215 /////////////////////////////////////////////////////////////////////
216 // CLASS IDENTIFICATION
218 // DialogGetProjectionsParameters
219 /////////////////////////////////////////////////////////////////////
221 DialogGetProjectionParameters::DialogGetProjectionParameters (wxFrame* pParent, int iDefaultNDet = 0, int iDefaultNView = 0, int iDefaultNSamples = 1, double dDefaultRotAngle = 1., const char* szDefaultGeometry = NULL)
222 : wxDialog (pParent, -1, "Set Projection Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
224 wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
226 pTopSizer->Add (new wxStaticText (this, -1, "Set Projection Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
228 pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
232 m_pTextCtrlNDet = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
233 ostringstream osNView;
234 osNView << iDefaultNView;
235 m_pTextCtrlNView = new wxTextCtrl (this, -1, osNView.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
236 ostringstream osNSamples;
237 osNSamples << iDefaultNSamples;
238 m_pTextCtrlNSamples = new wxTextCtrl (this, -1, osNSamples.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
239 ostringstream osRotAngle;
240 osRotAngle << dDefaultRotAngle;
241 m_pTextCtrlRotAngle = new wxTextCtrl (this, -1, osRotAngle.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
243 wxGridSizer *pGridSizer = new wxGridSizer (2, 4, 5);
244 pGridSizer->Add (new wxStaticText (this, -1, "Detectors"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
245 pGridSizer->Add (m_pTextCtrlNDet, 0, wxALIGN_CENTER_VERTICAL);
246 pGridSizer->Add (new wxStaticText (this, -1, "Views"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
247 pGridSizer->Add (m_pTextCtrlNView, 0, wxALIGN_CENTER_VERTICAL);
248 pGridSizer->Add (new wxStaticText (this, -1, "Samples per Detector"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
249 pGridSizer->Add (m_pTextCtrlNSamples, 0, wxALIGN_CENTER_VERTICAL);
250 pGridSizer->Add (new wxStaticText (this, -1, "Rotation Angle (PI units)"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
251 pGridSizer->Add (m_pTextCtrlRotAngle, 0, wxALIGN_CENTER_VERTICAL);
252 pTopSizer->Add (pGridSizer, 1, wxALL, 10);
253 m_sDefaultGeometry = szDefaultGeometry;
255 pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
257 wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
258 wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
259 wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
260 pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
261 pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
263 pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
265 SetAutoLayout (true);
266 SetSizer (pTopSizer);
267 pTopSizer->Fit (this);
268 pTopSizer->SetSizeHints (this);
271 DialogGetProjectionParameters::~DialogGetProjectionParameters (void)
277 DialogGetProjectionParameters::getNDet (void)
279 wxString strCtrl = m_pTextCtrlNDet->GetValue();
280 unsigned long lValue;
281 if (strCtrl.ToULong (&lValue))
284 return (m_iDefaultNDet);
288 DialogGetProjectionParameters::getNView (void)
290 wxString strCtrl = m_pTextCtrlNView->GetValue();
291 unsigned long lValue;
292 if (strCtrl.ToULong (&lValue))
295 return (m_iDefaultNView);
300 DialogGetProjectionParameters::getNSamples (void)
302 wxString strCtrl = m_pTextCtrlNSamples->GetValue();
303 unsigned long lValue;
304 if (strCtrl.ToULong (&lValue))
307 return (m_iDefaultNSamples);
311 DialogGetProjectionParameters::getRotAngle (void)
313 wxString strCtrl = m_pTextCtrlRotAngle->GetValue();
315 if (strCtrl.ToDouble (&dValue))
316 return (dValue * PI);
318 return (m_dDefaultRotAngle);
322 DialogGetProjectionParameters::getGeometry (void)
324 return m_sDefaultGeometry;