Hugin trunk 0.1
Loading...
Searching...
No Matches
PanoOutputDialog.cpp
Go to the documentation of this file.
1// -*- c-basic-offset: 4 -*-
2
11/* This is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
15 *
16 * This software is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public
22 * License along with this software. If not, see
23 * <http://www.gnu.org/licenses/>.
24 *
25 */
26
28#include "base_wx/wxPlatform.h"
29#include "panoinc.h"
30
31#include "hugin/huginApp.h"
32#include "base_wx/platform.h"
33#include "base_wx/wxutils.h"
37
39{
40 // load our children. some children might need special
41 // initialization. this will be done later.
42 wxXmlResource::Get()->LoadDialog(this, parent, "pano_output_dialog");
43
44 //set parameters
45 wxConfigBase * cfg = wxConfigBase::Get();
46 //position
47 hugin_utils::RestoreFramePositionOnly(this, "PanoOutputDialog");
48 // get number of stacks and exposure layers
50 HuginBase::UIntSet images=getImagesinROI(m_pano, m_pano.getActiveImages());
51 m_stacks=getHDRStacks(m_pano, images, m_pano.getOptions());
52 m_exposureLayers=getExposureLayers(m_pano, images, m_pano.getOptions());
53 // set initial width
55 wxConfigBase* config = wxConfigBase::Get();
57 {
58 // calc optimal size of pano, only of projection is supported
59 // otherwise use current width as start point
62 config->Read("/Assistant/panoDownsizeFactor", &sizeFactor, HUGIN_ASS_PANO_DOWNSIZE_FACTOR);
64 };
67 m_aspect=(double)m_newOpt.getROI().height()/m_newOpt.getROI().width();
68 m_edit_width=XRCCTRL(*this, "output_width", wxSpinCtrl);
69 m_edit_height=XRCCTRL(*this, "output_height", wxSpinCtrl);
70 m_edit_width->SetValue(m_newOpt.getROI().width());
71 m_edit_height->SetValue(m_newOpt.getROI().height());
72
73 //LDR output format, as in preferences set
74 int i = config->Read("/output/jpeg_quality",HUGIN_JPEG_QUALITY);
75 XRCCTRL(*this, "output_jpeg_quality", wxSpinCtrl)->SetValue(i);
76 i=config->Read("/output/tiff_compression", HUGIN_TIFF_COMPRESSION);
77 XRCCTRL(*this, "output_tiff_compression", wxChoice)->SetSelection(i);
78 i=config->Read("/output/ldr_format", HUGIN_LDR_OUTPUT_FORMAT);
79 XRCCTRL(*this, "output_ldr_format", wxChoice)->SetSelection(i);
80 //HDR output format, as in project given
81 if (m_newOpt.outputImageTypeHDR == "exr")
82 {
83 XRCCTRL(*this, "output_hdr_format", wxChoice)->SetSelection(0);
84 XRCCTRL(*this, "output_hdr_tiff_compression", wxChoice)->SetSelection(2);
85 }
86 else
87 {
88 XRCCTRL(*this, "output_hdr_format", wxChoice)->SetSelection(1);
90 {
91 XRCCTRL(*this, "output_hdr_tiff_compression", wxChoice)->SetSelection(1);
92 }
93 else
94 {
96 {
97 XRCCTRL(*this, "output_hdr_tiff_compression", wxChoice)->SetSelection(2);
98 }
99 else
100 {
102 {
103 XRCCTRL(*this, "output_hdr_tiff_compression", wxChoice)->SetSelection(3);
104 }
105 else
106 {
107 XRCCTRL(*this, "output_hdr_tiff_compression", wxChoice)->SetSelection(0);
108 };
109 };
110 };
111 };
113 wxCommandEvent dummy;
117 // bind event handler
118 Bind(wxEVT_CHECKBOX, &PanoOutputDialog::OnOutputChanged, this, XRCID("output_normal"));
119 Bind(wxEVT_CHECKBOX, &PanoOutputDialog::OnOutputChanged, this, XRCID("output_fused_blended"));
120 Bind(wxEVT_CHECKBOX, &PanoOutputDialog::OnOutputChanged, this, XRCID("output_blended_fused"));
121 Bind(wxEVT_CHECKBOX, &PanoOutputDialog::OnOutputChanged, this, XRCID("output_hdr"));
122 Bind(wxEVT_CHOICE, &PanoOutputDialog::OnLDRFormatChanged, this, XRCID("output_ldr_format"));
123 Bind(wxEVT_CHOICE, &PanoOutputDialog::OnHDRFormatChanged, this, XRCID("output_hdr_format"));
124 Bind(wxEVT_SPINCTRL, &PanoOutputDialog::OnWidthChanged, this, XRCID("output_width"));
125 Bind(wxEVT_SPINCTRL, &PanoOutputDialog::OnHeightChanged, this, XRCID("output_height"));
127
128};
129
131{
132 hugin_utils::StoreFramePositionOnly(this, "PanoOutputDialog");
133 wxConfigBase::Get()->Flush();
134};
135
137{
138 // check, if hdr images
139 wxFileName file1(wxString(m_pano.getImage(0).getFilename().c_str(), HUGIN_CONV_FILENAME));
140 wxString ext1=file1.GetExt().Lower();
141 if(ext1 == ".hdr" || ext1 == ".exr" || ext1=="hdr" || ext1=="exr")
142 {
143 XRCCTRL(*this, "output_normal", wxCheckBox)->SetValue(true);
144 XRCCTRL(*this, "output_normal", wxCheckBox)->Enable(true);
145 XRCCTRL(*this, "output_normal_bitmap", wxStaticBitmap)->Enable(true);
146 return;
147 }
148 //hide hdr controls for simple interface
150 {
151 XRCCTRL(*this, "output_hdr", wxCheckBox)->Hide();
152 XRCCTRL(*this, "output_hdr_bitmap", wxStaticBitmap)->Hide();
153 XRCCTRL(*this, "output_hdr_format_label", wxStaticText)->Hide();
154 XRCCTRL(*this, "output_hdr_format", wxChoice)->Hide();
155 XRCCTRL(*this, "output_hdr_compression_label", wxStaticText)->Hide();
156 XRCCTRL(*this, "output_hdr_tiff_compression", wxChoice)->Hide();
157 Layout();
158 GetSizer()->Fit(this);
159 };
160 //single image or normal panorama, enable only normal output
161 if(m_pano.getNrOfImages()==1 || m_stacks.size() >= 0.7 * m_pano.getNrOfImages())
162 {
163 XRCCTRL(*this, "output_normal", wxCheckBox)->SetValue(true);
164 XRCCTRL(*this, "output_normal", wxCheckBox)->Enable(true);
165 XRCCTRL(*this, "output_normal_bitmap", wxStaticBitmap)->Enable(true);
166 if(m_pano.getNrOfImages()==1 || m_stacks.size()==m_pano.getNrOfImages())
167 {
168 return;
169 };
170 };
171 XRCCTRL(*this, "output_fused_blended", wxCheckBox)->Enable(true);
172 XRCCTRL(*this, "output_fused_blended_bitmap", wxStaticBitmap)->Enable(true);
173 XRCCTRL(*this, "output_blended_fused", wxCheckBox)->Enable(true);
174 XRCCTRL(*this, "output_blended_fused_bitmap", wxStaticBitmap)->Enable(true);
176 {
177 XRCCTRL(*this, "output_hdr", wxCheckBox)->Enable(true);
178 XRCCTRL(*this, "output_hdr_bitmap", wxStaticBitmap)->Enable(true);
179 };
180 if(m_pano.getNrOfImages() % m_stacks.size() == 0)
181 {
182 XRCCTRL(*this, "output_fused_blended", wxCheckBox)->SetValue(true);
183 }
184 else
185 {
186 if(m_exposureLayers.size()==1)
187 {
188 XRCCTRL(*this, "output_normal", wxCheckBox)->SetValue(true);
189 XRCCTRL(*this, "output_normal", wxCheckBox)->Enable(true);
190 XRCCTRL(*this, "output_normal_bitmap", wxStaticBitmap)->Enable(true);
191 }
192 else
193 {
194 XRCCTRL(*this, "output_blended_fused", wxCheckBox)->SetValue(true);
195 };
196 };
197};
198
199void PanoOutputDialog::OnOk(wxCommandEvent & e)
200{
201 bool output_normal=XRCCTRL(*this, "output_normal", wxCheckBox)->GetValue();
202 bool output_fused_blended=XRCCTRL(*this, "output_fused_blended", wxCheckBox)->GetValue();
203 bool output_blended_fused=XRCCTRL(*this, "output_blended_fused", wxCheckBox)->GetValue();
204 bool output_hdr=XRCCTRL(*this, "output_hdr", wxCheckBox)->GetValue();
205 bool keep_intermediate=XRCCTRL(*this, "output_keep_intermediate", wxCheckBox)->GetValue();
206 //normal output
209 //fused stacks, then blended
213 // blended exposure layers, then fused
216 // HDR output
220 // read compression
222 {
223 if(m_newOpt.outputImageType=="jpg")
224 {
225 m_newOpt.quality=XRCCTRL(*this, "output_jpeg_quality", wxSpinCtrl)->GetValue();
226 }
227 else
228 {
229 if(m_newOpt.outputImageType=="tif")
230 {
231 switch(XRCCTRL(*this, "output_tiff_compression", wxChoice)->GetSelection())
232 {
233 case 0:
234 default:
236 m_newOpt.tiffCompression = "NONE";
237 break;
238 case 1:
240 m_newOpt.tiffCompression = "PACKBITS";
241 break;
242 case 2:
245 break;
246 case 3:
248 m_newOpt.tiffCompression = "DEFLATE";
249 break;
250 };
251 };
252 };
253 };
254 //HDR compression
255 if(output_hdr)
256 {
258 {
259 switch(XRCCTRL(*this, "output_hdr_tiff_compression", wxChoice)->GetSelection())
260 {
261 case 0:
262 default:
264 break;
265 case 1:
267 break;
268 case 2:
270 break;
271 case 3:
273 break;
274 };
275 };
276 }
277 // canvas size
278 double scale=m_edit_width->GetValue()/m_initalROIWidth;
280 //some checks to prevent some rounding errors, only for cropped outputs
282 {
283 if(m_newOpt.getROI().width()<m_edit_width->GetValue() || m_newOpt.getROI().height()<m_edit_height->GetValue())
284 {
286 };
287 vigra::Rect2D roi=m_newOpt.getROI();
288 if(roi.width()>m_edit_width->GetValue() || roi.height()>m_edit_height->GetValue())
289 {
290 roi.setSize(m_edit_width->GetValue(), m_edit_height->GetValue());
292 };
293 };
294 //send Ok
296};
297
298void PanoOutputDialog::OnOutputChanged(wxCommandEvent & e)
299{
300 bool output_normal=XRCCTRL(*this, "output_normal", wxCheckBox)->GetValue();
301 bool output_fused_blended=XRCCTRL(*this, "output_fused_blended", wxCheckBox)->GetValue();
302 bool output_blended_fused=XRCCTRL(*this, "output_blended_fused", wxCheckBox)->GetValue();
303 bool output_hdr=XRCCTRL(*this, "output_hdr", wxCheckBox)->GetValue();
304 //enable Ok only if at least one option is enabled
306 XRCCTRL(*this, "output_ldr_format_label", wxStaticText)->Enable(output_normal || output_fused_blended || output_blended_fused);
307 XRCCTRL(*this, "output_ldr_format", wxChoice)->Enable(output_normal || output_fused_blended || output_blended_fused);
308 XRCCTRL(*this, "output_ldr_compression_label", wxStaticText)->Enable(output_normal || output_fused_blended || output_blended_fused);
309 XRCCTRL(*this, "output_jpeg_quality", wxSpinCtrl)->Enable(output_normal || output_fused_blended || output_blended_fused);
310 XRCCTRL(*this, "output_tiff_compression", wxChoice)->Enable(output_normal || output_fused_blended || output_blended_fused);
311 XRCCTRL(*this, "output_hdr_format_label", wxStaticText)->Enable(output_hdr);
312 XRCCTRL(*this, "output_hdr_format", wxChoice)->Enable(output_hdr);
313 XRCCTRL(*this, "output_hdr_compression_label", wxStaticText)->Enable(output_hdr);
314 XRCCTRL(*this, "output_hdr_tiff_compression", wxChoice)->Enable(output_hdr);
315 GetSizer()->Layout();
316};
317
319{
320 int sel = XRCCTRL(*this, "output_ldr_format", wxChoice)->GetSelection();
321 switch (sel)
322 {
323 case 1:
325 XRCCTRL(*this, "output_ldr_compression_label", wxStaticText)->Show();
326 XRCCTRL(*this, "output_ldr_compression_label", wxStaticText)->SetLabel(_("Quality:"));
327 XRCCTRL(*this, "output_jpeg_quality", wxSpinCtrl)->Show();
328 XRCCTRL(*this, "output_tiff_compression", wxChoice)->Hide();
329 break;
330 case 2:
332 XRCCTRL(*this, "output_ldr_compression_label", wxStaticText)->Hide();
333 XRCCTRL(*this, "output_jpeg_quality", wxSpinCtrl)->Hide();
334 XRCCTRL(*this, "output_tiff_compression", wxChoice)->Hide();
335 break;
336 default:
337 case 0:
339 XRCCTRL(*this, "output_ldr_compression_label", wxStaticText)->Show();
340 XRCCTRL(*this, "output_ldr_compression_label", wxStaticText)->SetLabel(_("Compression:"));
341 XRCCTRL(*this, "output_jpeg_quality", wxSpinCtrl)->Hide();
342 XRCCTRL(*this, "output_tiff_compression", wxChoice)->Show();
343 break;
344 };
345 GetSizer()->Layout();
346};
347
348
350{
351 int sel = XRCCTRL(*this, "output_hdr_format", wxChoice)->GetSelection();
352 switch (sel)
353 {
354 case 1:
356 XRCCTRL(*this, "output_hdr_compression_label", wxStaticText)->Show();
357 XRCCTRL(*this, "output_hdr_tiff_compression", wxChoice)->Show();
358 break;
359 case 0:
360 default:
362 XRCCTRL(*this, "output_hdr_compression_label", wxStaticText)->Hide();
363 XRCCTRL(*this, "output_hdr_tiff_compression", wxChoice)->Hide();
364 break;
365 };
366 GetSizer()->Layout();
367};
368
370{
371 if(m_aspect>0)
372 {
373 m_edit_height->SetValue(m_edit_width->GetValue()*m_aspect);
374 };
375};
376
378{
379 if(m_aspect>0)
380 {
381 m_edit_width->SetValue(m_edit_height->GetValue()/m_aspect);
382 };
383};
GuiLevel
Definition GuiLevel.h:32
@ GUI_SIMPLE
Definition GuiLevel.h:33
declaration of functions to handle stacks and layers
Definition of PanoOutputDialog class.
static double calcOptimalScale(PanoramaData &panorama)
bool outputHDRLayers
save remapped layers (HDR)
bool outputLDRExposureLayers
save blended exposure layers, do not perform fusion (no exposure adjustment)
bool fovCalcSupported(ProjectionFormat f) const
true, if FOV calcuations are supported for projection f
bool outputLDRExposureBlended
< save exposure fused stacks (no exposure adjustment)
bool outputLDRExposureRemapped
save remapped layers (no exposure adjustment)
const vigra::Rect2D & getROI() const
void setWidth(unsigned int w, bool keepView=true)
set panorama width keep the HFOV, if keepView=true
void setROI(const vigra::Rect2D &val)
bool outputLDRBlended
save blended panorama (LDR)
bool outputLDRLayers
save remapped layers (LDR)
unsigned int getWidth() const
PanoramaOptions::ProjectionFormat getProjection() const
bool outputHDRStacks
save image stacks (HDR)
bool outputLDRExposureLayersFused
save blended exposure layers which are then fused (no exposure adjustment)
std::string outputImageTypeHDRCompression
bool outputHDRBlended
save blended panorama (HDR)
Model for a panorama.
Definition Panorama.h:153
const SrcPanoImage & getImage(std::size_t nr) const
get a panorama image, counting starts with 0
Definition Panorama.h:211
const PanoramaOptions & getOptions() const
returns the options for this panorama
Definition Panorama.h:481
UIntSet getActiveImages() const
get active images
std::size_t getNrOfImages() const
number of images.
Definition Panorama.h:205
void OnLDRFormatChanged(wxCommandEvent &e)
LDR format changed.
void OnWidthChanged(wxSpinEvent &e)
width changed
std::vector< HuginBase::UIntSet > m_exposureLayers
void OnHDRFormatChanged(wxCommandEvent &e)
HDR format changed.
~PanoOutputDialog()
destructor, save position
wxSpinCtrl * m_edit_width
void OnHeightChanged(wxSpinEvent &e)
height changed
std::vector< HuginBase::UIntSet > m_stacks
void OnOutputChanged(wxCommandEvent &e)
enabled Ok button and LDR/HDR format settings depeding on selected output settings
PanoOutputDialog(wxWindow *parent, HuginBase::Panorama &pano, GuiLevel guiLevel)
Constructor, read from xrc ressource; restore last uses settings, size and position.
HuginBase::PanoramaOptions m_newOpt
void OnOk(wxCommandEvent &e)
Saves current state of all checkboxes when closing dialog with Ok.
wxSpinCtrl * m_edit_height
HuginBase::Panorama & m_pano
#define HUGIN_JPEG_QUALITY
#define HUGIN_TIFF_COMPRESSION
#define HUGIN_ASS_PANO_DOWNSIZE_FACTOR
#define HUGIN_LDR_OUTPUT_FORMAT
implementation of huginApp Class
#define HUGIN_CONV_FILENAME
Definition platform.h:40
std::set< unsigned int > UIntSet
void StoreFramePositionOnly(wxTopLevelWindow *frame, const wxString &basename)
Definition wxutils.cpp:163
void RestoreFramePositionOnly(wxTopLevelWindow *frame, const wxString &basename)
Definition wxutils.cpp:143
int floori(double x)
Definition hugin_math.h:65
int roundi(T x)
Definition hugin_math.h:73
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.