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"
37 #include "ImagesList.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 OnImageSelect(wxListEvent &e);
96  void OnMaskSelect(wxListEvent &e);
98  void OnMaskTypeChange(wxCommandEvent &e);
100  void OnMaskAdd(wxCommandEvent &e);
102  void OnMaskSave(wxCommandEvent &e);
104  void OnMaskLoad(wxCommandEvent &e);
106  void OnMaskCopy(wxCommandEvent &e);
108  void OnMaskPaste(wxCommandEvent &e);
110  void OnMaskDelete(wxCommandEvent &e);
112  void OnZoom(wxCommandEvent & e);
114  void OnColourChanged(wxColourPickerEvent &e);
116  void OnShowActiveMasks(wxCommandEvent &e);
117  // reset crop area.
118  void OnResetButton(wxCommandEvent & e);
119  void OnSetLeft(wxCommandEvent & e);
120  void OnSetRight(wxCommandEvent & e);
121  void OnSetTop(wxCommandEvent & e);
122  void OnSetBottom(wxCommandEvent & e);
123  void OnAutoCenter(wxCommandEvent & e);
124  void OnModeChanged(wxNotebookEvent & e);
125 
126 private:
127 
131  void UpdateMaskList(bool restoreSelection=false);
133  unsigned int GetSelectedMask();
135  void OnColumnWidthChange( wxListEvent & e );
137  MaskImageCtrl::ImageRotation GetRot(const unsigned int imgNr);
139  void DisplayCrop(int imgNr);
140 
142  void UpdateCropDisplay();
143  // ensure that the crop roi is centered
144  void CenterCrop();
145 
146  size_t GetImgNr();
147 
148  // GUI controls
151  wxListCtrl *m_maskList;
152  wxChoice *m_maskType;
153  wxNotebook *m_maskCropCtrl;
154 
155  // my data
158  // current masks vector
161  // mask or crop mode
163  // the current images
165  // the current mask
166  unsigned int m_MaskNr;
167  // the filename of the current image
168  std::string m_File;
169 
170  // controls for crop editing
171  wxTextCtrl * m_left_textctrl;
172  wxTextCtrl * m_right_textctrl;
173  wxTextCtrl * m_top_textctrl;
174  wxTextCtrl * m_bottom_textctrl;
175  wxCheckBox * m_autocenter_cb;
176  wxCheckBox * m_cropLens;
178  vigra::Rect2D m_cropRect;
179  bool m_autoCenterCrop = true;
180  vigra::Point2D m_cropCenter;
181 
183  DECLARE_DYNAMIC_CLASS(MaskEditorPanel)
184 };
185 
187 class MaskEditorPanelXmlHandler : public wxXmlResourceHandler
188 {
189  DECLARE_DYNAMIC_CLASS(MaskEditorPanelXmlHandler)
190 
191 public:
193  virtual wxObject *DoCreateResource();
194  virtual bool CanHandle(wxXmlNode *node);
195 };
196 
197 
198 #endif // _MaskEditorPanel_H
void OnResetButton(wxCommandEvent &e)
ImageRotation
image rotation.
Definition: MaskImageCtrl.h:55
HuginBase::ConstStandardImageVariableGroups * m_imageGroups
void OnSetTop(wxCommandEvent &e)
HuginBase::UIntSet m_selectedImages
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_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
MaskImageCtrl * m_editImg
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.
ImagesListMask * m_imagesListMask
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 OnAutoCenter(wxCommandEvent &e)
wxTextCtrl * m_right_textctrl
void OnSetBottom(wxCommandEvent &e)
void OnSetRight(wxCommandEvent &e)
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 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 OnColumnWidthChange(wxListEvent &e)
called, when column with of mask list box was changed
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)
specialized to display the mask aspect of images
Definition: ImagesList.h:167
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 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