** This is part of the CTSim program
** Copyright (c) 1983-2001 Kevin Rosenberg
**
-** $Id: views.cpp,v 1.156 2002/05/30 17:02:32 kevin Exp $
+** $Id: views.cpp,v 1.162 2002/10/24 21:05:28 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
}
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()
{
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");
m_pFileMenu->Append(wxID_PREVIEW, "Print Preview");
m_pFileMenu->AppendSeparator();
m_pFileMenu->Append(MAINMENU_IMPORT, "&Import...\tCtrl-M");
-#ifdef CTSIM_MDI
m_pFileMenu->AppendSeparator();
m_pFileMenu->Append (MAINMENU_FILE_PREFERENCES, "Prefere&nces...");
m_pFileMenu->Append(MAINMENU_FILE_EXIT, "E&xit");
-#endif
GetDocumentManager()->FileHistoryAddFilesToMenu(m_pFileMenu);
GetDocumentManager()->FileHistoryUseMenu(m_pFileMenu);
#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);
+ Activate(true);
return true;
}
{
if (m_pFrame && m_pCanvas) {
wxSize bestSize = m_pCanvas->GetBestSize();
-
- if (bestSize.x > 800)
- bestSize.x = 800;
- if (bestSize.y > 800)
- bestSize.y = 800;
m_pFrame->SetClientSize (bestSize);
m_pFrame->Show (true);
bool
ImageFileView::OnClose (bool deleteWindow)
{
- //GetDocumentManager()->ActivateView (this, false, true);
if (! GetDocument() || ! GetDocument()->Close())
return false;
{
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 ()
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_pFileMenu->Append(wxID_PREVIEW, "Print Pre&view");
m_pFileMenu->AppendSeparator();
m_pFileMenu->Append(MAINMENU_IMPORT, "&Import...\tCtrl-M");
-#ifdef CTSIM_MDI
m_pFileMenu->AppendSeparator();
m_pFileMenu->Append (MAINMENU_FILE_PREFERENCES, "Prefere&nces...");
m_pFileMenu->Append(MAINMENU_FILE_EXIT, "E&xit");
-#endif
GetDocumentManager()->FileHistoryAddFilesToMenu(m_pFileMenu);
GetDocumentManager()->FileHistoryUseMenu(m_pFileMenu);
bool
PhantomFileView::OnClose (bool deleteWindow)
{
- //GetDocumentManager()->ActivateView (this, false, true);
if (! GetDocument() || ! GetDocument()->Close())
return false;
wxSize
ProjectionFileCanvas::GetBestSize () const
{
- wxSize best (0, 0);
- if (! m_pView)
- return best;
+ 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;
}
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);
m_pFileMenu->Append(wxID_PREVIEW, "Print Pre&view");
m_pFileMenu->AppendSeparator();
m_pFileMenu->Append(MAINMENU_IMPORT, "&Import...\tCtrl-M");
-#ifdef CTSIM_MDI
m_pFileMenu->AppendSeparator();
m_pFileMenu->Append (MAINMENU_FILE_PREFERENCES, "Prefere&nces...");
m_pFileMenu->Append(MAINMENU_FILE_EXIT, "E&xit");
-#endif
GetDocumentManager()->FileHistoryAddFilesToMenu(m_pFileMenu);
GetDocumentManager()->FileHistoryUseMenu(m_pFileMenu);
{
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);
-
+ m_pFrame->SetClientSize (m_pCanvas->GetBestSize());
+ m_pCanvas->SetClientSize (m_pCanvas->GetBestSize());
+ m_pFrame->SetTitle ("ProjectionFileView");
+
m_pFrame->Show(true);
Activate(true);
void
ProjectionFileView::setInitialClientSize ()
{
- wxSize bestSize = m_pCanvas->GetBestSize();
-
- if (bestSize.x > 800)
- bestSize.x = 800;
- if (bestSize.y > 800)
- bestSize.y = 800;
+ if (m_pFrame && m_pCanvas) {
+ wxSize bestSize = m_pCanvas->GetBestSize();
- m_pFrame->SetClientSize (bestSize);
- m_pFrame->Show (true);
- m_pFrame->SetFocus();
+ m_pFrame->SetClientSize (bestSize);
+ m_pFrame->Show (true);
+ m_pFrame->SetFocus();
+ }
}
void
// 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;
}
-wxSize
-PlotFileCanvas::GetBestSize() const
+PlotFileCanvas::~PlotFileCanvas ()
{
- if (! m_pView)
- return wxSize(0,0);
-
- 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);
}
-PlotFileCanvas::~PlotFileCanvas ()
+wxSize
+PlotFileCanvas::GetBestSize() const
{
- m_pView = NULL;
+ 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);
m_pFileMenu->Append(wxID_PREVIEW, "Print Pre&view");
m_pFileMenu->AppendSeparator();
m_pFileMenu->Append(MAINMENU_IMPORT, "&Import...\tCtrl-M");
-#ifdef CTSIM_MDI
m_pFileMenu->AppendSeparator();
m_pFileMenu->Append (MAINMENU_FILE_PREFERENCES, "Prefere&nces...");
m_pFileMenu->Append(MAINMENU_FILE_EXIT, "E&xit");
-#endif
GetDocumentManager()->FileHistoryAddFilesToMenu(m_pFileMenu);
GetDocumentManager()->FileHistoryUseMenu(m_pFileMenu);
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);
+ 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");
m_pFrame->Show (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_pFileMenu->Append(wxID_PREVIEW, "Print Pre&view");
m_pFileMenu->AppendSeparator();
m_pFileMenu->Append(MAINMENU_IMPORT, "&Import...\tCtrl-M");
-#ifdef CTSIM_MDI
m_pFileMenu->AppendSeparator();
m_pFileMenu->Append (MAINMENU_FILE_PREFERENCES, "Prefere&nces...");
m_pFileMenu->Append(MAINMENU_FILE_EXIT, "E&xit");
-#endif
GetDocumentManager()->FileHistoryAddFilesToMenu(m_pFileMenu);
GetDocumentManager()->FileHistoryUseMenu(m_pFileMenu);