00001 // -*- c-basic-offset: 4 -*- 00010 /* This is free software; you can redistribute it and/or 00011 * modify it under the terms of the GNU General Public 00012 * License as published by the Free Software Foundation; either 00013 * version 2 of the License, or (at your option) any later version. 00014 * 00015 * This software is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 * Lesser General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public 00021 * License along with this software; if not, write to the Free Software 00022 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00023 * 00024 */ 00025 00026 #ifndef _MaskEditorPanel_H 00027 #define _MaskEditorPanel_H 00028 00029 00030 //----------------------------------------------------------------------------- 00031 // Headers 00032 //----------------------------------------------------------------------------- 00033 00034 #include <PT/Panorama.h> 00035 #include <wx/clrpicker.h> 00036 #include "MaskImageCtrl.h" 00037 #include "ImagesList.h" 00038 00044 class MaskEditorPanel : public wxPanel, public PT::PanoramaObserver 00045 { 00046 public: 00049 MaskEditorPanel(); 00050 00051 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")); 00052 00053 void Init(PT::Panorama * pano); 00054 00057 virtual ~MaskEditorPanel(); 00058 00059 void SetPano(PT::Panorama * panorama) 00060 { m_pano = panorama; }; 00067 void setImage(unsigned int imgNr, bool updateListSelection=false); 00069 void setMask(unsigned int maskNr); 00071 void UpdateMask(); 00073 void AddMask(); 00075 void SelectMask(unsigned int newMaskNr); 00076 00081 void UpdateCrop(bool updateFromImgCtrl=false); 00083 void UpdateCropFromImage(); 00084 00088 void panoramaChanged(PT::Panorama &pano); 00089 void panoramaImagesChanged(PT::Panorama &pano, const PT::UIntSet & imgNr); 00090 00092 void OnImageSelect(wxListEvent &e); 00094 void OnMaskSelect(wxListEvent &e); 00096 void OnMaskTypeChange(wxCommandEvent &e); 00098 void OnMaskAdd(wxCommandEvent &e); 00100 void OnMaskSave(wxCommandEvent &e); 00102 void OnMaskLoad(wxCommandEvent &e); 00104 void OnMaskCopy(wxCommandEvent &e); 00106 void OnMaskPaste(wxCommandEvent &e); 00108 void OnMaskDelete(wxCommandEvent &e); 00110 void OnZoom(wxCommandEvent & e); 00112 void OnColourChanged(wxColourPickerEvent &e); 00114 void OnShowActiveMasks(wxCommandEvent &e); 00115 // reset crop area. 00116 void OnResetButton(wxCommandEvent & e); 00117 void OnSetLeft(wxCommandEvent & e); 00118 void OnSetRight(wxCommandEvent & e); 00119 void OnSetTop(wxCommandEvent & e); 00120 void OnSetBottom(wxCommandEvent & e); 00121 void OnAutoCenter(wxCommandEvent & e); 00122 void OnModeChanged(wxNotebookEvent & e); 00123 00124 private: 00125 00129 void UpdateMaskList(bool restoreSelection=false); 00131 unsigned int GetSelectedMask(); 00133 void OnColumnWidthChange( wxListEvent & e ); 00135 MaskImageCtrl::ImageRotation GetRot(const unsigned int imgNr); 00137 void DisplayCrop(int imgNr); 00138 00140 void UpdateCropDisplay(); 00141 // ensure that the crop roi is centered 00142 void CenterCrop(); 00143 00144 size_t GetImgNr(); 00145 00146 // GUI controls 00147 MaskImageCtrl *m_editImg; 00148 ImagesListMask *m_imagesListMask; 00149 wxListCtrl *m_maskList; 00150 wxChoice *m_maskType; 00151 wxNotebook *m_maskCropCtrl; 00152 00153 // my data 00154 PT::Panorama * m_pano; 00155 // current masks vector 00156 HuginBase::MaskPolygonVector m_currentMasks; 00157 HuginBase::MaskPolygon::MaskType m_defaultMaskType; 00158 // mask or crop mode 00159 bool m_maskMode; 00160 // the current images 00161 HuginBase::UIntSet m_selectedImages; 00162 // the current mask 00163 unsigned int m_MaskNr; 00164 // the filename of the current image 00165 std::string m_File; 00166 00167 // controls for crop editing 00168 wxTextCtrl * m_left_textctrl; 00169 wxTextCtrl * m_right_textctrl; 00170 wxTextCtrl * m_top_textctrl; 00171 wxTextCtrl * m_bottom_textctrl; 00172 wxCheckBox * m_autocenter_cb; 00173 HuginBase::SrcPanoImage::CropMode m_cropMode; 00174 vigra::Rect2D m_cropRect; 00175 bool m_autoCenterCrop; 00176 vigra::Point2D m_cropCenter; 00177 00178 DECLARE_EVENT_TABLE(); 00179 DECLARE_DYNAMIC_CLASS(MaskEditorPanel) 00180 }; 00181 00183 class MaskEditorPanelXmlHandler : public wxXmlResourceHandler 00184 { 00185 DECLARE_DYNAMIC_CLASS(MaskEditorPanelXmlHandler) 00186 00187 public: 00188 MaskEditorPanelXmlHandler(); 00189 virtual wxObject *DoCreateResource(); 00190 virtual bool CanHandle(wxXmlNode *node); 00191 }; 00192 00193 00194 #endif // _MaskEditorPanel_H
1.3.9.1