27 #include "hugin_config.h" 
   58 bool OptimizePanel::Create(wxWindow* parent, wxWindowID 
id , 
const wxPoint& pos, 
const wxSize& size, 
long style, 
const wxString& name)
 
   62     if (! wxPanel::Create(parent, 
id, pos, size, style, name) ) {
 
   69     wxXmlResource::Get()->LoadPanel(
this, 
"optimize_panel");
 
   70     wxPanel * panel = XRCCTRL(*
this, 
"optimize_panel", wxPanel);
 
   72     wxBoxSizer *topsizer = 
new wxBoxSizer( wxVERTICAL );
 
   73     topsizer->Add(panel, 1, wxEXPAND, 0);
 
   80     m_ignore_line_cp = XRCCTRL(*
this, 
"optimizer_panel_ignore_line_cp", wxCheckBox);
 
   91     m_edit_cb = XRCCTRL(*
this, 
"optimizer_panel_edit_script", wxCheckBox);
 
   94     XRCCTRL(*
this, 
"optimizer_panel_splitter", wxSplitterWindow)->SetSashGravity(0.66);
 
  143     XRCCTRL(*
this, 
"optimize_panel_optimize", wxButton)->Enable(pano.
getNrOfImages()>0);
 
  144     XRCCTRL(*
this, 
"optimize_panel_reset", wxButton)->Enable(pano.
getNrOfImages()>0);    
 
  158             hugin_utils::HuginMessageBox(_(
"The project does not contain any active images.\nPlease activate at least one image in the (fast) preview window.\nOptimization canceled."),
 
  159                 _(
"Hugin"), wxICON_ERROR | wxOK, wxGetActiveWindow());
 
  183         hugin_utils::HuginMessageBox(_(
"There are no control points in the current configuration for the optimizer.\nPlease add control points before running the optimizer.\nOptimization canceled."),
 
  184             _(
"Hugin"), wxICON_ERROR | wxOK, wxGetActiveWindow());
 
  206     char *p = setlocale(LC_ALL,NULL);
 
  207     char *oldlocale = strdup(p);
 
  208     setlocale(LC_ALL,
"C");
 
  244             for (
auto& cp : originalCps)
 
  248                     optCps.push_back(cp);
 
  253                 hugin_utils::HuginMessageBox(_(
"There are no control points in the current configuration for the optimizer.\nPlease add control points before running the optimizer.\nOptimization canceled."),
 
  254                     _(
"Hugin"), wxICON_ERROR | wxOK, wxGetActiveWindow());
 
  262             std::ostringstream scriptbuf;
 
  266             wxXmlResource::Get()->LoadDialog(&edit_dlg, 
this, 
"edit_script_dialog");
 
  267             wxTextCtrl *txtCtrl=XRCCTRL(edit_dlg,
"script_edit_text",wxTextCtrl);
 
  268             txtCtrl->SetValue(wxString(scriptbuf.str().c_str(), *wxConvCurrent));
 
  271             if (edit_dlg.ShowModal() == wxID_OK)
 
  273                 script = strdup(txtCtrl->GetValue().mb_str(*wxConvCurrent));
 
  277                 setlocale(LC_ALL,oldlocale);
 
  295     setlocale(LC_ALL,oldlocale);
 
  301     wxTheApp->ProcessIdle();
 
  306         if (!originalCps.empty())
 
  329     bool smallHFOV=
false;
 
  330     bool highDist = 
false;
 
  332     for (HuginBase::VariableMapVector::const_iterator it = vars.begin(); it != vars.end(); ++it)
 
  334         if (
const_map_get(*it,
"v").getValue() < 1.0) smallHFOV = 
true;
 
  335         if (fabs(
const_map_get(*it,
"a").getValue()) > 0.8) highDist = 
true;
 
  336         if (fabs(
const_map_get(*it,
"b").getValue()) > 0.8) highDist = 
true;
 
  337         if (fabs(
const_map_get(*it,
"c").getValue()) > 0.8) highDist = 
true;
 
  344         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?"));
 
  351             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?"),
 
  352                    mean, sqrt(var), max);
 
  353             style = wxYES_NO | wxICON_EXCLAMATION;
 
  357             msg.Printf(_(
"Optimizer run finished.\nResults:\n average control point distance: %f\n standard deviation: %f\n maximum: %f\n\nApply the changes?"),
 
  358                    mean, sqrt(var), max);
 
  359             style = wxYES_NO | wxICON_EXCLAMATION;
 
  420                 : wxXmlResourceHandler()
 
  429     cp->Create(m_parentAsWindow,
 
  431                    GetPosition(), GetSize(),
 
  442     return IsOfClass(node, 
"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 
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL, const wxString &name="panel")
Delayed creation. 
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. 
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
helper class, it disables the control/window in the constructor and automatically enables it back in ...
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 
int HuginMessageBox(const wxString &message, const wxString &caption, int style, wxWindow *parent)
void SetOptimizerMode()
sets to control into optimizer mode