Diff of /src/hugin1/hugin/PanoOutputDialog.cpp [000000] .. [26f7a4]  Maximize  Restore

  Switch to unified view

a b/src/hugin1/hugin/PanoOutputDialog.cpp
1
// -*- c-basic-offset: 4 -*-
2
3
/** @file PanoOutputDialog.cpp
4
 *
5
 *    @brief implementation of PanoOutputDialog class
6
 *
7
 *  @author T. Modes
8
 *
9
 */
10
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, write to the Free Software
23
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24
 *
25
 */
26
27
#include "hugin/PanoOutputDialog.h"
28
#include "base_wx/wxPlatform.h"
29
#include "panoinc.h"
30
31
#include "hugin/huginApp.h"
32
#include "base_wx/platform.h"
33
#include "hugin/config_defaults.h"
34
35
BEGIN_EVENT_TABLE(PanoOutputDialog,wxDialog)
36
    EVT_BUTTON(wxID_OK, PanoOutputDialog::OnOk)
37
    EVT_CHECKBOX(XRCID("output_normal"), PanoOutputDialog::OnOutputChanged)
38
    EVT_CHECKBOX(XRCID("output_fused_blended"), PanoOutputDialog::OnOutputChanged)
39
    EVT_CHECKBOX(XRCID("output_blended_fused"), PanoOutputDialog::OnOutputChanged)
40
    EVT_CHECKBOX(XRCID("output_hdr"), PanoOutputDialog::OnOutputChanged)
41
    EVT_CHOICE(XRCID("output_ldr_format"), PanoOutputDialog::OnLDRFormatChanged)
42
    EVT_CHOICE(XRCID("output_hdr_format"), PanoOutputDialog::OnHDRFormatChanged)
43
    EVT_SPINCTRL(XRCID("output_width"), PanoOutputDialog::OnWidthChanged)
44
    EVT_SPINCTRL(XRCID("output_height"), PanoOutputDialog::OnHeightChanged)
