X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=src%2Fviews.cpp;h=3411a45f67061e52f7970f54c35baff9149db003;hp=ead413d04ddca300cd6ff14d54dda90a1ce35df8;hb=e8462f7431582627e44906239077f1c696eefba1;hpb=a2ac3119d9f9572f113b1f32d7be996dd49037ae diff --git a/src/views.cpp b/src/views.cpp index ead413d..3411a45 100644 --- a/src/views.cpp +++ b/src/views.cpp @@ -1063,7 +1063,7 @@ ImageFileView::OnCreate (wxDocument *doc, long WXUNUSED(flags) ) m_pCanvas = CreateCanvas (m_pFrame); m_pFrame->SetClientSize (m_pCanvas->GetBestSize()); m_pCanvas->SetClientSize (m_pCanvas->GetBestSize()); - m_pFrame->SetTitle(_T("ImageFileView")); + m_pFrame->SetTitle(doc->GetFilename()); m_pFrame->Show(true); Activate(true); @@ -1310,14 +1310,9 @@ ImageFileView::OnExport (wxCommandEvent& event) strWildcard = _T("Miscellaneous (*.*)|*.*"); } -#if WXWIN_COMPATIBILITY_2_4 const wxString& strFilename = wxFileSelector (_T("Export Filename"), _T(""), - _T(""), strExt, strWildcard, wxOVERWRITE_PROMPT | wxHIDE_READONLY | wxSAVE); -#else - const wxString& strFilename = wxFileSelector (_T("Export Filename"), _T(""), - _T(""), strExt, strWildcard, wxOVERWRITE_PROMPT | wxSAVE); -#endif - if (strFilename) { + _T(""), strExt, strWildcard, wxFD_OVERWRITE_PROMPT | wxFD_SAVE); + if (strFilename.Length() > 0) { rIF.exportImage (strFormatName.mb_str(wxConvUTF8), strFilename.mb_str(wxConvUTF8), 1, 1, m_dMinPixel, m_dMaxPixel); *theApp->getLog() << _T("Exported file ") << strFilename << _T("\n"); } @@ -1413,7 +1408,7 @@ ImageFileView::OnPlotRow (wxCommandEvent& event) } else { PlotFile& rPlotFile = pPlotDoc->getPlotFile(); std::ostringstream os; - os << "Row " << yCursor << ": "; + os << "Row " << yCursor; std::string title("title "); title += os.str(); rPlotFile.addEzsetCommand (title.c_str()); @@ -1443,7 +1438,7 @@ ImageFileView::OnPlotRow (wxCommandEvent& event) } for (unsigned int iL = 0; iL < rIF.nLabels(); iL++) rPlotFile.addDescription (rIF.labelGet(iL).getLabelString().c_str()); - os << " Plot of " << wxConvUTF8.cWX2MB(dynamic_cast(GetDocument()->GetFirstView()->GetFrame())->GetTitle().c_str()); + os << ": plot of " << wxConvUTF8.cWX2MB(dynamic_cast(GetDocument()->GetFirstView()->GetFrame())->GetTitle().c_str()); *theApp->getLog() << wxConvUTF8.cMB2WX(os.str().c_str()) << _T("\n"); rPlotFile.addDescription (os.str().c_str()); } @@ -1499,7 +1494,7 @@ ImageFileView::OnPlotCol (wxCommandEvent& event) } else { PlotFile& rPlotFile = pPlotDoc->getPlotFile(); std::ostringstream os; - os << "Column " << xCursor << ": "; + os << "Column " << xCursor; std::string title("title "); title += os.str(); rPlotFile.addEzsetCommand (title.c_str()); @@ -1529,7 +1524,7 @@ ImageFileView::OnPlotCol (wxCommandEvent& event) } for (unsigned int iL = 0; iL < rIF.nLabels(); iL++) rPlotFile.addDescription (rIF.labelGet(iL).getLabelString().c_str()); - os << " Plot of " << wxConvUTF8.cWX2MB(dynamic_cast(GetDocument()->GetFirstView()->GetFrame())->GetTitle().c_str()); + os << " : plot of " << wxConvUTF8.cWX2MB(dynamic_cast(GetDocument()->GetFirstView()->GetFrame())->GetTitle().c_str()); *theApp->getLog() << wxConvUTF8.cMB2WX(os.str().c_str()) << _T("\n"); rPlotFile.addDescription (os.str().c_str()); } @@ -1599,7 +1594,7 @@ ImageFileView::OnPlotFFTRow (wxCommandEvent& event) } else { PlotFile& rPlotFile = pPlotDoc->getPlotFile(); std::ostringstream os; - os << "Row " << yCursor << ": "; + os << "Row " << yCursor; std::string title("title "); title += os.str(); rPlotFile.addEzsetCommand (title.c_str()); @@ -1624,7 +1619,7 @@ ImageFileView::OnPlotFFTRow (wxCommandEvent& event) rPlotFile.addColumn (3, pYMag); for (unsigned int iL = 0; iL < rIF.nLabels(); iL++) rPlotFile.addDescription (rIF.labelGet(iL).getLabelString().c_str()); - os << " FFT plot of " << wxConvUTF8.cWX2MB(dynamic_cast(GetDocument()->GetFirstView()->GetFrame())->GetTitle().c_str()); + os << ": FFT plot of " << wxConvUTF8.cWX2MB(dynamic_cast(GetDocument()->GetFirstView()->GetFrame())->GetTitle().c_str()); *theApp->getLog() << wxConvUTF8.cMB2WX(os.str().c_str()) << _T("\n"); rPlotFile.addDescription (os.str().c_str()); } @@ -1699,7 +1694,7 @@ ImageFileView::OnPlotFFTCol (wxCommandEvent& event) } else { PlotFile& rPlotFile = pPlotDoc->getPlotFile(); std::ostringstream os; - os << "Column " << xCursor << ": "; + os << "Column " << xCursor; std::string title("title "); title += os.str(); rPlotFile.addEzsetCommand (title.c_str()); @@ -1724,7 +1719,7 @@ ImageFileView::OnPlotFFTCol (wxCommandEvent& event) rPlotFile.addColumn (3, pYMag); for (unsigned int iL = 0; iL < rIF.nLabels(); iL++) rPlotFile.addDescription (rIF.labelGet(iL).getLabelString().c_str()); - os << " FFT plot of " << wxConvUTF8.cWX2MB(dynamic_cast(GetDocument()->GetFirstView()->GetFrame())->GetTitle().c_str()); + os << ": FFT plot of " << wxConvUTF8.cWX2MB(dynamic_cast(GetDocument()->GetFirstView()->GetFrame())->GetTitle().c_str()); *theApp->getLog() << wxConvUTF8.cMB2WX(os.str().c_str()) << _T("\n"); rPlotFile.addDescription (os.str().c_str()); } @@ -1956,42 +1951,42 @@ ImageFileView::OnPlotHistogram (wxCommandEvent& event) pX[i] = dMin + (i + 0.5) * dBinWidth; pY[i] = 0; } - for (int ix = 0; ix < nx; ix++) + for (int ix = 0; ix < nx; ix++) { for (int iy = 0; iy < ny; iy++) { int iBin = nearest ((v[ix][iy] - dMin) / dBinWidth); if (iBin >= 0 && iBin < NUMBER_HISTOGRAM_BINS) pY[iBin] += 1; } - - PlotFile& rPlotFile = pPlotDoc->getPlotFile(); + } + PlotFile& rPlotFile = pPlotDoc->getPlotFile(); + std::ostringstream os; + os << "Histogram"; + std::string title("title "); + title += os.str(); + rPlotFile.addEzsetCommand (title.c_str()); + rPlotFile.addEzsetCommand ("xlabel Pixel Value"); + rPlotFile.addEzsetCommand ("ylabel Count"); + rPlotFile.addEzsetCommand ("box"); + rPlotFile.addEzsetCommand ("grid"); + rPlotFile.setCurveSize (2, NUMBER_HISTOGRAM_BINS); + rPlotFile.addColumn (0, pX); + rPlotFile.addColumn (1, pY); + for (unsigned int iL = 0; iL < rIF.nLabels(); iL++) { std::ostringstream os; - os << "Histogram "; - std::string title("title "); - title += os.str(); - rPlotFile.addEzsetCommand (title.c_str()); - rPlotFile.addEzsetCommand ("xlabel Pixel Value"); - rPlotFile.addEzsetCommand ("ylabel Count"); - rPlotFile.addEzsetCommand ("box"); - rPlotFile.addEzsetCommand ("grid"); - rPlotFile.setCurveSize (2, NUMBER_HISTOGRAM_BINS); - rPlotFile.addColumn (0, pX); - rPlotFile.addColumn (1, pY); - for (unsigned int iL = 0; iL < rIF.nLabels(); iL++) { - std::ostringstream os; - os << dynamic_cast(GetDocument()->GetFirstView()->GetFrame())->GetTitle().mb_str(wxConvUTF8); - os << ": " << rIF.labelGet(iL).getLabelString(); - rPlotFile.addDescription (os.str().c_str()); - } - os << " Plot of " << wxConvUTF8.cWX2MB(dynamic_cast(GetDocument()->GetFirstView()->GetFrame())->GetTitle().c_str()); - *theApp->getLog() << wxConvUTF8.cMB2WX(os.str().c_str()) << _T("\n"); + os << dynamic_cast(GetDocument()->GetFirstView()->GetFrame())->GetTitle().mb_str(wxConvUTF8); + os << ": " << rIF.labelGet(iL).getLabelString(); rPlotFile.addDescription (os.str().c_str()); - delete pX; - delete pY; - if (theApp->getAskDeleteNewDocs()) - pPlotDoc->Modify (true); - pPlotDoc->getView()->getFrame()->Show(true); - pPlotDoc->UpdateAllViews (); - pPlotDoc->Activate(); + } + os << " plot of " << wxConvUTF8.cWX2MB(dynamic_cast(GetDocument()->GetFirstView()->GetFrame())->GetTitle().c_str()); + *theApp->getLog() << wxConvUTF8.cMB2WX(os.str().c_str()) << _T("\n"); + rPlotFile.addDescription (os.str().c_str()); + delete pX; + delete pY; + if (theApp->getAskDeleteNewDocs()) + pPlotDoc->Modify (true); + pPlotDoc->getView()->getFrame()->Show(true); + pPlotDoc->UpdateAllViews (); + pPlotDoc->Activate(); } } @@ -2312,7 +2307,6 @@ PhantomFileView::CreateCanvas (wxFrame *parent) wxSize(-1,-1), wxFULL_REPAINT_ON_RESIZE); pCanvas->SetBackgroundColour(*wxWHITE); pCanvas->ClearBackground(); - return pCanvas; } @@ -2391,7 +2385,7 @@ PhantomFileView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) m_pCanvas = CreateCanvas (m_pFrame); m_pFrame->SetClientSize (m_pCanvas->GetBestSize()); m_pCanvas->SetClientSize (m_pCanvas->GetBestSize()); - m_pFrame->SetTitle (_T("PhantomFileView")); + m_pFrame->SetTitle (doc->GetFilename()); m_pFrame->Show(true); Activate(true); @@ -3134,7 +3128,7 @@ ProjectionFileView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) m_pCanvas = CreateCanvas (m_pFrame); m_pFrame->SetClientSize (m_pCanvas->GetBestSize()); m_pCanvas->SetClientSize (m_pCanvas->GetBestSize()); - m_pFrame->SetTitle (_T("ProjectionFileView")); + m_pFrame->SetTitle (doc->GetFilename()); m_pFrame->Show(true); Activate(true); @@ -3255,7 +3249,9 @@ ProjectionFileView::OnClose (bool deleteWindow) // PlotFileCanvas -PlotFileCanvas::PlotFileCanvas (PlotFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style) +PlotFileCanvas::PlotFileCanvas (PlotFileView* v, wxFrame *frame, + const wxPoint& pos, const wxSize& size, + const long style) : wxScrolledWindow(frame, -1, pos, size, style), m_pView(v) { } @@ -3375,14 +3371,8 @@ PlotFileView::OnScaleMinMax (wxCommandEvent& event) void PlotFileView::OnScaleFull (wxCommandEvent& event) { - const PlotFile& rPlotFile = GetDocument()->getPlotFile(); - if (! rPlotFile.getMinMax (1, m_dMinPixel, m_dMaxPixel)) { - *theApp->getLog() << _T("Error: unable to find Min/Max\n"); - return; - } - - m_bMinSpecified = true; - m_bMaxSpecified = true; + m_bMinSpecified = false; + m_bMaxSpecified = false; OnUpdate (this, NULL); GetDocument()->Activate(); } @@ -3483,7 +3473,10 @@ PlotFileView::OnCreate (wxDocument *doc, long WXUNUSED(flags) ) m_pCanvas = CreateCanvas (m_pFrame); m_pFrame->SetClientSize (m_pCanvas->GetBestSize()); m_pCanvas->SetClientSize (m_pCanvas->GetBestSize()); - m_pFrame->SetTitle (_T("Plot File")); + m_pFrame->SetTitle (_T("test")); + *theApp->getLog() << _T("Plot doc name: ") << doc->GetDocumentName() << _T("\n"); + *theApp->getLog() << _T("Plot file name: ") << doc->GetFilename() << _T("\n"); + m_pFrame->SetTitle (doc->GetFilename()); m_pFrame->Show(true); Activate(true); @@ -3571,8 +3564,9 @@ PlotFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) ) delete pdY; } - if (m_pCanvas) + if (m_pCanvas) { m_pCanvas->Refresh(); + } } bool @@ -3620,9 +3614,8 @@ bool TextFileView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) int width, height; m_pFrame->GetClientSize(&width, &height); - m_pFrame->SetTitle(_T("TextFile")); + m_pFrame->SetTitle(doc->GetFilename()); m_pCanvas = new TextFileCanvas (this, m_pFrame, wxPoint(-1,-1), wxSize(width, height), wxTE_MULTILINE | wxTE_READONLY); - m_pFrame->SetTitle(_T("Log")); m_pFrame->Show (true); Activate (true);