1 /*
2 * myframe.h
3 * PHD Guiding
4 *
5 * Created by Craig Stark.
6 * Copyright (c) 2006-2010 Craig Stark.
7 * Refactored by Bret McKee
8 * Copyright (c) 2012 Bret McKee
9 * All rights reserved.
10 *
11 * This source code is distributed under the following "BSD" license
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions are met:
14 * Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 * Redistributions in binary form must reproduce the above copyright notice,
17 * this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * Neither the name of Craig Stark, Stark Labs nor the names of its
20 * contributors may be used to endorse or promote products derived from
21 * this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 *
35 */
36
37 #ifndef MYFRAME_H_INCLUDED
38 #define MYFRAME_H_INCLUDED
39
40 class WorkerThread;
41 class MyFrame;
42 class RefineDefMap;
43 struct alert_params;
44 class PHDStatusBar;
45
46 enum E_MYFRAME_WORKER_THREAD_MESSAGES
47 {
48 MYFRAME_WORKER_THREAD_EXPOSE_COMPLETE = wxID_HIGHEST+1,
49 MYFRAME_WORKER_THREAD_MOVE_COMPLETE,
50 };
51
52 wxDECLARE_EVENT(REQUEST_EXPOSURE_EVENT, wxCommandEvent);
53 wxDECLARE_EVENT(REQUEST_MOUNT_MOVE_EVENT, wxCommandEvent);
54 wxDECLARE_EVENT(WXMESSAGEBOX_PROXY_EVENT, wxCommandEvent);
55 wxDECLARE_EVENT(STATUSBAR_ENQUEUE_EVENT, wxCommandEvent);
56 wxDECLARE_EVENT(STATUSBAR_TIMER_EVENT, wxTimerEvent);
57 wxDECLARE_EVENT(SET_STATUS_TEXT_EVENT, wxThreadEvent);
58 wxDECLARE_EVENT(ALERT_FROM_THREAD_EVENT, wxThreadEvent);
59
60 enum NOISE_REDUCTION_METHOD
61 {
62 NR_NONE,
63 NR_2x2MEAN,
64 NR_3x3MEDIAN
65 };
66
67 struct AutoExposureCfg
68 {
69 bool enabled;
70 int minExposure;
71 int maxExposure;
72 double targetSNR;
73 };
74
75 typedef void alert_fn(long);
76
77 class MyFrameConfigDialogPane : public ConfigDialogPane
78 {
79
80 public:
81 MyFrameConfigDialogPane(wxWindow *pParent, MyFrame *pFrame);
~MyFrameConfigDialogPane()82 virtual ~MyFrameConfigDialogPane() {};
83
84 void LayoutControls(BrainCtrlIdMap& CtrlMap);
LoadValues()85 virtual void LoadValues() {};
UnloadValues()86 virtual void UnloadValues() {};
87 };
88
89 enum DitherMode
90 {
91 DITHER_RANDOM,
92 DITHER_SPIRAL,
93 };
94
95 struct DitherSpiral
96 {
97 int x, y, dx, dy;
98 bool prevRaOnly;
99
DitherSpiralDitherSpiral100 DitherSpiral() { Reset(); }
101 void Reset();
102 void GetDither(double amount, bool raOnly, double *dRA, double *dDec);
103 };
104
105 struct SingleExposure
106 {
107 bool enabled;
108 int duration;
109 wxRect subframe;
110 };
111
112 class MyFrameConfigDialogCtrlSet : public ConfigDialogCtrlSet
113 {
114 MyFrame *m_pFrame;
115 wxCheckBox *m_pResetConfiguration;
116 wxCheckBox *m_pResetDontAskAgain;
117 wxCheckBox *m_updateEnabled;
118 wxCheckBox *m_updateMajorOnly;
119 wxRadioButton *m_ditherRandom;
120 wxRadioButton *m_ditherSpiral;
121 wxSpinCtrlDouble *m_ditherScaleFactor;
122 wxCheckBox *m_ditherRaOnly;
123 wxChoice *m_pNoiseReduction;
124 wxSpinCtrl *m_pTimeLapse;
125 wxTextCtrl *m_pFocalLength;
126 wxChoice *m_pLanguage;
127 int m_oldLanguageChoice;
128 wxTextCtrl *m_pLogDir;
129 wxButton *m_pSelectDir;
130 wxCheckBox *m_EnableImageLogging;
131 wxStaticBoxSizer *m_LoggingOptions;
132 wxCheckBox *m_LogNextNFrames;
133 wxCheckBox *m_LogRelErrors;
134 wxCheckBox *m_LogAbsErrors;
135 wxCheckBox *m_LogDroppedFrames;
136 wxCheckBox *m_LogAutoSelectFrames;
137 wxSpinCtrlDouble *m_LogRelErrorThresh;
138 wxSpinCtrlDouble *m_LogAbsErrorThresh;
139 wxSpinCtrl *m_LogNextNFramesCount;
140 wxCheckBox *m_pAutoLoadCalibration;
141 wxComboBox *m_autoExpDurationMin;
142 wxComboBox *m_autoExpDurationMax;
143 wxSpinCtrlDouble *m_autoExpSNR;
144 void OnDirSelect(wxCommandEvent& evt);
145 void OnImageLogEnableChecked(wxCommandEvent& event);
146
147 public:
148 MyFrameConfigDialogCtrlSet(MyFrame *pFrame, AdvancedDialog* pAdvancedDialog, BrainCtrlIdMap& CtrlMap);
~MyFrameConfigDialogCtrlSet()149 virtual ~MyFrameConfigDialogCtrlSet() {};
150
151 virtual void LoadValues();
152 virtual void UnloadValues();
153 int GetFocalLength() const;
154 void SetFocalLength(int val);
155 };
156
157 class MyFrame : public wxFrame
158 {
159 protected:
160 NOISE_REDUCTION_METHOD GetNoiseReductionMethod() const;
161 bool SetNoiseReductionMethod(int noiseReductionMethod);
162
163 bool GetServerMode() const;
164 bool SetServerMode(bool val);
165
166 bool SetTimeLapse(int timeLapse);
167 int GetTimeLapse() const;
168
169 bool SetFocalLength(int focalLength);
170
171 friend class MyFrameConfigDialogPane;
172 friend class MyFrameConfigDialogCtrlSet;
173 friend class WorkerThread;
174
175 private:
176
177 NOISE_REDUCTION_METHOD m_noiseReductionMethod;
178 DitherMode m_ditherMode;
179 double m_ditherScaleFactor;
180 bool m_ditherRaOnly;
181 DitherSpiral m_ditherSpiral;
182 bool m_serverMode;
183 int m_timeLapse; // Delay between frames (useful for vid cameras)
184 int m_focalLength;
185 bool m_beepForLostStar;
186 double m_sampling;
187 bool m_autoLoadCalibration;
188
189 wxAuiManager m_mgr;
190 PHDStatusBar *m_statusbar;
191
192 bool m_continueCapturing; // should another image be captured?
193 SingleExposure m_singleExposure;
194
195 public:
196 MyFrame();
197 virtual ~MyFrame();
198
199 Guider *pGuider;
200 wxMenuBar *Menubar;
201 wxMenu *tools_menu, *view_menu, *bookmarks_menu, *darks_menu;
202 wxMenuItem *m_showBookmarksMenuItem;
203 wxMenuItem *m_bookmarkLockPosMenuItem;
204 wxAcceleratorEntry *m_showBookmarksAccel;
205 wxAcceleratorEntry *m_bookmarkLockPosAccel;
206 wxMenuItem *m_connectMenuItem;
207 wxMenuItem *m_loopMenuItem;
208 wxMenuItem *m_guideMenuItem;
209 wxMenuItem *m_stopMenuItem;
210 wxMenuItem *m_brainMenuItem;
211 wxMenuItem *m_cameraMenuItem;
212 wxMenuItem *m_autoSelectStarMenuItem;
213 wxMenuItem *m_takeDarksMenuItem;
214 wxMenuItem *m_useDarksMenuItem;
215 wxMenuItem *m_refineDefMapMenuItem;
216 wxMenuItem *m_useDefectMapMenuItem;
217 wxMenuItem *m_calibrationMenuItem;
218 wxMenuItem *m_importCamCalMenuItem;
219 wxMenuItem *m_upgradeMenuItem;
220 wxAuiToolBar *MainToolbar;
221 wxInfoBar *m_infoBar;
222 wxComboBox *Dur_Choice;
223 wxCheckBox *HotPixel_Checkbox;
224 wxHtmlHelpController *help;
225 wxSlider *Gamma_Slider;
226 AdvancedDialog *pAdvancedDialog;
227 GraphLogWindow *pGraphLog;
228 StatsWindow *pStatsWin;
229 GraphStepguiderWindow *pStepGuiderGraph;
230 GearDialog *pGearDialog;
231 ProfileWindow *pProfile;
232 TargetWindow *pTarget;
233 wxWindow *pDriftTool;
234 wxWindow *pPolarDriftTool;
235 wxWindow *pStaticPaTool;
236 wxWindow *pManualGuide;
237 wxDialog *pStarCrossDlg;
238 wxWindow *pNudgeLock;
239 wxWindow *pCometTool;
240 wxWindow *pGuidingAssistant;
241 wxWindow *pierFlipToolWin;
242 RefineDefMap *pRefineDefMap;
243 wxDialog *pCalSanityCheckDlg;
244 wxDialog *pCalReviewDlg;
245 bool CaptureActive; // Is camera looping captures?
246 bool m_exposurePending; // exposure scheduled and not completed
247 double Stretch_gamma;
248 unsigned int m_frameCounter;
249 wxDateTime m_guidingStarted;
250 wxStopWatch m_guidingElapsed;
251 Star::FindMode m_starFindMode;
252 double m_minStarHFD;
253 bool m_rawImageMode;
254 bool m_rawImageModeWarningDone;
255 wxSize m_prevDarkFrameSize;
256
257 void RegisterTextCtrl(wxTextCtrl *ctrl);
258
259 void OnMenuHighlight(wxMenuEvent& evt);
260 void OnAnyMenu(wxCommandEvent& evt);
261 void OnAnyMenuClose(wxMenuEvent& evt);
262 void OnQuit(wxCommandEvent& evt);
263 void OnClose(wxCloseEvent& evt);
264 void OnAbout(wxCommandEvent& evt);
265 void OnHelp(wxCommandEvent& evt);
266 void OnOverlay(wxCommandEvent& evt);
267 void OnOverlaySlitCoords(wxCommandEvent& evt);
268 void OnUpgrade(wxCommandEvent& evt);
269 void OnHelpOnline(wxCommandEvent& evt);
270 void OnHelpLogFolder(wxCommandEvent& evt);
271 void OnHelpUploadLogs(wxCommandEvent& evt);
272 void OnInstructions(wxCommandEvent& evt);
273 void OnSave(wxCommandEvent& evt);
274 void OnSettings(wxCommandEvent& evt);
275 void OnSelectGear(wxCommandEvent& evt);
276 void OnButtonLoop(wxCommandEvent& evt);
277 void OnButtonStop(wxCommandEvent& evt);
278 void OnButtonAutoStar(wxCommandEvent& evt);
279 void OnDark(wxCommandEvent& evt);
280 void OnLoadDark(wxCommandEvent& evt);
281 void OnLoadDefectMap(wxCommandEvent& evt);
282 void GuideButtonClick(bool interactive, const wxString& context);
283 void OnButtonGuide(wxCommandEvent& evt);
284 void OnAdvanced(wxCommandEvent& evt);
285 void OnIdle(wxIdleEvent& evt);
286 void OnTestGuide(wxCommandEvent& evt);
287 void OnStarCrossTest(wxCommandEvent& evt);
288 void OnPierFlipTool(wxCommandEvent& evt);
289 void OnEEGG(wxCommandEvent& evt);
290 void OnDriftTool(wxCommandEvent& evt);
291 void OnPolarDriftTool(wxCommandEvent& evt);
292 void OnStaticPaTool(wxCommandEvent& evt);
293 void OnCometTool(wxCommandEvent& evt);
294 void OnGuidingAssistant(wxCommandEvent& evt);
295 void OnSetupCamera(wxCommandEvent& evt);
296 void OnExposureDurationSelected(wxCommandEvent& evt);
297 void OnGammaSlider(wxScrollEvent& evt);
298 void OnSockServerEvent(wxSocketEvent& evt);
299 void OnSockServerClientEvent(wxSocketEvent& evt);
300 void HandleSockServerInput(wxSocketBase *sock);
301 void OnServerMenu(wxCommandEvent& evt);
302 void OnCharHook(wxKeyEvent& evt);
303 void OnTextControlSetFocus(wxFocusEvent& evt);
304 void OnTextControlKillFocus(wxFocusEvent& evt);
305 #if defined (GUIDE_INDI) || defined (INDI_CAMERA)
306 void OnINDIConfig(wxCommandEvent& evt);
307 void OnINDIDialog(wxCommandEvent& evt);
308 #endif
309 void OnPanelClose(wxAuiManagerEvent& evt);
310 #if defined (V4L_CAMERA)
311 void OnSaveSettings(wxCommandEvent& evt);
312 void OnRestoreSettings(wxCommandEvent& evt);
313 #endif
314 void OnGraph(wxCommandEvent& evt);
315 void OnStats(wxCommandEvent& evt);
316 void OnToolBar(wxCommandEvent& evt);
317 void OnAoGraph(wxCommandEvent& evt);
318 void OnStarProfile(wxCommandEvent& evt);
319 void OnTarget(wxCommandEvent& evt);
320 void OnRestoreWindows(wxCommandEvent& evt);
321 void OnAutoStar(wxCommandEvent& evt);
322 void OnBookmarksShow(wxCommandEvent& evt);
323 void OnBookmarksSetAtLockPos(wxCommandEvent& evt);
324 void OnBookmarksSetAtCurPos(wxCommandEvent& evt);
325 void OnBookmarksClearAll(wxCommandEvent& evt);
326 void OnRefineDefMap(wxCommandEvent& evt);
327 void OnImportCamCal(wxCommandEvent& evt);
328
329 void OnExposeComplete(wxThreadEvent& evt);
330 void OnExposeComplete(usImage *image, bool err);
331 void OnMoveComplete(wxThreadEvent& evt);
332
333 void LoadProfileSettings();
334 void UpdateTitle();
335
336 const std::vector<int>& GetExposureDurations() const;
337 bool SetCustomExposureDuration(int ms);
338 void GetExposureInfo(int *currExpMs, bool *autoExp) const;
339 bool SetExposureDuration(int val);
GetAutoExposureCfg()340 const AutoExposureCfg& GetAutoExposureCfg() const { return m_autoExp; }
341 bool SetAutoExposureCfg(int minExp, int maxExp, double targetSNR);
342 void ResetAutoExposure();
343 void AdjustAutoExposure(double curSNR);
344 static wxString ExposureDurationLabel(int exposure);
345 double GetDitherScaleFactor() const;
346 bool SetDitherScaleFactor(double ditherScaleFactor);
347 bool GetDitherRaOnly() const;
348 bool SetDitherRaOnly(bool ditherRaOnly);
349 static double GetDitherAmount(int ditherType);
350 Star::FindMode GetStarFindMode() const;
351 Star::FindMode SetStarFindMode(Star::FindMode mode);
352 bool GetRawImageMode() const;
353 bool SetRawImageMode(bool force);
354
355 bool StartServer(bool state);
356 bool FlipCalibrationData();
357 int RequestedExposureDuration();
358 int GetFocalLength() const;
359 bool GetAutoLoadCalibration() const;
360 void SetAutoLoadCalibration(bool val);
361 void LoadCalibration();
362 static wxString GetDefaultFileDir();
363 static wxString GetDarksDir();
364 bool DarkLibExists(int profileId, bool showAlert);
365 bool LoadDarkLibrary();
366 void SaveDarkLibrary(const wxString& note);
367 static void DeleteDarkLibraryFiles(int profileID);
368 static wxString DarkLibFileName(int profileId);
369 void SetDarkMenuState();
370 bool LoadDarkHandler(bool checkIt); // Use to also set menu item states
371 void LoadDefectMapHandler(bool checkIt);
372 void CheckDarkFrameGeometry();
373 void UpdateStatusBarCalibrationStatus();
374 void UpdateStatusBarStateLabels();
375 void UpdateStatusBarStarInfo(double SNR, bool Saturated);
376 void UpdateStatusBarGuiderInfo(const GuideStepInfo& info);
377 void ClearStatusBarGuiderInfo();
378 static void PlaceWindowOnScreen(wxWindow *window, int x, int y);
379 bool GetBeepForLostStar();
380 void SetBeepForLostStar(bool beep);
381
382 MyFrameConfigDialogPane *GetConfigDialogPane(wxWindow *pParent);
383 MyFrameConfigDialogCtrlSet *GetConfigDlgCtrlSet(MyFrame *pFrame, AdvancedDialog *pAdvancedDialog, BrainCtrlIdMap& CtrlMap);
384
385 void OnRequestExposure(wxCommandEvent& evt);
386 void OnRequestMountMove(wxCommandEvent& evt);
387
388 void ScheduleExposure();
389
390 void SchedulePrimaryMove(Mount *mount, const GuiderOffset& ofs, unsigned int moveOptions);
391 void ScheduleSecondaryMove(Mount *mount, const GuiderOffset& ofs, unsigned int moveOptions);
392 void ScheduleAxisMove(Mount *mount, const GUIDE_DIRECTION direction, int duration, unsigned int moveOptions);
393 void ScheduleManualMove(Mount *mount, const GUIDE_DIRECTION direction, int duration);
394
395 void StartCapturing();
396 bool StopCapturing();
397 bool StartSingleExposure(int duration, const wxRect& subframe);
398
399 bool AutoSelectStar(const wxRect& roi = wxRect());
400
401 void SetPaused(PauseType pause);
402
403 void StartLoopingInteractive(const wxString& context);
404
405 bool StartLooping(); // stop guiding and continue capturing, or, start capturing
406 bool StartGuiding();
407 bool Dither(double amount, bool raOnly);
408
409 static bool GuidingRAOnly();
410 double CurrentGuideError() const;
411 double CurrentGuideErrorSmoothed() const;
412
413 void NotifyUpdateButtonsStatus(); // can be called from any thread
414 void UpdateButtonsStatus();
415
416 static double GetPixelScale(double pixelSizeMicrons, int focalLengthMm, int binning);
417 double GetCameraPixelScale() const;
418
419 void Alert(const wxString& msg, int flags = wxICON_EXCLAMATION);
420 void Alert(const wxString& msg, alert_fn *DontShowFn, const wxString& buttonLabel, alert_fn *SpecialFn, long arg, bool showHelpButton = false, int flags = wxICON_EXCLAMATION);
421 void SuppressableAlert(const wxString& configPropKey, const wxString& msg, alert_fn *dontShowFn, long arg, bool showHelpButton = false, int flags = wxICON_EXCLAMATION);
422 void ClearAlert();
423 void StatusMsg(const wxString& text);
424 void StatusMsgNoTimeout(const wxString& text);
425 wxString GetSettingsSummary() const;
426 wxString ExposureDurationSummary() const;
427 wxString PixelScaleSummary() const;
428 void TryReconnect();
429
430 double TimeSinceGuidingStarted() const;
431
432 void NotifyGuidingStarted();
433 void NotifyGuidingStopped();
434
435 void SetDitherMode(DitherMode mode);
436 DitherMode GetDitherMode() const;
437
438 void HandleImageScaleChange(double NewToOldRatio);
439
440 void NotifyGuidingParam(const wxString& name, double val);
441 void NotifyGuidingParam(const wxString& name, int val);
442 void NotifyGuidingParam(const wxString& name, bool val);
443 void NotifyGuidingParam(const wxString& name, const wxString& val);
444 void NotifyGuidingParam(const wxString& name, const wxString& val, bool ForceLog);
445
446 void NotifyExposureChanged();
447
448 void NotifyUpdaterStateChanged();
449
450 // Following 2 functions are used by clients that need to size the spin control based on the max text width
451 wxSpinCtrl *MakeSpinCtrl(wxWindow *parent, wxWindowID id = -1, const wxString& value = wxEmptyString,
452 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSP_ARROW_KEYS,
453 int min = 0, int max = 100, int initial = 0, const wxString& name = wxT("wxSpinCtrl"));
454 wxSpinCtrlDouble *MakeSpinCtrlDouble(wxWindow *parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString,
455 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
456 long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, double min = 0, double max = 100, double initial = 0,
457 double inc = 1, const wxString& name = wxT("wxSpinCtrlDouble"));
458
459 private:
460 wxCriticalSection m_CSpWorkerThread;
461 WorkerThread *m_pPrimaryWorkerThread;
462 WorkerThread *m_pSecondaryWorkerThread;
463
464 wxSocketServer *SocketServer;
465 wxTimer m_statusbarTimer;
466
467 int m_exposureDuration;
468 AutoExposureCfg m_autoExp;
469
470 alert_fn *m_alertDontShowFn;
471 alert_fn *m_alertSpecialFn;
472 long m_alertFnArg;
473
474 std::vector<time_t> m_cameraReconnectAttempts; // for rate-limiting camera reconnect attempts
475
476 bool StartWorkerThread(WorkerThread*& pWorkerThread);
477 bool StopWorkerThread(WorkerThread*& pWorkerThread);
478 void OnStatusMsg(wxThreadEvent& event);
479 void DoAlert(const alert_params& params);
480 void OnAlertButton(wxCommandEvent& evt);
481 void OnAlertHelp(wxCommandEvent& evt);
482 void OnAlertFromThread(wxThreadEvent& event);
483 void OnReconnectCameraFromThread(wxThreadEvent& event);
484 void OnStatusBarTimerEvent(wxTimerEvent& evt);
485 void OnUpdaterStateChanged(wxThreadEvent& event);
486 void OnMessageBoxProxy(wxCommandEvent& evt);
487 void SetupMenuBar();
488 void SetupStatusBar();
489 void SetupToolBar();
490 void SetupKeyboardShortcuts();
491 void SetupHelpFile();
492 int GetTextWidth(wxControl *pControl, const wxString& string);
493 void SetComboBoxWidth(wxComboBox *pComboBox, unsigned int extra);
494 void FinishStop();
495 void DoTryReconnect();
496
497 // and of course, an event table
498 DECLARE_EVENT_TABLE()
499 };
500
501 extern MyFrame *pFrame;
502
503 enum {
504 MENU_SHOWHELP = 101,
505 BEGIN_SCOPES,
506 SCOPE_ASCOM,
507 SCOPE_CAMERA,
508 SCOPE_GPUSB,
509 SCOPE_GPINT3BC,
510 SCOPE_GPINT378,
511 SCOPE_GPINT278,
512 SCOPE_VOYAGER,
513 SCOPE_EQUINOX,
514 SCOPE_EQMAC,
515 SCOPE_GCUSBST4,
516 SCOPE_INDI,
517 END_SCOPES,
518 BEGIN_STEPGUIDERS,
519 AO_NONE,
520 AO_SXAO,
521 AO_SIMULATOR,
522 END_STEPGUIDERS,
523 BUTTON_GEAR,
524 BUTTON_CAL,
525 BUTTON_LOOP,
526 BUTTON_GUIDE,
527 BUTTON_STOP,
528 BUTTON_AUTOSTAR,
529 BUTTON_DURATION,
530 BUTTON_ADVANCED,
531 BUTTON_CAM_PROPERTIES,
532 BUTTON_ALERT_ACTION,
533 BUTTON_ALERT_CLOSE,
534 BUTTON_ALERT_HELP,
535 BUTTON_ALERT_DONTSHOW,
536 GEAR_DIALOG_IDS_BEGIN,
537 GEAR_PROFILES,
538 GEAR_PROFILE_MANAGE,
539 GEAR_PROFILE_NEW,
540 GEAR_PROFILE_DELETE,
541 GEAR_PROFILE_RENAME,
542 GEAR_PROFILE_LOAD,
543 GEAR_PROFILE_SAVE,
544 GEAR_PROFILE_WIZARD,
545
546 GEAR_CHOICE_CAMERA,
547 GEAR_BUTTON_SELECT_CAMERA,
548 MENU_SELECT_CAMERA_BEGIN, // a range of ids camera selection popup menu
549 MENU_SELECT_CAMERA_END = MENU_SELECT_CAMERA_BEGIN + 10,
550 GEAR_BUTTON_SETUP_CAMERA,
551 GEAR_BUTTON_CONNECT_CAMERA,
552 GEAR_BUTTON_DISCONNECT_CAMERA,
553
554 GEAR_CHOICE_SCOPE,
555 GEAR_BUTTON_SETUP_SCOPE,
556 GEAR_BUTTON_CONNECT_SCOPE,
557 GEAR_BUTTON_DISCONNECT_SCOPE,
558
559 GEAR_CHOICE_AUXSCOPE,
560 GEAR_BUTTON_SETUP_AUXSCOPE,
561 GEAR_BUTTON_CONNECT_AUXSCOPE,
562 GEAR_BUTTON_DISCONNECT_AUXSCOPE,
563
564 GEAR_BUTTON_MORE,
565
566 GEAR_CHOICE_STEPGUIDER,
567 GEAR_BUTTON_SETUP_STEPGUIDER,
568 GEAR_BUTTON_CONNECT_STEPGUIDER,
569 GEAR_BUTTON_DISCONNECT_STEPGUIDER,
570
571 GEAR_CHOICE_ROTATOR,
572 GEAR_BUTTON_SETUP_ROTATOR,
573 GEAR_BUTTON_CONNECT_ROTATOR,
574 GEAR_BUTTON_DISCONNECT_ROTATOR,
575
576 GEAR_BUTTON_CONNECT_ALL,
577 GEAR_BUTTON_DISCONNECT_ALL,
578 GEAR_DIALOG_IDS_END,
579 CTRL_GAMMA,
580 WIN_VFW, // Dummy event to capture VFW streams
581 MGUIDE1_UP,
582 MGUIDE1_DOWN,
583 MGUIDE1_RIGHT,
584 MGUIDE1_LEFT,
585 MGUIDE2_UP,
586 MGUIDE2_DOWN,
587 MGUIDE2_RIGHT,
588 MGUIDE2_LEFT,
589 MENU_CONNECT,
590 MENU_LOOP,
591 MENU_GUIDE,
592 MENU_STOP,
593 MENU_BRAIN,
594 MENU_CAM_SETTINGS,
595 MENU_MANGUIDE,
596 MENU_XHAIR0,
597 MENU_XHAIR1,
598 MENU_XHAIR2,
599 MENU_XHAIR3,
600 MENU_XHAIR4,
601 MENU_XHAIR5,
602 MENU_SLIT_OVERLAY_COORDS,
603 MENU_TAKEDARKS,
604 MENU_SERVER,
605 MENU_TOOLBAR,
606 MENU_GRAPH,
607 MENU_STATS,
608 MENU_AO_GRAPH,
609 MENU_STARPROFILE,
610 MENU_RESTORE_WINDOWS,
611 MENU_TARGET,
612 MENU_AUTOSTAR,
613 MENU_DRIFTTOOL,
614 MENU_POLARDRIFTTOOL,
615 MENU_STATICPATOOL,
616 MENU_COMETTOOL,
617 MENU_GUIDING_ASSISTANT,
618 MENU_SAVESETTINGS,
619 MENU_LOADSETTINGS,
620 MENU_LOADDARK,
621 MENU_LOADDEFECTMAP,
622 MENU_REFINEDEFECTMAP,
623 MENU_IMPORTCAMCAL,
624 MENU_INDICONFIG,
625 MENU_INDIDIALOG,
626 MENU_V4LSAVESETTINGS,
627 MENU_V4LRESTORESETTINGS,
628 BUTTON_GRAPH_LENGTH,
629 BUTTON_GRAPH_HEIGHT,
630 BUTTON_GRAPH_SETTINGS,
631 GRAPH_RADEC,
632 GRAPH_DXDY,
633 GRAPH_ARCSECS,
634 GRAPH_PIXELS,
635 GRAPH_STAR_MASS,
636 GRAPH_STAR_SNR,
637 GRAPH_RADX_COLOR,
638 GRAPH_DECDY_COLOR,
639 GRAPH_SCALE_CORR,
640 BUTTON_GRAPH_CLEAR,
641 TARGET_ENABLE_REF_CIRCLE,
642 TARGET_REF_CIRCLE_RADIUS,
643 MENU_LENGTH_BEGIN, // a range of ids for history size selection popup menus
644 MENU_LENGTH_END = MENU_LENGTH_BEGIN + 10,
645 MENU_HEIGHT_BEGIN, // a range of ids for height size selection popup menus
646 MENU_HEIGHT_END = MENU_HEIGHT_BEGIN + 10,
647 CHECKBOX_GRAPH_TRENDLINES,
648 CHECKBOX_GRAPH_CORRECTIONS,
649 BUTTON_GRAPH_ZOOMIN,
650 BUTTON_GRAPH_ZOOMOUT,
651 ABOUT_LINK,
652 EEGG_RESTORECAL,
653 EEGG_MANUALCAL,
654 EEGG_CLEARCAL,
655 EEGG_REVIEWCAL,
656 EEGG_MANUALLOCK,
657 EEGG_COMET_TOOL,
658 EEGG_STICKY_LOCK,
659 EEGG_FLIPCAL,
660 STAR_MASS_ENABLE,
661 MENU_BOOKMARKS_SHOW,
662 MENU_BOOKMARKS_SET_AT_LOCK,
663 MENU_BOOKMARKS_SET_AT_STAR,
664 MENU_BOOKMARKS_CLEAR_ALL,
665 MENU_STARCROSS_TEST,
666 MENU_PIERFLIP_TOOL,
667 MENU_HELP_UPGRADE,
668 MENU_HELP_ONLINE,
669 MENU_HELP_UPLOAD_LOGS,
670 MENU_HELP_LOG_FOLDER,
671 GA_REVIEW_BUTTON,
672 GA_REVIEW_ITEMS_BASE,
673 GA_REVIEW_ITEMS_LIMIT = GA_REVIEW_ITEMS_BASE + 4,
674 };
675
676 enum {
677 SOCK_SERVER_ID = 100,
678 SOCK_SERVER_CLIENT_ID,
679 EVENT_SERVER_ID,
680 EVENT_SERVER_CLIENT_ID,
681 };
682
683 wxDECLARE_EVENT(APPSTATE_NOTIFY_EVENT, wxCommandEvent);
684
StringWidth(const wxWindow * window,const wxString & s)685 inline static int StringWidth(const wxWindow *window, const wxString& s)
686 {
687 int width, height;
688 window->GetTextExtent(s, &width, &height);
689 return width;
690 }
691
692 inline static wxSize StringSize(const wxWindow *window, const wxString& s, int extra = 0)
693 {
694 return wxSize(StringWidth(window, s) + extra, -1);
695 }
696
GetPixelScale(double pixelSizeMicrons,int focalLengthMm,int binning)697 inline double MyFrame::GetPixelScale(double pixelSizeMicrons, int focalLengthMm, int binning)
698 {
699 return 206.265 * pixelSizeMicrons * (double) binning / (double) focalLengthMm;
700 }
701
TimeSinceGuidingStarted()702 inline double MyFrame::TimeSinceGuidingStarted() const
703 {
704 return (double) m_guidingElapsed.Time() / 1000.0;
705 }
706
GetStarFindMode()707 inline Star::FindMode MyFrame::GetStarFindMode() const
708 {
709 return m_starFindMode;
710 }
711
GetRawImageMode()712 inline bool MyFrame::GetRawImageMode() const
713 {
714 return m_rawImageMode;
715 }
716
GetDitherMode()717 inline DitherMode MyFrame::GetDitherMode() const
718 {
719 return m_ditherMode;
720 }
721
GetNoiseReductionMethod()722 inline NOISE_REDUCTION_METHOD MyFrame::GetNoiseReductionMethod() const
723 {
724 return m_noiseReductionMethod;
725 }
726
GetDitherScaleFactor()727 inline double MyFrame::GetDitherScaleFactor() const
728 {
729 return m_ditherScaleFactor;
730 }
731
GetDitherRaOnly()732 inline bool MyFrame::GetDitherRaOnly() const
733 {
734 return m_ditherRaOnly;
735 }
736
GetAutoLoadCalibration()737 inline bool MyFrame::GetAutoLoadCalibration() const
738 {
739 return m_autoLoadCalibration;
740 }
741
GetServerMode()742 inline bool MyFrame::GetServerMode() const
743 {
744 return m_serverMode;
745 }
746
GetTimeLapse()747 inline int MyFrame::GetTimeLapse() const
748 {
749 return m_timeLapse;
750 }
751
GetFocalLength()752 inline int MyFrame::GetFocalLength() const
753 {
754 return m_focalLength;
755 }
756
757 #endif /* MYFRAME_H_INCLUDED */
758