1 // -*- c-basic-offset: 4 -*- 2 /** @file ImagesTree.h 3 * 4 * @brief declaration of main image tree control 5 * 6 * @author T. Modes 7 */ 8 9 /* This is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU General Public 11 * License as published by the Free Software Foundation; either 12 * version 2 of the License, or (at your option) any later version. 13 * 14 * This software is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public 20 * License along with this software. If not, see 21 * <http://www.gnu.org/licenses/>. 22 * 23 */ 24 25 #ifndef _IMAGESTREE_H 26 #define _IMAGESTREE_H 27 28 #include <map> 29 #include "panodata/Panorama.h" 30 #include <panodata/StandardImageVariableGroups.h> 31 #include "treelistctrl.h" 32 #include "GuiLevel.h" 33 #include "hugin/PanoOperation.h" 34 35 /** the main images tree control, used on images and optimizer tabs */ 36 class ImagesTreeCtrl: public wxcode::wxTreeListCtrl, public HuginBase::PanoramaObserver 37 { 38 public: 39 /** enumeration for grouping mode */ 40 enum GroupMode 41 { 42 GROUP_NONE=0, 43 GROUP_LENS=1, 44 GROUP_STACK=2, 45 GROUP_OUTPUTLAYERS=3, 46 GROUP_OUTPUTSTACK=4, 47 }; 48 /** enumeration for display mode, limits the displayed columns */ 49 enum DisplayMode 50 { 51 DISPLAY_GENERAL=0, 52 DISPLAY_EXIF=1, 53 DISPLAY_POSITION=2, 54 DISPLAY_LENS=3, 55 DISPLAY_PHOTOMETRICS=4, 56 DISPLAY_PHOTOMETRICS_IMAGES=32, 57 DISPLAY_PHOTOMETRICS_LENSES=33, 58 }; 59 /** general constructor */ 60 ImagesTreeCtrl(); 61 62 /** creates the control */ 63 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")); 64 65 /** initialization, connects all control with Panorama, register observer */ 66 void Init(HuginBase::Panorama * pano); 67 68 /** destructor */ 69 virtual ~ImagesTreeCtrl(void) ; 70 71 /** sets the group mode to given mode */ 72 void SetGroupMode(GroupMode newMode); 73 /** sets the display mode to given mode */ 74 void SetDisplayMode(DisplayMode newMode); 75 76 /** sets the GuiLevel of the control */ 77 void SetGuiLevel(GuiLevel newSetting); 78 /** sets to control into optimizer mode 79 * 80 * this marks the variables, which should be optimized, bold and underlined, 81 * also activates the context menu for optimizer */ 82 void SetOptimizerMode(); 83 /** receives notification about panorama changes */ 84 virtual void panoramaChanged(HuginBase::Panorama & pano); 85 /** receive the update signal and update display accordingly 86 */ 87 void panoramaImagesChanged(HuginBase::Panorama &pano, const HuginBase::UIntSet & imgNr); 88 /** returns the selected images 89 * 90 * if a lens or stack is selected it returns all images of the selected lens/stack */ 91 HuginBase::UIntSet GetSelectedImages(); 92 /** sets the flag, if active/disabled image should be marked with different colour */ 93 void MarkActiveImages(const bool markActive); 94 95 protected: 96 /** updates the information for the given image in tree */ 97 void UpdateImageText(wxTreeItemId item); 98 /** updates the information fot the given lens/stack in the tree */ 99 void UpdateGroupText(wxTreeItemId item); 100 /** updates the given group, updates number of images and the images itself */ 101 void UpdateGroup(wxTreeItemId parent, const HuginBase::UIntSet imgs, HuginBase::UIntSet& changed); 102 /** event handler, when column width was changed, save into wxConfig */ 103 void OnColumnWidthChange(wxListEvent & e ); 104 /** event handler for linking image variables */ 105 void OnLinkImageVariables(wxCommandEvent &e); 106 /** event handler for unlinking image variables */ 107 void OnUnlinkImageVariables(wxCommandEvent &e); 108 /** event handler for showing image variables editing dialog */ 109 void OnEditImageVariables(wxCommandEvent &e); 110 /** event handler when dragging begins, veto if dragging is not possible */ 111 void OnBeginDrag(wxTreeEvent &e); 112 /** event handler for left up, handles end of dragging and updates of optimizer variables states */ 113 void OnLeftUp(wxMouseEvent &e); 114 /** event handler for left mouse down, handles toggle of optimizer variables */ 115 void OnLeftDown(wxMouseEvent &e); 116 /** event handler for mouse motion, handles focussing of check boxes */ 117 void OnMouseMove(wxMouseEvent &e); 118 /** event handler for left double click */ 119 void OnLeftDblClick(wxMouseEvent &e); 120 /** event handler for select all optimizer variables */ 121 void OnSelectAll(wxCommandEvent &e); 122 /** event handler for unselect all optimizer variables */ 123 void OnUnselectAll(wxCommandEvent &e); 124 /** event handler for select all optimizer variables for selected lens/stack*/ 125 void OnSelectLensStack(wxCommandEvent &e); 126 /** event handler for unselect all optimizer variables for selected lens/stack */ 127 void OnUnselectLensStack(wxCommandEvent &e); 128 /** event handler for key events */ 129 void OnChar(wxTreeEvent &e); 130 /** event handler for beginning editing */ 131 void OnBeginEdit(wxTreeEvent &e); 132 /** event handler for ending editing, updates the Panorama with modified value */ 133 void OnEndEdit(wxTreeEvent &e); 134 /** menu event handler for PanoOperation (context menu items) */ 135 void OnExecuteOperation(wxCommandEvent & e); 136 /** event handler to display context menu */ 137 void OnContextMenu(wxTreeEvent & e); 138 /** event handler for context menu on header */ 139 void OnHeaderContextMenu(wxListEvent & e); 140 /** event handler for activate image */ 141 void OnActivateImage(wxCommandEvent& e); 142 /** event handler for deactivate image */ 143 void OnDeactivateImage(wxCommandEvent& e); 144 #if wxCHECK_VERSION(3,1,3) 145 /** event handler for updating dpi */ 146 void OnDpiChanged(wxDPIChangedEvent& e); 147 #endif 148 149 private: 150 /** creates all columns and stores information in m_columnMap, m_columnVector, m_editableColumns and m_variableVector */ 151 void CreateColumns(); 152 /** helper procedure for link/unlink image variables */ 153 void UnLinkImageVariables(bool linked); 154 /** select/unselect all variables in the active column 155 * @select true selects all, false unselect all 156 * @allImages true works on all images, false only on images of current lens or stack 157 */ 158 void SelectAllParameters(bool select, bool allImages); 159 /** updates the display of the optimizer variables (set font) */ 160 void UpdateOptimizerVariables(); 161 /** generates submenu for given PanoOperationVector */ 162 void GenerateSubMenu(wxMenu* menu, PanoOperation::PanoOperationVector* operations, int& id); 163 /** update the font colour for all items */ 164 void UpdateItemFont(); 165 /** create image list with necessary images of checkboxes */ 166 void CreateCheckboxImages(); 167 168 169 // the model 170 HuginBase::Panorama * m_pano; 171 /** the active group mode */ 172 GroupMode m_groupMode; 173 174 // image variable group information 175 HuginBase::StandardImageVariableGroups * m_variable_groups; 176 177 // number of digits for display 178 int m_degDigits; 179 int m_distDigits; 180 int m_pixelDigits; 181 /** stores the active GuiLevel */ 182 GuiLevel m_guiLevel; 183 /** true, if in optimizer mode */ 184 bool m_optimizerMode; 185 /** true, if disabled images should be marked with other font color */ 186 bool m_markDisabledImages; 187 /** the active display mode */ 188 DisplayMode m_displayMode; 189 /** map for easier access to column information */ 190 std::map<std::string,size_t> m_columnMap; 191 /** vector for easier access to column information */ 192 std::vector<std::string> m_columnVector; 193 /** set, which contains editable columns (all column which contains numeric image variables */ 194 HuginBase::UIntSet m_editableColumns; 195 /** vector for easier access to linking information */ 196 std::vector<HuginBase::ImageVariableGroup::ImageVariableEnum> m_variableVector; 197 /** map with current active context menu PanoOperation */ 198 std::map<int,PanoOperation::PanoOperation*> m_menuOperation; 199 /** selected column */ 200 size_t m_selectedColumn; 201 /** UIntSet of dragging images */ 202 HuginBase::UIntSet m_draggingImages; 203 /** true, if dragging */ 204 bool m_dragging; 205 /** value, which is currently edited */ 206 double m_editVal; 207 /** wxString, as shown before editing started */ 208 wxString m_editOldString; 209 /** helper variable for update of output stacks/layers */ 210 bool m_needsUpdate; 211 212 /** pointer to root item, not shown */ 213 wxTreeItemId m_root; 214 215 /** stores last item on which the mouse was hovering */ 216 wxTreeItemId m_lastCurrentItem; 217 long m_lastCurrentCol; 218 /** stores where left mouse click happend */ 219 wxTreeItemId m_leftDownItem; 220 long m_leftDownColumn; 221 222 //for saving column width 223 wxString m_configClassName; 224 DECLARE_EVENT_TABLE() 225 DECLARE_DYNAMIC_CLASS(ImagesTreeCtrl) 226 }; 227 228 229 /** xrc handler */ 230 class ImagesTreeCtrlXmlHandler : public wxcode::wxTreeListCtrlXmlHandler 231 { 232 DECLARE_DYNAMIC_CLASS(ImagesTreeCtrlXmlHandler) 233 234 public: 235 ImagesTreeCtrlXmlHandler(); 236 virtual wxObject *DoCreateResource(); 237 virtual bool CanHandle(wxXmlNode *node); 238 }; 239 240 #endif // _IMAGESTREE_H 241