~ubuntu-branches/ubuntu/trusty/hugin/trusty-proposed

« back to all changes in this revision

Viewing changes to src/hugin1/hugin/huginApp.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Metzler
  • Date: 2011-01-06 14:28:24 UTC
  • mfrom: (1.1.9 upstream) (0.1.21 experimental)
  • Revision ID: james.westby@ubuntu.com-20110106142824-zn9lxylg5z44dynn
* Drop Cyril Brulebois from Uploaders. Thank you very much for your work.
* Bump package version. (rc3 was re-released as 2010.4.0).

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
#include "base_wx/huginConfig.h"
57
57
#ifdef __WXMSW__
58
58
#include "wx/dir.h"
 
59
#include "wx/cshelp.h"
59
60
#endif
60
61
 
61
 
 
62
62
#include <tiffio.h>
63
63
 
64
64
#include "AboutDialog.h"
77
77
 
78
78
wxString getDefaultProjectName(const Panorama & pano)
79
79
{
80
 
    if (pano.getNrOfImages() > 0) {
81
 
        
82
 
        wxString first_img(stripExtension(stripPath(pano.getImage(0).getFilename())).c_str(), HUGIN_CONV_FILENAME);
83
 
        wxString last_img(stripExtension(stripPath(pano.getImage(pano.getNrOfImages()-1).getFilename())).c_str(), HUGIN_CONV_FILENAME);
84
 
        return first_img + wxT("-") + last_img;
85
 
    } else {
86
 
        return wxString(wxT("pano"));
 
80
    bool t = (wxConfigBase::Get()->Read(wxT("ProjectNamingConvention"), HUGIN_PROJECT_NAMING_CONVENTION) != 0);
 
81
    if(t){
 
82
        if (pano.getNrOfImages() > 0) {
 
83
            wxString first_img(hugin_utils::getFolder(pano.getImage(0).getFilename()).c_str(), HUGIN_CONV_FILENAME);
 
84
            return first_img;
 
85
        } else {
 
86
            return wxString(wxT("pano"));
 
87
        }
 
88
    }else{
 
89
        if (pano.getNrOfImages() > 0) {
 
90
 
 
91
            wxString first_img(stripExtension(stripPath(pano.getImage(0).getFilename())).c_str(), HUGIN_CONV_FILENAME);
 
92
            wxString last_img(stripExtension(stripPath(pano.getImage(pano.getNrOfImages()-1).getFilename())).c_str(), HUGIN_CONV_FILENAME);
 
93
            return first_img + wxT("-") + last_img;
 
94
        } else {
 
95
            return wxString(wxT("pano"));
 
96
        }
87
97
    }
88
98
}
89
99
 
 
100
DEFINE_EVENT_TYPE( EVT_IMAGE_READY )
90
101
 
 
102
BEGIN_EVENT_TABLE(huginApp, wxApp)
 
103
    EVT_IMAGE_READY2(-1, huginApp::relayImageLoaded)
 
104
END_EVENT_TABLE()
91
105
 
92
106
// make wxwindows use this class as the main application
93
107
IMPLEMENT_APP(huginApp)
116
130
{
117
131
    DEBUG_TRACE("=========================== huginApp::OnInit() begin ===================");
118
132
    SetAppName(wxT("hugin"));
 
133
    
 
134
    // Connect to ImageCache: we need to tell it when it is safe to handle UI events.
 
135
    ImageCache::getInstance().asyncLoadCompleteSignal = &huginApp::imageLoadedAsync;
119
136
 
120
137
#ifdef __WXMAC__
121
138
    // do not use the native list control on OSX (it is very slow with the control point list window)
130
147
 
131
148
 
132
149
#if defined __WXMSW__
 
150
    // initialize help provider
 
151
    wxHelpControllerHelpProvider* provider = new wxHelpControllerHelpProvider;
 
152
    wxHelpProvider::Set(provider);
 
153
 
133
154
    wxString huginExeDir = getExePath(argv[0]);
134
155
 
135
156
    wxString huginRoot;
270
291
    // setup main frame size, after it has been created.
271
292
    RestoreFramePosition(frame, wxT("MainFrame"));
272
293
#ifdef __WXMSW__
 
294
    provider->SetHelpController(&frame->GetHelpController());
 
295
    frame->GetHelpController().Initialize(m_xrcPrefix+wxT("data/hugin_help_en_EN.chm"));
273
296
    frame->SendSizeEvent();
274
297
#endif
275
298
 
444
467
    }
445
468
}
446
469
 
 
470
MainFrame* huginApp::getMainFrame()
 
471
{
 
472
    if (m_this) {
 
473
        return m_this->frame;
 
474
    } else {
 
475
        return 0;
 
476
    }
 
477
}
 
478
 
 
479
void huginApp::relayImageLoaded(ImageReadyEvent & event)
 
480
{
 
481
    ImageCache::getInstance().postEvent(event.request, event.entry);
 
482
}
 
483
 
 
484
void huginApp::imageLoadedAsync(ImageCache::RequestPtr request, ImageCache::EntryPtr entry)
 
485
{
 
486
    ImageReadyEvent event(request, entry);
 
487
    // AddPendingEvent adds the event to the event queue and returns without
 
488
    // processing it. This is necessary since we are probably not in the
 
489
    // UI thread, but the event handler must be run in the UI thread since it
 
490
    // could update image views.
 
491
    Get()->AddPendingEvent(event);
 
492
}
 
493
 
447
494
#ifdef __WXMAC__
448
495
void huginApp::MacOpenFile(const wxString &fileName)
449
496
{
549
596
    }
550
597
#endif
551
598
}
 
599
 
 
600
IMPLEMENT_DYNAMIC_CLASS(MyHTML, wxHtmlWindow)
 
601
 
 
602
 BEGIN_EVENT_TABLE(MyHTML, wxHtmlWindow)
 
603
 // Add event tables here
 
604
 END_EVENT_TABLE()
 
605
 
 
606
 bool MyHTML::Create(wxWindow * parent, wxWindowID id,
 
607
                 const wxPoint & pos,
 
608
                 const wxSize & size,
 
609
                 long style)
 
610
 {
 
611
   SetParent(parent);
 
612
   wxXmlResource::Get()->LoadPanel(this, GetParent(), _T("dedication_html"));
 
613
   GetSizer()->Fit(this);
 
614
 
 
615
   return true;
 
616
 }
 
617
 
 
618
void MyHTML::OnLinkClicked(const wxHtmlLinkInfo& link)
 
619
{
 
620
  if (link.GetHref().StartsWith(_T("http://")))
 
621
    wxLaunchDefaultBrowser(link.GetHref());
 
622
  else
 
623
    wxHtmlWindow::OnLinkClicked(link);
 
624
}