X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=src%2Fviews.cpp;h=0bf911a79fe7d52582b4385260fc3fa5b66aac2e;hp=bd54f07afa54af3165a2182a55f1d306e2988614;hb=8a7697ce57b56cdc43698cd1241ad98d49f9b5ac;hpb=2093dcb9760e9261299ebbab4f8ff203e4d9af77 diff --git a/src/views.cpp b/src/views.cpp index bd54f07..0bf911a 100644 --- a/src/views.cpp +++ b/src/views.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (c) 1983-2001 Kevin Rosenberg ** -** $Id: views.cpp,v 1.160 2002/06/03 16:57:22 kevin Exp $ +** $Id$ ** ** 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 @@ -184,7 +184,7 @@ ImageFileCanvas::OnChar (wxKeyEvent& event) if (m_pView) m_pView->OnUpdate (NULL); } else - wxScrolledWindow::OnChar (event); + event.Skip(); } wxSize @@ -268,10 +268,10 @@ EVT_MENU(IFMENU_PLOT_HISTOGRAM, ImageFileView::OnPlotHistogram) 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_pBitmap(0), 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() { @@ -329,6 +329,7 @@ ImageFileView::OnScaleAuto (wxCommandEvent& event) m_dMinPixel = dMin; m_dMaxPixel = dMax; m_dAutoScaleFactor = dialogAutoScale.getAutoScaleFactor(); + OnUpdate(this, NULL); GetDocument()->UpdateAllViews (this); } } @@ -355,6 +356,7 @@ ImageFileView::OnScaleMinMax (wxCommandEvent& event) m_bMaxSpecified = true; m_dMinPixel = dialogMinMax.getMinimum(); m_dMaxPixel = dialogMinMax.getMaximum(); + OnUpdate(this, NULL); GetDocument()->UpdateAllViews (this); } GetDocument()->Activate(); @@ -366,6 +368,7 @@ ImageFileView::OnScaleFull (wxCommandEvent& event) if (m_bMinSpecified || m_bMaxSpecified) { m_bMinSpecified = false; m_bMaxSpecified = false; + OnUpdate(this, NULL); GetDocument()->UpdateAllViews (this); } GetDocument()->Activate(); @@ -423,6 +426,7 @@ ImageFileView::OnCompare (wxCommandEvent& event) pDifferenceImage->labelAdd (os.str().c_str()); if (theApp->getAskDeleteNewDocs()) pDifferenceDoc->Modify (true); + OnUpdate(this, NULL); pDifferenceDoc->UpdateAllViews(this); pDifferenceDoc->getView()->setInitialClientSize(); pDifferenceDoc->Activate(); @@ -440,6 +444,7 @@ ImageFileView::OnInvertValues (wxCommandEvent& event) rIF.labelAdd ("Invert Pixel Values"); if (theApp->getAskDeleteNewDocs()) GetDocument()->Modify (true); + OnUpdate(this, NULL); GetDocument()->UpdateAllViews (this); GetDocument()->Activate(); } @@ -452,6 +457,7 @@ ImageFileView::OnSquare (wxCommandEvent& event) rIF.labelAdd ("Square Pixel Values"); if (theApp->getAskDeleteNewDocs()) GetDocument()->Modify (true); + OnUpdate(this, NULL); GetDocument()->UpdateAllViews (this); GetDocument()->Activate(); } @@ -464,6 +470,7 @@ ImageFileView::OnSquareRoot (wxCommandEvent& event) rIF.labelAdd ("Square-root Pixel Values"); if (theApp->getAskDeleteNewDocs()) GetDocument()->Modify (true); + OnUpdate(this, NULL); GetDocument()->UpdateAllViews (this); GetDocument()->Activate(); } @@ -476,6 +483,7 @@ ImageFileView::OnLog (wxCommandEvent& event) rIF.labelAdd ("Logrithm base-e Pixel Values"); if (theApp->getAskDeleteNewDocs()) GetDocument()->Modify (true); + OnUpdate(this, NULL); GetDocument()->UpdateAllViews (this); GetDocument()->Activate(); } @@ -488,6 +496,7 @@ ImageFileView::OnExp (wxCommandEvent& event) rIF.labelAdd ("Exponent base-e Pixel Values"); if (theApp->getAskDeleteNewDocs()) GetDocument()->Modify (true); + OnUpdate(this, NULL); GetDocument()->UpdateAllViews (this); GetDocument()->Activate(); } @@ -526,6 +535,7 @@ ImageFileView::OnAdd (wxCommandEvent& event) *theApp->getLog() << os.str().c_str() << "\n"; if (theApp->getAskDeleteNewDocs()) pNewDoc->Modify (true); + OnUpdate(this, NULL); pNewDoc->UpdateAllViews (this); pNewDoc->getView()->setInitialClientSize(); pNewDoc->Activate(); @@ -567,6 +577,7 @@ ImageFileView::OnSubtract (wxCommandEvent& event) *theApp->getLog() << os.str().c_str() << "\n"; if (theApp->getAskDeleteNewDocs()) pNewDoc->Modify (true); + OnUpdate(this, NULL); pNewDoc->UpdateAllViews (this); pNewDoc->getView()->setInitialClientSize(); pNewDoc->Activate(); @@ -608,6 +619,7 @@ ImageFileView::OnMultiply (wxCommandEvent& event) *theApp->getLog() << os.str().c_str() << "\n"; if (theApp->getAskDeleteNewDocs()) pNewDoc->Modify (true); + OnUpdate(this, NULL); pNewDoc->UpdateAllViews (this); pNewDoc->getView()->setInitialClientSize(); pNewDoc->Activate(); @@ -649,6 +661,7 @@ ImageFileView::OnDivide (wxCommandEvent& event) *theApp->getLog() << os.str().c_str() << "\n"; if (theApp->getAskDeleteNewDocs()) pNewDoc->Modify (true); + OnUpdate(this, NULL); pNewDoc->UpdateAllViews (this); pNewDoc->getView()->setInitialClientSize(); pNewDoc->Activate(); @@ -668,6 +681,7 @@ ImageFileView::OnFFT (wxCommandEvent& event) m_bMaxSpecified = false; if (theApp->getAskDeleteNewDocs()) GetDocument()->Modify (true); + OnUpdate(this, NULL); GetDocument()->UpdateAllViews (this); GetDocument()->Activate(); } @@ -682,6 +696,7 @@ ImageFileView::OnIFFT (wxCommandEvent& event) m_bMaxSpecified = false; if (theApp->getAskDeleteNewDocs()) GetDocument()->Modify (true); + OnUpdate(this, NULL); GetDocument()->UpdateAllViews (this); GetDocument()->Activate(); } @@ -696,6 +711,7 @@ ImageFileView::OnFFTRows (wxCommandEvent& event) m_bMaxSpecified = false; if (theApp->getAskDeleteNewDocs()) GetDocument()->Modify (true); + OnUpdate(this, NULL); GetDocument()->UpdateAllViews (this); GetDocument()->Activate(); } @@ -710,6 +726,7 @@ ImageFileView::OnIFFTRows (wxCommandEvent& event) m_bMaxSpecified = false; if (theApp->getAskDeleteNewDocs()) GetDocument()->Modify (true); + OnUpdate(this, NULL); GetDocument()->UpdateAllViews (this); GetDocument()->Activate(); } @@ -724,6 +741,7 @@ ImageFileView::OnFFTCols (wxCommandEvent& event) m_bMaxSpecified = false; if (theApp->getAskDeleteNewDocs()) GetDocument()->Modify (true); + OnUpdate(this, NULL); GetDocument()->UpdateAllViews (this); GetDocument()->Activate(); } @@ -738,6 +756,7 @@ ImageFileView::OnIFFTCols (wxCommandEvent& event) m_bMaxSpecified = false; if (theApp->getAskDeleteNewDocs()) GetDocument()->Modify (true); + OnUpdate(this, NULL); GetDocument()->UpdateAllViews (this); GetDocument()->Activate(); } @@ -754,6 +773,7 @@ ImageFileView::OnFourier (wxCommandEvent& event) m_bMaxSpecified = false; if (theApp->getAskDeleteNewDocs()) GetDocument()->Modify (true); + OnUpdate(this, NULL); GetDocument()->UpdateAllViews (this); GetDocument()->Activate(); } @@ -769,6 +789,7 @@ ImageFileView::OnInverseFourier (wxCommandEvent& event) m_bMaxSpecified = false; if (theApp->getAskDeleteNewDocs()) GetDocument()->Modify (true); + OnUpdate(this, NULL); GetDocument()->UpdateAllViews (this); GetDocument()->Activate(); } @@ -783,6 +804,7 @@ ImageFileView::OnShuffleNaturalToFourierOrder (wxCommandEvent& event) m_bMaxSpecified = false; if (theApp->getAskDeleteNewDocs()) GetDocument()->Modify (true); + OnUpdate(this, NULL); GetDocument()->UpdateAllViews (this); GetDocument()->Activate(); } @@ -797,6 +819,7 @@ ImageFileView::OnShuffleFourierToNaturalOrder (wxCommandEvent& event) m_bMaxSpecified = false; if (theApp->getAskDeleteNewDocs()) GetDocument()->Modify (true); + OnUpdate(this, NULL); GetDocument()->UpdateAllViews (this); GetDocument()->Activate(); } @@ -811,6 +834,7 @@ ImageFileView::OnMagnitude (wxCommandEvent& event) m_bMaxSpecified = false; if (theApp->getAskDeleteNewDocs()) GetDocument()->Modify (true); + OnUpdate(this, NULL); GetDocument()->UpdateAllViews (this); GetDocument()->Activate(); } @@ -826,6 +850,7 @@ ImageFileView::OnPhase (wxCommandEvent& event) m_bMaxSpecified = false; if (theApp->getAskDeleteNewDocs()) GetDocument()->Modify (true); + OnUpdate(this, NULL); GetDocument()->UpdateAllViews (this); } GetDocument()->Activate(); @@ -842,6 +867,7 @@ ImageFileView::OnReal (wxCommandEvent& event) m_bMaxSpecified = false; if (theApp->getAskDeleteNewDocs()) GetDocument()->Modify (true); + OnUpdate(this, NULL); GetDocument()->UpdateAllViews (this); } GetDocument()->Activate(); @@ -858,6 +884,7 @@ ImageFileView::OnImaginary (wxCommandEvent& event) m_bMaxSpecified = false; if (theApp->getAskDeleteNewDocs()) GetDocument()->Modify (true); + OnUpdate(this, NULL); GetDocument()->UpdateAllViews (this); } GetDocument()->Activate(); @@ -908,11 +935,9 @@ ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view) 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); @@ -1062,8 +1087,12 @@ ImageFileView::setInitialClientSize () void ImageFileView::OnDraw (wxDC* dc) { - if (m_bitmap.Ok()) - dc->DrawBitmap(m_bitmap, 0, 0, false); + if (m_pBitmap && m_pBitmap->Ok()) { +#ifdef DEBUG + *theApp->getLog() << "Drawing bitmap\n"; +#endif + dc->DrawBitmap(*m_pBitmap, 0, 0, false); + } int xCursor, yCursor; if (m_pCanvas->GetCurrentCursor (xCursor, yCursor)) @@ -1113,7 +1142,14 @@ ImageFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) ) } } wxImage image (nx, ny, imageData, true); - m_bitmap = image.ConvertToBitmap(); + if (m_pBitmap) { + delete m_pBitmap; + m_pBitmap = NULL; + } +#ifdef DEBUG + *theApp->getLog() << "Making new bitmap\n"; +#endif + m_pBitmap = new wxBitmap (image); delete imageData; m_pCanvas->SetScrollbars(20, 20, nx/20, ny/20); m_pCanvas->SetBackgroundColour(*wxWHITE); @@ -1154,8 +1190,9 @@ void ImageFileView::OnEditCopy (wxCommandEvent& event) { wxBitmapDataObject *pBitmapObject = new wxBitmapDataObject; - - pBitmapObject->SetBitmap (m_bitmap); + + if (m_pBitmap) + pBitmapObject->SetBitmap (*m_pBitmap); if (wxTheClipboard->Open()) { wxTheClipboard->SetData (pBitmapObject); @@ -1198,7 +1235,7 @@ ImageFileView::OnEditPaste (wxCommandEvent& event) bool bMonochrome = false; if (bitmap.Ok() == true && bitmap.GetWidth() == nx && bitmap.GetHeight() == ny) { - wxImage image (bitmap); + wxImage image (bitmap.ConvertToImage()); double dScale3 = 3 * 255; unsigned char* pixels = image.GetData(); ImageFileArray v = rIF.getArray(); @@ -1310,6 +1347,7 @@ ImageFileView::OnScaleSize (wxCommandEvent& event) *theApp->getLog() << os.str().c_str() << "\n"; if (theApp->getAskDeleteNewDocs()) pScaledDoc->Modify (true); + OnUpdate(this, NULL); pScaledDoc->UpdateAllViews (this); pScaledDoc->getView()->setInitialClientSize(); pScaledDoc->Activate(); @@ -2175,6 +2213,7 @@ PhantomFileView::OnProjections (wxCommandEvent& event) pProjectionDoc->setProjections (pProj); if (theApp->getAskDeleteNewDocs()) pProjectionDoc-> Modify(true); + OnUpdate(this, NULL); pProjectionDoc->UpdateAllViews (this); pProjectionDoc->getView()->setInitialClientSize(); pProjectionDoc->Activate(); @@ -2299,11 +2338,9 @@ PhantomFileView::CreateChildFrame(wxDocument *doc, wxView *view) 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); @@ -2465,7 +2502,7 @@ END_EVENT_TABLE() ProjectionFileView::ProjectionFileView() -: wxView(), m_pFrame(0), m_pCanvas(0), m_pFileMenu(0) + : wxView(), m_pBitmap(0), m_pFrame(0), m_pCanvas(0), m_pFileMenu(0) { #ifdef DEBUG m_iDefaultNX = 115; @@ -2484,7 +2521,7 @@ ProjectionFileView::ProjectionFileView() m_iDefaultFilterMethod = ProcessSignal::FILTER_METHOD_CONVOLUTION; m_iDefaultFilterGeneration = ProcessSignal::FILTER_GENERATION_DIRECT; #endif - m_iDefaultZeropad = 1; + m_iDefaultZeropad = 2; m_iDefaultBackprojector = Backprojector::BPROJ_IDIFF; m_iDefaultInterpolation = Backprojector::INTERP_LINEAR; m_iDefaultInterpParam = 1; @@ -2493,7 +2530,7 @@ ProjectionFileView::ProjectionFileView() m_iDefaultPolarNX = 256; m_iDefaultPolarNY = 256; m_iDefaultPolarInterpolation = Projections::POLAR_INTERP_BILINEAR; - m_iDefaultPolarZeropad = 1; + m_iDefaultPolarZeropad = 2; } ProjectionFileView::~ProjectionFileView() @@ -2560,7 +2597,6 @@ ProjectionFileView::OnConvertPolar (wxCommandEvent& event) wxString strInterpolation (dialogPolar.getInterpolationName()); m_iDefaultPolarNX = dialogPolar.getXSize(); m_iDefaultPolarNY = dialogPolar.getYSize(); - ImageFileDocument* pPolarDoc = theApp->newImageDoc(); ImageFile* pIF = new ImageFile (m_iDefaultPolarNX, m_iDefaultPolarNY); m_iDefaultPolarInterpolation = Projections::convertInterpNameToID (strInterpolation.c_str()); @@ -2570,7 +2606,7 @@ ProjectionFileView::OnConvertPolar (wxCommandEvent& event) return; } - pPolarDoc = theApp->newImageDoc (); + ImageFileDocument* pPolarDoc = theApp->newImageDoc(); if (! pPolarDoc) { sys_error (ERR_SEVERE, "Unable to create image file"); return; @@ -3020,20 +3056,18 @@ ProjectionFileView::CreateChildFrame(wxDocument *doc, wxView *view) 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); - wxMenu *convert_menu = new wxMenu; - convert_menu->Append (PJMENU_CONVERT_RECTANGULAR, "&Rectangular Image"); - convert_menu->Append (PJMENU_CONVERT_POLAR, "&Polar Image...\tCtrl-L"); - convert_menu->Append (PJMENU_CONVERT_FFT_POLAR, "FF&T->Polar Image...\tCtrl-T"); - convert_menu->AppendSeparator(); - convert_menu->Append (PJMENU_CONVERT_PARALLEL, "&Interpolate to Parallel"); + m_pConvertMenu = new wxMenu; + m_pConvertMenu->Append (PJMENU_CONVERT_RECTANGULAR, "&Rectangular Image"); + m_pConvertMenu->Append (PJMENU_CONVERT_POLAR, "&Polar Image...\tCtrl-L"); + m_pConvertMenu->Append (PJMENU_CONVERT_FFT_POLAR, "FF&T->Polar Image...\tCtrl-T"); + m_pConvertMenu->AppendSeparator(); + m_pConvertMenu->Append (PJMENU_CONVERT_PARALLEL, "&Interpolate to Parallel"); // wxMenu* filter_menu = new wxMenu; // filter_menu->Append (PJMENU_ARTIFACT_REDUCTION, "&Artifact Reduction"); @@ -3042,11 +3076,10 @@ ProjectionFileView::CreateChildFrame(wxDocument *doc, wxView *view) analyze_menu->Append (PJMENU_PLOT_HISTOGRAM, "&Plot Histogram"); analyze_menu->Append (PJMENU_PLOT_TTHETA_SAMPLING, "Plot T-T&heta Sampling...\tCtrl-H"); - 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"); - // still buggy - // reconstruct_menu->Append (PJMENU_RECONSTRUCT_FOURIER, "&Fourier...\tCtrl-E", "Reconstruct image using inverse Fourier"); + m_pReconstructMenu = new wxMenu; + m_pReconstructMenu->Append (PJMENU_RECONSTRUCT_FBP, "&Filtered Backprojection...\tCtrl-R", "Reconstruct image using filtered backprojection"); + m_pReconstructMenu->Append (PJMENU_RECONSTRUCT_FBP_REBIN, "Filtered &Backprojection (Rebin to Parallel)...\tCtrl-B", "Reconstruct image using filtered backprojection"); + m_pReconstructMenu->Append (PJMENU_RECONSTRUCT_FOURIER, "&Inverse Fourier...\tCtrl-E", "Direct inverse Fourier"); wxMenu *help_menu = new wxMenu; help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents\tF1"); @@ -3057,10 +3090,10 @@ ProjectionFileView::CreateChildFrame(wxDocument *doc, wxView *view) wxMenuBar *menu_bar = new wxMenuBar; menu_bar->Append (m_pFileMenu, "&File"); - menu_bar->Append (convert_menu, "&Convert"); + menu_bar->Append (m_pConvertMenu, "&Convert"); // menu_bar->Append (filter_menu, "Fi<er"); menu_bar->Append (analyze_menu, "&Analyze"); - menu_bar->Append (reconstruct_menu, "&Reconstruct"); + menu_bar->Append (m_pReconstructMenu, "&Reconstruct"); menu_bar->Append (help_menu, "&Help"); subframe->SetMenuBar(menu_bar); @@ -3100,8 +3133,8 @@ ProjectionFileView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) void ProjectionFileView::OnDraw (wxDC* dc) { - if (m_bitmap.Ok()) - dc->DrawBitmap (m_bitmap, 0, 0, false); + if (m_pBitmap && m_pBitmap->Ok()) + dc->DrawBitmap (*m_pBitmap, 0, 0, false); } @@ -3123,6 +3156,14 @@ ProjectionFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) const Projections& rProj = GetDocument()->getProjections(); const int nDet = rProj.nDet(); const int nView = rProj.nView(); + if (rProj.geometry() == Scanner::GEOMETRY_PARALLEL) { + m_pReconstructMenu->Enable (PJMENU_RECONSTRUCT_FBP_REBIN, false); + m_pConvertMenu->Enable (PJMENU_CONVERT_PARALLEL, false); + } else { + m_pReconstructMenu->Enable (PJMENU_RECONSTRUCT_FBP_REBIN, true); + m_pConvertMenu->Enable (PJMENU_CONVERT_PARALLEL, true); + } + if (nDet != 0 && nView != 0) { const DetectorArray& detarray = rProj.getDetectorArray(0); const DetectorValue* detval = detarray.detValues(); @@ -3156,7 +3197,11 @@ ProjectionFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) } } wxImage image (nDet, nView, imageData, true); - m_bitmap = image.ConvertToBitmap(); + if (m_pBitmap) { + delete m_pBitmap; + m_pBitmap = NULL; + } + m_pBitmap = new wxBitmap (image); delete imageData; } @@ -3199,33 +3244,21 @@ ProjectionFileView::OnClose (bool deleteWindow) // 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 (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) { @@ -3246,7 +3279,8 @@ EVT_MENU(PLOTMENU_VIEW_SCALE_FULL, PlotFileView::OnScaleFull) 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) { } @@ -3256,6 +3290,7 @@ PlotFileView::~PlotFileView() delete m_pEZPlot; GetDocumentManager()->FileHistoryRemoveMenu (m_pFileMenu); + GetDocumentManager()->ActivateView(this, FALSE, TRUE); } void @@ -3341,11 +3376,8 @@ PlotFileCanvas* PlotFileView::CreateCanvas (wxFrame* parent) { PlotFileCanvas* pCanvas; - int width, height; - parent->GetClientSize(&width, &height); - - pCanvas = new PlotFileCanvas (this, parent, wxPoint(-1,-1), wxSize(width, height), 0); + pCanvas = new PlotFileCanvas (this, parent, wxPoint(-1,-1), wxSize(-1,-1), 0); pCanvas->SetBackgroundColour(*wxWHITE); pCanvas->Clear(); @@ -3360,9 +3392,9 @@ wxDocChildFrame* PlotFileView::CreateChildFrame(wxDocument *doc, wxView *view) { #ifdef CTSIM_MDI - wxDocMDIChildFrame *subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "Plot Frame", wxPoint(-1,-1), 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(-1,-1), 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); @@ -3384,11 +3416,9 @@ PlotFileView::CreateChildFrame(wxDocument *doc, wxView *view) 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); @@ -3427,17 +3457,16 @@ PlotFileView::CreateChildFrame(wxDocument *doc, wxView *view) 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); @@ -3445,6 +3474,19 @@ PlotFileView::OnCreate (wxDocument *doc, long WXUNUSED(flags) ) 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) { @@ -3519,7 +3561,6 @@ PlotFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) ) bool PlotFileView::OnClose (bool deleteWindow) { - //GetDocumentManager()->ActivateView (this, false, true); if (! GetDocument() || ! GetDocument()->Close()) return false; @@ -3632,11 +3673,9 @@ TextFileView::CreateChildFrame (wxDocument *doc, wxView *view) 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);