/*****************************************************************************
** FILE IDENTIFICATION
**
-** Name: view.cpp
+** Name: views.cpp
** Purpose: View & Canvas routines for CTSim program
** Programmer: Kevin Rosenberg
** Date Started: July 2000
** This is part of the CTSim program
** Copyright (c) 1983-2001 Kevin Rosenberg
**
-** $Id: views.cpp,v 1.147 2001/09/27 02:11:29 kevin Exp $
+** $Id: views.cpp,v 1.161 2002/06/06 22:50:24 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
#include <sstream_subst>
#endif
+// Used to reduce calls to progress bar update function
+const short int ITER_PER_UPDATE = 10;
// ImageFileCanvas
}
ImageFileCanvas::~ImageFileCanvas()
-{
- m_pView = NULL;
-}
+{}
void
ImageFileCanvas::OnDraw(wxDC& dc)
wxSize
ImageFileCanvas::GetBestSize() const
{
- if (! m_pView)
- return wxSize(0,0);
+ const int iMinX = 50;
+ const int iMinY = 20;
+ wxSize bestSize (iMinX,iMinY);
+
+ if (m_pView) {
+ const ImageFile& rIF = m_pView->GetDocument()->getImageFile();
+ bestSize.Set (rIF.nx(), rIF.ny());
+ }
+
+ if (bestSize.x > 800)
+ bestSize.x = 800;
+ if (bestSize.y > 800)
+ bestSize.y = 800;
- const ImageFile& rIF = m_pView->GetDocument()->getImageFile();
- return wxSize (rIF.nx(), rIF.ny());
+ if (bestSize.y < iMinY)
+ bestSize.y = iMinY;
+ if (bestSize.x < iMinX)
+ bestSize.x = iMinX;
+
+ return bestSize;
}
END_EVENT_TABLE()
ImageFileView::ImageFileView()
-: wxView(), m_pFrame(NULL), m_pCanvas(NULL), m_pFileMenu(0), m_pFilterMenu(0), m_bMinSpecified(false), m_bMaxSpecified(false)
-{
- m_iDefaultExportFormatID = ImageFile::EXPORT_FORMAT_PNG;
-}
+: wxView(), m_pFrame(0), m_pCanvas(0), m_pFileMenu(0), m_pFilterMenu(0),
+ m_bMinSpecified(false), m_bMaxSpecified(false),
+ m_iDefaultExportFormatID(ImageFile::EXPORT_FORMAT_PNG)
+{}
ImageFileView::~ImageFileView()
{
pDifferenceImage->labelAdd (os.str().c_str());
if (theApp->getAskDeleteNewDocs())
pDifferenceDoc->Modify (true);
- pDifferenceDoc->UpdateAllViews (this);
- pDifferenceDoc->getView()->OnUpdate (this, NULL);
- pDifferenceDoc->getView()->getFrame()->Show(true);
+ pDifferenceDoc->UpdateAllViews(this);
+ pDifferenceDoc->getView()->setInitialClientSize();
pDifferenceDoc->Activate();
}
wxMessageBox(os.str().c_str(), "Image Comparison");
if (theApp->getAskDeleteNewDocs())
pNewDoc->Modify (true);
pNewDoc->UpdateAllViews (this);
- pNewDoc->getView()->getFrame()->Show(true);
+ pNewDoc->getView()->setInitialClientSize();
pNewDoc->Activate();
}
}
if (theApp->getAskDeleteNewDocs())
pNewDoc->Modify (true);
pNewDoc->UpdateAllViews (this);
- pNewDoc->getView()->getFrame()->Show(true);
+ pNewDoc->getView()->setInitialClientSize();
pNewDoc->Activate();
}
}
if (theApp->getAskDeleteNewDocs())
pNewDoc->Modify (true);
pNewDoc->UpdateAllViews (this);
- pNewDoc->getView()->getFrame()->Show(true);
+ pNewDoc->getView()->setInitialClientSize();
pNewDoc->Activate();
}
}
if (theApp->getAskDeleteNewDocs())
pNewDoc->Modify (true);
pNewDoc->UpdateAllViews (this);
- pNewDoc->getView()->getFrame()->Show(true);
+ pNewDoc->getView()->setInitialClientSize();
pNewDoc->Activate();
}
}
ImageFileCanvas*
ImageFileView::CreateCanvas (wxFrame* parent)
{
- ImageFileCanvas* pCanvas;
- int width, height;
- parent->GetClientSize(&width, &height);
-
- pCanvas = new ImageFileCanvas (this, parent, wxPoint(0, 0), wxSize(width, height), 0);
-
- pCanvas->SetScrollbars(20, 20, 50, 50);
+ ImageFileCanvas* pCanvas = new ImageFileCanvas (this, parent, wxPoint(-1,-1),
+ wxSize(-1,-1), 0);
pCanvas->SetBackgroundColour(*wxWHITE);
pCanvas->Clear();
ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view)
{
#if CTSIM_MDI
- wxDocMDIChildFrame* subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "ImageFile Frame", wxPoint(-1, -1), wxSize(0, 0), wxDEFAULT_FRAME_STYLE);
+ wxDocMDIChildFrame* subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "ImageFile Frame", wxPoint(-1,-1), wxSize(-1,-1), wxDEFAULT_FRAME_STYLE);
#else
- wxDocChildFrame* subframe = new wxDocChildFrame (doc, view, theApp->getMainFrame(), -1, "ImageFile Frame", wxPoint(-1, -1), wxSize(0, 0), wxDEFAULT_FRAME_STYLE);
+ wxDocChildFrame* subframe = new wxDocChildFrame (doc, view, theApp->getMainFrame(), -1, "ImageFile Frame", wxPoint(-1,-1), wxSize(-1,-1), wxDEFAULT_FRAME_STYLE);
#endif
theApp->setIconForFrame (subframe);
-
+
m_pFileMenu = new wxMenu;
m_pFileMenu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom...\tCtrl-P");
m_pFileMenu->Append(MAINMENU_FILE_CREATE_FILTER, "Create &Filter...\tCtrl-F");
#if wxUSE_GLCANVAS
accelEntries[iEntry++].Set (wxACCEL_CTRL, static_cast<int>('3'), IFMENU_IMAGE_CONVERT3D);
#endif
+
wxAcceleratorTable accelTable (iEntry, accelEntries);
-
subframe->SetAcceleratorTable (accelTable);
return subframe;
bool
ImageFileView::OnCreate (wxDocument *doc, long WXUNUSED(flags) )
{
- m_pFrame = CreateChildFrame(doc, this);
-
m_bMinSpecified = false;
m_bMaxSpecified = false;
m_dAutoScaleFactor = 1.;
- int width, height;
- m_pFrame->GetClientSize (&width, &height);
- m_pFrame->SetTitle("ImageFileView");
+ m_pFrame = CreateChildFrame(doc, this);
+ SetFrame (m_pFrame);
m_pCanvas = CreateCanvas (m_pFrame);
-
- int x, y; // X requires a forced resize
- m_pFrame->GetSize(&x, &y);
- m_pFrame->SetSize(-1, -1, x, y);
- m_pFrame->SetFocus();
+ m_pFrame->SetClientSize (m_pCanvas->GetBestSize());
+ m_pCanvas->SetClientSize (m_pCanvas->GetBestSize());
+ m_pFrame->SetTitle("ImageFileView");
+
m_pFrame->Show(true);
Activate(true);
return true;
}
+void
+ImageFileView::setInitialClientSize ()
+{
+ if (m_pFrame && m_pCanvas) {
+ wxSize bestSize = m_pCanvas->GetBestSize();
+
+ m_pFrame->SetClientSize (bestSize);
+ m_pFrame->Show (true);
+ m_pFrame->SetFocus();
+ }
+}
+
void
ImageFileView::OnDraw (wxDC* dc)
{
- wxSize sizeWindow = m_pFrame->GetClientSize();
- wxSize sizeBest = m_pCanvas->GetBestSize();
- if (sizeWindow.x > sizeBest.x || sizeWindow.y > sizeBest.y)
- m_pFrame->SetClientSize (sizeBest);
-
if (m_bitmap.Ok())
dc->DrawBitmap(m_bitmap, 0, 0, false);
wxImage image (nx, ny, imageData, true);
m_bitmap = image.ConvertToBitmap();
delete imageData;
- int xSize = nx;
- int ySize = ny;
- ySize = clamp (ySize, 0, 800);
- m_pFrame->SetClientSize (xSize, ySize);
m_pCanvas->SetScrollbars(20, 20, nx/20, ny/20);
m_pCanvas->SetBackgroundColour(*wxWHITE);
}
bool
ImageFileView::OnClose (bool deleteWindow)
{
- //GetDocumentManager()->ActivateView (this, false, true);
if (! GetDocument() || ! GetDocument()->Close())
return false;
if (theApp->getAskDeleteNewDocs())
pScaledDoc->Modify (true);
pScaledDoc->UpdateAllViews (this);
- pScaledDoc->getView()->getFrame()->Show(true);
+ pScaledDoc->getView()->setInitialClientSize();
pScaledDoc->Activate();
}
}
{
ImageFile& rIF = GetDocument()->getImageFile();
Graph3dFileDocument* pGraph3d = theApp->newGraph3dDoc();
+ pGraph3d->getView()->getFrame()->Show (false);
pGraph3d->setBadFileOpen();
pGraph3d->createFromImageFile (rIF);
- pGraph3d->getView()->OnUpdate (this, NULL);
pGraph3d->UpdateAllViews();
- pGraph3d->getView()->getFrame()->SetClientSize (400, 400);
pGraph3d->getView()->getFrame()->Show (true);
- GetDocumentManager()->ActivateView (pGraph3d->getView(), true, false);
+ pGraph3d->getView()->Activate(true);
::wxYield();
pGraph3d->getView()->getCanvas()->SetFocus();
}
// PhantomCanvas
PhantomCanvas::PhantomCanvas (PhantomFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style)
-: wxScrolledWindow(frame, -1, pos, size, style)
+ : wxScrolledWindow(frame, -1, pos, size, style), m_pView(v)
{
- m_pView = v;
}
PhantomCanvas::~PhantomCanvas ()
#ifdef CTSIM_MDI
ySize = xSize = (xSize / 4);
#else
- ySize = xSize;
+ xSize = ySize = static_cast<int>(ySize * .7);
#endif
+
return wxSize (xSize, ySize);
}
for (int i = 0; i < pProj->nView(); i++) {
//theScanner.collectProjections (*pProj, rPhantom, i, 1, true, m_iDefaultTrace);
theScanner.collectProjections (*pProj, rPhantom, i, 1, theScanner.offsetView(), true, m_iDefaultTrace);
- if (! dlgProgress.Update (i+1)) {
- delete pProj;
- return;
- }
+ if ((i + 1) % ITER_PER_UPDATE == 0)
+ if (! dlgProgress.Update (i+1)) {
+ delete pProj;
+ return;
+ }
}
}
}
return;
}
pProjectionDoc->setProjections (pProj);
- ProjectionFileView* projView = pProjectionDoc->getView();
- if (projView) {
- projView->OnUpdate (projView, NULL);
- if (projView->getCanvas())
- projView->getCanvas()->SetClientSize (m_iDefaultNDet, m_iDefaultNView);
- if (wxFrame* pFrame = projView->getFrame()) {
- pFrame->Show(true);
- pFrame->SetFocus();
- pFrame->Raise();
- }
- GetDocumentManager()->ActivateView (projView, true, false);
- }
if (theApp->getAskDeleteNewDocs())
pProjectionDoc-> Modify(true);
pProjectionDoc->UpdateAllViews (this);
+ pProjectionDoc->getView()->setInitialClientSize();
pProjectionDoc->Activate();
}
#endif
{
ImageFile* pImageFile = new ImageFile (m_iDefaultRasterNX, m_iDefaultRasterNY);
- wxProgressDialog dlgProgress (wxString("Rasterize"), wxString("Rasterization Progress"),
- pImageFile->nx() + 1, getFrameForChild(), wxPD_CAN_ABORT );
+
+ wxProgressDialog dlgProgress (wxString("Rasterize"),
+ wxString("Rasterization Progress"),
+ pImageFile->nx() + 1,
+ getFrameForChild(),
+ wxPD_CAN_ABORT );
Timer timer;
for (unsigned int i = 0; i < pImageFile->nx(); i++) {
- rPhantom.convertToImagefile (*pImageFile, m_dDefaultRasterViewRatio, m_iDefaultRasterNSamples, Trace::TRACE_NONE, i, 1, true);
- if (! dlgProgress.Update (i+1)) {
- delete pImageFile;
- return;
- }
+ rPhantom.convertToImagefile (*pImageFile, m_dDefaultRasterViewRatio,
+ m_iDefaultRasterNSamples, Trace::TRACE_NONE,
+ i, 1, true);
+ if ((i + 1) % ITER_PER_UPDATE == 0)
+ if (! dlgProgress.Update (i+1)) {
+ delete pImageFile;
+ return;
+ }
}
ImageFileDocument* pRasterDoc = theApp->newImageDoc();
pRasterDoc->setImageFile (pImageFile);
if (theApp->getAskDeleteNewDocs())
pRasterDoc->Modify (true);
- pRasterDoc->UpdateAllViews (this);
- pRasterDoc->getView()->getFrame()->Show(true);
*theApp->getLog() << os.str().c_str() << "\n";
pImageFile->labelAdd (os.str().c_str(), timer.timerEnd());
- ImageFileView* rasterView = pRasterDoc->getView();
- if (rasterView) {
- rasterView->getFrame()->SetFocus();
- rasterView->OnUpdate (rasterView, NULL);
- }
+
+ pRasterDoc->UpdateAllViews(this);
+ pRasterDoc->getView()->setInitialClientSize();
pRasterDoc->Activate();
}
}
PhantomCanvas*
PhantomFileView::CreateCanvas (wxFrame *parent)
{
- PhantomCanvas* pCanvas;
-
- pCanvas = new PhantomCanvas (this, parent, wxPoint(0, 0), wxSize(0,0), 0);
+ PhantomCanvas* pCanvas = new PhantomCanvas (this, parent, wxPoint(-1,-1),
+ wxSize(-1,-1), 0);
pCanvas->SetBackgroundColour(*wxWHITE);
pCanvas->Clear();
PhantomFileView::CreateChildFrame(wxDocument *doc, wxView *view)
{
#if CTSIM_MDI
- wxDocMDIChildFrame *subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "Phantom Frame", wxPoint(10, 10), wxSize(0, 0), wxDEFAULT_FRAME_STYLE);
+ wxDocMDIChildFrame *subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "Phantom Frame", wxPoint(-1,-1), wxSize(-1,-1), wxDEFAULT_FRAME_STYLE);
#else
- wxDocChildFrame *subframe = new wxDocChildFrame (doc, view, theApp->getMainFrame(), -1, "Phantom Frame", wxPoint(10, 10), wxSize(0, 0), wxDEFAULT_FRAME_STYLE);
+ wxDocChildFrame *subframe = new wxDocChildFrame (doc, view, theApp->getMainFrame(), -1, "Phantom Frame", wxPoint(-1,-1), wxSize(-1,-1), wxDEFAULT_FRAME_STYLE);
#endif
theApp->setIconForFrame (subframe);
m_pCanvas = CreateCanvas (m_pFrame);
m_pFrame->SetClientSize (m_pCanvas->GetBestSize());
m_pCanvas->SetClientSize (m_pCanvas->GetBestSize());
-
m_pFrame->SetTitle ("PhantomFileView");
-
-#ifdef __X__
- int x, y; // X requires a forced resize
- m_pFrame->GetSize(&x, &y);
- m_pFrame->SetSize(-1, -1, x, y);
-#endif
-
+
m_pFrame->Show(true);
Activate(true);
bool
PhantomFileView::OnClose (bool deleteWindow)
{
- //GetDocumentManager()->ActivateView (this, false, true);
if (! GetDocument() || ! GetDocument()->Close())
return false;
wxSize
ProjectionFileCanvas::GetBestSize () const
{
- wxSize best (0, 0);
+ const int iMinX = 50;
+ const int iMinY = 20;
+ wxSize bestSize (iMinX,iMinY);
+
if (m_pView) {
Projections& rProj = m_pView->GetDocument()->getProjections();
- best.Set (rProj.nDet(), rProj.nView());
+ bestSize.Set (rProj.nDet(), rProj.nView());
}
- return best;
+ if (bestSize.x > 800)
+ bestSize.x = 800;
+ if (bestSize.y > 800)
+ bestSize.y = 800;
+
+ if (bestSize.x < iMinX)
+ bestSize.x = iMinX;
+ if (bestSize.y < iMinY)
+ bestSize.y = iMinY;
+
+ return bestSize;
}
EVT_MENU(PJMENU_CONVERT_PARALLEL, ProjectionFileView::OnConvertParallel)
EVT_MENU(PJMENU_PLOT_TTHETA_SAMPLING, ProjectionFileView::OnPlotTThetaSampling)
EVT_MENU(PJMENU_PLOT_HISTOGRAM, ProjectionFileView::OnPlotHistogram)
-EVT_MENU(PJMENU_ARTIFACT_REDUCTION, ProjectionFileView::OnArtifactReduction)
+ // EVT_MENU(PJMENU_ARTIFACT_REDUCTION, ProjectionFileView::OnArtifactReduction)
END_EVENT_TABLE()
pIF->labelAdd (os.str().c_str());
if (theApp->getAskDeleteNewDocs())
pRectDoc->Modify (true);
- pRectDoc->getView()->getFrame()->Show(true);
- pRectDoc->UpdateAllViews ();
+ pRectDoc->UpdateAllViews();
+ pRectDoc->getView()->setInitialClientSize();
pRectDoc->Activate();
}
pIF->labelAdd (os.str().c_str());
if (theApp->getAskDeleteNewDocs())
pPolarDoc->Modify (true);
- pPolarDoc->getView()->getFrame()->Show(true);
pPolarDoc->UpdateAllViews ();
+ pPolarDoc->getView()->setInitialClientSize();
pPolarDoc->Activate();
}
}
pIF->labelAdd (os.str().c_str());
if (theApp->getAskDeleteNewDocs())
pPolarDoc->Modify (true);
- pPolarDoc->getView()->getFrame()->Show(true);
- pPolarDoc->UpdateAllViews ();
+ pPolarDoc->UpdateAllViews (this);
+ pPolarDoc->getView()->setInitialClientSize();
pPolarDoc->Activate();
}
}
if (theApp->getAskDeleteNewDocs())
pProjDocNew-> Modify(true);
pProjDocNew->UpdateAllViews (this);
+ pProjDocNew->getView()->setInitialClientSize();
pProjDocNew->Activate();
}
pIF->labelAdd (os.str().c_str());
if (theApp->getAskDeleteNewDocs())
pPolarDoc->Modify (true);
- pPolarDoc->getView()->getFrame()->Show(true);
pPolarDoc->UpdateAllViews ();
+ pPolarDoc->getView()->setInitialClientSize();
pPolarDoc->Activate();
}
}
for (int iView = 0; iView < rProj.nView(); iView++) {
pReconstructor->reconstructView (iView, 1);
- if (! dlgProgress.Update (iView + 1)) {
- delete pReconstructor;
- return; // don't make new window, thread will do this
- }
+ if ((iView + 1) % ITER_PER_UPDATE == 0)
+ if (! dlgProgress.Update (iView + 1)) {
+ delete pReconstructor;
+ return; // don't make new window, thread will do this
+ }
}
pReconstructor->postProcessing();
delete pReconstructor;
sys_error (ERR_SEVERE, "Unable to create image file");
return;
}
+ *theApp->getLog() << os.str().c_str() << "\n";
+ pImageFile->labelAdd (rProj.getLabel());
+ pImageFile->labelAdd (os.str().c_str(), timerRecon.timerEnd());
+
pReconDoc->setImageFile (pImageFile);
if (theApp->getAskDeleteNewDocs())
pReconDoc->Modify (true);
- pReconDoc->UpdateAllViews (this);
+ pReconDoc->UpdateAllViews();
+ pReconDoc->getView()->setInitialClientSize();
pReconDoc->Activate();
- if (ImageFileView* rasterView = pReconDoc->getView()) {
- rasterView->OnUpdate (rasterView, NULL);
- rasterView->getFrame()->SetFocus();
- rasterView->getFrame()->Show(true);
- }
- *theApp->getLog() << os.str().c_str() << "\n";
- pImageFile->labelAdd (rProj.getLabel());
- pImageFile->labelAdd (os.str().c_str(), timerRecon.timerEnd());
}
int width, height;
parent->GetClientSize(&width, &height);
- pCanvas = new ProjectionFileCanvas (this, parent, wxPoint(0, 0), wxSize(width, height), 0);
+ pCanvas = new ProjectionFileCanvas (this, parent, wxPoint(-1,-1), wxSize(width, height), 0);
pCanvas->SetScrollbars(20, 20, 50, 50);
pCanvas->SetBackgroundColour(*wxWHITE);
ProjectionFileView::CreateChildFrame(wxDocument *doc, wxView *view)
{
#ifdef CTSIM_MDI
- wxDocMDIChildFrame *subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "Projection Frame", wxPoint(10, 10), wxSize(0, 0), wxDEFAULT_FRAME_STYLE);
+ wxDocMDIChildFrame *subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "Projection Frame", wxPoint(-1,-1), wxSize(-1,-1), wxDEFAULT_FRAME_STYLE);
#else
- wxDocChildFrame *subframe = new wxDocChildFrame (doc, view, theApp->getMainFrame(), -1, "Projection Frame", wxPoint(10, 10), wxSize(0, 0), wxDEFAULT_FRAME_STYLE);
+ wxDocChildFrame *subframe = new wxDocChildFrame (doc, view, theApp->getMainFrame(), -1, "Projection Frame", wxPoint(-1,-1), wxSize(-1,-1), wxDEFAULT_FRAME_STYLE);
#endif
theApp->setIconForFrame (subframe);
convert_menu->AppendSeparator();
convert_menu->Append (PJMENU_CONVERT_PARALLEL, "&Interpolate to Parallel");
- wxMenu* filter_menu = new wxMenu;
- filter_menu->Append (PJMENU_ARTIFACT_REDUCTION, "&Artifact Reduction");
+ // wxMenu* filter_menu = new wxMenu;
+ // filter_menu->Append (PJMENU_ARTIFACT_REDUCTION, "&Artifact Reduction");
wxMenu* analyze_menu = new wxMenu;
analyze_menu->Append (PJMENU_PLOT_HISTOGRAM, "&Plot Histogram");
wxMenu *reconstruct_menu = new wxMenu;
reconstruct_menu->Append (PJMENU_RECONSTRUCT_FBP, "&Filtered Backprojection...\tCtrl-R", "Reconstruct image using filtered backprojection");
reconstruct_menu->Append (PJMENU_RECONSTRUCT_FBP_REBIN, "Filtered &Backprojection (Rebin to Parallel)...\tCtrl-B", "Reconstruct image using filtered backprojection");
- reconstruct_menu->Append (PJMENU_RECONSTRUCT_FOURIER, "&Fourier...\tCtrl-E", "Reconstruct image using inverse Fourier");
+ // still buggy
+ // reconstruct_menu->Append (PJMENU_RECONSTRUCT_FOURIER, "&Fourier...\tCtrl-E", "Reconstruct image using inverse Fourier");
wxMenu *help_menu = new wxMenu;
help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents\tF1");
menu_bar->Append (m_pFileMenu, "&File");
menu_bar->Append (convert_menu, "&Convert");
- menu_bar->Append (filter_menu, "Fi<er");
+ // menu_bar->Append (filter_menu, "Fi<er");
menu_bar->Append (analyze_menu, "&Analyze");
menu_bar->Append (reconstruct_menu, "&Reconstruct");
menu_bar->Append (help_menu, "&Help");
{
m_pFrame = CreateChildFrame(doc, this);
SetFrame(m_pFrame);
-
- int width, height;
- m_pFrame->GetClientSize (&width, &height);
- m_pFrame->SetTitle ("ProjectionFileView");
m_pCanvas = CreateCanvas (m_pFrame);
-
-#ifdef __X__
- int x, y; // X requires a forced resize
- m_pFrame->GetSize(&x, &y);
- m_pFrame->SetSize(-1, -1, x, y);
-#endif
-
+ m_pFrame->SetClientSize (m_pCanvas->GetBestSize());
+ m_pCanvas->SetClientSize (m_pCanvas->GetBestSize());
+ m_pFrame->SetTitle ("ProjectionFileView");
+
m_pFrame->Show(true);
Activate(true);
void
ProjectionFileView::OnDraw (wxDC* dc)
{
- wxSize clientSize = m_pFrame->GetClientSize();
- wxSize bestSize = m_pCanvas->GetBestSize();
-
- if (clientSize.x > bestSize.x || clientSize.y > bestSize.y)
- m_pFrame->SetClientSize (bestSize);
-
if (m_bitmap.Ok())
dc->DrawBitmap (m_bitmap, 0, 0, false);
}
+void
+ProjectionFileView::setInitialClientSize ()
+{
+ if (m_pFrame && m_pCanvas) {
+ wxSize bestSize = m_pCanvas->GetBestSize();
+
+ m_pFrame->SetClientSize (bestSize);
+ m_pFrame->Show (true);
+ m_pFrame->SetFocus();
+ }
+}
+
void
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_pFrame->SetClientSize (xSize, ySize);
- m_pCanvas->SetScrollbars (20, 20, nDet/20, nView/20);
}
- if (m_pCanvas)
- m_pCanvas->Refresh();
+ m_pCanvas->SetScrollbars(20, 20, nDet/20, nView/20);
+ m_pCanvas->SetBackgroundColour(*wxWHITE);
+
+ if (m_pCanvas)
+ m_pCanvas->Refresh();
}
bool
// PlotFileCanvas
PlotFileCanvas::PlotFileCanvas (PlotFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style)
-: wxScrolledWindow(frame, -1, pos, size, style)
+ : wxScrolledWindow(frame, -1, pos, size, style), m_pView(v)
{
- m_pView = v;
}
PlotFileCanvas::~PlotFileCanvas ()
{
- m_pView = NULL;
}
+wxSize
+PlotFileCanvas::GetBestSize() const
+{
+ return wxSize (500, 300);
+}
+
+
void
PlotFileCanvas::OnDraw(wxDC& dc)
{
END_EVENT_TABLE()
PlotFileView::PlotFileView()
-: wxView(), m_pFrame(NULL), m_pCanvas(NULL), m_pEZPlot(NULL), m_pFileMenu(0), m_bMinSpecified(false), m_bMaxSpecified(false)
+: wxView(), m_pFrame(0), m_pCanvas(0), m_pEZPlot(0), m_pFileMenu(0),
+ m_bMinSpecified(false), m_bMaxSpecified(false)
{
}
delete m_pEZPlot;
GetDocumentManager()->FileHistoryRemoveMenu (m_pFileMenu);
+ GetDocumentManager()->ActivateView(this, FALSE, TRUE);
}
void
PlotFileView::CreateCanvas (wxFrame* parent)
{
PlotFileCanvas* pCanvas;
- int width, height;
- parent->GetClientSize(&width, &height);
-
- pCanvas = new PlotFileCanvas (this, parent, wxPoint(0, 0), wxSize(width, height), 0);
+ pCanvas = new PlotFileCanvas (this, parent, wxPoint(-1,-1), wxSize(-1,-1), 0);
pCanvas->SetBackgroundColour(*wxWHITE);
pCanvas->Clear();
PlotFileView::CreateChildFrame(wxDocument *doc, wxView *view)
{
#ifdef CTSIM_MDI
- wxDocMDIChildFrame *subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "Plot Frame", wxPoint(10, 10), wxSize(500, 300), wxDEFAULT_FRAME_STYLE);
+ wxDocMDIChildFrame *subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "Plot Frame", wxPoint(-1,-1), wxSize(-1,-1), wxDEFAULT_FRAME_STYLE);
#else
- wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, theApp->getMainFrame(), -1, "Plot Frame", wxPoint(10, 10), wxSize(500, 300), wxDEFAULT_FRAME_STYLE);
+ wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, theApp->getMainFrame(), -1, "Plot Frame", wxPoint(-1,-1), wxSize(-1,-1), wxDEFAULT_FRAME_STYLE);
#endif
theApp->setIconForFrame (subframe);
bool
PlotFileView::OnCreate (wxDocument *doc, long WXUNUSED(flags) )
{
- m_pFrame = CreateChildFrame(doc, this);
- SetFrame(m_pFrame);
-
m_bMinSpecified = false;
m_bMaxSpecified = false;
m_dAutoScaleFactor = 1.;
- int width, height;
- m_pFrame->GetClientSize(&width, &height);
- m_pFrame->SetTitle ("Plot File");
+ m_pFrame = CreateChildFrame(doc, this);
+ SetFrame(m_pFrame);
m_pCanvas = CreateCanvas (m_pFrame);
-
-#ifdef __X__
- int x, y; // X requires a forced resize
- m_pFrame->GetSize(&x, &y);
- m_pFrame->SetSize(-1, -1, x, y);
-#endif
+ m_pFrame->SetClientSize (m_pCanvas->GetBestSize());
+ m_pCanvas->SetClientSize (m_pCanvas->GetBestSize());
+ m_pFrame->SetTitle ("Plot File");
m_pFrame->Show(true);
Activate(true);
return true;
}
+void
+PlotFileView::setInitialClientSize ()
+{
+ if (m_pFrame && m_pCanvas) {
+ wxSize bestSize = m_pCanvas->GetBestSize();
+
+ m_pFrame->SetClientSize (bestSize);
+ m_pFrame->Show (true);
+ m_pFrame->SetFocus();
+ }
+}
+
+
void
PlotFileView::OnDraw (wxDC* dc)
{
bool
PlotFileView::OnClose (bool deleteWindow)
{
- //GetDocumentManager()->ActivateView (this, false, true);
if (! GetDocument() || ! GetDocument()->Close())
return false;
int width, height;
m_pFrame->GetClientSize(&width, &height);
m_pFrame->SetTitle("TextFile");
- m_pCanvas = new TextFileCanvas (this, m_pFrame, wxPoint(0, 0), wxSize(width, height), wxTE_MULTILINE | wxTE_READONLY);
+ m_pCanvas = new TextFileCanvas (this, m_pFrame, wxPoint(-1,-1), wxSize(width, height), wxTE_MULTILINE | wxTE_READONLY);
m_pFrame->SetTitle("Log");
-#ifdef __X__
- // X seems to require a forced resize
- int x, y;
- frame->GetSize(&x, &y);
- frame->SetSize(-1, -1, x, y);
-#endif
-
m_pFrame->Show (true);
Activate (true);
TextFileView::CreateChildFrame (wxDocument *doc, wxView *view)
{
#if CTSIM_MDI
- wxDocMDIChildFrame* subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "TextFile Frame", wxPoint(-1, -1), wxSize(0,0), wxDEFAULT_FRAME_STYLE, "Log");
+ wxDocMDIChildFrame* subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "TextFile Frame", wxPoint(-1, -1), wxSize(-1,-1), wxDEFAULT_FRAME_STYLE, "Log");
#else
wxDocChildFrame* subframe = new wxDocChildFrame (doc, view, theApp->getMainFrame(), -1, "TextFile Frame", wxPoint(-1, -1), wxSize(300, 150), wxDEFAULT_FRAME_STYLE, "Log");
#endif
{
m_pView = NULL;
}
+
+wxSize
+TextFileCanvas::GetBestSize() const
+{
+ int xSize, ySize;
+ theApp->getMainFrame()->GetClientSize (&xSize, &ySize);
+ xSize = maxValue<int> (xSize, ySize);
+#ifdef CTSIM_MDI
+ ySize = xSize = (xSize / 4);
+#else
+ ySize = xSize;
+#endif
+ return wxSize (xSize, ySize);
+}