Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ToolboxFrame.cpp
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
10 /*
11  * This program 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  * 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 
27 #include "base_wx/platform.h"
28 #include "base_wx/wxutils.h"
29 #include "ToolboxFrame.h"
30 #include "ToolboxApp.h"
31 #include "EnfusePanel.h"
32 #include "PerspectivePanel.h"
33 #include "huginapp/ImageCache.h"
34 #include "hugin/config_defaults.h"
35 #include "CreateBrightImgDlg.h"
36 
37 ToolboxFrame::ToolboxFrame(wxWindow* parent)
38 {
39  // load from XRC
40  wxXmlResource::Get()->LoadFrame(this, parent, "toolbox_frame");
41  SetMinSize(wxSize(500, 400));
42  SetMenuBar(wxXmlResource::Get()->LoadMenuBar(this, "toolbox_menubar"));
43 
44  // set the minimize icon
45 #ifdef __WXMSW__
46  wxIconBundle myIcons(GetXRCPath() + "data/hugin.ico", wxBITMAP_TYPE_ICO);
47  SetIcons(myIcons);
48 #else
49  wxIcon myIcon(GetXRCPath() + "data/hugin.png",wxBITMAP_TYPE_PNG);
50  SetIcon(myIcon);
51 #endif
52  SetTitle(_("Hugin toolbox GUI"));
53  // create a status bar
54  const int fields(2);
55  CreateStatusBar(fields);
56  int widths[fields] = { -1, 85 };
57  SetStatusWidths(fields, &widths[0]);
58  // load monitor profile
59  wxString profileName;
61  m_hasMonitorProfile = !profileName.IsEmpty();
62 
63  // initialize image cache
64  ImageCache::getInstance().setProgressDisplay(this);
65  wxConfigBase* config = wxConfigBase::Get();
66 #if defined __WXMSW__
67  unsigned long long mem = HUGIN_IMGCACHE_UPPERBOUND;
68  unsigned long mem_low = config->Read("/ImageCache/UpperBound", HUGIN_IMGCACHE_UPPERBOUND);
69  unsigned long mem_high = config->Read("/ImageCache/UpperBoundHigh", (long)0);
70  if (mem_high > 0)
71  {
72  mem = ((unsigned long long) mem_high << 32) + mem_low;
73  }
74  else
75  {
76  mem = mem_low;
77  }
78  ImageCache::getInstance().SetUpperLimit(mem);
79 #else
80  ImageCache::getInstance().SetUpperLimit(config->Read("/ImageCache/UpperBound", HUGIN_IMGCACHE_UPPERBOUND));
81 #endif
82 
83  // create splitter window
84  m_mainSplitter = XRCCTRL(*this, "toolbox_splitter", wxSplitterWindow);
85  // create log window
86  m_logPanel = new MyExecPanel(this);
87  wxXmlResource::Get()->AttachUnknownControl("toolbox_logpanel", m_logPanel, this);
88  // create main notebook
89  m_mainNotebook = XRCCTRL(*this, "toolbox_notebook", wxNotebook);
90  m_enfusePanel = new EnfusePanel();
94  m_mainNotebook->AddPage(m_enfusePanel, _("Enfuse"));
95  m_mainNotebook->AddPage(m_perspectivePanel, _("Perspective"));
96  m_mainNotebook->SetSelection(config->ReadLong("/ToolboxFrame/ActiveTab", 0l));
97  // load frame size and position
98  RestoreFramePosition(this, "ToolboxFrame");
99  Layout();
100  if (config->HasEntry("/ToolboxFrame/Main_Splitter"))
101  {
102  m_mainSplitter->SetSashPosition(config->ReadLong("/ToolboxFrame/Main_Splitter", 500));
103  };
104  // bind event handler
105  Bind(wxEVT_MENU, &ToolboxFrame::OnExit, this, XRCID("toolbox_close"));
106  Bind(EVT_QUEUE_PROGRESS, &ToolboxFrame::OnQueueProgress, this);
107 }
108 
110 {
111  // store positions/size/settings
112  StoreFramePosition(this, "ToolboxFrame");
113  wxConfigBase* config = wxConfigBase::Get();
114  config->Write("/ToolboxFrame/Main_Splitter", m_mainSplitter->GetSashPosition());
115  config->Write("/ToolboxFrame/ActiveTab", m_mainNotebook->GetSelection());
116 }
117 
118 const wxString & ToolboxFrame::GetXRCPath() const
119 {
120  return wxGetApp().GetXRCPath();
121 }
122 
124 {
125  return m_hasMonitorProfile;
126 }
127 
129 {
130  return m_monitorProfile;
131 }
132 
133 void ToolboxFrame::OnExit(wxCommandEvent &e)
134 {
135  Close();
136 }
137 
139 {
140  // update progress messages in status bar
141  wxString msg;
142  if (!m_message.empty())
143  {
144  msg = wxGetTranslation(wxString(m_message.c_str(), wxConvLocal));
145  if (!m_filename.empty())
146  {
147  msg.Append(" ");
148  msg.Append(wxString(ProgressDisplay::m_filename.c_str(), HUGIN_CONV_FILENAME));
149  };
150  };
151  GetStatusBar()->SetStatusText(msg, 0);
152 }
153 
154 void ToolboxFrame::OnQueueProgress(wxCommandEvent& e)
155 {
156  if (e.GetInt() == -1)
157  {
158  // notify children about finished process to update their controls
159  if (m_mainNotebook->GetSelection() == 0)
160  {
162  }
163  else
164  {
165  if (m_mainNotebook->GetSelection() == 1)
166  {
168  };
169  };
170  };
171 }
cmsHPROFILE m_monitorProfile
monitor profile
Definition: ToolboxFrame.h:69
bool Create(wxWindow *parent, MyExecPanel *logWindow)
create the panel and populate all controls
implementation of huginApp Class
void updateProgressDisplay()
called when a progress message should be displayed
const wxString & GetXRCPath() const
get the path to the xrc directory
void OnExit(wxCommandEvent &e)
#define HUGIN_CONV_FILENAME
Definition: platform.h:40
declaration of panel for perspective correction GUI
bool HasMonitorProfile() const
wxSplitterWindow * m_mainSplitter
Definition: ToolboxFrame.h:65
virtual ~ToolboxFrame()
destructor
wxNotebook * m_mainNotebook
Definition: ToolboxFrame.h:63
#define HUGIN_IMGCACHE_UPPERBOUND
void OnProcessFinished(wxCommandEvent &e)
clean up temporary files at end
EnfusePanel * m_enfusePanel
Definition: ToolboxFrame.h:66
cmsHPROFILE GetMonitorProfile() const
Definition of dialog class to create brighter/darker versions of the image.
PerspectivePanel * m_perspectivePanel
Definition: ToolboxFrame.h:67
void StoreFramePosition(wxTopLevelWindow *frame, const wxString &basename)
Store window size and position in configfile/registry.
Definition: wxutils.cpp:133
declaration of main frame class for toolbox GUI
declaration of panel for enfuse GUI
bool Create(wxWindow *parent, MyExecPanel *logPanel)
creates the control and populates all controls with their settings
ToolboxFrame(wxWindow *parent)
constructor
MyExecPanel * m_logPanel
Definition: ToolboxFrame.h:64
panel for enfuse GUI
Definition: EnfusePanel.h:37
void OnProcessFinished(wxCommandEvent &e)
call at the end of the enfuse command, to load result back and enable buttons again ...
bool m_hasMonitorProfile
true, if we found a real monitor profile
Definition: ToolboxFrame.h:71
panel for enfuse GUI
void GetMonitorProfile(wxString &profileName, cmsHPROFILE &profile)
retrieve monitor profile from system
Definition: wxcms.cpp:201
void OnQueueProgress(wxCommandEvent &e)
void RestoreFramePosition(wxTopLevelWindow *frame, const wxString &basename)
Restore window size and position from configfile/registry.
Definition: wxutils.cpp:65