From 16d093f9366acfccee0f701f736840bcd47c0709 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Tue, 18 Jul 2000 14:51:06 +0000 Subject: [PATCH] r153: *** empty log message *** --- ChangeLog | 4 + include/scanner.h | 5 +- src/dialogs.cpp | 241 ++++++++++++++++++++++++++++++++++++++++++---- src/dialogs.h | 55 ++++++++++- src/views.cpp | 104 +++++++++++++++----- src/views.h | 4 +- 6 files changed, 360 insertions(+), 53 deletions(-) diff --git a/ChangeLog b/ChangeLog index 13f950d..f13e24e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2.0.0-b6 - 7/19/00 + ctsim program: improved initial size and scroll area for image and projection files + ctsim program: added rasterization dialog + 2.0.0-b5 - 7/17/00 ctsim program: Added dialog to set minimum/maximum display levels Started ctsim.tex document file diff --git a/include/scanner.h b/include/scanner.h index 39a9002..1a01c89 100644 --- a/include/scanner.h +++ b/include/scanner.h @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: scanner.h,v 1.5 2000/06/25 17:32:24 kevin Exp $ +** $Id: scanner.h,v 1.6 2000/07/18 14:51:06 kevin Exp $ ** ** ** This program is free software; you can redistribute it and/or modify @@ -30,7 +30,8 @@ #define SCANNER_H class Projections; - +class Phantom; +class PhantomElement; // Projections are collected along an array of ndet detectors. The data // for these detectors is stored in the class DetectorArray diff --git a/src/dialogs.cpp b/src/dialogs.cpp index 4c8d967..4b37f4b 100644 --- a/src/dialogs.cpp +++ b/src/dialogs.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: dialogs.cpp,v 1.1 2000/07/18 03:14:35 kevin Exp $ +** $Id: dialogs.cpp,v 1.2 2000/07/18 14:51:06 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -48,14 +48,18 @@ #include "wx/sizer.h" #include "dialogs.h" #include +#include "ctsupport.h" +#include "scanner.h" DialogGetImageMinMax::DialogGetImageMinMax (wxFrame* pParent, const ImageFile& rImagefile, double dDefaultMin = 0., double dDefaultMax = 0.) - : wxDialog (pParent, -1, "Set Image Display Minimum & Maximum", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxCAPTION), m_pTopSizer(NULL), m_pTextCtrlMin(NULL), m_pTextCtrlMax(NULL), m_pButtonSizer(NULL), m_pButtonOk(NULL), m_pButtonCancel(NULL), m_dDefaultMin(dDefaultMin), m_dDefaultMax(dDefaultMax) + : wxDialog (pParent, -1, "Set Image Display Minimum & Maximum", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION) { - wxBoxSizer* m_pTopSizer = new wxBoxSizer (wxVERTICAL); + wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL); - m_pTopSizer->Add (new wxStaticText (this, -1, "Set Image Display Minimum and Maximum"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5); + pTopSizer->Add (new wxStaticText (this, -1, "Set Image Display Minimum and Maximum"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5); + pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5); + ostringstream os; os << dDefaultMin; m_pTextCtrlMin = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); @@ -68,33 +72,29 @@ DialogGetImageMinMax::DialogGetImageMinMax (wxFrame* pParent, const ImageFile& r pGridSizer->Add (m_pTextCtrlMin, 0, wxALIGN_CENTER_VERTICAL); pGridSizer->Add (new wxStaticText (this, -1, "Maximum"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); pGridSizer->Add (m_pTextCtrlMax, 0, wxALIGN_CENTER_VERTICAL); - m_pTopSizer->Add (pGridSizer, 1, wxALL, 10); + pTopSizer->Add (pGridSizer, 1, wxALL, 10); - m_pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5); + pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5); - m_pButtonSizer = new wxBoxSizer (wxHORIZONTAL); - m_pButtonOk = new wxButton (this, wxID_OK, "Okay"); - m_pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel"); - m_pButtonSizer->Add (m_pButtonOk, 0, wxEXPAND | wxALL, 10); - m_pButtonSizer->Add (m_pButtonCancel, 0, wxEXPAND | wxALL, 10); + wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL); + wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay"); + wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel"); + pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10); + pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10); - m_pTopSizer->Add (m_pButtonSizer, 0, wxALIGN_CENTER); + pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER); SetAutoLayout (true); - SetSizer (m_pTopSizer); - m_pTopSizer->Fit (this); - m_pTopSizer->SetSizeHints (this); + SetSizer (pTopSizer); + pTopSizer->Fit (this); + pTopSizer->SetSizeHints (this); } DialogGetImageMinMax::~DialogGetImageMinMax (void) { #if 0 - delete m_pTopSizer; delete m_pTextCtrlMin; delete m_pTextCtrlMax; - delete m_pButtonSizer; - delete m_pButtonOk; - delete m_pButtonCancel; #endif } @@ -120,3 +120,206 @@ DialogGetImageMinMax::getMaximum (void) return (m_dDefaultMax); } + +///////////////////////////////////////////////////////////////////// +// CLASS IDENTIFICATION +// +// DialogGetRasterParameters +///////////////////////////////////////////////////////////////////// + +DialogGetRasterParameters::DialogGetRasterParameters (wxFrame* pParent, int iDefaultXSize = 0, int iDefaultYSize = 0, int iDefaultNSamples = 1) + : wxDialog (pParent, -1, "Set Rasterization Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION) +{ + wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL); + + pTopSizer->Add (new wxStaticText (this, -1, "Set Rasterization Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5); + + pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5); + + ostringstream os; + os << iDefaultXSize; + m_pTextCtrlXSize = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); + ostringstream osYSize; + osYSize << iDefaultYSize; + m_pTextCtrlYSize = new wxTextCtrl (this, -1, osYSize.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); + ostringstream osNSamples; + osNSamples << iDefaultNSamples; + m_pTextCtrlNSamples = new wxTextCtrl (this, -1, osNSamples.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); + + wxGridSizer *pGridSizer = new wxGridSizer (2, 3, 5); + pGridSizer->Add (new wxStaticText (this, -1, "X Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pGridSizer->Add (m_pTextCtrlXSize, 0, wxALIGN_CENTER_VERTICAL); + pGridSizer->Add (new wxStaticText (this, -1, "Y Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pGridSizer->Add (m_pTextCtrlYSize, 0, wxALIGN_CENTER_VERTICAL); + pGridSizer->Add (new wxStaticText (this, -1, "Samples per Pixel"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pGridSizer->Add (m_pTextCtrlNSamples, 0, wxALIGN_CENTER_VERTICAL); + pTopSizer->Add (pGridSizer, 1, wxALL, 10); + + pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5); + + wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL); + wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay"); + wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel"); + pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10); + pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10); + + pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER); + + SetAutoLayout (true); + SetSizer (pTopSizer); + pTopSizer->Fit (this); + pTopSizer->SetSizeHints (this); +} + +DialogGetRasterParameters::~DialogGetRasterParameters (void) +{ +} + + +unsigned int +DialogGetRasterParameters::getXSize (void) +{ + wxString strCtrl = m_pTextCtrlXSize->GetValue(); + unsigned long lValue; + if (strCtrl.ToULong (&lValue)) + return lValue; + else + return (m_iDefaultXSize); +} + +unsigned int +DialogGetRasterParameters::getYSize (void) +{ + wxString strCtrl = m_pTextCtrlYSize->GetValue(); + unsigned long lValue; + if (strCtrl.ToULong (&lValue)) + return lValue; + else + return (m_iDefaultYSize); +} + + +unsigned int +DialogGetRasterParameters::getNSamples (void) +{ + wxString strCtrl = m_pTextCtrlNSamples->GetValue(); + unsigned long lValue; + if (strCtrl.ToULong (&lValue)) + return lValue; + else + return (m_iDefaultNSamples); +} + + + +///////////////////////////////////////////////////////////////////// +// CLASS IDENTIFICATION +// +// DialogGetProjectionsParameters +///////////////////////////////////////////////////////////////////// + +DialogGetProjectionParameters::DialogGetProjectionParameters (wxFrame* pParent, int iDefaultNDet = 0, int iDefaultNView = 0, int iDefaultNSamples = 1, double dDefaultRotAngle = 1., const char* szDefaultGeometry = NULL) + : wxDialog (pParent, -1, "Set Projection Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION) +{ + wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL); + + pTopSizer->Add (new wxStaticText (this, -1, "Set Projection Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5); + + pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5); + + ostringstream os; + os << iDefaultNDet; + m_pTextCtrlNDet = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); + ostringstream osNView; + osNView << iDefaultNView; + m_pTextCtrlNView = new wxTextCtrl (this, -1, osNView.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); + ostringstream osNSamples; + osNSamples << iDefaultNSamples; + m_pTextCtrlNSamples = new wxTextCtrl (this, -1, osNSamples.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); + ostringstream osRotAngle; + osRotAngle << dDefaultRotAngle; + m_pTextCtrlRotAngle = new wxTextCtrl (this, -1, osRotAngle.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); + + wxGridSizer *pGridSizer = new wxGridSizer (2, 4, 5); + pGridSizer->Add (new wxStaticText (this, -1, "Detectors"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pGridSizer->Add (m_pTextCtrlNDet, 0, wxALIGN_CENTER_VERTICAL); + pGridSizer->Add (new wxStaticText (this, -1, "Views"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pGridSizer->Add (m_pTextCtrlNView, 0, wxALIGN_CENTER_VERTICAL); + pGridSizer->Add (new wxStaticText (this, -1, "Samples per Detector"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pGridSizer->Add (m_pTextCtrlNSamples, 0, wxALIGN_CENTER_VERTICAL); + pGridSizer->Add (new wxStaticText (this, -1, "Rotation Angle (PI units)"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pGridSizer->Add (m_pTextCtrlRotAngle, 0, wxALIGN_CENTER_VERTICAL); + pTopSizer->Add (pGridSizer, 1, wxALL, 10); + m_sDefaultGeometry = szDefaultGeometry; + + pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5); + + wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL); + wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay"); + wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel"); + pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10); + pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10); + + pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER); + + SetAutoLayout (true); + SetSizer (pTopSizer); + pTopSizer->Fit (this); + pTopSizer->SetSizeHints (this); +} + +DialogGetProjectionParameters::~DialogGetProjectionParameters (void) +{ +} + + +unsigned int +DialogGetProjectionParameters::getNDet (void) +{ + wxString strCtrl = m_pTextCtrlNDet->GetValue(); + unsigned long lValue; + if (strCtrl.ToULong (&lValue)) + return lValue; + else + return (m_iDefaultNDet); +} + +unsigned int +DialogGetProjectionParameters::getNView (void) +{ + wxString strCtrl = m_pTextCtrlNView->GetValue(); + unsigned long lValue; + if (strCtrl.ToULong (&lValue)) + return lValue; + else + return (m_iDefaultNView); +} + + +unsigned int +DialogGetProjectionParameters::getNSamples (void) +{ + wxString strCtrl = m_pTextCtrlNSamples->GetValue(); + unsigned long lValue; + if (strCtrl.ToULong (&lValue)) + return lValue; + else + return (m_iDefaultNSamples); +} + +double +DialogGetProjectionParameters::getRotAngle (void) +{ + wxString strCtrl = m_pTextCtrlRotAngle->GetValue(); + double dValue; + if (strCtrl.ToDouble (&dValue)) + return (dValue * PI); + else + return (m_dDefaultRotAngle); +} + +const string& +DialogGetProjectionParameters::getGeometry (void) +{ + return m_sDefaultGeometry; +} diff --git a/src/dialogs.h b/src/dialogs.h index 03582ac..6c5c727 100644 --- a/src/dialogs.h +++ b/src/dialogs.h @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: dialogs.h,v 1.1 2000/07/18 03:14:35 kevin Exp $ +** $Id: dialogs.h,v 1.2 2000/07/18 14:51:06 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -30,6 +30,7 @@ #define __DIALOGSH__ #include "wx/wx.h" +#include class ImageFile; class DialogGetImageMinMax : public wxDialog @@ -42,16 +43,60 @@ class DialogGetImageMinMax : public wxDialog double getMaximum (void); private: - wxBoxSizer* m_pTopSizer; wxTextCtrl* m_pTextCtrlMin; wxTextCtrl* m_pTextCtrlMax; - wxBoxSizer* m_pButtonSizer; - wxButton* m_pButtonOk; - wxButton* m_pButtonCancel; double m_dDefaultMin; double m_dDefaultMax; }; + +class DialogGetRasterParameters : public wxDialog +{ + public: + DialogGetRasterParameters (wxFrame* pParent, int iDefaultXSize = 0, int iDefaultYSize = 0, int iDefaultNSamples = 1); + ~DialogGetRasterParameters (void); + + unsigned int getXSize (void); + unsigned int getYSize (void); + unsigned int getNSamples (void); + + private: + wxTextCtrl* m_pTextCtrlXSize; + wxTextCtrl* m_pTextCtrlYSize; + wxTextCtrl* m_pTextCtrlNSamples; + + int m_iDefaultXSize; + int m_iDefaultYSize; + int m_iDefaultNSamples; +}; + + +class DialogGetProjectionParameters : public wxDialog +{ + public: + DialogGetProjectionParameters (wxFrame* pParent, int iDefaultNDet = 0, int iDefaultNView = 0, int iDefaultNSamples = 1, double dDefaultRotAngle = 1., const char* szDefaultGeometry = NULL); + ~DialogGetProjectionParameters (void); + + unsigned int getNDet (void); + unsigned int getNView (void); + unsigned int getNSamples (void); + double getRotAngle (void); + const string& getGeometry(void); + + private: + wxTextCtrl* m_pTextCtrlNDet; + wxTextCtrl* m_pTextCtrlNView; + wxTextCtrl* m_pTextCtrlNSamples; + wxTextCtrl* m_pTextCtrlRotAngle; + wxTextCtrl* m_pTextCtrlGeometry; + + int m_iDefaultNDet; + int m_iDefaultNView; + int m_iDefaultNSamples; + double m_dDefaultRotAngle; + string m_sDefaultGeometry; +}; + #endif diff --git a/src/views.cpp b/src/views.cpp index 6677068..3d46d04 100644 --- a/src/views.cpp +++ b/src/views.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: views.cpp,v 1.3 2000/07/18 03:14:35 kevin Exp $ +** $Id: views.cpp,v 1.4 2000/07/18 14:51:06 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -84,7 +84,7 @@ ImageFileCanvas::OnMouseEvent(wxMouseEvent& event) wxPoint pt(event.GetLogicalPosition(dc)); - if (event.LeftUp()) { + if (event.LeftIsDown()) { const ImageFile& rIF = m_pView->GetDocument()->getImageFile(); ImageFileArrayConst v = rIF.getArray(); int nx = rIF.nx(); @@ -133,6 +133,16 @@ ImageFileView::OnProperties (wxCommandEvent& event) ostringstream os; os << "file: " << rFilename << "\nmin: "<getLog() << os.str().c_str(); + + int xSize, ySize; + ostringstream osSize; + m_frame->GetSize (&xSize, &ySize); + osSize << "Frame size: (" << xSize << "," << ySize << ")\n"; + m_frame->GetClientSize (&xSize, &ySize); + osSize << "Frame Client size: (" << xSize << "," << ySize << ")\n"; + m_canvas->GetSize (&xSize, &ySize); + osSize << "Canvas size: (" << xSize << "," << ySize << ")\n"; + *theApp->getLog() << osSize.str().c_str(); } } @@ -186,10 +196,11 @@ ImageFileView::CreateCanvas (wxView *view, wxFrame *parent) wxFrame* ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view) { - wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, theApp->getMainFrame(), -1, "ImageFile Frame", wxPoint(10, 10), wxSize(300, 300), wxDEFAULT_FRAME_STYLE); + wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, theApp->getMainFrame(), -1, "ImageFile Frame", wxPoint(-1, -1), wxSize(0, 0), wxDEFAULT_FRAME_STYLE); wxMenu *file_menu = new wxMenu; + file_menu->Append(MAINMENU_FILE_CREATE_PHANTOM, "&Create Phantom..."); file_menu->Append(wxID_OPEN, "&Open..."); file_menu->Append(wxID_CLOSE, "&Close"); file_menu->Append(wxID_SAVE, "&Save"); @@ -204,8 +215,8 @@ ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view) file_menu->Append(wxID_PREVIEW, "Print Pre&view"); wxMenu *view_menu = new wxMenu; - view_menu->Append(IFMENU_VIEW_WINDOW_AUTO, "&Window auto"); view_menu->Append(IFMENU_VIEW_WINDOW_MINMAX, "&Set Window Min/Max"); + view_menu->Append(IFMENU_VIEW_WINDOW_AUTO, "&Auto Window..."); wxMenu *help_menu = new wxMenu; help_menu->Append(MAINMENU_HELP_ABOUT, "&About"); @@ -275,7 +286,7 @@ ImageFileView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) ) } double scaleWidth = m_dMaxPixel - m_dMinPixel; - unsigned char imageData [nx * ny * 3]; + unsigned char* imageData = new unsigned char [nx * ny * 3]; for (int ix = 0; ix < nx; ix++) { for (int iy = 0; iy < ny; iy++) { double scaleValue = ((v[ix][iy] - m_dMinPixel) / scaleWidth) * 255; @@ -287,6 +298,14 @@ ImageFileView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) ) } wxImage image (ny, nx, imageData, true); m_bitmap = image.ConvertToBitmap(); + delete imageData; + int xSize = nx; + int ySize = ny; + xSize = clamp (xSize, 0, 800); + ySize = clamp (ySize, 0, 800); + m_frame->SetClientSize (xSize, ySize); + m_canvas->SetScrollbars(20, 20, nx/20, ny/20); + m_canvas->SetBackgroundColour(*wxWHITE); } if (m_canvas) @@ -321,7 +340,7 @@ ImageFileView::OnClose (bool deleteWindow) // PhantomCanvas PhantomCanvas::PhantomCanvas (PhantomView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style) - : wxScrolledWindow(frame, -1, pos, size, style) + : wxPanel(frame, -1, pos, size, style) { m_pView = v; } @@ -370,27 +389,54 @@ PhantomView::OnProperties (wxCommandEvent& event) void PhantomView::OnProjections (wxCommandEvent& event) { - const Phantom& rPhantom = GetDocument()->getPhantom(); - ProjectionFileDocument* pProjectionDoc = dynamic_cast(theApp->getDocManager()->CreateDocument("untitled.pj", wxDOC_SILENT)); - Projections& rProj = pProjectionDoc->getProjections(); - Scanner theScanner (rPhantom, "parallel", 367, 320, 2, PI); - rProj.initFromScanner (theScanner); - theScanner.collectProjections (rProj, rPhantom, 0, TRACE_NONE); - pProjectionDoc->Modify(true); - pProjectionDoc->UpdateAllViews(this); + DialogGetProjectionParameters dialogProjection (m_frame, 367, 320, 1, 1., Scanner::GEOMETRY_PARALLEL_STR); + int retVal = dialogProjection.ShowModal(); + if (retVal == wxID_OK) { + int nDet = dialogProjection.getNDet(); + int nView = dialogProjection.getNView(); + int nSamples = dialogProjection.getNSamples(); + double dRotAngle = dialogProjection.getRotAngle(); + string sGeometry = dialogProjection.getGeometry(); + if (nDet > 0 && nView > 0 && sGeometry != "") { + const Phantom& rPhantom = GetDocument()->getPhantom(); + ProjectionFileDocument* pProjectionDoc = dynamic_cast(theApp->getDocManager()->CreateDocument("untitled.pj", wxDOC_SILENT)); + Projections& rProj = pProjectionDoc->getProjections(); + Scanner theScanner (rPhantom, sGeometry.c_str(), nDet, nView, nSamples, dRotAngle); + rProj.initFromScanner (theScanner); + theScanner.collectProjections (rProj, rPhantom, 0, TRACE_NONE); + pProjectionDoc->Modify(true); + pProjectionDoc->UpdateAllViews(this); + } + } } void PhantomView::OnRasterize (wxCommandEvent& event) { - const Phantom& rPhantom = GetDocument()->getPhantom(); - ImageFileDocument* pRasterDoc = dynamic_cast(theApp->getDocManager()->CreateDocument("untitled.if", wxDOC_SILENT)); - ImageFile& imageFile = pRasterDoc->getImageFile(); - imageFile.setArraySize (256, 256); - rPhantom.convertToImagefile (imageFile, 1, TRACE_NONE); - pRasterDoc->Modify(true); - pRasterDoc->UpdateAllViews(this); + DialogGetRasterParameters dialogRaster (m_frame, 256, 256, 1); + int retVal = dialogRaster.ShowModal(); + if (retVal == wxID_OK) { + int xSize = dialogRaster.getXSize(); + int ySize = dialogRaster.getYSize(); + int nSamples = dialogRaster.getNSamples(); + if (nSamples < 1) + nSamples = 1; + if (xSize > 0 && ySize > 0) { + const Phantom& rPhantom = GetDocument()->getPhantom(); + ImageFileDocument* pRasterDoc = dynamic_cast(theApp->getDocManager()->CreateDocument("untitled.if", wxDOC_SILENT)); + ImageFile& imageFile = pRasterDoc->getImageFile(); + + imageFile.setArraySize (xSize, ySize); + rPhantom.convertToImagefile (imageFile, nSamples, TRACE_NONE); + pRasterDoc->Modify(true); + pRasterDoc->UpdateAllViews(this); + + ostringstream os; + os << "Rasterize Phantom " << rPhantom.name() << ": XSize=" << xSize << ", YSize=" << ySize << ", nSamples=" << nSamples << "\n"; + *theApp->getLog() << os.str().c_str(); + } + } } @@ -403,7 +449,6 @@ PhantomView::CreateCanvas (wxView *view, wxFrame *parent) pCanvas = new PhantomCanvas (dynamic_cast(view), parent, wxPoint(0, 0), wxSize(width, height), 0); - pCanvas->SetScrollbars(20, 20, 50, 50); pCanvas->SetBackgroundColour(*wxWHITE); pCanvas->Clear(); @@ -413,10 +458,11 @@ PhantomView::CreateCanvas (wxView *view, wxFrame *parent) wxFrame* PhantomView::CreateChildFrame(wxDocument *doc, wxView *view) { - wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, theApp->getMainFrame(), -1, "Phantom Frame", wxPoint(10, 10), wxSize(300, 300), wxDEFAULT_FRAME_STYLE); + wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, theApp->getMainFrame(), -1, "Phantom Frame", wxPoint(10, 10), wxSize(256, 256), wxDEFAULT_FRAME_STYLE); wxMenu *file_menu = new wxMenu; + file_menu->Append(MAINMENU_FILE_CREATE_PHANTOM, "&Create Phantom..."); file_menu->Append(wxID_OPEN, "&Open..."); file_menu->Append(wxID_CLOSE, "&Close"); @@ -593,10 +639,11 @@ ProjectionFileView::CreateCanvas (wxView *view, wxFrame *parent) wxFrame* ProjectionFileView::CreateChildFrame(wxDocument *doc, wxView *view) { - wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, theApp->getMainFrame(), -1, "Projection Frame", wxPoint(10, 10), wxSize(300, 300), wxDEFAULT_FRAME_STYLE); + wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, theApp->getMainFrame(), -1, "Projection Frame", wxPoint(10, 10), wxSize(0, 0), wxDEFAULT_FRAME_STYLE); wxMenu *file_menu = new wxMenu; + file_menu->Append(MAINMENU_FILE_CREATE_PHANTOM, "&Create Phantom..."); file_menu->Append(wxID_OPEN, "&Open..."); file_menu->Append(wxID_CLOSE, "&Close"); @@ -682,7 +729,7 @@ ProjectionFileView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) } } - unsigned char imageData [nDet * nView * 3]; + unsigned char* imageData = new unsigned char [nDet * nView * 3]; double scale = (max - min) / 255; for (int iy = 0; iy < nView; iy++) { const DetectorArray& detarray = rProj.getDetectorArray(iy); @@ -696,6 +743,13 @@ ProjectionFileView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) } wxImage image (nDet, nView, imageData, true); m_bitmap = image.ConvertToBitmap(); + delete imageData; + int xSize = nDet; + int ySize = nView; + xSize = clamp (xSize, 0, 800); + ySize = clamp (ySize, 0, 800); + m_frame->SetClientSize (xSize, ySize); + m_canvas->SetScrollbars (20, 20, nDet/20, nView/20); } if (m_canvas) diff --git a/src/views.h b/src/views.h index 96de20e..99ae275 100644 --- a/src/views.h +++ b/src/views.h @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: views.h,v 1.3 2000/07/18 03:14:35 kevin Exp $ +** $Id: views.h,v 1.4 2000/07/18 14:51:06 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -157,7 +157,7 @@ public: DECLARE_EVENT_TABLE() }; -class PhantomCanvas: public wxScrolledWindow +class PhantomCanvas: public wxPanel { public: PhantomView* m_pView; -- 2.34.1