Hugin trunk 0.1
Loading...
Searching...
No Matches
MaskLoadDialog.cpp
Go to the documentation of this file.
1// -*- c-basic-offset: 4 -*-
2
13/* This is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public
15 * License as published by the Free Software Foundation; either
16 * version 2 of the License, or (at your option) any later version.
17 *
18 * This software is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public
24 * License along with this software. If not, see
25 * <http://www.gnu.org/licenses/>.
26 *
27 */
28
30#include "base_wx/wxPlatform.h"
31#include "base_wx/wxutils.h"
32#ifdef __APPLE__
33#include "panoinc_WX.h"
34#include "panoinc.h"
35#endif
37#include "hugin/huginApp.h"
38
40{
41 wxXmlResource::Get()->LoadDialog(this, parent, "mask_load_dialog");
42
43 m_image=XRCCTRL(*this,"mask_preview",MaskImageCtrl);
45 //load and set colours
48 wxColour colour=wxConfigBase::Get()->Read("/MaskEditorPanel/ColourPolygonNegative",defaultColour.GetAsString(wxC2S_HTML_SYNTAX));
51 colour=wxConfigBase::Get()->Read("/MaskEditorPanel/ColourPolygonPositive",defaultColour.GetAsString(wxC2S_HTML_SYNTAX));
54 colour=wxConfigBase::Get()->Read("/MaskEditorPanel/ColourPointSelected",defaultColour.GetAsString(wxC2S_HTML_SYNTAX));
57 colour=wxConfigBase::Get()->Read("/MaskEditorPanel/ColourPointUnselected",defaultColour.GetAsString(wxC2S_HTML_SYNTAX));
59
60 m_maskScaleMode=XRCCTRL(*this,"mask_rescale",wxRadioBox);
62 m_maskRotateMode=XRCCTRL(*this,"mask_rotate",wxRadioBox);
64
65 hugin_utils::RestoreFramePosition(this, "MaskLoadDialog");
66 if(GetSize().GetWidth()<400)
67 SetClientSize(400,GetSize().GetHeight());
68};
69
74
76{
79 m_image->setScale(0);
81 m_imageSize=image.getSize();
83 // set dummy value
84 if(m_imageSize.width()==0)
85 m_imageSize.setWidth(100);
86 if(m_imageSize.height()==0)
87 m_imageSize.setHeight(100);
88 if((m_maskSize.width()==0) || (m_maskSize.height()==0))
90 XRCCTRL(*this,"label_image_size",wxStaticText)->SetLabel(wxString::Format("%d x %d",m_imageSize.width(),m_imageSize.height()));
91 XRCCTRL(*this,"label_mask_size",wxStaticText)->SetLabel(wxString::Format("%d x %d",m_maskSize.width(),m_maskSize.height()));
92 //if image is rotated, set rotation to clockwise
93 if((m_maskSize.width()==m_imageSize.height()) && (m_maskSize.height()==m_imageSize.width()))
94 m_maskRotateMode->SetSelection(1);
95 wxCommandEvent dummy;
97};
98
99void MaskLoadDialog::ProcessMask(wxCommandEvent &e)
100{
102 if(m_processedMask.empty())
103 {
105 return;
106 };
107 double maskWidth;
108 double maskHeight;
109 if(m_maskRotateMode->GetSelection()==0)
110 {
111 maskWidth=m_maskSize.width();
112 maskHeight=m_maskSize.height();
113 }
114 else
115 {
116 maskWidth=m_maskSize.height();
117 maskHeight=m_maskSize.width();
118 bool clockwise=(m_maskRotateMode->GetSelection()==1);
119 for(unsigned int i=0;i<m_processedMask.size();i++)
120 m_processedMask[i].rotate90(clockwise,m_maskSize.width(),m_maskSize.height());
121 };
122 switch(m_maskScaleMode->GetSelection())
123 {
124 case 0:
125 // clip mask
126 for(unsigned int i=0;i<m_processedMask.size();i++)
127 m_processedMask[i].clipPolygon(vigra::Rect2D(-0.5*HuginBase::maskOffset,-0.5*HuginBase::maskOffset,
129 break;
130 case 1:
131 // scale mask
132 for(unsigned int i=0;i<m_processedMask.size();i++)
133 m_processedMask[i].scale((double)m_imageSize.width()/maskWidth,(double)m_imageSize.height()/maskHeight);
134 break;
135 case 2:
136 // proportional scale mask
137 {
138 double factor=std::min((double)m_imageSize.width()/maskWidth,(double)m_imageSize.height()/maskHeight);
139 for(unsigned int i=0;i<m_processedMask.size();i++)
140 m_processedMask[i].scale(factor);
141 };
142 break;
143 };
144
146};
147
Definition of mask load dialog.
All variables of a source image.
mask editor
void SetUserColourPointUnselected(wxColour newColour)
void setImage(const std::string &filename, HuginBase::MaskPolygonVector newMask, HuginBase::MaskPolygonVector masksToDraw, ImageRotation rot)
set the current image and mask list, this loads also the image from cache
void SetUserColourPolygonPositive(wxColour newColour)
void setScale(double factor)
set the scaling factor for mask editing display.
void setNewMasks(HuginBase::MaskPolygonVector newMasks, HuginBase::MaskPolygonVector masksToDraw)
updates masks for currently selected image
void SetUserColourPointSelected(wxColour newColour)
void setPreviewOnly()
if called, the mouse handlers are deactivated
void SetUserColourPolygonNegative(wxColour newColour)
sets the colour for different parts
void initValues(const HuginBase::SrcPanoImage image, const HuginBase::MaskPolygonVector newMask, const vigra::Size2D maskSize)
sets the default values
void ProcessMask(wxCommandEvent &e)
virtual ~MaskLoadDialog()
wxRadioBox * m_maskRotateMode
wxRadioBox * m_maskScaleMode
HuginBase::MaskPolygonVector m_processedMask
vigra::Size2D m_imageSize
MaskImageCtrl * m_image
MaskLoadDialog(wxWindow *parent)
Constructor, read from xrc ressource.
vigra::Size2D m_maskSize
HuginBase::MaskPolygonVector m_loadedMask
#define HUGIN_MASK_COLOUR_POINT_SELECTED
#define HUGIN_MASK_COLOUR_POINT_UNSELECTED
#define HUGIN_MASK_COLOUR_POLYGON_NEGATIVE
#define HUGIN_MASK_COLOUR_POLYGON_POSITIVE
std::vector< MaskPolygon > MaskPolygonVector
Definition Mask.h:150
const int maskOffset
polygon can exceed the image maximal maskOffset pixels in each direction bigger polygons will be clip...
Definition Mask.h:44
void StoreFramePosition(wxTopLevelWindow *frame, const wxString &basename, const bool ignoreMaximize)
Definition wxutils.cpp:106
void RestoreFramePosition(wxTopLevelWindow *frame, const wxString &basename, const bool ignoreMaximize)
Definition wxutils.cpp:67
include file for the hugin project
include file for the hugin project
std::vector< deghosting::BImagePtr > threshold(const std::vector< deghosting::FImagePtr > &inputImages, const double threshold, const uint16_t flags)
Threshold function used for creating alpha masks for images.
Definition threshold.h:41
platform/compiler specific stuff.