Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages
hugin1/hugin/CropPanel.h
Go to the documentation of this file.00001 // -*- c-basic-offset: 4 -*- 00024 #ifndef _CROP_PANEL_H 00025 #define _CROP_PANEL_H 00026 00027 00028 #ifdef __WXMAC__ 00029 // use wxChoice 00030 #define HUGIN_CP_IMG_CHOICE 00031 #else 00032 // use wxNotebook tab 00033 #define HUGIN_CP_IMG_TAB 00034 #endif 00035 00036 class CenterCanvas; 00037 class ImagesListCrop; 00038 00039 #include <base_wx/ImageCache.h> 00040 00044 class CropPanel: public wxPanel, public PT::PanoramaObserver 00045 { 00046 public: 00047 CropPanel(); 00048 00049 bool Create(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL, const wxString& name = wxT("panel")); 00050 void Init(PT::Panorama * pano); 00051 00052 virtual ~CropPanel(void); 00053 00054 #if 0 00055 00056 void RestoreLayout(); 00058 void RestoreLayoutOnNextResize() 00059 { 00060 m_restoreLayoutOnResize = true; 00061 } 00062 #endif 00063 00064 void panoramaImagesChanged(PT::Panorama &pano, const PT::UIntSet & imgNr); 00065 00066 void CropChanged(vigra::Rect2D & crop, bool dragging); 00067 00068 00069 protected: 00070 void Pano2Display(int imgNr); 00071 void Display2Pano(); 00072 00074 void UpdateDisplay(); 00075 00077 void ListSelectionChanged(wxListEvent& e); 00078 00079 // reset crop area. 00080 void OnResetButton(wxCommandEvent & e); 00081 void OnSetLeft(wxCommandEvent & e); 00082 void OnSetRight(wxCommandEvent & e); 00083 void OnSetTop(wxCommandEvent & e); 00084 void OnSetBottom(wxCommandEvent & e); 00085 void OnAutoCenter(wxCommandEvent & e); 00086 00087 // ensure that the crop roi is centered 00088 void CenterCrop(); 00089 00090 wxTextCtrl * m_left_textctrl; 00091 wxTextCtrl * m_right_textctrl; 00092 wxTextCtrl * m_top_textctrl; 00093 wxTextCtrl * m_bottom_textctrl; 00094 wxCheckBox * m_autocenter_cb; 00095 00096 private: 00097 00098 Panorama * m_pano; 00099 00100 CenterCanvas * m_Canvas; 00101 ImagesListCrop * m_imagesList; 00102 00103 UIntSet m_selectedImages; 00104 std::string m_currentImageFile; 00105 00106 ImageOptions m_imgOpts; 00107 vigra::Point2D m_center; 00108 bool m_circular; 00109 00110 DECLARE_EVENT_TABLE() 00111 DECLARE_DYNAMIC_CLASS(CropPanel) 00112 }; 00113 00115 class CropPanelXmlHandler : public wxXmlResourceHandler 00116 { 00117 DECLARE_DYNAMIC_CLASS(CropPanelXmlHandler) 00118 00119 public: 00120 CropPanelXmlHandler(); 00121 virtual wxObject *DoCreateResource(); 00122 virtual bool CanHandle(wxXmlNode *node); 00123 }; 00124 00129 class CenterCanvas: public wxPanel 00130 { 00131 public: 00132 CenterCanvas(); 00133 bool Create(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL, const wxString& name = wxT("panel")); 00134 void Init(CropPanel * listener); 00135 00136 virtual ~CenterCanvas(void) ; 00137 00139 void SetImage(ImageCache::EntryPtr img); 00140 void UpdateDisplay(const vigra::Rect2D & crop, bool circle, 00141 const vigra::Point2D & center, bool useCenter); 00142 00143 protected: 00145 void DrawView(); 00146 void UpdateCropCircle(); 00147 00148 00149 wxCursor * m_cursor_no_sel; 00150 wxCursor * m_cursor_circ_drag; 00151 wxCursor * m_cursor_move_crop; 00152 wxCursor * m_cursor_drag_vert; 00153 wxCursor * m_cursor_drag_horiz; 00154 00155 private: 00156 void Resize ( wxSizeEvent & e ); 00157 void OnPaint(wxPaintEvent & dc); 00158 void OnMouse ( wxMouseEvent & event ); 00159 00160 // the image to adjust ( full scale ) 00161 ImageCache::EntryPtr m_imgCacheImg; 00162 wxImage img; 00163 // the scaled image (clear/dirty) 00164 wxBitmap m_scaled_img; 00165 // image with center cross and circle 00166 wxBitmap m_display_img; 00167 00168 CropPanel * m_listener; 00169 00170 enum PointState { NO_SEL, RECT_DRAGGING, CIRC_DRAGGING, CROP_SELECTED, CROP_MOVE, 00171 RECT_LEFT_DRAG, RECT_RIGHT_DRAG, RECT_TOP_DRAG, RECT_BOTTOM_DRAG}; 00172 00173 void ChangeMode(PointState m); 00174 00175 wxPoint m_moveAnchor; 00176 00177 PointState m_state; 00178 00179 // the selected rectangle 00180 vigra::Rect2D m_roi; 00181 00182 // circular crop 00183 bool m_circle; 00184 vigra::Point2D m_circ_first_point; 00185 vigra::Point2D m_circ_second_point; 00186 00187 // center 00188 vigra::Point2D m_center; 00189 bool m_centered; 00190 00191 // scale factor 00192 float m_scale; 00193 00194 DECLARE_EVENT_TABLE() 00195 DECLARE_DYNAMIC_CLASS(CenterCanvas) 00196 }; 00197 00199 class CenterCanvasXmlHandler : public wxXmlResourceHandler 00200 { 00201 DECLARE_DYNAMIC_CLASS(CenterCanvasXmlHandler) 00202 00203 public: 00204 CenterCanvasXmlHandler(); 00205 virtual wxObject *DoCreateResource(); 00206 virtual bool CanHandle(wxXmlNode *node); 00207 }; 00208 00209 00210 #endif // _IMAGECENTER_H
1.3.9.1