PCL
ReadoutOptions.h
Go to the documentation of this file.
1 // ____ ______ __
2 // / __ \ / ____// /
3 // / /_/ // / / /
4 // / ____// /___ / /___ PixInsight Class Library
5 // /_/ \____//_____/ PCL 2.6.11
6 // ----------------------------------------------------------------------------
7 // pcl/ReadoutOptions.h - Released 2024-05-07T15:27:32Z
8 // ----------------------------------------------------------------------------
9 // This file is part of the PixInsight Class Library (PCL).
10 // PCL is a multiplatform C++ framework for development of PixInsight modules.
11 //
12 // Copyright (c) 2003-2024 Pleiades Astrophoto S.L. All Rights Reserved.
13 //
14 // Redistribution and use in both source and binary forms, with or without
15 // modification, is permitted provided that the following conditions are met:
16 //
17 // 1. All redistributions of source code must retain the above copyright
18 // notice, this list of conditions and the following disclaimer.
19 //
20 // 2. All redistributions in binary form must reproduce the above copyright
21 // notice, this list of conditions and the following disclaimer in the
22 // documentation and/or other materials provided with the distribution.
23 //
24 // 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
25 // of their contributors, may be used to endorse or promote products derived
26 // from this software without specific prior written permission. For written
27 // permission, please contact info@pixinsight.com.
28 //
29 // 4. All products derived from this software, in any form whatsoever, must
30 // reproduce the following acknowledgment in the end-user documentation
31 // and/or other materials provided with the product:
32 //
33 // "This product is based on software from the PixInsight project, developed
34 // by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
35 //
36 // Alternatively, if that is where third-party acknowledgments normally
37 // appear, this acknowledgment must be reproduced in the product itself.
38 //
39 // THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
40 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
41 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
43 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
44 // EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
45 // INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
46 // DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
47 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49 // POSSIBILITY OF SUCH DAMAGE.
50 // ----------------------------------------------------------------------------
51 
52 #ifndef __PCL_ReadoutOptions_h
53 #define __PCL_ReadoutOptions_h
54 
56 
57 #include <pcl/Defs.h>
58 
59 #include <pcl/Utility.h>
60 
61 namespace pcl
62 {
63 
64 // ----------------------------------------------------------------------------
65 
81 namespace ReadoutData
82 {
83  enum value_type
84  {
85  RGBK, // RGB components or grayscale
86  RGBL, // RGB components + CIE L*
87  RGBY, // RGB components + CIE Y
88  CIEXYZ, // CIE XYZ unit vectors
89  CIELab, // CIE L*a*b* normalized components
90  CIELch, // CIE L*c*h* normalized components
91  HSV, // HSV components
92  HSI, // HSI components
93  NumberOfModes
94  };
95 }
96 
97 // ----------------------------------------------------------------------------
98 
110 namespace ReadoutMode
111 {
112  enum value_type
113  {
114  Mean, // Average of probe pixel values
115  Median, // Median of probe pixel values
116  Minimum, // The maximum pixel value in the probe area
117  Maximum, // The minimum pixel value in the probe area
118  NumberOfModes
119  };
120 }
121 
122 // ----------------------------------------------------------------------------
123 
159 class PCL_CLASS ReadoutOptions
160 {
161 public:
162 
166  using readout_data = ReadoutData::value_type;
167 
171  using readout_mode = ReadoutMode::value_type;
172 
176  enum { MaxProbeSize = 15 };
177 
181  enum { MaxPrecision = 15 };
182 
186  enum { MinPreviewSize = 15, MaxPreviewSize = 127 };
187 
191  enum { MaxPreviewZoomFactor = 16 };
192 
196  ReadoutOptions() = default;
197 
201  ReadoutOptions( const ReadoutOptions& ) = default;
202 
206  ReadoutOptions& operator =( const ReadoutOptions& ) = default;
207 
213 
217  static void SetCurrentOptions( const ReadoutOptions& );
218 
222  readout_data Data() const
223  {
224  return data;
225  }
226 
230  void SetData( readout_data d )
231  {
232  data = d;
233  }
234 
238  readout_mode Mode() const
239  {
240  return mode;
241  }
242 
246  void SetMode( readout_mode m )
247  {
248  mode = m;
249  }
250 
255  bool ShowAlphaChannel() const
256  {
257  return showAlpha;
258  }
259 
263  void EnableAlphaChannel( bool enable = true )
264  {
265  showAlpha = enable;
266  }
267 
274  void DisableAlphaChannel( bool disable = true )
275  {
276  EnableAlphaChannel( !disable );
277  }
278 
283  bool ShowMaskChannel() const
284  {
285  return showMask;
286  }
287 
291  void EnableMaskChannel( bool enable = true )
292  {
293  showMask = enable;
294  }
295 
302  void DisableMaskChannel( bool disable = true )
303  {
304  EnableMaskChannel( !disable );
305  }
306 
310  int ProbeSize() const
311  {
312  return probeSize;
313  }
314 
320  void SetProbeSize( int sz )
321  {
322  probeSize = pcl::Range( sz, 1, int( MaxProbeSize ) ) | 1;
323  }
324 
328  int PreviewSize() const
329  {
330  return previewSize;
331  }
332 
337  void SetPreviewSize( int sz )
338  {
339  previewSize = pcl::Range( sz, int( MinPreviewSize ), int( MaxPreviewSize ) ) | 1;
340  }
341 
347  int PreviewZoomFactor() const
348  {
349  return previewZoom;
350  }
351 
357  void SetPreviewZoomFactor( int zoom )
358  {
359  previewZoom = pcl::Range( zoom, 1, int( MaxPreviewZoomFactor ) );
360  }
361 
366  bool ShowPreview() const
367  {
368  return showPreview;
369  }
370 
374  void EnablePreview( bool enable = true )
375  {
376  showPreview = enable;
377  }
378 
382  void DisablePreview( bool disable = true )
383  {
384  EnablePreview( !disable );
385  }
386 
391  bool ShowPreviewCenter() const
392  {
393  return previewCenter;
394  }
395 
399  void EnablePreviewCenter( bool enable = true )
400  {
401  previewCenter = enable;
402  }
403 
407  void DisablePreviewCenter( bool disable = true )
408  {
409  EnablePreviewCenter( !disable );
410  }
411 
418  {
419  return showEquatorial;
420  }
421 
426  void EnableEquatorialCoordinates( bool enable = true )
427  {
428  showEquatorial = enable;
429  }
430 
435  void DisableEquatorialCoordinates( bool disable = true )
436  {
437  EnableEquatorialCoordinates( !disable );
438  }
439 
446  {
447  return showEcliptic;
448  }
449 
454  void EnableEclipticCoordinates( bool enable = true )
455  {
456  showEcliptic = enable;
457  }
458 
463  void DisableEclipticCoordinates( bool disable = true )
464  {
465  EnableEclipticCoordinates( !disable );
466  }
467 
474  {
475  return showGalactic;
476  }
477 
482  void EnableGalacticCoordinates( bool enable = true )
483  {
484  showGalactic = enable;
485  }
486 
491  void DisableGalacticCoordinates( bool disable = true )
492  {
493  EnableGalacticCoordinates( !disable );
494  }
495 
504  int CoordinateItems() const
505  {
506  return coordinateItems;
507  }
508 
517  void SetCoordinateItems( int n )
518  {
519  coordinateItems = Range( n, 1, 3 );
520  }
521 
528  {
529  return coordinatePrecision;
530  }
531 
540  {
541  return Range( coordinatePrecision, 0, 3 + 2*(3 - coordinateItems) );
542  }
543 
550  {
551  coordinatePrecision = Range( n, 0, 8 );
552  }
553 
559  bool IsBroadcastEnabled() const
560  {
561  return broadcast;
562  }
563 
568  void EnableBroadcast( bool enable = true )
569  {
570  broadcast = enable;
571  }
572 
577  void DisableBroadcast( bool disable = true )
578  {
579  EnableBroadcast( !disable );
580  }
581 
586  bool IsReal() const
587  {
588  return real;
589  }
590 
594  void SetReal( bool b = true )
595  {
596  real = b;
597  }
598 
606  bool IsInteger() const
607  {
608  return !IsReal();
609  }
610 
617  void SetInteger( bool b = true )
618  {
619  SetReal( !b );
620  }
621 
627  int Precision() const
628  {
629  return precision;
630  }
631 
637  void SetPrecision( int n )
638  {
639  precision = pcl::Range( n, 0, int( MaxPrecision ) );
640  }
641 
645  unsigned IntegerRange() const
646  {
647  return range;
648  }
649 
653  void SetIntegerRange( unsigned n )
654  {
655  range = pcl::Range( uint32( n ), uint32( 1 ), ~uint32( 0 ) );
656  }
657 
665  {
666  SetIntegerRange( uint8_max );
667  }
668 
676  {
677  SetIntegerRange( uint16_max );
678  }
679 
687  {
688  SetIntegerRange( uint32_max );
689  }
690 
691 #ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
692 protected:
693 #else
694 private:
695 #endif
696 
697  readout_data data = ReadoutData::RGBK;
698  readout_mode mode = ReadoutMode::Mean;
699  int probeSize = 1; // size of the square probe - must be an odd number
700  int previewSize = 25; // size of the square preview - must be an odd number
701  int previewZoom = 8; // readout preview zoom factor >= 1
702  int precision = 4; // number of decimal digits if real==true
703  unsigned range = uint16_max; // maximum discrete value if real==false
704  bool showAlpha = true; // show alpha channel readouts?
705  bool showMask = true; // show mask channel readouts?
706  bool showPreview = true; // show real-time readout previews?
707  bool previewCenter = true; // draw center crosshairs on readout previews?
708  bool showEquatorial = true; // show equatorial coordinates
709  bool showEcliptic = false; // show ecliptic coordinates
710  bool showGalactic = false; // show galactic coordinates
711  int coordinateItems = 3; // 1=degrees/hours 2=minutes 3=seconds
712  int coordinatePrecision = 2; // decimal digits of last represented item
713  bool broadcast = true; // broadcast readouts?
714  bool real = true; // true=real, false=integer
715 };
716 
717 // ----------------------------------------------------------------------------
718 
719 } // pcl
720 
721 #endif // __PCL_ReadoutOptions_h
722 
723 // ----------------------------------------------------------------------------
724 // EOF pcl/ReadoutOptions.h - Released 2024-05-07T15:27:32Z
A structure to hold global pixel readout options.
void SetPrecision(int n)
readout_data Data() const
bool ShowMaskChannel() const
void EnableEclipticCoordinates(bool enable=true)
bool ShowEclipticCoordinates() const
void SetCoordinatePrecision(int n)
void SetPreviewSize(int sz)
void SetProbeSize(int sz)
int CoordinateItems() const
void EnableEquatorialCoordinates(bool enable=true)
void EnableAlphaChannel(bool enable=true)
bool ShowGalacticCoordinates() const
static void SetCurrentOptions(const ReadoutOptions &)
ReadoutOptions()=default
void SetReal(bool b=true)
void EnableBroadcast(bool enable=true)
bool IsInteger() const
void DisablePreviewCenter(bool disable=true)
void EnableMaskChannel(bool enable=true)
void EnableGalacticCoordinates(bool enable=true)
void EnablePreview(bool enable=true)
readout_mode Mode() const
int PreviewSize() const
static ReadoutOptions GetCurrentOptions()
int PreviewZoomFactor() const
void DisableEquatorialCoordinates(bool disable=true)
bool ShowPreviewCenter() const
bool ShowPreview() const
void DisableEclipticCoordinates(bool disable=true)
ReadoutOptions(const ReadoutOptions &)=default
int RealCoordinatePrecision() const
bool ShowEquatorialCoordinates() const
void DisablePreview(bool disable=true)
void DisableMaskChannel(bool disable=true)
bool ShowAlphaChannel() const
void SetCoordinateItems(int n)
unsigned IntegerRange() const
void SetMode(readout_mode m)
void SetInteger(bool b=true)
void DisableAlphaChannel(bool disable=true)
void DisableGalacticCoordinates(bool disable=true)
void SetData(readout_data d)
void EnablePreviewCenter(bool enable=true)
void SetIntegerRange(unsigned n)
bool IsBroadcastEnabled() const
void DisableBroadcast(bool disable=true)
void SetPreviewZoomFactor(int zoom)
int CoordinatePrecision() const
#define uint16_max
Definition: Defs.h:835
#define uint32_max
Definition: Defs.h:875
#define uint8_max
Definition: Defs.h:814
unsigned int uint32
Definition: Defs.h:666
constexpr const T & Range(const T &x, const T &a, const T &b) noexcept
Definition: Utility.h:190
PCL root namespace.
Definition: AbstractImage.h:77