27 #include "hugin_config.h"
54 EVT_BUTTON(XRCID("optimize_panel_optimize"),
OptimizePanel::OnOptimizeButton)
55 EVT_BUTTON(XRCID("optimize_panel_reset"),
OptimizePanel::OnReset)
56 EVT_CHECKBOX(XRCID("optimizer_panel_only_active_images"),
OptimizePanel::OnCheckOnlyActiveImages)
57 EVT_CHECKBOX(XRCID("optimizer_panel_ignore_line_cp"),
OptimizePanel::OnCheckIgnoreLineCP)
66 bool OptimizePanel::Create(wxWindow* parent, wxWindowID
id ,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name)
70 if (! wxPanel::Create(parent,
id, pos, size, style, name) ) {
77 wxXmlResource::Get()->LoadPanel(
this, wxT(
"optimize_panel"));
78 wxPanel * panel = XRCCTRL(*
this,
"optimize_panel", wxPanel);
80 wxBoxSizer *topsizer =
new wxBoxSizer( wxVERTICAL );
81 topsizer->Add(panel, 1, wxEXPAND, 0);
87 m_ignore_line_cp = XRCCTRL(*
this,
"optimizer_panel_ignore_line_cp", wxCheckBox);
95 SetOnlyActiveImages(wxConfigBase::Get()->Read(wxT(
"/OptimizePanel/OnlyActiveImages"), 1l) != 0);
97 m_edit_cb = XRCCTRL(*
this,
"optimizer_panel_edit_script", wxCheckBox);
100 XRCCTRL(*
this,
"optimizer_panel_splitter", wxSplitterWindow)->SetSashGravity(0.66);
145 XRCCTRL(*
this,
"optimize_panel_optimize", wxButton)->Enable(pano.
getNrOfImages()>0);
146 XRCCTRL(*
this,
"optimize_panel_reset", wxButton)->Enable(pano.
getNrOfImages()>0);
153 wxWindowDisabler winDisable;
162 wxMessageBox(_(
"The project does not contain any active images.\nPlease activate at least one image in the (fast) preview window.\nOptimization canceled."),
168 wxICON_ERROR | wxOK);
189 wxWindow* activeWindow = wxGetActiveWindow();
194 wxMessageBox(_(
"There are no control points in the current configuration for the optimizer.\nPlease add control points before running the optimizer.\nOptimization canceled."),
200 wxICON_ERROR | wxOK);
219 char *p = setlocale(LC_ALL,NULL);
220 char *oldlocale = strdup(p);
221 setlocale(LC_ALL,
"C");
257 for (
auto& cp : originalCps)
261 optCps.push_back(cp);
266 wxMessageBox(_(
"There are no control points in the current configuration for the optimizer.\nPlease add control points before running the optimizer.\nOptimization canceled."),
272 wxICON_ERROR | wxOK);
280 std::ostringstream scriptbuf;
284 wxXmlResource::Get()->LoadDialog(&edit_dlg,
this, wxT(
"edit_script_dialog"));
285 wxTextCtrl *txtCtrl=XRCCTRL(edit_dlg,
"script_edit_text",wxTextCtrl);
286 txtCtrl->SetValue(wxString(scriptbuf.str().c_str(), *wxConvCurrent));
289 if (edit_dlg.ShowModal() == wxID_OK)
291 script = strdup(txtCtrl->GetValue().mb_str(*wxConvCurrent));
295 setlocale(LC_ALL,oldlocale);
313 setlocale(LC_ALL,oldlocale);
319 wxTheApp->ProcessIdle();
324 if (!originalCps.empty())
347 bool smallHFOV=
false;
348 bool highDist =
false;
350 for (HuginBase::VariableMapVector::const_iterator it = vars.begin(); it != vars.end(); ++it)
352 if (
const_map_get(*it,
"v").getValue() < 1.0) smallHFOV =
true;
353 if (fabs(
const_map_get(*it,
"a").getValue()) > 0.8) highDist =
true;
354 if (fabs(
const_map_get(*it,
"b").getValue()) > 0.8) highDist =
true;
355 if (fabs(
const_map_get(*it,
"c").getValue()) > 0.8) highDist =
true;
362 msg.Printf( _(
"Optimizer run finished.\nWARNING: a very small Field of View (v) has been estimated\n\nThe results are probably invalid.\n\nOptimization of the Field of View (v) of partial panoramas can lead to bad results.\nTry adding more images and control points.\n\nApply the changes anyway?"));
369 msg.Printf(_(
"Optimizer run finished.\nResults:\n average control point distance: %f\n standard deviation: %f\n maximum: %f\n\n*WARNING*: very high distortion coefficients (a,b,c) have been estimated.\nThe results are probably invalid.\nOnly optimize all distortion parameters when many, well spread control points are used.\nPlease reset the a,b and c parameters to zero and add more control points\n\nApply the changes anyway?"),
370 mean, sqrt(var), max);
371 style = wxYES_NO | wxICON_EXCLAMATION;
375 msg.Printf(_(
"Optimizer run finished.\nResults:\n average control point distance: %f\n standard deviation: %f\n maximum: %f\n\nApply the changes?"),
376 mean, sqrt(var), max);
377 style = wxYES_NO | wxICON_EXCLAMATION;
381 int id = wxMessageBox(msg, _(
"Optimization result"), style, activeWindow);
440 : wxXmlResourceHandler()
449 cp->Create(m_parentAsWindow,
451 GetPosition(), GetSize(),
452 GetStyle(wxT(
"style")),
462 return IsOfClass(node, wxT(
"OptimizePanel"));
ImagesTreeCtrl * m_lens_tree_list
Base class for all panorama commands.
PanoramaOptions::ProjectionFormat getProjection() const
ImagesTreeCtrl * m_images_tree_list
void SetGroupMode(GroupMode newMode)
sets the group mode to given mode
virtual PanoCommand::PanoCommand * GetCommand(wxWindow *parent, HuginBase::Panorama &pano, HuginBase::UIntSet images, GuiLevel guiLevel)
returns the appropriate PanoCommand::PanoCommand to be inserted into GlobalCmdHistory, checks if operation is enabled
virtual void panoramaImagesChanged(HuginBase::Panorama &pano, const HuginBase::UIntSet &imgNr)
receives notification about panorama changes
declaration of main image tree control
bool removeObserver(PanoramaObserver *observer)
remove a panorama observer.
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL, const wxString &name=wxT("panel"))
Delayed creation.
void registerPTWXDlgFcn()
static void calcCtrlPntsErrorStats(const PanoramaData &pano, double &min, double &max, double &mean, double &var, const int &imgNr=-1, const bool onlyActive=false, const bool ignoreLineCp=false)
void OnReset(wxCommandEvent &e)
void deregisterPTWXDlgFcn()
std::size_t getNrOfCtrlPoints() const
number of control points
void SetOptimizeOnlyActiveImages(const bool onlyActive)
sets the status of the "optimize only active images" menu item
#define DEBUG_ASSERT(cond)
include file for the hugin project
virtual void run()
runs the algorithm.
Panorama getSubset(const UIntSet &imgs) const
get a subset of the panorama
const CPVector & getCtrlPoints() const
get all control point of this Panorama
void OnCheckIgnoreLineCP(wxCommandEvent &e)
handle "ignore line cp" checkbox
virtual bool CanHandle(wxXmlNode *node)
const Map::mapped_type & const_map_get(const Map &m, const typename Map::key_type &key)
Definition of PanoOperation class.
void Init(HuginBase::Panorama *pano)
initialization, connects all control with Panorama, register observer
wxCheckBox * m_only_active_images_cb
void Init(HuginBase::Panorama *pano)
std::set< unsigned int > UIntSet
HuginBase::Panorama * m_pano
void runOptimizer(const HuginBase::UIntSet &img, const bool ignoreLineCp)
std::vector< VariableMap > VariableMapVector
void MarkActiveImages(const bool markActive)
sets the flag, if active/disabled image should be marked with different colour
const OptimizeVector & getOptimizeVector() const
return the optimize settings stored inside panorama
some definitions to work with optimizer master switches
void SetDisplayMode(DisplayMode newMode)
sets the display mode to given mode
VariableMapVector getVariables() const
get variables of this panorama
std::size_t getNrOfImages() const
number of images.
static MainFrame * Get()
hack.. kind of a pseudo singleton...
void SetIgnoreLineCP(const bool noLineCp)
for external setting of "ignore line cp" checkbox
void SetOnlyActiveImages(const bool onlyActive)
for external setting of "only active image" checkbox
void setCtrlPoints(const CPVector &points)
set all control points (Ippei: Is this supposed to be 'add' method?)
wxCheckBox * m_ignore_line_cp
IMPLEMENT_DYNAMIC_CLASS(wxTreeListHeaderWindow, wxWindow)
void OnOptimizeButton(wxCommandEvent &e)
run the optimizer
bool AskApplyResult(wxWindow *activeWindow, const HuginBase::Panorama &pano)
void SetOptimizeIgnoreLineCp(const bool ignoreLineCP)
sets the status of the "ignore line cp" menu item
static GlobalCmdHist & getInstance()
virtual wxObject * DoCreateResource()
update all variables & control points
void addCommand(PanoCommand *command, bool execute=true)
Adds a command to the history.
void SetGuiLevel(GuiLevel newSetting)
sets the GuiLevel of the control
!! from PTOptimise.h 1951
UIntSet getActiveImages() const
get active images
void SetGuiLevel(GuiLevel newGuiLevel)
HuginBase::UIntSet GetSelectedImages()
returns the selected images
void addObserver(PanoramaObserver *o)
add a panorama observer.
include file for the hugin project
const GuiLevel GetGuiLevel() const
const PanoramaOptions & getOptions() const
returns the options for this panorama
the main images tree control, used on images and optimizer tabs
PanoOperation to reset image variables.
const int getOptimizerSwitch() const
returns optimizer master switch
std::vector< ControlPoint > CPVector
void fill_set(_Container &c, typename _Container::key_type begin, typename _Container::key_type end)
void setOptions(const PanoramaOptions &opt)
set new output settings This is not used directly for optimizing/stiching, but it can be feed into ru...
void printPanoramaScript(std::ostream &o, const OptimizeVector &optvars, const PanoramaOptions &options, const UIntSet &imgs, bool forPTOptimizer, const std::string &stripPrefix="") const
create an optimizer script
virtual void panoramaChanged(HuginBase::Panorama &pano)
receives notification about panorama changes
void setProjection(ProjectionFormat f)
set the Projection format and adjust the hfov/vfov if nessecary
void OnClose(wxCloseEvent &e)
void OnCheckOnlyActiveImages(wxCommandEvent &e)
handle "only active images" checkbox
void SetOptimizerMode()
sets to control into optimizer mode