1 /*****************************************************************************
4 ** Name: dlgprojections.cpp
5 ** Purpose: Projection Collection Animation Dialog
6 ** Programmer: Kevin Rosenberg
7 ** Date Started: August 2000
9 ** This is part of the CTSim program
10 ** Copyright (C) 1983-2000 Kevin Rosenberg
12 ** $Id: dlgprojections.cpp,v 1.1 2000/08/27 20:32:55 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 "dlgprojections.h"
32 // For compilers that support precompilation, includes "wx.h".
33 #include "wx/wxprec.h"
42 #include "wx/button.h"
43 #include "wx/stattext.h"
44 #include "wx/layout.h"
47 #include "wx/settings.h"
48 #include "wx/dcclient.h"
52 #include "dlgprojections.h"
56 static const int LAYOUT_X_MARGIN = 4;
57 static const int LAYOUT_Y_MARGIN = 4;
59 BEGIN_EVENT_TABLE(ProjectionsDialog, wxDialog)
60 EVT_BUTTON(wxID_CANCEL, ProjectionsDialog::OnCancel)
61 EVT_CLOSE(ProjectionsDialog::OnClose)
64 IMPLEMENT_CLASS(ProjectionsDialog, wxDialog)
67 ProjectionsDialog::ProjectionsDialog (Scanner& rScanner, Projections& rProj, const Phantom& rPhantom, const int iTrace, wxWindow *parent)
68 : wxDialog(parent, -1, "Collect Projections"), m_rScanner(rScanner), m_rProjections(rProj), m_rPhantom(rPhantom), m_pSGPDriver(NULL), m_pSGP(NULL), m_iTrace(iTrace), m_pDC(NULL)
73 while ( m_parentTop && m_parentTop->GetParent() )
74 m_parentTop = m_parentTop->GetParent();
76 m_btnAbort = new wxButton(this, wxID_CANCEL, _("Cancel"));
77 wxLayoutConstraints* c = new wxLayoutConstraints;
78 c->right.SameAs(this, wxRight, 2*LAYOUT_X_MARGIN);
79 c->bottom.SameAs(this, wxBottom, 2*LAYOUT_Y_MARGIN);
81 wxSize sizeBtn = wxButton::GetDefaultSize();
82 c->width.Absolute(sizeBtn.x);
83 c->height.Absolute(sizeBtn.y);
85 m_btnAbort->SetConstraints(c);
90 wxSize sizeDlg (600,600);
91 if (sizeDlg.x != sizeDlg.y) {
92 sizeDlg.x = max(sizeDlg.x,sizeDlg.y);
93 sizeDlg.y = max(sizeDlg.x,sizeDlg.y);
95 SetClientSize(sizeDlg);
97 Centre(wxCENTER_FRAME | wxBOTH);
100 m_parentTop->Enable(FALSE);
103 Enable(TRUE); // enable this window
105 m_pDC = dynamic_cast<wxDC*> (new wxClientDC (this));
107 this->GetClientSize(&x, &y);
108 m_pSGPDriver = new SGPDriver (m_pDC, x, y);
109 m_pSGP = new SGP (*m_pSGPDriver);
111 wxYield(); // Update the display
114 MacUpdateImmediately();
119 ProjectionsDialog::projectView (int iViewNumber)
121 if ( iViewNumber < m_rProjections.nView() ) {
122 m_rScanner.collectProjections (m_rProjections, m_rPhantom, iViewNumber, 1, true, m_iTrace, m_pSGP);
123 wxYield(); // update the display
125 m_state = Finished; // so that we return TRUE below and
126 // that [Cancel] handler knew what to do
129 m_btnAbort->SetLabel(_("Close")); // tell the user what he should do...
137 MacUpdateImmediately();
140 return m_state != Canceled;
146 void ProjectionsDialog::OnCancel (wxCommandEvent& event)
148 if ( m_state == Finished ) {
149 // this means that the count down is already finished and we're being
150 // shown as a modal dialog - so just let the default handler do the job
153 // request to cancel was received, the next time Update() is called we
157 // update the button state immediately so that the user knows that the
158 // request has been noticed
159 m_btnAbort->Disable();
163 void ProjectionsDialog::OnClose(wxCloseEvent& event)
165 if ( m_state == Uncancelable )
166 event.Veto(TRUE); // can't close this dialog
167 else if ( m_state == Finished )
168 event.Skip(); // let the default handler close the window as we already terminated
170 m_state = Canceled; // next Update() will notice it
174 /////////////////////////////////////////////////////
177 ProjectionsDialog::~ProjectionsDialog()
180 m_parentTop->Enable(TRUE);