Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MaskEditorPanel.h
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
10 /* This is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This software is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public
21  * License along with this software. If not, see
22  * <http://www.gnu.org/licenses/>.
23  *
24  */
25 
26 #ifndef _MaskEditorPanel_H
27 #define _MaskEditorPanel_H
28 
29 
30 //-----------------------------------------------------------------------------
31 // Headers
32 //-----------------------------------------------------------------------------
33 
34 #include <panodata/Panorama.h>
35 #include <wx/clrpicker.h>
36 #include "MaskImageCtrl.h"
38 
44 class MaskEditorPanel : public wxPanel, public HuginBase::PanoramaObserver
45 {
46 public:
50 
51  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"));
52 
53  void Init(HuginBase::Panorama * pano);
54 
57  virtual ~MaskEditorPanel();
58 
59  void SetPano(HuginBase::Panorama * panorama)
60  { m_pano = panorama; };
67  void setImage(unsigned int imgNr, bool updateListSelection=false);
69  void setMask(unsigned int maskNr);
71  void UpdateMask();
73  void AddMask();
75  void SelectMask(unsigned int newMaskNr);
76 
81  void UpdateCrop(bool updateFromImgCtrl=false);
83  void UpdateCropFromImage();
85  void SwitchToCropMode();
86 
92 
94  void OnImageListChar(wxKeyEvent& e);
96  void OnImageSelect(wxListEvent &e);
98  void OnMaskSelect(wxListEvent &e);
100  void OnMaskTypeChange(wxCommandEvent &e);
102  void OnMaskAdd(wxCommandEvent &e);
104  void OnMaskSave(wxCommandEvent &e);
106  void OnMaskLoad(wxCommandEvent &e);
108  void OnMaskCopy(wxCommandEvent &e);
110  void OnMaskPaste(wxCommandEvent &e);
112  void OnMaskDelete(wxCommandEvent &e);
114  void OnZoom(wxCommandEvent & e);
116  void OnColourChanged(wxColourPickerEvent &e);
118  void OnShowActiveMasks(wxCommandEvent &e);
119  // reset crop area.
120  void OnResetButton(wxCommandEvent & e);
121  void OnSetLeft(wxCommandEvent & e);
122  void OnSetRight(wxCommandEvent & e);
123  void OnSetTop(wxCommandEvent & e);
124  void OnSetBottom(wxCommandEvent & e);
125  void OnAutoCenter(wxCommandEvent & e);
126  void OnModeChanged(wxNotebookEvent & e);
127 
128 private:
129 
133  void UpdateMaskList(bool restoreSelection=false);
135  unsigned int GetSelectedMask();
139  void OnImagesColumnWidthChange(wxListEvent& e);
141  void OnMaskColumnWidthChange( wxListEvent & e );
143  MaskImageCtrl::ImageRotation GetRot(const unsigned int imgNr);
145  void DisplayCrop(int imgNr);
147  void UpdateImage(size_t imgNr);
148 
150  void UpdateCropDisplay();
151  // ensure that the crop roi is centered
152  void CenterCrop();
153 
154  size_t GetImgNr();
155 
156  // GUI controls
158  wxListCtrl *m_imagesListMask;
159  wxListCtrl *m_maskList;
160  wxChoice *m_maskType;
161  wxNotebook *m_maskCropCtrl;
162 
163  // my data
166  // current masks vector
169  // mask or crop mode
171  // the current mask
172  unsigned int m_MaskNr;
173  // the filename of the current image
174  std::string m_File;
175 
176  // controls for crop editing
177  wxTextCtrl * m_left_textctrl;
178  wxTextCtrl * m_right_textctrl;
179  wxTextCtrl * m_top_textctrl;
180  wxTextCtrl * m_bottom_textctrl;
181  wxCheckBox * m_autocenter_cb;
182  wxCheckBox * m_cropLens;
184  vigra::Rect2D m_cropRect;
185  bool m_autoCenterCrop = true;
186  vigra::Point2D m_cropCenter;
187 
188  DECLARE_DYNAMIC_CLASS(MaskEditorPanel)
189 };
190 
192 class MaskEditorPanelXmlHandler : public wxXmlResourceHandler
193 {
194  DECLARE_DYNAMIC_CLASS(MaskEditorPanelXmlHandler)
195 
196 public:
198  virtual wxObject *DoCreateResource();
199  virtual bool CanHandle(wxXmlNode *node);
200 };
201 
202 
203 #endif // _MaskEditorPanel_H
void OnResetButton(wxCommandEvent &e)
ImageRotation
image rotation.
Definition: MaskImageCtrl.h:55
HuginBase::ConstStandardImageVariableGroups * m_imageGroups
void OnSetTop(wxCommandEvent &e)
void UpdateMaskList(bool restoreSelection=false)
updates the display after another image has been selected.
void UpdateCropFromImage()
updates the displayed crop in the text boxes (for dragging)
unsigned int m_MaskNr
wxListCtrl * m_imagesListMask
wxListCtrl * m_maskList
HuginBase::Panorama * m_pano
void OnMaskPaste(wxCommandEvent &e)
called when user wants to paste a mask from clipboard
void SelectMask(unsigned int newMaskNr)
selects the mask with index newMaskNr in the listbox
xrc handler for handling mask editor panel
Somewhere to specify what variables belong to what.
MaskImageCtrl * m_editImg
void OnMaskColumnWidthChange(wxListEvent &e)
called, when column with of mask list box was changed
void OnImageSelect(wxListEvent &e)
called when user selected another image
virtual bool CanHandle(wxXmlNode *node)
wxChoice * m_maskType
HuginBase::SrcPanoImage::CropMode m_cropMode
mask editor panel.
void setImage(unsigned int imgNr, bool updateListSelection=false)
sets the image, which is currently edited
void OnMaskLoad(wxCommandEvent &e)
called when user wants to load a mask into the selected image
HuginBase::MaskPolygonVector m_currentMasks
void OnImageListChar(wxKeyEvent &e)
key handler for images list
void OnAutoCenter(wxCommandEvent &e)
wxTextCtrl * m_right_textctrl
void OnSetBottom(wxCommandEvent &e)
void OnSetRight(wxCommandEvent &e)
const HuginBase::UIntSet GetSelectedImages()
return the currently selected image(s)
mask editor
Definition: MaskImageCtrl.h:38
void setMask(unsigned int maskNr)
sets active mask number, set to UINT_MAX, if no mask is currently editing
vigra::Rect2D m_cropRect
std::set< unsigned int > UIntSet
Definition: PanoramaData.h:51
void OnZoom(wxCommandEvent &e)
sets the actual zoom factor
Model for a panorama.
Definition: Panorama.h:152
void panoramaImagesChanged(HuginBase::Panorama &pano, const HuginBase::UIntSet &imgNr)
notifies about changes to images
HuginBase::MaskPolygon::MaskType m_defaultMaskType
void OnMaskTypeChange(wxCommandEvent &e)
handler when mask type was changed
void OnImagesColumnWidthChange(wxListEvent &e)
called, when column with of images list box was changed
void SwitchToCropMode()
switches the controls to crop mode
MaskType
enumeration with type of possible masks
Definition: Mask.h:56
void OnColourChanged(wxColourPickerEvent &e)
event handler for changing colours
void OnModeChanged(wxNotebookEvent &e)
vigra::Point2D m_cropCenter
void UpdateMask()
called when mask where changed in MaskImageCtrl
Make an ImageVariableGroup for lenses and other common concepts.
void UpdateCrop(bool updateFromImgCtrl=false)
updated the crop in the Panorama object with the current values from GUI
wxCheckBox * m_autocenter_cb
void OnMaskSave(wxCommandEvent &e)
called when user wants to save active mask
std::vector< MaskPolygon > MaskPolygonVector
Definition: Mask.h:147
void Init(HuginBase::Panorama *pano)
wxCheckBox * m_cropLens
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"))
std::string m_File
void OnSetLeft(wxCommandEvent &e)
this handler class will receive change events from the Panorama.
Definition: PanoramaData.h:401
wxNotebook * m_maskCropCtrl
virtual ~MaskEditorPanel()
dtor.
void DisplayCrop(int imgNr)
copies the crop information from the Panorama object to GUI
void UpdateCropDisplay()
update GUI display
wxTextCtrl * m_bottom_textctrl
MaskImageCtrl::ImageRotation GetRot(const unsigned int imgNr)
determines, if the image should be rotated for display
void OnMaskDelete(wxCommandEvent &e)
called when user wants to delete active mask
void UpdateImage(size_t imgNr)
update the list box for the given imgNr
void OnMaskSelect(wxListEvent &e)
called when user selected another mask
void OnMaskAdd(wxCommandEvent &e)
called when user wants to create new polygon
void panoramaChanged(HuginBase::Panorama &pano)
called when the panorama changes and we should update our display
void OnShowActiveMasks(wxCommandEvent &e)
event handler for changing option if active masks should be drawn
void SetPano(HuginBase::Panorama *panorama)
void AddMask()
called when new mask added in MaskImageCtrl
wxTextCtrl * m_top_textctrl
virtual wxObject * DoCreateResource()
wxTextCtrl * m_left_textctrl
unsigned int GetSelectedMask()
return index of currently selected masks, return UINT_MAX if no mask is selected
void OnMaskCopy(wxCommandEvent &e)
called when user wants to copy a mask to clipboard