29 #include <wx/stdpaths.h>
30 #include <wx/wfstream.h>
32 #if defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
50 wxXmlResource::Get()->LoadDialog(
this, parent,
"change_user_defined_dialog");
53 wxIconBundle myIcons(xrcPrefix+
"data/ptbatcher.ico",wxBITMAP_TYPE_ICO);
56 wxIcon myIcon(xrcPrefix +
"data/ptbatcher.png",wxBITMAP_TYPE_PNG);
60 m_radio_default = XRCCTRL(*
this,
"radio_default_sequence", wxRadioButton);
61 m_radio_user_sequence = XRCCTRL(*
this,
"radio_user_defined", wxRadioButton);
62 m_choice_user_define=XRCCTRL(*
this,
"choice_user_defined", wxChoice);
63 m_label_user_define = XRCCTRL(*
this,
"label_user_defined", wxStaticText);
64 m_label_user_define_filename = XRCCTRL(*
this,
"label_user_defined_filename", wxStaticText);
65 m_radio_external = XRCCTRL(*
this,
"radio_external_sequence", wxRadioButton);
66 m_text_external_file = XRCCTRL(*
this,
"text_external_file", wxTextCtrl);
67 m_text_external_file->AutoCompleteFileNames();
68 m_button_external_file = XRCCTRL(*
this,
"button_external_file", wxButton);
70 m_isAssistantUserDefined = assistantUserDefined;
71 if (m_isAssistantUserDefined)
73 FillAssistantUserDefined();
77 FillStitcherUserDefined();
79 if (userDefinedSequence.IsEmpty())
81 m_radio_default->SetValue(
true);
85 int index = m_userFileNames.Index(userDefinedSequence);
86 if (index == wxNOT_FOUND)
90 m_radio_external->SetValue(
true);
91 m_text_external_file->SetValue(userDefinedSequence);
96 m_radio_user_sequence->SetValue(
true);
97 m_choice_user_define->Select(index);
100 wxCommandEvent dummy;
104 wxConfigBase* config = wxConfigBase::Get();
107 wxDisplaySize(&dx,&dy);
109 int w = config->Read(
"/UserDefinedSequenceDialog/width", -1l);
110 int h = config->Read(
"/UserDefinedSequenceDialog/height", -1l);
111 if (w > 0 && w <= dx)
113 this->SetClientSize(w,h);
120 int x = config->Read(
"/UserDefinedSequenceDialog/positionX", -1l);
121 int y = config->Read(
"/UserDefinedSequenceDialog/positionY", -1l);
122 if ( y >= 0 && x >= 0 && x < dx && y < dy)
134 wxConfigBase* config=wxConfigBase::Get();
135 wxSize sz = this->GetClientSize();
136 config->Write(
"/UserDefinedSequenceDialog/width", sz.GetWidth());
137 config->Write(
"/UserDefinedSequenceDialog/height", sz.GetHeight());
138 wxPoint ps = this->GetPosition();
139 config->Write(
"/UserDefinedSequenceDialog/positionX", ps.x);
140 config->Write(
"/UserDefinedSequenceDialog/positionY", ps.y);
155 const long id = e.GetSelection();
165 wxFileDialog userOutputDlg(
this, (
m_isAssistantUserDefined ? _(
"Select user defined assistant") : _(
"Select user defined output")),
167 wxFD_OPEN | wxFD_FILE_MUST_EXIST, wxDefaultPosition);
168 if (userOutputDlg.ShowModal() == wxID_OK)
180 if (filename.IsEmpty())
182 wxMessageBox(_(
"Please provide a filename to the user defined sequence."),
188 wxOK | wxOK_DEFAULT | wxICON_WARNING);
193 wxMessageBox(wxString::Format(_(
"The file \"%s\" does not exists.\nPlease provide an existing file to the user defined sequence."), filename.c_str()),
199 wxOK | wxOK_DEFAULT | wxICON_WARNING);
210 return wxEmptyString;
220 return wxEmptyString;
229 #if defined __WXMSW__
230 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
231 exePath.RemoveLastDir();
232 const wxString huginRoot = exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
233 return huginRoot +
"share\\hugin\\data\\";
234 #elif defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
237 wxString thePath = MacGetPathToBundledResourceFile(CFSTR(
"xrc"));
238 if (thePath.IsEmpty())
240 wxMessageBox(_(
"xrc directory not found in bundle"), _(
"Fatal Error"));
241 return wxEmptyString;
243 return thePath +
"/";
245 #elif defined UNIX_SELF_CONTAINED_BUNDLE
248 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
249 m_utilsBinDir = exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
250 exePath.RemoveLastDir();
251 const wxString huginRoot = exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
252 return huginRoot +
"share/hugin/data/";
256 return INSTALL_DATA_DIR;
264 wxDir::GetAllFiles(
GetDataPath() +
"assistant", &files,
"*.assistant", wxDIR_FILES | wxDIR_HIDDEN | wxDIR_NO_FOLLOW);
273 wxDir::GetAllFiles(
GetDataPath() +
"output", &files,
"*.executor", wxDIR_FILES | wxDIR_HIDDEN | wxDIR_NO_FOLLOW);
280 if (!files.IsEmpty())
282 for (
auto file : files)
285 wxFileInputStream inputStream(file);
286 if (inputStream.IsOk())
289 wxFileConfig executorFile(inputStream);
298 help = wxString::Format(_(
"User defined sequence: %s"), file);
309 wxCommandEvent dummy;
bool FileExists(const std::string &filename)
checks if file exists
wxRadioButton * m_radio_user_sequence
wxString GetDataPath()
return path to data directory, it depends on operating system
wxArrayString m_userHelpTexts
wxTextCtrl * m_text_external_file
void OnChangeUserDefinedChoice(wxCommandEvent &e)
wxString GetNewSequence()
returns the newly selected sequence
bool m_isAssistantUserDefined
~ChangeUserDefinedSequenceDialog()
destructor, saves size and position
basic classes and function for queuing commands in wxWidgets
void FillUserDefinedChoice(const wxArrayString &files)
void UpdateStatus(wxCommandEvent &e)
void FillStitcherUserDefined()
wxRadioButton * m_radio_default
Dialog for changing the user defined sequence.
wxStaticText * m_label_user_define
wxArrayString m_userFileNames
const wxString GetSettingStringTranslated(wxConfigBase *setting, const wxString &name, const wxString defaultValue)
read a translated string from settings and remove all whitespaces
wxButton * m_button_external_file
std::string GetUserAppDataDir()
returns the directory for user specific Hugin settings, e.g.
void OnChooseFilename(wxCommandEvent &e)
void FillAssistantUserDefined()
wxStaticText * m_label_user_define_filename
wxChoice * m_choice_user_define
wxRadioButton * m_radio_external
void OnOk(wxCommandEvent &e)