r308: plotfile changes
[ctsim.git] / src / views.cpp
index d3827f0e41a281b0833a42d1bf755ca3d6dd2d8a..d40fd5edd988240a2f38ff43d1fda38b4a95f770 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: views.cpp,v 1.32 2000/12/20 14:39:09 kevin Exp $
+**  $Id: views.cpp,v 1.33 2000/12/20 14:52:30 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
@@ -432,15 +432,17 @@ ImageFileView::OnPlotRow (wxCommandEvent& event)
                        sys_error (ERR_SEVERE, "Internal error: unable to create Plot file");\r
                } else {\r
                        PlotFile& rPlot = pPlotDoc->getPlotFile();\r
-                       rPlot.setTitle("Row Plot");\r
+                       std::ostringstream title;\r
+                       title << "Row " << yCursor;\r
+                       rPlot.setTitle(title.str());\r
                        rPlot.setXLabel("Column");\r
                        rPlot.setYLabel("Pixel Value");\r
                        rPlot.setCurveSize (2, nx);\r
                        rPlot.addColumn (0, pX);\r
                        rPlot.addColumn (1, pY);\r
-                       delete pX;\r
-                       delete pY;\r
                }\r
+               delete pX;\r
+               delete pY;\r
        }\r
 \r
 }\r
@@ -460,16 +462,35 @@ ImageFileView::OnPlotCol (wxCommandEvent& event)
     int ny = rIF.ny();\r
 \r
     if (v != NULL && xCursor < nx) {\r
-               double* pVec = new double [ny];\r
+               double* pX = new double [ny];\r
+               double* pY = new double [ny];\r
                double minVal = v[xCursor][0];\r
                double maxVal = minVal;\r
                for (int i = 0; i < ny; i++) {\r
-                       if (minVal < v[xCursor][i])\r
-                               minVal = v[xCursor][i];\r
-                       else if (maxVal > v[xCursor][i])\r
-                               maxVal = v[xCursor][i];\r
-                       pVec[i] = v[xCursor][i];\r
+                       double y = v[xCursor][i];\r
+                       if (minVal < y)\r
+                               minVal = y;\r
+                       else if (maxVal > y)\r
+                               maxVal = y;\r
+                       pX[i] = i;\r
+                       pY[i] = y;\r
+               }\r
+               PlotFileDocument* pPlotDoc = dynamic_cast<PlotFileDocument*>(theApp->getDocManager()->CreateDocument("untitled.plt", wxDOC_SILENT));\r
+               if (! pPlotDoc) {\r
+                       sys_error (ERR_SEVERE, "Internal error: unable to create Plot file");\r
+               } else {\r
+                       PlotFile& rPlot = pPlotDoc->getPlotFile();\r
+                       std::ostringstream title;\r
+                       title << "Column " << xCursor;\r
+                       rPlot.setTitle(title.str());\r
+                       rPlot.setXLabel("Row");\r
+                       rPlot.setYLabel("Pixel Value");\r
+                       rPlot.setCurveSize (2, nx);\r
+                       rPlot.addColumn (0, pX);\r
+                       rPlot.addColumn (1, pY);\r
                }\r
+               delete pX;\r
+               delete pY;\r
        }\r
 }\r
 \r