+class BitmapControl : public wxPanel
+{
+private:
+ DECLARE_DYNAMIC_CLASS (BitmapControl)
+ DECLARE_EVENT_TABLE ()
+ wxBitmap* m_pBitmap;
+
+public:
+ BitmapControl (wxBitmap* pBitmap, wxWindow *parent, wxWindowID id = -1,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = wxSTATIC_BORDER,
+ const wxValidator& validator = wxDefaultValidator,
+ const wxString& name = "BitmapCtrl");
+
+
+ virtual ~BitmapControl();
+
+ virtual wxSize GetBestSize() const;
+
+ wxBitmap* getBitmap()
+ { return m_pBitmap; }
+
+ void OnPaint(wxPaintEvent& event);
+};
+
+
+BEGIN_EVENT_TABLE(BitmapControl, wxPanel)
+EVT_PAINT(BitmapControl::OnPaint)
+END_EVENT_TABLE()
+
+IMPLEMENT_CLASS(BitmapControl, wxPanel)
+
+
+BitmapControl::BitmapControl (wxBitmap* pBitmap, wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
+ long style, const wxValidator& validator, const wxString& name)
+ : m_pBitmap(pBitmap)
+{
+ Create(parent, id, pos, size, style, name);
+
+ SetSize (GetBestSize());
+}
+
+wxSize
+BitmapControl::GetBestSize () const
+{
+ if (m_pBitmap)
+ return wxSize (m_pBitmap->GetWidth(), m_pBitmap->GetHeight());
+ else
+ return wxSize(0,0);
+}
+
+BitmapControl::~BitmapControl()
+{}
+
+void
+BitmapControl::OnPaint (wxPaintEvent& event)
+{
+ wxPaintDC dc(this);
+ if (m_pBitmap)
+ dc.DrawBitmap (*m_pBitmap, 0, 0);
+}
+
+
+class BitmapDialog : public wxDialog {
+private:
+ BitmapControl* m_pBitmapCtrl;
+
+public:
+ BitmapDialog (wxBitmap* pBitmap, char const* pszTitle);
+ virtual ~BitmapDialog();
+};
+
+BitmapDialog::BitmapDialog (wxBitmap* pBitmap, char const* pszTitle)
+: wxDialog(theApp->getMainFrame(), -1, wxString(pszTitle), wxDefaultPosition, wxDefaultSize, wxDIALOG_MODAL | wxDEFAULT_DIALOG_STYLE)
+{
+ wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
+
+ pTopSizer->Add (new BitmapControl (pBitmap, this), 0, wxALIGN_CENTER | wxALL, 5);
+
+ wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
+ wxButton* pButtonOk = new wxButton (this, wxID_OK, "Ok");
+ pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
+
+ pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
+
+ SetAutoLayout (true);
+ SetSizer (pTopSizer);
+ pTopSizer->Fit (this);
+ pTopSizer->SetSizeHints (this);
+}
+
+BitmapDialog::~BitmapDialog()
+{}
+
+
+#include "./splash.xpm"
+void
+MainFrame::OnAbout(wxCommandEvent& WXUNUSED(event) )
+{
+ wxBitmap bmp (splash);
+ if (bmp.Ok()) {
+ BitmapDialog dlg (&bmp, "About CTSim");
+ dlg.Show(true);
+ } else {
+ wxString msg = "CTSim\nThe Open Source Computed Tomography Simulator\n";
+#ifdef CTSIMVERSION
+ msg += "Version ";
+ msg += CTSIMVERSION;
+ msg += "\n\n";
+#elif defined(VERSION)
+ msg << "Version: " << VERSION << "\n\n";
+#endif
+ msg += "Author: Kevin Rosenberg <kevin@rosenberg.net>\nUsage: ctsim [files-to-open..] [--help]";
+
+ wxMessageBox(msg, "About CTSim", wxOK | wxICON_INFORMATION, this);
+ }
+}
+
+
+ProjectionFileDocument*
+CTSimApp::newProjectionDoc()
+{
+ ProjectionFileDocument* newDoc = dynamic_cast<ProjectionFileDocument*>(m_pDocTemplProjection->CreateDocument (""));
+ if (newDoc) {
+ ProjectionFileView* pView = newDoc->getView();
+ if (pView) {
+ wxFrame* pFrame = pView->getFrame();
+ if (pFrame) {
+ pFrame->SetSize (0,0);
+ pFrame->Show (false);
+ }
+ }
+ newDoc->SetDocumentName (m_pDocTemplProjection->GetDocumentName());
+ newDoc->SetDocumentTemplate (m_pDocTemplProjection);
+ newDoc->OnNewDocument();
+ }
+
+ return newDoc;
+}
+
+ImageFileDocument*
+CTSimApp::newImageDoc()
+{
+ ImageFileDocument* newDoc = dynamic_cast<ImageFileDocument*>(m_pDocTemplImage->CreateDocument (""));
+ if (newDoc) {
+ ImageFileView* pView = newDoc->getView();
+ if (pView) {
+ wxFrame* pFrame = pView->getFrame();
+ if (pFrame) {
+ pFrame->SetSize (0,0);
+ pFrame->Show (false);
+ }
+ }
+ newDoc->SetDocumentName (m_pDocTemplImage->GetDocumentName());
+ newDoc->SetDocumentTemplate (m_pDocTemplImage);
+ newDoc->OnNewDocument();
+ }
+
+ return newDoc;
+}
+
+PlotFileDocument*
+CTSimApp::newPlotDoc()
+{
+ PlotFileDocument* newDoc = dynamic_cast<PlotFileDocument*>(m_pDocTemplPlot->CreateDocument (""));
+ if (newDoc) {
+ PlotFileView* pView = newDoc->getView();
+ if (pView) {
+ wxFrame* pFrame = pView->getFrame();
+ if (pFrame) {
+ wxSize size;
+ m_pFrame->GetClientSize (&size.x, &size.y);
+ pFrame->SetSize (size.x / 2, size.y / 2);
+ pFrame->Show (false);
+ }
+ }
+ newDoc->SetDocumentName (m_pDocTemplPlot->GetDocumentName());
+ newDoc->SetDocumentTemplate (m_pDocTemplPlot);
+ newDoc->OnNewDocument();
+ }
+
+ return newDoc;
+}
+
+
+TextFileDocument*
+CTSimApp::newTextDoc()
+{
+ wxString strFilename (getUntitledFilename());
+ strFilename += ".txt";
+
+ TextFileDocument* newDoc = dynamic_cast<TextFileDocument*>(m_pDocTemplText->CreateDocument (""));
+ if (newDoc) {
+ TextFileView* pView = newDoc->getView();
+ if (pView) {
+ wxFrame* pFrame = pView->getFrame();
+ if (pFrame) {
+ wxSize size;
+ m_pFrame->GetClientSize (&size.x, &size.y);;
+ pFrame->SetSize (size.x / 2, size.y / 2);
+ pFrame->Show (false);
+ }
+ }
+ newDoc->SetDocumentName (m_pDocTemplText->GetDocumentName());
+ newDoc->SetDocumentTemplate (m_pDocTemplText);
+ newDoc->OnNewDocument();
+ }
+
+ return newDoc;
+}
+
+
+PhantomFileDocument*
+CTSimApp::newPhantomDoc()
+{
+ PhantomFileDocument* newDoc = dynamic_cast<PhantomFileDocument*>(m_pDocTemplPhantom->CreateDocument (""));
+ if (newDoc) {
+ PhantomFileView* pView = newDoc->getView();
+ if (pView) {
+ wxFrame* pFrame = pView->getFrame();
+ if (pFrame)
+ pFrame->SetSize (0,0);
+ }
+ newDoc->SetDocumentName (m_pDocTemplPhantom->GetDocumentName());
+ newDoc->SetDocumentTemplate (m_pDocTemplPhantom);
+ newDoc->OnNewDocument();
+ }
+
+ return newDoc;
+}
+
+#if wxUSE_GLCANVAS
+
+Graph3dFileDocument*
+CTSimApp::newGraph3dDoc()
+{
+ Graph3dFileDocument* newDoc = dynamic_cast<Graph3dFileDocument*>(m_pDocTemplGraph3d->CreateDocument (""));
+ if (newDoc) {
+ Graph3dFileView* pView = newDoc->getView();
+ if (pView) {
+ wxFrame* pFrame = pView->getFrame();
+ if (pFrame)
+ pFrame->SetSize (0,0);
+ }
+ newDoc->SetDocumentName (m_pDocTemplGraph3d->GetDocumentName());
+ newDoc->SetDocumentTemplate (m_pDocTemplGraph3d);
+ newDoc->OnNewDocument();
+ }
+
+ return newDoc;
+}
+#endif