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 "StackerPanel.h"
33 #include "PerspectivePanel.h"
34 #include "huginapp/ImageCache.h"
35 #include "hugin/config_defaults.h"
36 #include "CreateBrightImgDlg.h"
37 
38 ToolboxFrame::ToolboxFrame(wxWindow* parent)
39 {
40  // load from XRC
41  wxXmlResource::Get()->LoadFrame(this, parent, "toolbox_frame");
42  SetMinSize(wxSize(500, 400));
43  SetMenuBar(wxXmlResource::Get()->LoadMenuBar(this, "toolbox_menubar"));
44 
45  // set the minimize icon
46 #ifdef __WXMSW__
47  wxIconBundle myIcons(GetXRCPath() + "data/hugin.ico", wxBITMAP_TYPE_ICO);
48  SetIcons(myIcons);
49 #else
50  wxIcon myIcon(GetXRCPath() + "data/hugin.png",wxBITMAP_TYPE_PNG);
51  SetIcon(myIcon);
52 #endif
53  SetTitle(_("Hugin toolbox GUI"));
54  // create a status bar
55  const int fields(2);
56  CreateStatusBar(fields);
57  int widths[fields] = { -1, 85 };
58  SetStatusWidths(fields, &widths[0]);
59  // load monitor profile
60  wxString profileName;
62  m_hasMonitorProfile = !profileName.IsEmpty();
63 
64  // initialize image cache
65  ImageCache::getInstance().setProgressDisplay(this);
66  wxConfigBase* config = wxConfigBase::Get();
67 #if defined __WXMSW__
68  unsigned long long mem = HUGIN_IMGCACHE_UPPERBOUND;
69  unsigned long mem_low = config->Read("/ImageCache/UpperBound", HUGIN_IMGCACHE_UPPERBOUND);
70  unsigned long mem_high = config->Read("/ImageCache/UpperBoundHigh", (long)0);
71  if (mem_high > 0)
72  {
73  mem = ((unsigned long long) mem_high << 32) + mem_low;
74  }
75  else
76  {
77  mem = mem_low;
78  }
79  ImageCache::getInstance().SetUpperLimit(mem);
80 #else
81  ImageCache::getInstance().SetUpperLimit(config->Read("/ImageCache/UpperBound", HUGIN_IMGCACHE_UPPERBOUND));
82 #endif
83 
84  // create splitter window
85  m_mainSplitter = XRCCTRL(*this, "toolbox_splitter", wxSplitterWindow);
86  // create log window
87  m_logPanel = new MyExecPanel(this);
88  wxXmlResource::Get()->AttachUnknownControl("toolbox_logpanel", m_logPanel, this);
89  // create main notebook
90  m_mainNotebook = XRCCTRL(*this, "toolbox_notebook", wxNotebook);
91  m_enfusePanel = new EnfusePanel();
97  m_mainNotebook->AddPage(m_enfusePanel, _("Enfuse"));
98  m_mainNotebook->AddPage(m_stackerPanel, _("Stacker"));
99  m_mainNotebook->AddPage(m_perspectivePanel, _("Perspective"));
100  m_mainNotebook->SetSelection(config->ReadLong("/ToolboxFrame/ActiveTab", 0l));
101  // load frame size and position
102  hugin_utils::RestoreFramePosition(this, "ToolboxFrame/MainWindow");
103  Layout();
104  if (config->HasEntry("/ToolboxFrame/Main_Splitter"))
105  {
106  m_mainSplitter->SetSashPosition(config->ReadLong("/ToolboxFrame/Main_Splitter", 500));
107  };
108  // bind event handler
109  Bind(wxEVT_MENU, &ToolboxFrame::OnExit, this, XRCID("toolbox_close"));
110  Bind(EVT_QUEUE_PROGRESS, &ToolboxFrame::OnQueueProgress, this);
111 }
112 
114 {
115  // store positions/size/settings
116  hugin_utils::StoreFramePosition(this, "ToolboxFrame/MainWindow");
117  wxConfigBase* config = wxConfigBase::Get();
118  config->Write("/ToolboxFrame/Main_Splitter", m_mainSplitter->GetSashPosition());
119  config->Write("/ToolboxFrame/ActiveTab", m_mainNotebook->GetSelection());
120 }
121 
122 const wxString & ToolboxFrame::GetXRCPath() const
123 {
124  return wxGetApp().GetXRCPath();
125 }
126 
128 {
129  return m_hasMonitorProfile;
130 }
131 
133 {
134  return m_monitorProfile;
135 }
136 
137 void ToolboxFrame::OnExit(wxCommandEvent &e)
138 {
139  Close();
140 }
141 
143 {
144  // update progress messages in status bar
145  wxString msg;
146  if (!m_message.empty())
147  {
148  msg = wxGetTranslation(wxString(m_message.c_str(), wxConvLocal));
149  if (!m_filename.empty())
150  {
151  msg.Append(" ");
152  msg.Append(wxString(ProgressDisplay::m_filename.c_str(), HUGIN_CONV_FILENAME));
153  };
154  };
155  GetStatusBar()->SetStatusText(msg, 0);
156 }
157 
158 void ToolboxFrame::OnQueueProgress(wxCommandEvent& e)
159 {
160  if (e.GetInt() == -1)
161  {
162  // notify children about finished process to update their controls
163  if (m_mainNotebook->GetSelection() == 0)
164  {
166  }
167  else
168  {
169  if (m_mainNotebook->GetSelection() == 1)
170  {
172  }
173  else
174  {
175  if (m_mainNotebook->GetSelection() == 2)
176  {
178  };
179  };
180  };
181  };
182 }
cmsHPROFILE m_monitorProfile
monitor profile
Definition: ToolboxFrame.h:71
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
declaration of panel for stacker GUI
void RestoreFramePosition(wxTopLevelWindow *frame, const wxString &basename, const bool ignoreMaximize)
Definition: wxutils.cpp:67
void StoreFramePosition(wxTopLevelWindow *frame, const wxString &basename, const bool ignoreMaximize)
Definition: wxutils.cpp:106
void OnProcessFinished(wxCommandEvent &e)
call at the end of the enfuse command, to load result back and enable buttons again ...
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:66
virtual ~ToolboxFrame()
destructor
wxNotebook * m_mainNotebook
Definition: ToolboxFrame.h:64
#define HUGIN_IMGCACHE_UPPERBOUND
void OnProcessFinished(wxCommandEvent &e)
clean up temporary files at end
EnfusePanel * m_enfusePanel
Definition: ToolboxFrame.h:67
cmsHPROFILE GetMonitorProfile() const
StackerPanel * m_stackerPanel
Definition: ToolboxFrame.h:68
bool Create(wxWindow *parent, MyExecPanel *logPanel)
creates the control and populates all controls with their settings
Definition of dialog class to create brighter/darker versions of the image.
PerspectivePanel * m_perspectivePanel
Definition: ToolboxFrame.h:69
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:65
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 ...
panel for stacker GUI
Definition: StackerPanel.h:37
bool m_hasMonitorProfile
true, if we found a real monitor profile
Definition: ToolboxFrame.h:73
panel for enfuse GUI
void GetMonitorProfile(wxString &profileName, cmsHPROFILE &profile)
retrieve monitor profile from system
Definition: wxcms.cpp:201
void OnQueueProgress(wxCommandEvent &e)