45
END_EVENT_TABLE()
46
47
PanoOutputDialog::PanoOutputDialog(wxWindow *parent, PT::Panorama& pano) : m_pano(pano)
48
{
49
    // load our children. some children might need special
50
    // initialization. this will be done later.
51
    wxXmlResource::Get()->LoadDialog(this, parent, wxT("pano_output_dialog"));
52
53
#ifdef __WXMSW__
54
    wxIcon myIcon(huginApp::Get()->GetXRCPath() + wxT("data/hugin.ico"),wxBITMAP_TYPE_ICO);
55
#else
56
    wxIcon myIcon(huginApp::Get()->GetXRCPath() + wxT("data/hugin.png"),wxBITMAP_TYPE_PNG);
57
#endif
58
    SetIcon(myIcon);
59
    //set parameters
60
    wxConfigBase * cfg = wxConfigBase::Get();
61
    //position
62
    int x = cfg->Read(wxT("/PanoOutputDialog/positionX"),-1l);
63
    int y = cfg->Read(wxT("/PanoOutputDialog/positionY"),-1l);
64
    if ( y >= 0 && x >= 0) 
65
    {
66
        this->Move(x, y);
67
    } 
68
    else 
69
    {
70
        this->Move(0, 44);
71
    };
72
    m_stacks=getHDRStacks(m_pano, m_pano.getActiveImages(), m_pano.getOptions());
73
    m_exposureLayers=getExposureLayers(m_pano, m_pano.getActiveImages(), m_pano.getOptions());
74
    m_optWidth=m_pano.calcOptimalWidth();
75
    m_newOpt=m_pano.getOptions();
76
    m_newOpt.setWidth(m_optWidth, true);
77
    m_optHeight=m_newOpt.getHeight();
78
    double sizeFactor = HUGIN_ASS_PANO_DOWNSIZE_FACTOR;
79
    wxConfigBase* config = wxConfigBase::Get();
80
    config->Read(wxT("/Assistant/panoDownsizeFactor"), &sizeFactor, HUGIN_ASS_PANO_DOWNSIZE_FACTOR);
81
    m_edit_width=XRCCTRL(*this, "output_width", wxSpinCtrl);
82
    m_edit_height=XRCCTRL(*this, "output_height", wxSpinCtrl);
83
    m_edit_width->SetValue(hugin_utils::floori(sizeFactor*m_optWidth));
84
    m_edit_height->SetValue(m_optHeight*m_edit_width->GetValue()/m_optWidth);
85
86
    //LDR output format, as in preferences set
87
    int i = config->Read(wxT("/output/jpeg_quality"),HUGIN_JPEG_QUALITY);
88
    XRCCTRL(*this, "output_jpeg_quality", wxSpinCtrl)->SetValue(i);
89
    i=config->Read(wxT("/output/tiff_compression"), HUGIN_TIFF_COMPRESSION);
90
    XRCCTRL(*this, "output_tiff_compression", wxChoice)->SetSelection(i);
91
    i=config->Read(wxT("/output/ldr_format"), HUGIN_LDR_OUTPUT_FORMAT);
92
    XRCCTRL(*this, "output_ldr_format", wxChoice)->SetSelection(i);
93
    //HDR output format, as in project given
94
    if (m_newOpt.outputImageTypeHDR == "exr")
95
    {
96
        XRCCTRL(*this, "output_hdr_format", wxChoice)->SetSelection(0);
97
        XRCCTRL(*this, "output_hdr_tiff_compression", wxChoice)->SetSelection(2);
98
    }
99
    else
100
    {
101
        XRCCTRL(*this, "output_hdr_format", wxChoice)->SetSelection(1);
102
        if (m_newOpt.outputImageTypeHDRCompression  == "PACKBITS")
103
        {
104
            XRCCTRL(*this, "output_hdr_tiff_compression", wxChoice)->SetSelection(1);
105
        }
106
        else
107
        {
108
            if (m_newOpt.outputImageTypeHDRCompression == "LZW")
109
            {
110
                XRCCTRL(*this, "output_hdr_tiff_compression", wxChoice)->SetSelection(2);
111
            }
112
            else
113
            {
114
                if (m_newOpt.outputImageTypeHDRCompression  == "DEFLATE")
115
                {
116
                    XRCCTRL(*this, "output_hdr_tiff_compression", wxChoice)->SetSelection(3);
117
                }
118
                else
119
                {
120
                    XRCCTRL(*this, "output_hdr_tiff_compression", wxChoice)->SetSelection(0);
121
                };
122
            };
123
        };
124
    };
125
    EnableOutputOptions();
126
    wxCommandEvent dummy;
127
    OnOutputChanged(dummy);
128
    OnLDRFormatChanged(dummy);
129
    OnHDRFormatChanged(dummy);
130
};
131
132
PanoOutputDialog::~PanoOutputDialog()
133
{
134
    wxConfigBase * cfg = wxConfigBase::Get();
135
    wxPoint ps = this->GetPosition();
136
    cfg->Write(wxT("/PanoOutputDialog/positionX"), ps.x);
137
    cfg->Write(wxT("/PanoOutputDialog/positionY"), ps.y);
138
    cfg->Flush();
139
};
140
141
void PanoOutputDialog::EnableOutputOptions()
142
{
143
    // check, if hdr images
144
    wxFileName file1(wxString(m_pano.getImage(0).getFilename().c_str(), HUGIN_CONV_FILENAME));
145
    wxString ext1=file1.GetExt().Lower();
146
    if(ext1==wxT(".hdr") || ext1==wxT(".exr"))
147
    {
148
        XRCCTRL(*this, "output_hdr", wxCheckBox)->SetValue(true);
149
        XRCCTRL(*this, "output_hdr", wxCheckBox)->Enable(true);
150
        XRCCTRL(*this, "output_hdr_bitmap", wxCheckBox)->Enable(true);
151
        return;
152
    }
153
    //single image or normal panorama, enable only normal output
154
    if(m_pano.getNrOfImages()==1 || m_stacks.size() >= 0.8 * m_pano.getNrOfImages())
155
    {
156
        XRCCTRL(*this, "output_normal", wxCheckBox)->SetValue(true);
157
        XRCCTRL(*this, "output_normal", wxCheckBox)->Enable(true);
158
        XRCCTRL(*this, "output_normal_bitmap", wxCheckBox)->Enable(true);
159
        if(m_pano.getNrOfImages()==1 || m_stacks.size()==m_pano.getNrOfImages())
160
        {
161
            return;
162
        };
163
    };
164
    XRCCTRL(*this, "output_fused_blended", wxCheckBox)->Enable(true);
165
    XRCCTRL(*this, "output_fused_blended_bitmap", wxCheckBox)->Enable(true);
166
    XRCCTRL(*this, "output_blended_fused", wxCheckBox)->Enable(true);
167
    XRCCTRL(*this, "output_blended_fused_bitmap", wxCheckBox)->Enable(true);
168
    XRCCTRL(*this, "output_hdr", wxCheckBox)->Enable(true);
169
    XRCCTRL(*this, "output_hdr_bitmap", wxCheckBox)->Enable(true);
170
    if(m_pano.getNrOfImages() % m_stacks.size() == 0)
171
    {
172
        XRCCTRL(*this, "output_fused_blended", wxCheckBox)->SetValue(true);
173
    }
174
    else
175
    {
176
        if(m_exposureLayers.size()==1)
177
        {
178
            XRCCTRL(*this, "output_normal", wxCheckBox)->SetValue(true);
179
        }
180
        else
181
        {
182
            XRCCTRL(*this, "output_blended_fused", wxCheckBox)->SetValue(true);
183
        };
184
    };
185
};
186
187
void PanoOutputDialog::OnOk(wxCommandEvent & e)
188
{
189
    bool output_normal=XRCCTRL(*this, "output_normal", wxCheckBox)->GetValue();
190
    bool output_fused_blended=XRCCTRL(*this, "output_fused_blended", wxCheckBox)->GetValue();
191
    bool output_blended_fused=XRCCTRL(*this, "output_blended_fused", wxCheckBox)->GetValue();
192
    bool output_hdr=XRCCTRL(*this, "output_hdr", wxCheckBox)->GetValue();
193
    bool keep_intermediate=XRCCTRL(*this, "output_keep_intermediate", wxCheckBox)->GetValue();
194
    //normal output
195
    m_newOpt.outputLDRBlended=output_normal;
196
    m_newOpt.outputLDRLayers=output_normal && keep_intermediate;
197
    //fused stacks, then blended
198
    m_newOpt.outputLDRExposureBlended=output_fused_blended;
199
    m_newOpt.outputLDRExposureRemapped=(output_fused_blended || output_blended_fused) && keep_intermediate;
200
    m_newOpt.outputLDRStacks=output_fused_blended && keep_intermediate;
201
    // blended exposure layers, then fused
202
    m_newOpt.outputLDRExposureLayersFused=output_blended_fused;
203
    m_newOpt.outputLDRExposureLayers=output_blended_fused && keep_intermediate;
204
    // HDR output
205
    m_newOpt.outputHDRBlended=output_hdr;
206
    m_newOpt.outputHDRLayers=output_hdr && keep_intermediate;
207
    m_newOpt.outputHDRStacks=output_hdr && keep_intermediate;
208
    // read compression
209
    if(output_normal || output_fused_blended || output_blended_fused)
210
    {
211
        if(m_newOpt.outputImageType=="jpg")
212
        {
213
            m_newOpt.quality=XRCCTRL(*this, "output_jpeg_quality", wxSpinCtrl)->GetValue();
214
        }
215
        else
216
        {
217
            if(m_newOpt.outputImageType=="tif")
218
            {
219
                switch(XRCCTRL(*this, "output_tiff_compression", wxChoice)->GetSelection())
220
                {
221
                    case 0:
222
                    default:
223
                        m_newOpt.outputImageTypeCompression = "NONE";
224
                        m_newOpt.tiffCompression = "NONE";
225
                        break;
226
                    case 1:
227
                        m_newOpt.outputImageTypeCompression = "PACKBITS";
228
                        m_newOpt.tiffCompression = "PACKBITS";
229
                        break;
230
                    case 2:
231
                        m_newOpt.outputImageTypeCompression = "LZW";
232
                        m_newOpt.tiffCompression = "LZW";
233
                        break;
234
                    case 3:
235
                        m_newOpt.outputImageTypeCompression = "DEFLATE";
236
                        m_newOpt.tiffCompression = "DEFLATE";
237
                        break;
238
                };
239
            };
240
        };
241
    };
242
    //HDR compression
243
    if(output_hdr)
244
    {
245
        if(m_newOpt.outputImageTypeHDR=="tif")
246
        {
247
            switch(XRCCTRL(*this, "output_hdr_tiff_compression", wxChoice)->GetSelection())
248
            {
249
                case 0:
250
                default:
251
                    m_newOpt.outputImageTypeHDRCompression = "NONE";
252
                    break;
253
                case 1:
254
                    m_newOpt.outputImageTypeHDRCompression = "PACKBITS";
255
                    break;
256
                case 2:
257
                    m_newOpt.outputImageTypeHDRCompression = "LZW";
258
                    break;
259
                case 3:
260
                    m_newOpt.outputImageTypeHDRCompression = "DEFLATE";
261
                    break;
262
            };
263
        };
264
    }
265
    // canvas size
266
    m_newOpt.setWidth(m_edit_width->GetValue(), true);
267
    //send Ok
268
    EndModal(wxID_OK);
269
};
270
271
void PanoOutputDialog::OnOutputChanged(wxCommandEvent & e)
272
{
273
    bool output_normal=XRCCTRL(*this, "output_normal", wxCheckBox)->GetValue();
274
    bool output_fused_blended=XRCCTRL(*this, "output_fused_blended", wxCheckBox)->GetValue();
275
    bool output_blended_fused=XRCCTRL(*this, "output_blended_fused", wxCheckBox)->GetValue();
276
    bool output_hdr=XRCCTRL(*this, "output_hdr", wxCheckBox)->GetValue();
277
    //enable Ok only if at least one option is enabled
278
    XRCCTRL(*this, "wxID_OK", wxButton)->Enable(output_normal || output_fused_blended || output_blended_fused || output_hdr);
279
    XRCCTRL(*this, "output_ldr_format_label", wxStaticText)->Enable(output_normal || output_fused_blended || output_blended_fused);
280
    XRCCTRL(*this, "output_ldr_format", wxChoice)->Enable(output_normal || output_fused_blended || output_blended_fused);
281
    XRCCTRL(*this, "output_ldr_compression_label", wxStaticText)->Enable(output_normal || output_fused_blended || output_blended_fused);
282
    XRCCTRL(*this, "output_jpeg_quality", wxSpinCtrl)->Enable(output_normal || output_fused_blended || output_blended_fused);
283
    XRCCTRL(*this, "output_tiff_compression", wxChoice)->Enable(output_normal || output_fused_blended || output_blended_fused);
284
    XRCCTRL(*this, "output_hdr_format_label", wxStaticText)->Enable(output_hdr);
285
    XRCCTRL(*this, "output_hdr_format", wxChoice)->Enable(output_hdr);
286
    XRCCTRL(*this, "output_hdr_compression_label", wxStaticText)->Enable(output_hdr);
287
    XRCCTRL(*this, "output_hdr_tiff_compression", wxChoice)->Enable(output_hdr);
288
    GetSizer()->Layout();
289
};
290
291
void PanoOutputDialog::OnLDRFormatChanged(wxCommandEvent & e)
292
{
293
    int sel = XRCCTRL(*this, "output_ldr_format", wxChoice)->GetSelection();
294
    switch (sel)
295
    {
296
        case 1:
297
            m_newOpt.outputImageType ="jpg";
298
            XRCCTRL(*this, "output_ldr_compression_label", wxStaticText)->Show();
299
            XRCCTRL(*this, "output_ldr_compression_label", wxStaticText)->SetLabel(_("Quality:"));
300
            XRCCTRL(*this, "output_jpeg_quality", wxSpinCtrl)->Show();
301
            XRCCTRL(*this, "output_tiff_compression", wxChoice)->Hide();
302
            break;
303
        case 2:
304
            m_newOpt.outputImageType ="png";
305
            XRCCTRL(*this, "output_ldr_compression_label", wxStaticText)->Hide();
306
            XRCCTRL(*this, "output_jpeg_quality", wxSpinCtrl)->Hide();
307
            XRCCTRL(*this, "output_tiff_compression", wxChoice)->Hide();
308
            break;
309
        default:
310
        case 0:
311
            m_newOpt.outputImageType ="tif";
312
            XRCCTRL(*this, "output_ldr_compression_label", wxStaticText)->Show();
313
            XRCCTRL(*this, "output_ldr_compression_label", wxStaticText)->SetLabel(_("Compression:"));
314
            XRCCTRL(*this, "output_jpeg_quality", wxSpinCtrl)->Hide();
315
            XRCCTRL(*this, "output_tiff_compression", wxChoice)->Show();
316
            break;
317
    };
318
    GetSizer()->Layout();
319
};
320
321
322
void PanoOutputDialog::OnHDRFormatChanged(wxCommandEvent & e)
323
{
324
    int sel = XRCCTRL(*this, "output_hdr_format", wxChoice)->GetSelection();
325
    switch (sel)
326
    {
327
        case 1:
328
            m_newOpt.outputImageTypeHDR="tif";
329
            XRCCTRL(*this, "output_hdr_compression_label", wxStaticText)->Show();
330
            XRCCTRL(*this, "output_hdr_tiff_compression", wxChoice)->Show();
331
            break;
332
        case 0:
333
        default:
334
            m_newOpt.outputImageTypeHDR="exr";
335
            XRCCTRL(*this, "output_hdr_compression_label", wxStaticText)->Hide();
336
            XRCCTRL(*this, "output_hdr_tiff_compression", wxChoice)->Hide();
337
            break;
338
    };
339
    GetSizer()->Layout();
340
};
341
342
void PanoOutputDialog::OnWidthChanged(wxSpinEvent & e)
343
{
344
    m_edit_height->SetValue(m_edit_width->GetValue()*m_optHeight/m_optWidth);
345
};
346
347
void PanoOutputDialog::OnHeightChanged(wxSpinEvent & e)
348
{
349
    m_edit_width->SetValue(m_edit_height->GetValue()*m_optWidth/m_optHeight);
350
};

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks