1 /* 2 * configdialog.h 3 * PHD Guiding 4 * 5 * Created by Bret McKee 6 * Copyright (c) 2012 Bret McKee 7 * All rights reserved. 8 * 9 * This source code is distributed under the following "BSD" license 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions are met: 12 * Redistributions of source code must retain the above copyright notice, 13 * this list of conditions and the following disclaimer. 14 * Redistributions in binary form must reproduce the above copyright notice, 15 * this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * Neither the name of Craig Stark, Stark Labs nor the names of its 18 * contributors may be used to endorse or promote products derived from 19 * this software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 * POSSIBILITY OF SUCH DAMAGE. 32 * 33 */ 34 35 #ifndef CONFIG_DIALOG_H_INCLUDED 36 #define CONFIG_DIALOG_H_INCLUDED 37 38 39 // Design Notes: The goal here is to separate the ownership of various controls from where they are displayed in the AD. A class that "owns" a control 40 // will create it and handle all its behavior - loading, unloading, all the semantics. This part is handled by the ConfigDlgControlSet. Where those controls 41 // are displayed is determined by the BrainIDControlMap, a dictionary that maps the control ids to the AD panel where they will be displayed. The owner of the 42 // AD panel - the "host" - is responsible for creating the panel UI and rendering all the controls that belong on that panel. This will be handled in the 43 // LayoutControls() method of the hosting class. Beyond that, the host class has no involvement with controls that are owned by a different class. 44 // Example: the focal length control (AD_szFocalLength) is owned by MyFrame but is displayed on the guiding tab 45 46 // Segmented by the tab page location seen in the UI 47 // "sz" => element is a sizer 48 enum BRAIN_CTRL_IDS 49 { 50 AD_UNASSIGNED, 51 52 AD_cbResetConfig, 53 AD_cbDontAsk, 54 AD_szLanguage, 55 AD_szSoftwareUpdate, 56 AD_szLogFileInfo, 57 AD_cbEnableImageLogging, 58 AD_szImageLoggingOptions, 59 AD_szDither, 60 AD_GLOBAL_TAB_BOUNDARY, //-----end of global tab controls 61 62 AD_cbUseSubFrames, 63 AD_szNoiseReduction, 64 AD_szAutoExposure, 65 AD_szSaturationOptions, 66 AD_szCameraTimeout, 67 AD_szTimeLapse, 68 AD_szPixelSize, 69 AD_szGain, 70 AD_szDelay, 71 AD_szPort, 72 AD_szBinning, 73 AD_szCooler, 74 AD_CAMERA_TAB_BOUNDARY, // ------ end of camera tab controls 75 76 AD_cbScaleImages, 77 AD_szFocalLength, 78 AD_cbAutoRestoreCal, 79 AD_cbFastRecenter, 80 AD_szStarTracking, 81 AD_cbClearCalibration, 82 AD_cbEnableGuiding, 83 AD_szCalibrationDuration, 84 AD_cbReverseDecOnFlip, 85 AD_cbAssumeOrthogonal, 86 AD_cbSlewDetection, 87 AD_cbUseDecComp, 88 AD_cbBeepForLostStar, 89 AD_GUIDER_TAB_BOUNDARY, // --------------- end of guiding tab controls 90 91 AD_szBLCompCtrls, 92 AD_szMaxRAAmt, 93 AD_szMaxDecAmt, 94 AD_szDecGuideMode, 95 AD_MOUNT_TAB_BOUNDARY, // ----------- end of mount tab controls 96 97 AD_AOTravel, 98 AD_szCalStepsPerIteration, 99 AD_szSamplesToAverage, 100 AD_szBumpPercentage, 101 AD_szBumpSteps, 102 AD_cbBumpOnDither, 103 AD_szBumpBLCompCtrls, 104 AD_cbClearAOCalibration, 105 AD_cbEnableAOGuiding, 106 AD_cbRotatorReverse, 107 AD_DEVICES_TAB_BOUNDARY // ----------- end of devices tab controls 108 }; 109 110 struct BrainCtrlInfo 111 { 112 wxObject *panelCtrl; 113 bool isPositioned; // debug only 114 BrainCtrlInfoBrainCtrlInfo115 BrainCtrlInfo() 116 : 117 panelCtrl(0), 118 isPositioned(false) 119 { 120 } 121 BrainCtrlInfoBrainCtrlInfo122 BrainCtrlInfo(BRAIN_CTRL_IDS id, wxObject *ctrl) 123 : 124 panelCtrl(ctrl), 125 isPositioned(false) 126 { 127 } 128 }; 129 130 typedef std::map<BRAIN_CTRL_IDS, BrainCtrlInfo> BrainCtrlIdMap; 131 132 class ConfigDialogPane : public wxStaticBoxSizer 133 { 134 protected: 135 wxWindow *m_pParent; 136 public: 137 ConfigDialogPane(const wxString& heading, wxWindow *pParent); ~ConfigDialogPane(void)138 virtual ~ConfigDialogPane(void) {}; 139 140 virtual void LoadValues(void) = 0; 141 virtual void UnloadValues(void) = 0; 142 virtual void Undo(); 143 144 wxWindow *GetSingleCtrl(BrainCtrlIdMap& CtrlMap, BRAIN_CTRL_IDS id); 145 wxSizer *GetSizerCtrl(BrainCtrlIdMap& CtrlMap, BRAIN_CTRL_IDS id); 146 void CondAddCtrl(wxSizer *szr, BrainCtrlIdMap& CtrlMap, BRAIN_CTRL_IDS id, const wxSizerFlags& flags = 0); 147 virtual void OnImageScaleChange(); // Only for adjustments made within the AD panels 148 virtual void EnableDecControls(bool enable); // Needed for guide algo ConfigDialogPanes which inherit directly from this class 149 150 protected: 151 wxSizer *MakeLabeledControl(const wxString& label, wxWindow *pControl, const wxString& toolTip, wxWindow *pControl2 = nullptr); 152 void DoAdd(wxSizer *pSizer); 153 void DoAdd(wxWindow *pWindow); 154 void DoAdd(wxWindow *pWindow, const wxString& toolTip); 155 void DoAdd(const wxString& Label, wxWindow *pControl, const wxString& toolTip, wxWindow *pControl2 = nullptr); 156 157 int StringWidth(const wxString& string); 158 int StringArrayWidth(wxString string[], int nElements); 159 }; 160 161 class MyFrame; 162 class AdvancedDialog; 163 164 class ConfigDialogCtrlSet 165 { 166 protected: 167 wxWindow *m_pParent; 168 AdvancedDialog *m_pAdvDlg; 169 170 public: 171 ConfigDialogCtrlSet(wxWindow *pParent, AdvancedDialog *pAdvancedDialog, BrainCtrlIdMap& CtrlMap); ~ConfigDialogCtrlSet(void)172 virtual ~ConfigDialogCtrlSet(void) {}; 173 174 virtual void LoadValues(void) = 0; 175 virtual void UnloadValues(void) = 0; 176 177 public: 178 wxSizer *MakeLabeledControl(BRAIN_CTRL_IDS id, const wxString& label, wxWindow *pControl, const wxString& toolTip); 179 void AddMapElement(BrainCtrlIdMap& CtrlMap, BRAIN_CTRL_IDS, wxObject *pElem); 180 void AddGroup(BrainCtrlIdMap& CtrlMap, BRAIN_CTRL_IDS id, wxSizer *pSizer); // Sizer 181 void AddCtrl(BrainCtrlIdMap& CtrlMap, BRAIN_CTRL_IDS id, wxControl *pCtrl); // Bare control 182 void AddLabeledCtrl(BrainCtrlIdMap& CtrlMap, BRAIN_CTRL_IDS id, const wxString& Label, wxControl *pCtrl, const wxString& toolTip); 183 void AddCtrl(BrainCtrlIdMap& CtrlMap, BRAIN_CTRL_IDS id, wxControl *pCtrl, const wxString& toolTip); // Control with tooltip 184 185 wxWindow *GetParentWindow(BRAIN_CTRL_IDS id); 186 187 int StringWidth(const wxString& string); 188 int StringArrayWidth(wxString string[], int nElements); 189 int StringArrayWidth(const wxArrayString& ary); 190 }; 191 #endif // CONFIG_DIALOG_H_INCLUDED 192