PCL
ImageWindow.h
Go to the documentation of this file.
1 // ____ ______ __
2 // / __ \ / ____// /
3 // / /_/ // / / /
4 // / ____// /___ / /___ PixInsight Class Library
5 // /_/ \____//_____/ PCL 2.7.0
6 // ----------------------------------------------------------------------------
7 // pcl/ImageWindow.h - Released 2024-06-18T15:48:54Z
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_ImageWindow_h
53 #define __PCL_ImageWindow_h
54 
56 
57 #include <pcl/Defs.h>
58 
59 #include <pcl/Flags.h>
61 
62 #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
63 
64 #include <pcl/Bitmap.h>
65 #include <pcl/ByteArray.h>
66 #include <pcl/FITSHeaderKeyword.h>
67 #include <pcl/ImageOptions.h>
68 #include <pcl/UIObject.h>
69 #include <pcl/View.h>
70 
71 #endif // !__PCL_BUILDING_PIXINSIGHT_APPLICATION
72 
73 namespace pcl
74 {
75 
76 #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
77 
78 class RGBColorSystem;
79 class ICCProfile;
80 class ProcessInterface;
81 
82 #endif // !__PCL_BUILDING_PIXINSIGHT_APPLICATION
83 
84 // ----------------------------------------------------------------------------
85 
103 namespace ImageMode
104 {
105  enum value_type
106  {
107  Invalid = -1, // Represents an invalid or unsupported mode
108  Readout = 0, // Default mode, click to get real-time readouts
109  ZoomIn, // Click to zoom in the current view
110  ZoomOut, // Click to zoom out the current view
111  Pan, // Click and drag to pan the current view
112  Center, // Click to center the view at the mouse position
113  NewPreview, // Click and drag to define a new preview
114  EditPreview, // Click and drag to change an existing preview
115  DynamicOperation, // Module-defined dynamic operation
116 
117  NumberOfModes,
118 
119  Default = Readout
120  };
121 
126  inline bool IsValidPreviewMode( value_type m )
127  {
128  return m != NewPreview && m != EditPreview;
129  }
130 
135  inline bool IsValidMainViewMode( value_type m )
136  {
137  return !IsValidPreviewMode( m );
138  }
139 }
140 
141 // ----------------------------------------------------------------------------
142 
161 namespace BackgroundBrush
162 {
163  enum value_type
164  {
165  Small, // Small chessboard pattern
166  Medium, // Medium chessboard pattern
167  Large, // Large chessboard pattern
168  SmallCrossPattern, // Small cross pattern
169  MediumCrossPattern, // Medium cross pattern
170  LargeCrossPattern, // Large cross pattern
171  SmallDiagPattern, // Small diagonal pattern
172  MediumDiagPattern, // Medium diagonal pattern
173  LargeDiagPattern, // Large diagonal pattern
174  Solid, // Solid brush with the foreground color
175 
176  NumberOfBrushes,
177 
178  Default = Small
179  };
180 }
181 
182 // ----------------------------------------------------------------------------
183 
195 namespace TransparencyMode
196 {
197  enum value_type
198  {
199  Hide, // Don't show transparencies
200  BackgroundBrush, // Use the transparency background brush
201  Color, // Use an opaque background color
202 
203  NumberOfModes,
204 
205  Default = BackgroundBrush
206  };
207 };
208 
209 // ----------------------------------------------------------------------------
210 
239 namespace UndoFlag
240 {
241  /*
242  * ### TODO: PCL 2.x: Get rid of all project depencies on UndoFlags.
243  */
244  enum mask_type
245  {
246  DefaultMode = 0x00000000, // Save pixel data, astrometric solution and previews
247  PixelData = 0x00000001, // Save pixel data
248  RGBWS = 0x00000002, // RGB Working Space data
249  ICCProfile = 0x00000004, // ICC profile
250  Keywords = 0x00000008, // %FITS keywords
251  //Metadata = 0x00000010, // ### DEPRECATED - Keep unused for now, for compatibility with existing projects
252  FormatData = 0x00000020, // Format-specific data
253  ImageId = 0x00000040, // %Image identifier
254  Resolution = 0x00000080, // %Image resolution
255  AstrometricSolution = 0x00000100, // Save the current astrometric solution
256  ViewProperties = 0x00010000, // The process modifies view properties (since core build 1607)
257  All = 0x000FFFFF, // Save all data items
258  DeletePropertiesOnEntry = 0x01000000, // Destroy/delete non-permanent view properties before execution
259  DeletePropertiesOnExit = 0x02000000, // Destroy/delete non-permanent view properties after execution
260  ExcludePreviews = 0x80000000, // Don't save state of previews
261  ExcludeMaskRelations = 0x40000000 // Don't save masking dependencies
262  };
263 }
264 
269 using UndoFlags = Flags<UndoFlag::mask_type>;
270 
271 // ----------------------------------------------------------------------------
272 
273 #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
274 
275 // ----------------------------------------------------------------------------
276 
286 class PCL_CLASS ImageWindow : public UIObject
287 {
288 public:
289 
294  using gui_mode = ImageMode::value_type;
295 
301  using display_channel = DisplayChannel::value_type;
302 
308  using mask_mode = MaskMode::value_type;
309 
315  using background_brush = BackgroundBrush::value_type;
316 
322  using transparency_mode = TransparencyMode::value_type;
323 
328  ImageWindow() = default;
329 
375  ImageWindow( int width, int height, int numberOfChannels = 1,
376  int bitsPerSample = 32, bool floatSample = true, bool color = false,
377  bool initialProcessing = true,
378  const IsoString& id = IsoString() );
379 
380  ImageWindow( int width, int height, int numberOfChannels,
381  int bitsPerSample, bool floatSample, bool color,
382  bool initialProcessing,
383  const IsoString::ustring_base& id )
384  : ImageWindow( width, height, numberOfChannels,
385  bitsPerSample, floatSample, color,
386  initialProcessing,
387  IsoString( id ) )
388  {
389  }
390 
403  : UIObject( w )
404  {
405  }
406 
411  : UIObject( std::move( x ) )
412  {
413  }
414 
422  ~ImageWindow() override
423  {
424  }
425 
437  ImageWindow& operator =( const ImageWindow& window )
438  {
439  Assign( window );
440  return *this;
441  }
442 
446  ImageWindow& operator =( ImageWindow&& x )
447  {
448  Transfer( x );
449  return *this;
450  }
451 
457  static ImageWindow& Null();
458 
533  static Array<ImageWindow> Open( const String& url,
534  const IsoString& id = IsoString(),
535  const IsoString& formatHints = IsoString(),
536  bool asCopy = false,
537  bool allowMessages = true );
538 
539  template <class S1, class S2>
540  static Array<ImageWindow> Open( const String& url,
541  const S1& id,
542  const S2& formatHints,
543  bool asCopy = false,
544  bool allowMessages = true )
545  {
546  return Open( url, IsoString( id ), IsoString( formatHints ), asCopy, allowMessages );
547  }
548 
554  bool IsNew() const;
555 
568  bool IsACopy() const;
569 
579  String FilePath() const;
580 
586  String FileURL() const;
587 
592  bool HasURL() const
593  {
594  return !FileURL().IsEmpty();
595  }
596 
602 
609 
614  bool IsModified() const
615  {
616  return ModifyCount() > 0;
617  }
618 
639  bool Close();
640 
648  void ForceClose();
649 
656  View MainView() const;
657 
665  View CurrentView() const;
666 
670  void SelectView( View& );
671 
676  {
677  View v( MainView() ); SelectView( v );
678  }
679 
684 
689  bool IsValidView( const View& ) const;
690 
694  int NumberOfPreviews() const;
695 
700  bool HasPreviews() const
701  {
702  return NumberOfPreviews() > 0;
703  }
704 
711 
719  View PreviewById( const IsoString& previewId ) const;
720 
721  View PreviewById( const IsoString::ustring_base& previewId ) const
722  {
723  return PreviewById( IsoString( previewId ) );
724  }
725 
731  bool PreviewExists( const IsoString& previewId ) const
732  {
733  return !IsNull() && !PreviewById( previewId ).IsNull();
734  }
735 
736  bool PreviewExists( const IsoString::ustring_base& previewId ) const
737  {
738  return PreviewExists( IsoString( previewId ) );
739  }
740 
753 
759  void SelectPreview( View& );
760 
766  void SelectPreview( const IsoString& previewId )
767  {
768  View v( PreviewById( previewId ) ), SelectPreview( v );
769  }
770 
771  void SelectPreview( const IsoString::ustring_base& previewId )
772  {
773  SelectPreview( IsoString( previewId ) );
774  }
775 
784  View CreatePreview( const Rect& r, const IsoString& previewId = IsoString() )
785  {
786  return CreatePreview( r.x0, r.y0, r.x1, r.y1, previewId );
787  }
788 
789  View CreatePreview( const Rect& r, const IsoString::ustring_base& previewId )
790  {
791  return CreatePreview( r, IsoString( previewId ) );
792  }
793 
813  View CreatePreview( int x0, int y0, int x1, int y1, const IsoString& previewId = IsoString() );
814 
815  View CreatePreview( int x0, int y0, int x1, int y1, const IsoString::ustring_base& previewId )
816  {
817  return CreatePreview( x0, y0, x1, y1, IsoString( previewId ) );
818  }
819 
828  void ModifyPreview( const IsoString& previewId, const Rect& r, const IsoString& newId = IsoString() )
829  {
830  ModifyPreview( previewId, r.x0, r.y0, r.x1, r.y1, newId );
831  }
832 
833  void ModifyPreview( const IsoString::ustring_base& previewId, const Rect& r )
834  {
835  ModifyPreview( IsoString( previewId ), r );
836  }
837 
838  void ModifyPreview( const IsoString::ustring_base& previewId, const Rect& r, const IsoString::ustring_base& newId )
839  {
840  ModifyPreview( IsoString( previewId ), r, IsoString( newId ) );
841  }
842 
865  void ModifyPreview( const IsoString& previewId, int x0, int y0, int x1, int y1,
866  const IsoString& newId = IsoString() );
867 
868  void ModifyPreview( const IsoString::ustring_base& previewId, int x0, int y0, int x1, int y1 )
869  {
870  ModifyPreview( IsoString( previewId ), x0, y0, x1, y1 );
871  }
872 
873  void ModifyPreview( const IsoString::ustring_base& previewId, int x0, int y0, int x1, int y1,
874  const IsoString::ustring_base& newId )
875  {
876  ModifyPreview( IsoString( previewId ), x0, y0, x1, y1, IsoString( newId ) );
877  }
878 
886  Rect PreviewRect( const IsoString& previewId ) const;
887 
888  Rect PreviewRect( const IsoString::ustring_base& previewId ) const
889  {
890  return PreviewRect( IsoString( previewId ) );
891  }
892 
902  void DeletePreview( const IsoString& previewId );
903 
904  void DeletePreview( const IsoString::ustring_base& previewId )
905  {
906  DeletePreview( IsoString( previewId ) );
907  }
908 
916 
928  void GetSampleFormat( int& bitsPerSample, bool& floatSample ) const;
929 
943  void SetSampleFormat( int bitsPerSample, bool floatSample );
944 
949  ImageWindow Mask() const;
950 
959  void SetMask( ImageWindow& w, bool inverted = false );
960 
964  void RemoveMask()
965  {
966  SetMask( Null() );
967  }
968 
972  bool IsMaskInverted() const;
973 
977  void InvertMask( bool invert = true )
978  {
979  ImageWindow mask = Mask();
980  SetMask( mask, invert );
981  }
982 
986  bool IsMaskEnabled() const;
987 
991  void EnableMask( bool = true );
992 
996  void DisableMask( bool disable = true )
997  {
998  EnableMask( !disable );
999  }
1000 
1004  bool IsMaskVisible() const;
1005 
1009  void ShowMask( bool = true );
1010 
1014  void HideMask( bool hide = true )
1015  {
1016  ShowMask( !hide );
1017  }
1018 
1031 
1036  bool HasMaskReferences() const;
1037 
1046 
1053 
1061  void GetRGBWS( RGBColorSystem& rgbws ) const;
1062 
1069  void SetRGBWS( const RGBColorSystem& rgbws );
1070 
1078  bool UsingGlobalRGBWS() const;
1079 
1087 
1100  static void GetGlobalRGBWS( RGBColorSystem& rgbws );
1101 
1112  static void SetGlobalRGBWS( const RGBColorSystem& rgbws );
1113 
1118 
1138  void EnableColorManagement( bool = true );
1139 
1149  void DisableColorManagement( bool disable = true )
1150  {
1151  EnableColorManagement( !disable );
1152  }
1153 
1158  bool IsProofingEnabled() const;
1159 
1173  void EnableProofing( bool = true );
1174 
1184  void DisableProofing( bool disable = true )
1185  {
1186  EnableProofing( !disable );
1187  }
1188 
1193  bool IsGamutCheckEnabled() const;
1194 
1208  void EnableGamutCheck( bool = true );
1209 
1221  void DisableGamutCheck( bool disable = true )
1222  {
1223  EnableGamutCheck( !disable );
1224  }
1225 
1243  void SetColorManagementFeatures( bool cmEnabled, bool proofing, bool gamutCheck );
1244 
1251  bool GetICCProfile( ICCProfile& icc ) const;
1252 
1263  void SetICCProfile( const ICCProfile& icc );
1264 
1275  void SetICCProfile( const String& filePath );
1276 
1288 
1295 
1306  bool GetKeywords( FITSKeywordArray& keywords ) const
1307  {
1308  keywords = Keywords();
1309  return !keywords.IsEmpty();
1310  }
1311 
1322  void SetKeywords( const FITSKeywordArray& keywords );
1323 
1328 
1335 
1356  bool RegenerateAstrometricSolution( bool allowGUIMessages = true, bool notify = true );
1357 
1380  bool CopyAstrometricSolution( const ImageWindow& source, bool notify = true );
1381 
1415  void ClearAstrometricSolution( bool notify = true );
1416 
1430  void UpdateAstrometryMetadata( bool notify = true );
1431 
1462  bool ImageToCelestial( double& x, double& y, bool rawRA = false ) const;
1463 
1479  template <typename T>
1480  bool ImageToCelestial( DPoint& pRD, const GenericPoint<T>& pI, bool rawRA = false ) const
1481  {
1482  DPoint qI( double( pI.x ), double( pI.y ) );
1483  if ( ImageToCelestial( qI.x, qI.y, rawRA ) )
1484  {
1485  pRD = qI;
1486  return true;
1487  }
1488  return false;
1489  }
1490 
1512  bool CelestialToImage( double& ra, double& dec ) const;
1513 
1528  bool CelestialToImage( DPoint& pI, const DPoint& pRD ) const
1529  {
1530  DPoint qI = pRD;
1531  if ( CelestialToImage( qI.x, qI.y ) )
1532  {
1533  pI = qI;
1534  return true;
1535  }
1536  return false;
1537  }
1538 
1557  void GetResolution( double& xRes, double& yRes, bool& metric ) const;
1558 
1573  void SetResolution( double xRes, double yRes, bool metric = false );
1574 
1588  void SetResolution( double r, bool metric = false )
1589  {
1590  SetResolution( r, r, metric );
1591  }
1592 
1614  static void GetDefaultResolution( double& xRes, double& yRes, bool& metric );
1615 
1629 
1643 
1655 
1667 
1682 
1706  static bool SetSwapDirectories( const StringList& directories );
1707 
1722  static int CursorTolerance();
1723 
1730  static gui_mode CurrentMode();
1731 
1742  static void SelectMode( gui_mode mode );
1743 
1750  display_channel CurrentChannel() const;
1751 
1757  {
1758  return CurrentChannel() >= DisplayChannel::Alpha;
1759  }
1760 
1771  {
1772  return CurrentChannel() - DisplayChannel::Alpha;
1773  }
1774 
1789  void SelectChannel( display_channel c );
1790 
1796  mask_mode MaskMode() const;
1797 
1806  void SetMaskMode( mask_mode mode );
1807 
1830  static background_brush GetBackgroundBrush( uint32& fgColor, uint32& bgColor );
1831 
1855  static void SetBackgroundBrush( background_brush brush, uint32 fgColor = 0, uint32 bgColor = 0 );
1856 
1863  transparency_mode TransparencyMode() const;
1864 
1873 
1882  {
1883  return TransparencyMode() != pcl::TransparencyMode::Hide;
1884  }
1885 
1898  void SetTransparencyMode( transparency_mode mode, RGBA color = 0 );
1899 
1908  {
1909  SetTransparencyMode( pcl::TransparencyMode::Hide );
1910  }
1911 
1957  void SetViewport( double cx, double cy, int zoom = 0 );
1958 
1969  void SetViewport( const DPoint& center, int zoom = 0 )
1970  {
1971  SetViewport( center.x, center.y, zoom );
1972  }
1973 
1983  void FitWindow();
1984 
2015  void ZoomToFit( bool optimalFit = true,
2016  bool allowMagnification = true,
2017  bool allowAnimations = true,
2018  bool noLimits = false );
2019 
2026  int ZoomFactor() const;
2027 
2035  void SetZoomFactor( int z );
2036 
2043  void ZoomIn()
2044  {
2045  int z = ZoomFactor() + 1;
2046  SetZoomFactor( (z > 0) ? z : +1 );
2047  }
2048 
2055  void ZoomOut()
2056  {
2057  int z = ZoomFactor() - 1;
2058  SetZoomFactor( (z > 0 || z < -1) ? z : -2 );
2059  }
2060 
2075  void GetViewportSize( int& width, int& height ) const;
2076 
2080  int ViewportWidth() const
2081  {
2082  int w, dum;
2083  GetViewportSize( w, dum );
2084  return w;
2085  }
2086 
2090  int ViewportHeight() const
2091  {
2092  int dum, h;
2093  GetViewportSize( dum, h );
2094  return h;
2095  }
2096 
2107 
2117  void SetViewportPosition( int x, int y );
2118 
2127  void SetViewportPosition( const Point& p )
2128  {
2129  SetViewportPosition( p.x, p.y );
2130  }
2131 
2140 
2146  {
2147  return VisibleViewportRect().Width();
2148  }
2149 
2155  {
2156  return VisibleViewportRect().Height();
2157  }
2158 
2162  bool IsVisible() const;
2163 
2179  void Show( bool fitWindow = true );
2180 
2185  void Hide();
2186 
2190  bool IsIconic() const;
2191 
2195  void Iconize();
2196 
2200  void Deiconize();
2201 
2212 
2223  void SendToBack();
2224 
2233  static bool IsDynamicSessionActive();
2234 
2250 
2265  static bool TerminateDynamicSession( bool closeInterface = true );
2266 
2285  void SetDynamicCursor( const char** xpm, int hx = 0, int hy = 0 );
2286 
2299  void SetDynamicCursor( const char** xpm, const Point& p )
2300  {
2301  SetDynamicCursor( xpm, p.x, p.y );
2302  }
2303 
2326  void SetDynamicCursor( const Bitmap& bmp, int hx = 0, int hy = 0 );
2327 
2336  void SetDynamicCursor( const Bitmap& bmp, const Point& p )
2337  {
2338  SetDynamicCursor( bmp, p.x, p.y );
2339  }
2340 
2346  {
2347  SetDynamicCursor( Bitmap::Null() );
2348  }
2349 
2355 
2363 
2393  double DisplayPixelRatio() const;
2394 
2401  void ViewportToImage( int& x, int& y ) const;
2402 
2407  void ViewportToImage( double& x, double& y ) const;
2408 
2414  template <typename T>
2416  {
2417  DPoint p1 = p;
2418  ViewportToImage( p1.x, p1.y );
2419  return p1;
2420  }
2421 
2427  template <typename T>
2429  {
2430  DRect r1 = r;
2431  ViewportToImage( r1.x0, r1.y0 );
2432  ViewportToImage( r1.x1, r1.y1 );
2433  return r1;
2434  }
2435 
2447  void ViewportToImage( Point* p, size_type n ) const;
2448 
2458  void ViewportToImage( DPoint* p, size_type n ) const;
2459 
2467  template <typename T>
2469  {
2470  ViewportToImage( a.Begin(), a.Length() );
2471  }
2472 
2486  void ViewportScalarToImage( int* d, size_type n ) const;
2487 
2498  void ViewportScalarToImage( double* d, size_type n ) const;
2499 
2505  double ViewportScalarToImage( double d ) const;
2506 
2512  template <typename T>
2513  double ViewportScalarToImage( T d ) const
2514  {
2515  return ViewportScalarToImage( double( d ) );
2516  }
2517 
2524  void ImageToViewport( int& x, int& y ) const;
2525 
2530  void ImageToViewport( double& x, double& y ) const;
2531 
2541  template <typename T>
2543  {
2544  GenericPoint<T> p1 = p;
2545  ImageToViewport( p1.x, p1.y );
2546  return p1;
2547  }
2548 
2558  template <typename T>
2560  {
2561  GenericRectangle<T> r1 = r;
2562  ImageToViewport( r1.x0, r1.y0 );
2563  ImageToViewport( r1.x1, r1.y1 );
2564  return r1;
2565  }
2566 
2578  void ImageToViewport( Point* p, size_type n ) const;
2579 
2589  void ImageToViewport( DPoint* p, size_type n ) const;
2590 
2598  template <typename T>
2600  {
2601  ImageToViewport( a.Begin(), a.Length() );
2602  }
2603 
2617  void ImageScalarToViewport( int* d, size_type n ) const;
2618 
2629  void ImageScalarToViewport( double* d, size_type n ) const;
2630 
2639  int ImageScalarToViewport( int ) const;
2640 
2646  double ImageScalarToViewport( double ) const;
2647 
2654  void ViewportToGlobal( int& x, int& y ) const;
2655 
2660  Point ViewportToGlobal( const Point& p ) const
2661  {
2662  Point p1 = p;
2663  ViewportToGlobal( p1.x, p1.y );
2664  return p1;
2665  }
2666 
2672  Rect ViewportToGlobal( const Rect& r ) const
2673  {
2674  Rect r1 = r;
2675  ViewportToGlobal( r1.x0, r1.y0 );
2676  ViewportToGlobal( r1.x1, r1.y1 );
2677  return r1;
2678  }
2679 
2686  void GlobalToViewport( int& x, int& y ) const;
2687 
2693  Point GlobalToViewport( const Point& p ) const
2694  {
2695  Point p1 = p;
2696  GlobalToViewport( p1.x, p1.y );
2697  return p1;
2698  }
2699 
2705  Rect GlobalToViewport( const Rect& r ) const
2706  {
2707  Rect r1 = r;
2708  GlobalToViewport( r1.x0, r1.y0 );
2709  GlobalToViewport( r1.x1, r1.y1 );
2710  return r1;
2711  }
2712 
2721  void Reset()
2722  {
2723  SetZoomFactor( ZoomFactor() );
2724  }
2725 
2731  void Regenerate();
2732 
2741  void RegenerateViewportRect( const Rect& r )
2742  {
2743  RegenerateViewportRect( r.x0, r.y0, r.x1, r.y1 );
2744  }
2745 
2760  void RegenerateViewportRect( int x0, int y0, int x1, int y1 );
2761 
2771  {
2772  RegenerateImageRect( r.x0, r.y0, r.x1, r.y1 );
2773  }
2774 
2789  void RegenerateImageRect( double x0, double y0, double x1, double y1 );
2790 
2796 
2805  void UpdateViewportRect( const Rect& r )
2806  {
2807  UpdateViewportRect( r.x0, r.y0, r.x1, r.y1 );
2808  }
2809 
2824  void UpdateViewportRect( int x0, int y0, int x1, int y1 );
2825 
2834  void UpdateImageRect( const pcl::DRect& r )
2835  {
2836  UpdateImageRect( r.x0, r.y0, r.x1, r.y1 );
2837  }
2838 
2854  void UpdateImageRect( double x0, double y0, double x1, double y1 );
2855 
2859  bool HasPendingUpdates() const;
2860 
2880 
2886 
2895  Bitmap ViewportBitmap( const Rect& r, uint32 flags = 0 ) const
2896  {
2897  return ViewportBitmap( r.x0, r.y0, r.x1, r.y1, flags );
2898  }
2899 
2919  Bitmap ViewportBitmap( int x0, int y0, int x1, int y1, uint32 flags = 0 ) const;
2920 
2929  void BeginSelection( const Point& p, uint32 flags = 0 )
2930  {
2931  BeginSelection( p.x, p.y, flags );
2932  }
2933 
2950  void BeginSelection( int x, int y, uint32 flags = 0 );
2951 
2960  void ModifySelection( const Point& p, uint32 flags = 0 )
2961  {
2962  ModifySelection( p.x, p.y, flags );
2963  }
2964 
2978  void ModifySelection( int x, int y, uint32 flags = 0 );
2979 
2984 
2989 
2994 
3004  Rect SelectionRect( uint32* flags = nullptr ) const;
3005 
3010  bool IsSelection() const;
3011 
3017  static ImageWindow WindowById( const IsoString& id );
3018 
3019  static ImageWindow WindowById( const IsoString::ustring_base& id )
3020  {
3021  return WindowById( IsoString( id ) );
3022  }
3023 
3029  static ImageWindow WindowByFilePath( const String& filePath );
3030 
3042 
3050  static Array<ImageWindow> AllWindows( bool includeIconicWindows = true );
3051 
3052 private:
3053 
3054  ImageWindow( void* h ) : UIObject( h )
3055  {
3056  }
3057 
3058  friend class View;
3059  friend class ProcessInstance; // for IsMaskable()
3060  friend class ProcessContextDispatcher;
3061  friend class InternalWindowEnumerator;
3062 };
3063 
3064 // ----------------------------------------------------------------------------
3065 
3066 #endif // !__PCL_BUILDING_PIXINSIGHT_APPLICATION
3067 
3068 } // pcl
3069 
3070 #endif // __PCL_ImageWindow_h
3071 
3072 // ----------------------------------------------------------------------------
3073 // EOF pcl/ImageWindow.h - Released 2024-06-18T15:48:54Z
Generic dynamic array.
Definition: Array.h:100
bool IsEmpty() const noexcept
Definition: Array.h:312
Client-side interface to a PixInsight Bitmap object.
Definition: Bitmap.h:204
static Bitmap & Null()
A generic point in the two-dimensional space.
Definition: Point.h:100
component x
Abscissa (horizontal, or X-axis coordinate).
Definition: Point.h:111
component y
Ordinate (vertical, or Y-axis coordinate).
Definition: Point.h:112
A generic rectangle in the two-dimensional space.
Definition: Rectangle.h:314
component x1
Horizontal coordinate of the lower right corner.
Definition: Rectangle.h:334
component y1
Vertical coordinate of the lower right corner.
Definition: Rectangle.h:335
component y0
Vertical coordinate of the upper left corner.
Definition: Rectangle.h:333
component x0
Horizontal coordinate of the upper left corner.
Definition: Rectangle.h:332
A high-level interface to ICC color profiles.
Definition: ICCProfile.h:235
Format-independent, fundamental image stream options.
Definition: ImageOptions.h:98
High-level interface to an image window object in the PixInsight core application.
Definition: ImageWindow.h:287
void SetResolution(double xRes, double yRes, bool metric=false)
void BeginSelection(int x, int y, uint32 flags=0)
View CreatePreview(int x0, int y0, int x1, int y1, const IsoString &previewId=IsoString())
void SetICCProfile(const ICCProfile &icc)
void EnableColorManagement(bool=true)
void SetRGBWS(const RGBColorSystem &rgbws)
GenericRectangle< T > ImageToViewport(const GenericRectangle< T > &r) const
Definition: ImageWindow.h:2559
ImageOptions FileInfo() const
void RegenerateImageRect(double x0, double y0, double x1, double y1)
int ZoomFactor() const
bool IsModified() const
Definition: ImageWindow.h:614
ImageWindow()=default
void CancelSelection()
static ImageWindow ActiveWindow()
bool HasPendingUpdates() const
GenericPoint< T > ImageToViewport(const GenericPoint< T > &p) const
Definition: ImageWindow.h:2542
bool IsACopy() const
void CommitPendingUpdates()
ImageWindow(ImageWindow &&x)
Definition: ImageWindow.h:410
void ViewportToGlobal(int &x, int &y) const
static bool IsDefaultThumbnailEmbeddingEnabled()
display_channel CurrentChannel() const
void SetDynamicCursor(const char **xpm, const Point &p)
Definition: ImageWindow.h:2299
bool GetKeywords(FITSKeywordArray &keywords) const
Definition: ImageWindow.h:1306
static bool SetSwapDirectories(const StringList &directories)
int CurrentAlphaChannel() const
Definition: ImageWindow.h:1770
ImageWindow(const ImageWindow &w)
Definition: ImageWindow.h:402
DPoint ViewportToImage(const GenericPoint< T > &p) const
Definition: ImageWindow.h:2415
void ModifySelection(int x, int y, uint32 flags=0)
void ZoomToFit(bool optimalFit=true, bool allowMagnification=true, bool allowAnimations=true, bool noLimits=false)
void RegenerateViewportRect(const Rect &r)
Definition: ImageWindow.h:2741
void HideMask(bool hide=true)
Definition: ImageWindow.h:1014
void SelectChannel(display_channel c)
void SetMaskMode(mask_mode mode)
ImageWindow(int width, int height, int numberOfChannels=1, int bitsPerSample=32, bool floatSample=true, bool color=false, bool initialProcessing=true, const IsoString &id=IsoString())
bool HasMaskReferences() const
bool GetICCProfile(ICCProfile &icc) const
void ViewportToImage(Point *p, size_type n) const
Bitmap DynamicCursorBitmap() const
bool IsMaskCompatible(const ImageWindow &)
bool IsIconic() const
void BeginSelection(const Point &p, uint32 flags=0)
Definition: ImageWindow.h:2929
Rect GlobalToViewport(const Rect &r) const
Definition: ImageWindow.h:2705
bool IsSelection() const
View CurrentView() const
void DisableProofing(bool disable=true)
Definition: ImageWindow.h:1184
void DeleteICCProfile()
void UpdateViewportRect(int x0, int y0, int x1, int y1)
void GetViewportSize(int &width, int &height) const
Point DynamicCursorHotSpot() const
void SetResolution(double r, bool metric=false)
Definition: ImageWindow.h:1588
void SetDynamicCursor(const char **xpm, int hx=0, int hy=0)
void SelectPreview(const IsoString &previewId)
Definition: ImageWindow.h:766
View CreatePreview(const Rect &r, const IsoString &previewId=IsoString())
Definition: ImageWindow.h:784
static ImageWindow & Null()
View PreviewById(const IsoString &previewId) const
int ImageScalarToViewport(int) const
void ViewportScalarToImage(int *d, size_type n) const
int VisibleViewportHeight() const
Definition: ImageWindow.h:2154
static ImageWindow WindowById(const IsoString &id)
void HideTransparency()
Definition: ImageWindow.h:1907
int ViewportHeight() const
Definition: ImageWindow.h:2090
Point GlobalToViewport(const Point &p) const
Definition: ImageWindow.h:2693
void Show(bool fitWindow=true)
void RegenerateViewportRect(int x0, int y0, int x1, int y1)
void RemoveMaskReferences()
Rect VisibleViewportRect() const
void UpdateSelection()
void DeletePreview(const IsoString &previewId)
Array< View > Previews() const
bool IsMaskInverted() const
void SetICCProfile(const String &filePath)
void ViewportToImage(Array< GenericPoint< T > > &a) const
Definition: ImageWindow.h:2468
bool PreviewExists(const IsoString &previewId) const
Definition: ImageWindow.h:731
static void SetBackgroundBrush(background_brush brush, uint32 fgColor=0, uint32 bgColor=0)
bool IsAlphaChannelDisplayed() const
Definition: ImageWindow.h:1756
void EnableProofing(bool=true)
~ImageWindow() override
Definition: ImageWindow.h:422
void EnableGamutCheck(bool=true)
void InvertMask(bool invert=true)
Definition: ImageWindow.h:977
static bool IsDefaultICCProfileEmbeddingEnabledForRGBImages()
void ModifySelection(const Point &p, uint32 flags=0)
Definition: ImageWindow.h:2960
bool IsMaskVisible() const
Rect ViewportToGlobal(const Rect &r) const
Definition: ImageWindow.h:2672
bool HasPreviews() const
Definition: ImageWindow.h:700
bool IsVisible() const
void SetDynamicCursor(const Bitmap &bmp, int hx=0, int hy=0)
Point ViewportToGlobal(const Point &p) const
Definition: ImageWindow.h:2660
ImageWindow Mask() const
double ViewportScalarToImage(T d) const
Definition: ImageWindow.h:2513
void GetResolution(double &xRes, double &yRes, bool &metric) const
DRect ViewportToImage(const GenericRectangle< T > &r) const
Definition: ImageWindow.h:2428
static StringList SwapDirectories()
static void GetDefaultResolution(double &xRes, double &yRes, bool &metric)
Rect PreviewRect(const IsoString &previewId) const
bool IsTransparencyVisible() const
Definition: ImageWindow.h:1881
double ImageScalarToViewport(double) const
void ModifyPreview(const IsoString &previewId, int x0, int y0, int x1, int y1, const IsoString &newId=IsoString())
void ResetDynamicCursor()
Definition: ImageWindow.h:2345
View MainView() const
void GetSampleFormat(int &bitsPerSample, bool &floatSample) const
void PurgeProperties()
static gui_mode CurrentMode()
static bool IsDynamicSessionActive()
String FilePath() const
static ImageWindow WindowByFilePath(const String &filePath)
void DisableGamutCheck(bool disable=true)
Definition: ImageWindow.h:1221
void ImageToViewport(DPoint *p, size_type n) const
void UpdateImageRect(double x0, double y0, double x1, double y1)
void EnableMask(bool=true)
Rect SelectionRect(uint32 *flags=nullptr) const
void ShowMask(bool=true)
static bool IsDefaultICCProfileEmbeddingEnabledForGrayscaleImages()
static Array< ImageWindow > AllWindows(bool includeIconicWindows=true)
static bool IsDefaultPropertiesEmbeddingEnabled()
void ViewportToImage(DPoint *p, size_type n) const
void ViewportScalarToImage(double *d, size_type n) const
void SetViewportPosition(const Point &p)
Definition: ImageWindow.h:2127
static ProcessInterface * ActiveDynamicInterface()
int NumberOfPreviews() const
Rect ViewportUpdateRect() const
int ViewportWidth() const
Definition: ImageWindow.h:2080
Bitmap ViewportBitmap(int x0, int y0, int x1, int y1, uint32 flags=0) const
void UpdateImageRect(const pcl::DRect &r)
Definition: ImageWindow.h:2834
void SetSampleFormat(int bitsPerSample, bool floatSample)
bool IsProofingEnabled() const
void SetTransparencyMode(transparency_mode mode, RGBA color=0)
void ImageToViewport(Array< GenericPoint< T > > &a) const
Definition: ImageWindow.h:2599
mask_mode MaskMode() const
static void SelectMode(gui_mode mode)
void UpdateViewportRect(const Rect &r)
Definition: ImageWindow.h:2805
static void GetGlobalRGBWS(RGBColorSystem &rgbws)
void ViewportToImage(double &x, double &y) const
bool IsGamutCheckEnabled() const
double DisplayPixelRatio() const
static background_brush GetBackgroundBrush(uint32 &fgColor, uint32 &bgColor)
int VisibleViewportWidth() const
Definition: ImageWindow.h:2145
void ImageToViewport(Point *p, size_type n) const
size_type ModifyCount() const
void ModifyPreview(const IsoString &previewId, const Rect &r, const IsoString &newId=IsoString())
Definition: ImageWindow.h:828
void SetMask(ImageWindow &w, bool inverted=false)
void SelectPreview(View &)
static bool TerminateDynamicSession(bool closeInterface=true)
void DisableMask(bool disable=true)
Definition: ImageWindow.h:996
void UpdateMaskReferences()
void GlobalToViewport(int &x, int &y) const
void RegenerateImageRect(const pcl::DRect &r)
Definition: ImageWindow.h:2770
void SetViewport(double cx, double cy, int zoom=0)
bool IsValidView(const View &) const
static int CursorTolerance()
bool IsMaskEnabled() const
void ImageToViewport(int &x, int &y) const
bool UsingGlobalRGBWS() const
double ViewportScalarToImage(double d) const
void DisableColorManagement(bool disable=true)
Definition: ImageWindow.h:1149
RGBA TransparencyColor() const
Point ViewportPosition() const
void SetColorManagementFeatures(bool cmEnabled, bool proofing, bool gamutCheck)
void SetDynamicCursor(const Bitmap &bmp, const Point &p)
Definition: ImageWindow.h:2336
bool IsColorManagementEnabled() const
bool IsNew() const
static Array< ImageWindow > Open(const String &url, const IsoString &id=IsoString(), const IsoString &formatHints=IsoString(), bool asCopy=false, bool allowMessages=true)
FITSKeywordArray Keywords() const
static void SetGlobalRGBWS(const RGBColorSystem &rgbws)
void SelectView(View &)
void ImageScalarToViewport(double *d, size_type n) const
void GetRGBWS(RGBColorSystem &rgbws) const
void ImageToViewport(double &x, double &y) const
void SetViewport(const DPoint &center, int zoom=0)
Definition: ImageWindow.h:1969
transparency_mode TransparencyMode() const
Bitmap ViewportBitmap(const Rect &r, uint32 flags=0) const
Definition: ImageWindow.h:2895
void ViewportToImage(int &x, int &y) const
bool HasURL() const
Definition: ImageWindow.h:592
void SetViewportPosition(int x, int y)
View SelectedPreview() const
void SetZoomFactor(int z)
void SelectMainView()
Definition: ImageWindow.h:675
void ImageScalarToViewport(int *d, size_type n) const
void SetKeywords(const FITSKeywordArray &keywords)
String FileURL() const
Eight-bit string (ISO/IEC-8859-1 or UTF-8 string)
Definition: String.h:5425
GenericString< char16_type, CharTraits, PCL_STRING_ALLOCATOR > ustring_base
Definition: String.h:5488
High-level interface to a process instance.
Client-side interface to a PixInsight process interface window.
Colorimetrically defined RGB working color space.
32-bit integer rectangle on the plane.
Unicode (UTF-16) string.
Definition: String.h:8113
Root base class for all user interface objects.
Definition: UIObject.h:95
A collection of history data item specifiers.
High-level interface to a PixInsight view object.
Definition: View.h:213
bool CelestialToImage(DPoint &pI, const DPoint &pRD) const
Definition: ImageWindow.h:1528
bool CelestialToImage(double &ra, double &dec) const
bool ImageToCelestial(DPoint &pRD, const GenericPoint< T > &pI, bool rawRA=false) const
Definition: ImageWindow.h:1480
bool CopyAstrometricSolution(const ImageWindow &source, bool notify=true)
void UpdateAstrometryMetadata(bool notify=true)
bool HasAstrometricSolution() const
void ClearAstrometricSolution(bool notify=true)
bool ImageToCelestial(double &x, double &y, bool rawRA=false) const
bool RegenerateAstrometricSolution(bool allowGUIMessages=true, bool notify=true)
unsigned int uint32
Definition: Defs.h:666
uint32 RGBA
Definition: Color.h:92
size_t size_type
Definition: Defs.h:609
bool IsValidMainViewMode(value_type m)
Definition: ImageWindow.h:135
bool IsValidPreviewMode(value_type m)
Definition: ImageWindow.h:126
PCL root namespace.
Definition: AbstractImage.h:77