X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=src%2Fviews.cpp;h=465990360c18f9dc160ff598a4e48bca40db67ac;hb=65732cc5d8dbf867ed56a021c07c5636cea93b5a;hp=740c81c03615fca0236f43947be4c453041d817c;hpb=c551b53b39a7571cf52831f5e117be1cca95c420;p=ctsim.git diff --git a/src/views.cpp b/src/views.cpp index 740c81c..4659903 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.36 2000/12/22 04:18:00 kevin Exp $ +** $Id: views.cpp,v 1.39 2000/12/27 03:16:02 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 @@ -91,9 +91,10 @@ ImageFileCanvas::DrawRubberBandCursor (wxDC& dc, int x, int y) int nx = rIF.nx(); int ny = rIF.ny(); + int yPt = ny - y - 1; dc.SetLogicalFunction (wxINVERT); dc.SetPen (*wxGREEN_PEN); - dc.DrawLine (0, y, nx, y); + dc.DrawLine (0, yPt, nx, yPt); dc.DrawLine (x, 0, x, ny); dc.SetLogicalFunction (wxCOPY); } @@ -121,38 +122,33 @@ ImageFileCanvas::OnMouseEvent(wxMouseEvent& event) wxPoint pt(event.GetLogicalPosition(dc)); + const ImageFile& rIF = m_pView->GetDocument()->getImageFile(); + ImageFileArrayConst v = rIF.getArray(); + int nx = rIF.nx(); + int ny = rIF.ny(); + const int yPt = ny - 1 - pt.y; if (event.RightIsDown()) { - const ImageFile& rIF = m_pView->GetDocument()->getImageFile(); - ImageFileArrayConst v = rIF.getArray(); - int nx = rIF.nx(); - int ny = rIF.ny(); - if (pt.x >= 0 && pt.x < nx && pt.y >= 0 && pt.y < ny) { std::ostringstream os; - os << "Image value (" << pt.x << "," << pt.y << ") = " << v[pt.x][ny - 1 - pt.y] << "\n"; + os << "Image value (" << pt.x << "," << yPt << ") = " << v[pt.x][yPt] << "\n"; *theApp->getLog() << os.str().c_str(); } else - *theApp->getLog() << "Mouse out of image range (" << pt.x << "," << pt.y << ")\n"; + *theApp->getLog() << "Mouse out of image range (" << pt.x << "," << yPt << ")\n"; } - else if (event.LeftIsDown() || event.LeftUp()) { - const ImageFile& rIF = m_pView->GetDocument()->getImageFile(); - ImageFileArrayConst v = rIF.getArray(); - int nx = rIF.nx(); - int ny = rIF.ny(); - + else if (event.LeftIsDown() || event.LeftUp() || event.RightUp()) { if (pt.x >= 0 && pt.x < nx && pt.y >= 0 && pt.y < ny) { if (m_xCursor >= 0 && m_yCursor >= 0) { DrawRubberBandCursor (dc, m_xCursor, m_yCursor); } - DrawRubberBandCursor (dc, pt.x, pt.y); + DrawRubberBandCursor (dc, pt.x, yPt); m_xCursor = pt.x; - m_yCursor = pt.y; + m_yCursor = yPt; } else - *theApp->getLog() << "Mouse out of image range (" << pt.x << "," << pt.y << ")\n"; + *theApp->getLog() << "Mouse out of image range (" << pt.x << "," << yPt << ")\n"; } if (event.LeftUp()) { std::ostringstream os; - os << "Selected column" << pt.x << " and row" << pt.y << "\n"; + os << "Selected column " << pt.x << " , row " << yPt << "\n"; *theApp->getLog() << os.str().c_str(); } } @@ -284,7 +280,8 @@ ImageFileView::OnCompare (wxCommandEvent& event) return; } - pDifferenceDoc->Modify(true); + if (theApp->getSetModifyNewDocs()) + pDifferenceDoc->Modify(true); pDifferenceDoc->UpdateAllViews(this); pDifferenceDoc->GetFirstView()->OnUpdate (this, NULL); } @@ -493,18 +490,24 @@ ImageFileView::OnPlotRow (wxCommandEvent& event) sys_error (ERR_SEVERE, "Internal error: unable to create Plot file"); } else { PlotFile& rPlotFile = pPlotDoc->getPlotFile(); - std::ostringstream title; - title << "Row " << yCursor; - rPlotFile.setTitle(title.str()); - rPlotFile.setXLabel("Column"); - rPlotFile.setYLabel("Pixel Value"); + std::ostringstream os; + os << "Row " << yCursor; + std::string title("title "); + title += os.str(); + rPlotFile.addEzsetCommand (title.c_str()); + rPlotFile.addEzsetCommand ("xlabel Column"); + rPlotFile.addEzsetCommand ("ylabel Pixel Value"); + rPlotFile.addEzsetCommand ("lxfrac 0"); + rPlotFile.addEzsetCommand ("box"); + rPlotFile.addEzsetCommand ("grid"); rPlotFile.setCurveSize (2, nx); rPlotFile.addColumn (0, pX); rPlotFile.addColumn (1, pY); } delete pX; delete pY; - pPlotDoc->Modify(true); + if (theApp->getSetModifyNewDocs()) + pPlotDoc->Modify(true); } } @@ -535,18 +538,24 @@ ImageFileView::OnPlotCol (wxCommandEvent& event) sys_error (ERR_SEVERE, "Internal error: unable to create Plot file"); } else { PlotFile& rPlotFile = pPlotDoc->getPlotFile(); - std::ostringstream title; - title << "Column " << xCursor; - rPlotFile.setTitle(title.str()); - rPlotFile.setXLabel("Row"); - rPlotFile.setYLabel("Pixel Value"); + std::ostringstream os; + os << "Column " << xCursor; + std::string title("title "); + title += os.str(); + rPlotFile.addEzsetCommand (title.c_str()); + rPlotFile.addEzsetCommand ("xlabel Row"); + rPlotFile.addEzsetCommand ("ylabel Pixel Value"); + rPlotFile.addEzsetCommand ("lxfrac 0"); + rPlotFile.addEzsetCommand ("box"); + rPlotFile.addEzsetCommand ("grid"); rPlotFile.setCurveSize (2, nx); rPlotFile.addColumn (0, pX); rPlotFile.addColumn (1, pY); } delete pX; delete pY; - pPlotDoc->Modify(true); + if (theApp->getSetModifyNewDocs()) + pPlotDoc->Modify(true); } } @@ -561,7 +570,10 @@ ImageFileView::OnCompareCol (wxCommandEvent& event) std::vector vecIFDoc; theApp->getCompatibleImages (GetDocument(), vecIFDoc); - + if (vecIFDoc.size() == 0) { + wxMessageBox ("No compatible images for Column Comparison", "Error"); + return; + } DialogGetComparisonImage dialogGetCompare (m_frame, "Get Comparison Image", vecIFDoc, false); if (dialogGetCompare.ShowModal() == wxID_OK) { @@ -588,11 +600,21 @@ ImageFileView::OnCompareCol (wxCommandEvent& event) sys_error (ERR_SEVERE, "Internal error: unable to create Plot file"); } else { PlotFile& rPlotFile = pPlotDoc->getPlotFile(); - std::ostringstream title; - title << "Comparison of Column " << xCursor; - rPlotFile.setTitle(title.str()); - rPlotFile.setXLabel("Row"); - rPlotFile.setYLabel("Pixel Value"); + std::ostringstream os; + os << "Column " << xCursor << " Comparison"; + std::string title("title "); + title += os.str(); + rPlotFile.addEzsetCommand (title.c_str()); + rPlotFile.addEzsetCommand ("xlabel Row"); + rPlotFile.addEzsetCommand ("ylabel Pixel Value"); + rPlotFile.addEzsetCommand ("lxfrac 0"); + rPlotFile.addEzsetCommand ("curve 1"); + rPlotFile.addEzsetCommand ("color 2"); + rPlotFile.addEzsetCommand ("curve 2"); + rPlotFile.addEzsetCommand ("color 4"); + rPlotFile.addEzsetCommand ("dash 5"); + rPlotFile.addEzsetCommand ("box"); + rPlotFile.addEzsetCommand ("grid"); rPlotFile.setCurveSize (3, nx); rPlotFile.addColumn (0, pX); rPlotFile.addColumn (1, pY1); @@ -601,7 +623,8 @@ ImageFileView::OnCompareCol (wxCommandEvent& event) delete pX; delete pY1; delete pY2; - pPlotDoc->Modify(true); + if (theApp->getSetModifyNewDocs()) + pPlotDoc->Modify(true); } } } @@ -618,6 +641,11 @@ ImageFileView::OnCompareRow (wxCommandEvent& event) std::vector vecIFDoc; theApp->getCompatibleImages (GetDocument(), vecIFDoc); + if (vecIFDoc.size() == 0) { + wxMessageBox ("No compatible images for Row Comparison", "Error"); + return; + } + DialogGetComparisonImage dialogGetCompare (m_frame, "Get Comparison Image", vecIFDoc, false); if (dialogGetCompare.ShowModal() == wxID_OK) { @@ -644,11 +672,21 @@ ImageFileView::OnCompareRow (wxCommandEvent& event) sys_error (ERR_SEVERE, "Internal error: unable to create Plot file"); } else { PlotFile& rPlotFile = pPlotDoc->getPlotFile(); - std::ostringstream title; - title << "Comparison of Row " << yCursor; - rPlotFile.setTitle(title.str()); - rPlotFile.setXLabel("Column"); - rPlotFile.setYLabel("Pixel Value"); + std::ostringstream os; + os << "Row " << yCursor << " Comparison"; + std::string title("title "); + title += os.str(); + rPlotFile.addEzsetCommand (title.c_str()); + rPlotFile.addEzsetCommand ("xlabel Column"); + rPlotFile.addEzsetCommand ("ylabel Pixel Value"); + rPlotFile.addEzsetCommand ("lxfrac 0"); + rPlotFile.addEzsetCommand ("curve 1"); + rPlotFile.addEzsetCommand ("color 2"); + rPlotFile.addEzsetCommand ("curve 2"); + rPlotFile.addEzsetCommand ("color 4"); + rPlotFile.addEzsetCommand ("dash 5"); + rPlotFile.addEzsetCommand ("box"); + rPlotFile.addEzsetCommand ("grid"); rPlotFile.setCurveSize (3, ny); rPlotFile.addColumn (0, pX); rPlotFile.addColumn (1, pY1); @@ -657,7 +695,8 @@ ImageFileView::OnCompareRow (wxCommandEvent& event) delete pX; delete pY1; delete pY2; - pPlotDoc->Modify(true); + if (theApp->getSetModifyNewDocs()) + pPlotDoc->Modify(true); } } } @@ -800,7 +839,8 @@ PhantomView::OnProjections (wxCommandEvent& event) theApp->getDocManager()->ActivateView (pView, true, false); } ::wxYield(); - pProjectionDoc->Modify(true); + if (theApp->getSetModifyNewDocs()) + pProjectionDoc->Modify(true); pProjectionDoc->UpdateAllViews(this); } } @@ -836,7 +876,8 @@ PhantomView::OnRasterize (wxCommandEvent& event) return; } } - pRasterDoc->Modify(true); + if (theApp->getSetModifyNewDocs()) + pRasterDoc->Modify(true); pRasterDoc->UpdateAllViews(this); ImageFileView* rasterView = dynamic_cast(pRasterDoc->GetFirstView()); if (rasterView) { @@ -1060,7 +1101,7 @@ ProjectionFileView::OnReconstruct (wxCommandEvent& event) m_iDefaultTrace = dialogReconstruction.getTrace(); if (m_iDefaultNX > 0 && m_iDefaultNY > 0) { ImageFileDocument* pReconDoc = dynamic_cast(theApp->getDocManager()->CreateDocument("untitled.if", wxDOC_SILENT)); - if (pReconDoc) { + if (! pReconDoc) { sys_error (ERR_SEVERE, "Unable to create image file"); return; } @@ -1122,7 +1163,8 @@ ProjectionFileView::OnReconstruct (wxCommandEvent& event) } } delete pReconstruct; - pReconDoc->Modify(true); + if (theApp->getSetModifyNewDocs()) + pReconDoc->Modify(true); pReconDoc->UpdateAllViews(this); ImageFileView* rasterView = dynamic_cast(pReconDoc->GetFirstView()); if (rasterView) { @@ -1498,25 +1540,11 @@ PlotFileView::OnDraw (wxDC* dc) m_canvas->GetClientSize (&xsize, &ysize); SGPDriver driver (dc, xsize, ysize); SGP sgp (driver); - const PlotFile& rPhantom = GetDocument()->getPlotFile(); EZPlot plot (sgp); - - if (! rPlotFile.getTitle().empty()) { - std::string s("title "); - s += rPlotFile.getTitle(); - plot.ezset (s); - } - if (! rPlotFile.getXLabel().empty()) { - std::string s("xlabel "); - s += rPlotFile.getXLabel(); - plot.ezset (s); - } - if (! rPlotFile.getYLabel().empty()) { - std::string s("ylabel "); - s += rPlotFile.getYLabel(); - plot.ezset (s); - } - + + for (int iEzset = 0; iEzset < rPlotFile.getNumEzsetCommands(); iEzset++) + plot.ezset (rPlotFile.getEzsetCommand (iEzset)); + if (m_bMinSpecified) { std::ostringstream os; os << "ymin " << m_dMinPixel;