1 // -*- c-basic-offset: 4 -*- 2 /** @file LensTools.h 3 * 4 * @brief some helper classes for graphes 5 * 6 * @author T. Modes 7 * 8 */ 9 10 /* 11 * This is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU General Public 13 * License as published by the Free Software Foundation; either 14 * version 2 of the License, or (at your option) any later version. 15 * 16 * This software is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public 22 * License along with this software. If not, see 23 * <http://www.gnu.org/licenses/>. 24 * 25 */ 26 27 #ifndef GRAPHTOOLS_H 28 #define GRAPHTOOLS_H 29 30 #include <hugin_shared.h> 31 #include "panoinc_WX.h" 32 #include "panoinc.h" 33 #include "wx/popupwin.h" 34 35 namespace wxGraphTools 36 { 37 /** simple popup to show graph */ 38 class WXIMPEX GraphPopupWindow : public wxPopupTransientWindow 39 { 40 public: 41 GraphPopupWindow(wxWindow* parent, wxBitmap bitmap); 42 protected: 43 void OnLeftDown(wxMouseEvent &e); 44 void OnRightDown(wxMouseEvent &e); 45 private: 46 wxStaticBitmap* m_bitmapControl; 47 DECLARE_CLASS(GraphPopupWindow) 48 }; 49 50 /**help class to draw charts */ 51 class WXIMPEX Graph 52 { 53 public: 54 /** constructors, set size and background colour of resulting bitmap */ 55 Graph(int graphWidth, int graphHeight, wxColour backgroundColour); 56 /** destructor */ 57 ~Graph(); 58 /** set where to draw the chart on the bitmap */ 59 void SetChartArea(int left, int top, int right, int bottom); 60 /** set the real dimension of the chart */ 61 void SetChartDisplay(double xmin, double ymin, double xmax, double ymax); 62 /** draws the grid with linesX lines in x-direction and linexY lines in y-direction */ 63 void DrawGrid(size_t linesX, size_t linesY); 64 /** draws a line with the coordinates given in points */ 65 void DrawLine(std::vector<hugin_utils::FDiff2D> points, wxColour colour, int penWidth = 1); 66 const wxBitmap GetGraph() const; 67 private: 68 // prevent copying of class 69 Graph(const Graph&); 70 Graph& operator=(const Graph&); 71 //helper function to transform coordinates from real world to bitmap 72 int TransformX(double x); 73 int TransformY(double y); 74 // area to be drawn 75 double m_xmin, m_xmax, m_ymin, m_ymax; 76 // size of canvas 77 int m_width, m_height; 78 // chart area 79 int m_left, m_top, m_right, m_bottom; 80 // bitmap 81 wxBitmap* m_bitmap; 82 wxMemoryDC m_dc; 83 }; 84 85 /** return wxBitmap with graph of distortion for given SrcPanoImage */ 86 wxBitmap WXIMPEX GetDistortionGraph(const HuginBase::SrcPanoImage& srcImage); 87 } 88 #endif // GRAPHTOOLS_H 89