PCL
ImageWindow.h
Go to the documentation of this file.
1 // ____ ______ __
2 // / __ \ / ____// /
3 // / /_/ // / / /
4 // / ____// /___ / /___ PixInsight Class Library
5 // /_/ \____//_____/ PCL 2.6.11
6 // ----------------------------------------------------------------------------
7 // pcl/ImageWindow.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_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 
238 namespace UndoFlag
239 {
240  /*
241  * ### TODO: PCL 2.x: Get rid of all project depencies on UndoFlags.
242  */
243  enum mask_type
244  {
245  DefaultMode = 0x00000000, // Save pixel data, astrometric solution and previews
246  PixelData = 0x00000001, // Save pixel data
247  RGBWS = 0x00000002, // RGB Working Space data
248  ICCProfile = 0x00000004, // ICC profile
249  Keywords = 0x00000008, // %FITS keywords
250  //Metadata = 0x00000010, // ### DEPRECATED - Keep unused for now, for compatibility with existing projects
251  FormatData = 0x00000020, // Format-specific data
252  ImageId = 0x00000040, // %Image identifier
253  Resolution = 0x00000080, // %Image resolution
254  AstrometricSolution = 0x00000100, // Save the current astrometric solution
255  All = 0x000FFFFF, // Save all data items
256  DeletePropertiesOnEntry = 0x01000000, // Destroy/delete non-permanent view properties before execution
257  DeletePropertiesOnExit = 0x02000000, // Destroy/delete non-permanent view properties after execution
258  ExcludePreviews = 0x80000000, // Don't save state of previews
259  ExcludeMaskRelations = 0x40000000 // Don't save masking dependencies
260  };
261 }
262 
267 using UndoFlags = Flags<UndoFlag::mask_type>;
268 
269 // ----------------------------------------------------------------------------
270 
271 #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
272 
273 // ----------------------------------------------------------------------------
274 
284 class PCL_CLASS ImageWindow : public UIObject
285 {
286 public:
287 
292  using gui_mode = ImageMode::value_type;
293 
299  using display_channel = DisplayChannel::value_type;
300 
306  using mask_mode = MaskMode::value_type;
307 
313  using background_brush = BackgroundBrush::value_type;
314 
320  using transparency_mode = TransparencyMode::value_type;
321 
326  ImageWindow() = default;
327 
373  ImageWindow( int width, int height, int numberOfChannels = 1,
374  int bitsPerSample = 32, bool floatSample = true, bool color = false,
375  bool initialProcessing = true,
376  const IsoString& id = IsoString() );
377 
378  ImageWindow( int width, int height, int numberOfChannels,
379  int bitsPerSample, bool floatSample, bool color,
380  bool initialProcessing,
381  const IsoString::ustring_base& id )
382  : ImageWindow( width, height, numberOfChannels,
383  bitsPerSample, floatSample, color,
384  initialProcessing,
385  IsoString( id ) )
386  {
387  }
388 
401  : UIObject( w )
402  {
403  }
404 
409  : UIObject( std::move( x ) )
410  {
411  }
412 
420  ~ImageWindow() override
421  {
422  }
423 
435  ImageWindow& operator =( const ImageWindow& window )
436  {
437  Assign( window );
438  return *this;
439  }
440 
444  ImageWindow& operator =( ImageWindow&& x )
445  {
446  Transfer( x );
447  return *this;
448  }
449 
455  static ImageWindow& Null();
456 
531  static Array<ImageWindow> Open( const String& url,
532  const IsoString& id = IsoString(),
533  const IsoString& formatHints = IsoString(),
534  bool asCopy = false,
535  bool allowMessages = true );
536 
537  template <class S1, class S2>
538  static Array<ImageWindow> Open( const String& url,
539  const S1& id,
540  const S2& formatHints,
541  bool asCopy = false,
542  bool allowMessages = true )
543  {
544  return Open( url, IsoString( id ), IsoString( formatHints ), asCopy, allowMessages );
545  }
546 
552  bool IsNew() const;
553 
566  bool IsACopy() const;
567 
577  String FilePath() const;
578 
584  String FileURL() const;
585 
590  bool HasURL() const
591  {
592  return !FileURL().IsEmpty();
593  }
594 
600 
607 
612  bool IsModified() const
613  {
614  return ModifyCount() > 0;
615  }
616 
637  bool Close();
638 
646  void ForceClose();
647 
654  View MainView() const;
655 
663  View CurrentView() const;
664 
668  void SelectView( View& );
669 
674  {
675  View v( MainView() ); SelectView( v );
676  }
677 
682 
687  bool IsValidView( const View& ) const;
688 
692  int NumberOfPreviews() const;
693 
698  bool HasPreviews() const
699  {
700  return NumberOfPreviews() > 0;
701  }
702 
709 
717  View PreviewById( const IsoString& previewId ) const;
718 
719  View PreviewById( const IsoString::ustring_base& previewId ) const
720  {
721  return PreviewById( IsoString( previewId ) );
722  }
723 
729  bool PreviewExists( const IsoString& previewId ) const
730  {
731  return !IsNull() && !PreviewById( previewId ).IsNull();
732  }
733 
734  bool PreviewExists( const IsoString::ustring_base& previewId ) const
735  {
736  return PreviewExists( IsoString( previewId ) );
737  }
738 
751 
757  void SelectPreview( View& );
758 
764  void SelectPreview( const IsoString& previewId )
765  {
766  View v( PreviewById( previewId ) ), SelectPreview( v );
767  }
768 
769  void SelectPreview( const IsoString::ustring_base& previewId )
770  {
771  SelectPreview( IsoString( previewId ) );
772  }
773 
782  View CreatePreview( const Rect& r, const IsoString& previewId = IsoString() )
783  {
784  return CreatePreview( r.x0, r.y0, r.x1, r.y1, previewId );
785  }
786 
787  View CreatePreview( const Rect& r, const IsoString::ustring_base& previewId )
788  {
789  return CreatePreview( r, IsoString( previewId ) );
790  }
791 
811  View CreatePreview( int x0, int y0, int x1, int y1, const IsoString& previewId = IsoString() );
812 
813  View CreatePreview( int x0, int y0, int x1, int y1, const IsoString::ustring_base& previewId )
814  {
815  return CreatePreview( x0, y0, x1, y1, IsoString( previewId ) );
816  }
817 
826  void ModifyPreview( const IsoString& previewId, const Rect& r, const IsoString& newId = IsoString() )
827  {
828  ModifyPreview( previewId, r.x0, r.y0, r.x1, r.y1, newId );
829  }
830 
831  void ModifyPreview( const IsoString::ustring_base& previewId, const Rect& r )
832  {
833  ModifyPreview( IsoString( previewId ), r );
834  }
835 
836  void ModifyPreview( const IsoString::ustring_base& previewId, const Rect& r, const IsoString::ustring_base& newId )
837  {
838  ModifyPreview( IsoString( previewId ), r, IsoString( newId ) );
839  }
840 
863  void ModifyPreview( const IsoString& previewId, int x0, int y0, int x1, int y1,
864  const IsoString& newId = IsoString() );
865 
866  void ModifyPreview( const IsoString::ustring_base& previewId, int x0, int y0, int x1, int y1 )
867  {
868  ModifyPreview( IsoString( previewId ), x0, y0, x1, y1 );
869  }
870 
871  void ModifyPreview( const IsoString::ustring_base& previewId, int x0, int y0, int x1, int y1,
872  const IsoString::ustring_base& newId )
873  {
874  ModifyPreview( IsoString( previewId ), x0, y0, x1, y1, IsoString( newId ) );
875  }
876 
884  Rect PreviewRect( const IsoString& previewId ) const;
885 
886  Rect PreviewRect( const IsoString::ustring_base& previewId ) const
887  {
888  return PreviewRect( IsoString( previewId ) );
889  }
890 
900  void DeletePreview( const IsoString& previewId );
901 
902  void DeletePreview( const IsoString::ustring_base& previewId )
903  {
904  DeletePreview( IsoString( previewId ) );
905  }
906 
914 
926  void GetSampleFormat( int& bitsPerSample, bool& floatSample ) const;
927 
941  void SetSampleFormat( int bitsPerSample, bool floatSample );
942 
947  ImageWindow Mask() const;
948 
957  void SetMask( ImageWindow& w, bool inverted = false );
958 
962  void RemoveMask()
963  {
964  SetMask( Null() );
965  }
966 
970  bool IsMaskInverted() const;
971 
975  void InvertMask( bool invert = true )
976  {
977  ImageWindow mask = Mask();
978  SetMask( mask, invert );
979  }
980 
984  bool IsMaskEnabled() const;
985 
989  void EnableMask( bool = true );
990 
994  void DisableMask( bool disable = true )
995  {
996  EnableMask( !disable );
997  }
998 
1002  bool IsMaskVisible() const;
1003 
1007  void ShowMask( bool = true );
1008 
1012  void HideMask( bool hide = true )
1013  {
1014  ShowMask( !hide );
1015  }
1016 
1029 
1034  bool HasMaskReferences() const;
1035 
1044 
1051 
1059  void GetRGBWS( RGBColorSystem& rgbws ) const;
1060 
1067  void SetRGBWS( const RGBColorSystem& rgbws );
1068 
1076  bool UsingGlobalRGBWS() const;
1077 
1085 
1098  static void GetGlobalRGBWS( RGBColorSystem& rgbws );
1099 
1110  static void SetGlobalRGBWS( const RGBColorSystem& rgbws );
1111 
1116 
1136  void EnableColorManagement( bool = true );
1137 
1147  void DisableColorManagement( bool disable = true )
1148  {
1149  EnableColorManagement( !disable );
1150  }
1151 
1156  bool IsProofingEnabled() const;
1157 
1171  void EnableProofing( bool = true );
1172 
1182  void DisableProofing( bool disable = true )
1183  {
1184  EnableProofing( !disable );
1185  }
1186 
1191  bool IsGamutCheckEnabled() const;
1192 
1206  void EnableGamutCheck( bool = true );
1207 
1219  void DisableGamutCheck( bool disable = true )
1220  {
1221  EnableGamutCheck( !disable );
1222  }
1223 
1241  void SetColorManagementFeatures( bool cmEnabled, bool proofing, bool gamutCheck );
1242 
1249  bool GetICCProfile( ICCProfile& icc ) const;
1250 
1261  void SetICCProfile( const ICCProfile& icc );
1262 
1273  void SetICCProfile( const String& filePath );
1274 
1286 
1293 
1304  bool GetKeywords( FITSKeywordArray& keywords ) const
1305  {
1306  keywords = Keywords();
1307  return !keywords.IsEmpty();
1308  }
1309 
1320  void SetKeywords( const FITSKeywordArray& keywords );
1321 
1326 
1333 
1354  bool RegenerateAstrometricSolution( bool allowGUIMessages = true, bool notify = true );
1355 
1378  bool CopyAstrometricSolution( const ImageWindow& source, bool notify = true );
1379 
1413  void ClearAstrometricSolution( bool notify = true );
1414 
1428  void UpdateAstrometryMetadata( bool notify = true );
1429 
1460  bool ImageToCelestial( double& x, double& y, bool rawRA = false ) const;
1461 
1477  template <typename T>
1478  bool ImageToCelestial( DPoint& pRD, const GenericPoint<T>& pI, bool rawRA = false ) const
1479  {
1480  DPoint qI( double( pI.x ), double( pI.y ) );
1481  if ( ImageToCelestial( qI.x, qI.y, rawRA ) )
1482  {
1483  pRD = qI;
1484  return true;
1485  }
1486  return false;
1487  }
1488 
1510  bool CelestialToImage( double& ra, double& dec ) const;
1511 
1526  bool CelestialToImage( DPoint& pI, const DPoint& pRD ) const
1527  {
1528  DPoint qI = pRD;
1529  if ( CelestialToImage( qI.x, qI.y ) )
1530  {
1531  pI = qI;
1532  return true;
1533  }
1534  return false;
1535  }
1536 
1555  void GetResolution( double& xRes, double& yRes, bool& metric ) const;
1556 
1571  void SetResolution( double xRes, double yRes, bool metric = false );
1572 
1586  void SetResolution( double r, bool metric = false )
1587  {
1588  SetResolution( r, r, metric );
1589  }
1590 
1612  static void GetDefaultResolution( double& xRes, double& yRes, bool& metric );
1613 
1627 
1641 
1653 
1665 
1680 
1704  static bool SetSwapDirectories( const StringList& directories );
1705 
1720  static int CursorTolerance();
1721 
1728  static gui_mode CurrentMode();
1729 
1740  static void SelectMode( gui_mode mode );
1741 
1748  display_channel CurrentChannel() const;
1749 
1755  {
1756  return CurrentChannel() >= DisplayChannel::Alpha;
1757  }
1758 
1769  {
1770  return CurrentChannel() - DisplayChannel::Alpha;
1771  }
1772 
1787  void SelectChannel( display_channel c );
1788 
1794  mask_mode MaskMode() const;
1795 
1804  void SetMaskMode( mask_mode mode );
1805 
1828  static background_brush GetBackgroundBrush( uint32& fgColor, uint32& bgColor );
1829 
1853  static void SetBackgroundBrush( background_brush brush, uint32 fgColor = 0, uint32 bgColor = 0 );
1854 
1861  transparency_mode TransparencyMode() const;
1862 
1871 
1880  {
1881  return TransparencyMode() != pcl::TransparencyMode::Hide;
1882  }
1883 
1896  void SetTransparencyMode( transparency_mode mode, RGBA color = 0 );
1897 
1906  {
1907  SetTransparencyMode( pcl::TransparencyMode::Hide );
1908  }
1909 
1955  void SetViewport( double cx, double cy, int zoom = 0 );
1956 
1967  void SetViewport( const DPoint& center, int zoom = 0 )
1968  {
1969  SetViewport( center.x, center.y, zoom );
1970  }
1971 
1981  void FitWindow();
1982 
2013  void ZoomToFit( bool optimalFit = true,
2014  bool allowMagnification = true,
2015  bool allowAnimations = true,
2016  bool noLimits = false );
2017 
2024  int ZoomFactor() const;
2025 
2033  void SetZoomFactor( int z );
2034 
2041  void ZoomIn()
2042  {
2043  int z = ZoomFactor() + 1;
2044  SetZoomFactor( (z > 0) ? z : +1 );
2045  }
2046 
2053  void ZoomOut()
2054  {
2055  int z = ZoomFactor() - 1;
2056  SetZoomFactor( (z > 0 || z < -1) ? z : -2 );
2057  }
2058 
2073  void GetViewportSize( int& width, int& height ) const;
2074 
2078  int ViewportWidth() const
2079  {
2080  int w, dum;
2081  GetViewportSize( w, dum );
2082  return w;
2083  }
2084 
2088  int ViewportHeight() const
2089  {
2090  int dum, h;
2091  GetViewportSize( dum, h );
2092  return h;
2093  }
2094 
2105 
2115  void SetViewportPosition( int x, int y );
2116 
2125  void SetViewportPosition( const Point& p )
2126  {
2127  SetViewportPosition( p.x, p.y );
2128  }
2129 
2138 
2144  {
2145  return VisibleViewportRect().Width();
2146  }
2147 
2153  {
2154  return VisibleViewportRect().Height();
2155  }
2156 
2160  bool IsVisible() const;
2161 
2177  void Show( bool fitWindow = true );
2178 
2183  void Hide();
2184 
2188  bool IsIconic() const;
2189 
2193  void Iconize();
2194 
2198  void Deiconize();
2199 
2210 
2221  void SendToBack();
2222 
2231  static bool IsDynamicSessionActive();
2232 
2248 
2263  static bool TerminateDynamicSession( bool closeInterface = true );
2264 
2283  void SetDynamicCursor( const char** xpm, int hx = 0, int hy = 0 );
2284 
2297  void SetDynamicCursor( const char** xpm, const Point& p )
2298  {
2299  SetDynamicCursor( xpm, p.x, p.y );
2300  }
2301 
2324  void SetDynamicCursor( const Bitmap& bmp, int hx = 0, int hy = 0 );
2325 
2334  void SetDynamicCursor( const Bitmap& bmp, const Point& p )
2335  {
2336  SetDynamicCursor( bmp, p.x, p.y );
2337  }
2338 
2344  {
2345  SetDynamicCursor( Bitmap::Null() );
2346  }
2347 
2353 
2361 
2391  double DisplayPixelRatio() const;
2392 
2399  void ViewportToImage( int& x, int& y ) const;
2400 
2405  void ViewportToImage( double& x, double& y ) const;
2406 
2412  template <typename T>
2414  {
2415  DPoint p1 = p;
2416  ViewportToImage( p1.x, p1.y );
2417  return p1;
2418  }
2419 
2425  template <typename T>
2427  {
2428  DRect r1 = r;
2429  ViewportToImage( r1.x0, r1.y0 );
2430  ViewportToImage( r1.x1, r1.y1 );
2431  return r1;
2432  }
2433 
2445  void ViewportToImage( Point* p, size_type n ) const;
2446 
2456  void ViewportToImage( DPoint* p, size_type n ) const;
2457 
2465  template <typename T>
2467  {
2468  ViewportToImage( a.Begin(), a.Length() );
2469  }
2470 
2484  void ViewportScalarToImage( int* d, size_type n ) const;
2485 
2496  void ViewportScalarToImage( double* d, size_type n ) const;
2497 
2503  double ViewportScalarToImage( double d ) const;
2504 
2510  template <typename T>
2511  double ViewportScalarToImage( T d ) const
2512  {
2513  return ViewportScalarToImage( double( d ) );
2514  }
2515 
2522  void ImageToViewport( int& x, int& y ) const;
2523 
2528  void ImageToViewport( double& x, double& y ) const;
2529 
2539  template <typename T>
2541  {
2542  GenericPoint<T> p1 = p;
2543  ImageToViewport( p1.x, p1.y );
2544  return p1;
2545  }
2546 
2556  template <typename T>
2558  {
2559  GenericRectangle<T> r1 = r;
2560  ImageToViewport( r1.x0, r1.y0 );
2561  ImageToViewport( r1.x1, r1.y1 );
2562  return r1;
2563  }
2564 
2576  void ImageToViewport( Point* p, size_type n ) const;
2577 
2587  void ImageToViewport( DPoint* p, size_type n ) const;
2588 
2596  template <typename T>
2598  {
2599  ImageToViewport( a.Begin(), a.Length() );
2600  }
2601 
2615  void ImageScalarToViewport( int* d, size_type n ) const;
2616 
2627  void ImageScalarToViewport( double* d, size_type n ) const;
2628 
2637  int ImageScalarToViewport( int ) const;
2638 
2644  double ImageScalarToViewport( double ) const;
2645 
2652  void ViewportToGlobal( int& x, int& y ) const;
2653 
2658  Point ViewportToGlobal( const Point& p ) const
2659  {
2660  Point p1 = p;
2661  ViewportToGlobal( p1.x, p1.y );
2662  return p1;
2663  }
2664 
2670  Rect ViewportToGlobal( const Rect& r ) const
2671  {
2672  Rect r1 = r;
2673  ViewportToGlobal( r1.x0, r1.y0 );
2674  ViewportToGlobal( r1.x1, r1.y1 );
2675  return r1;
2676  }
2677 
2684  void GlobalToViewport( int& x, int& y ) const;
2685 
2691  Point GlobalToViewport( const Point& p ) const
2692  {
2693  Point p1 = p;
2694  GlobalToViewport( p1.x, p1.y );
2695  return p1;
2696  }
2697 
2703  Rect GlobalToViewport( const Rect& r ) const
2704  {
2705  Rect r1 = r;
2706  GlobalToViewport( r1.x0, r1.y0 );
2707  GlobalToViewport( r1.x1, r1.y1 );
2708  return r1;
2709  }
2710 
2719  void Reset()
2720  {
2721  SetZoomFactor( ZoomFactor() );
2722  }
2723 
2729  void Regenerate();
2730 
2739  void RegenerateViewportRect( const Rect& r )
2740  {
2741  RegenerateViewportRect( r.x0, r.y0, r.x1, r.y1 );
2742  }
2743 
2758  void RegenerateViewportRect( int x0, int y0, int x1, int y1 );
2759 
2769  {
2770  RegenerateImageRect( r.x0, r.y0, r.x1, r.y1 );
2771  }
2772 
2787  void RegenerateImageRect( double x0, double y0, double x1, double y1 );
2788 
2794 
2803  void UpdateViewportRect( const Rect& r )
2804  {
2805  UpdateViewportRect( r.x0, r.y0, r.x1, r.y1 );
2806  }
2807 
2822  void UpdateViewportRect( int x0, int y0, int x1, int y1 );
2823 
2832  void UpdateImageRect( const pcl::DRect& r )
2833  {
2834  UpdateImageRect( r.x0, r.y0, r.x1, r.y1 );
2835  }
2836 
2852  void UpdateImageRect( double x0, double y0, double x1, double y1 );
2853 
2857  bool HasPendingUpdates() const;
2858 
2878 
2884 
2893  Bitmap ViewportBitmap( const Rect& r, uint32 flags = 0 ) const
2894  {
2895  return ViewportBitmap( r.x0, r.y0, r.x1, r.y1, flags );
2896  }
2897 
2917  Bitmap ViewportBitmap( int x0, int y0, int x1, int y1, uint32 flags = 0 ) const;
2918 
2927  void BeginSelection( const Point& p, uint32 flags = 0 )
2928  {
2929  BeginSelection( p.x, p.y, flags );
2930  }
2931 
2948  void BeginSelection( int x, int y, uint32 flags = 0 );
2949 
2958  void ModifySelection( const Point& p, uint32 flags = 0 )
2959  {
2960  ModifySelection( p.x, p.y, flags );
2961  }
2962 
2976  void ModifySelection( int x, int y, uint32 flags = 0 );
2977 
2982 
2987 
2992 
3002  Rect SelectionRect( uint32* flags = nullptr ) const;
3003 
3008  bool IsSelection() const;
3009 
3015  static ImageWindow WindowById( const IsoString& id );
3016 
3017  static ImageWindow WindowById( const IsoString::ustring_base& id )
3018  {
3019  return WindowById( IsoString( id ) );
3020  }
3021 
3027  static ImageWindow WindowByFilePath( const String& filePath );
3028 
3040 
3048  static Array<ImageWindow> AllWindows( bool includeIconicWindows = true );
3049 
3050 private:
3051 
3052  ImageWindow( void* h ) : UIObject( h )
3053  {
3054  }
3055 
3056  friend class View;
3057  friend class ProcessInstance; // for IsMaskable()
3058  friend class ProcessContextDispatcher;
3059  friend class InternalWindowEnumerator;
3060 };
3061 
3062 // ----------------------------------------------------------------------------
3063 
3064 #endif // !__PCL_BUILDING_PIXINSIGHT_APPLICATION
3065 
3066 } // pcl
3067 
3068 #endif // __PCL_ImageWindow_h
3069 
3070 // ----------------------------------------------------------------------------
3071 // EOF pcl/ImageWindow.h - Released 2024-05-07T15:27:32Z
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:285
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:2557
ImageOptions FileInfo() const
void RegenerateImageRect(double x0, double y0, double x1, double y1)
int ZoomFactor() const
bool IsModified() const
Definition: ImageWindow.h:612
ImageWindow()=default
void CancelSelection()
static ImageWindow ActiveWindow()
bool HasPendingUpdates() const
GenericPoint< T > ImageToViewport(const GenericPoint< T > &p) const
Definition: ImageWindow.h:2540
bool IsACopy() const
void CommitPendingUpdates()
ImageWindow(ImageWindow &&x)
Definition: ImageWindow.h:408
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:2297
bool GetKeywords(FITSKeywordArray &keywords) const
Definition: ImageWindow.h:1304
static bool SetSwapDirectories(const StringList &directories)
int CurrentAlphaChannel() const
Definition: ImageWindow.h:1768
ImageWindow(const ImageWindow &w)
Definition: ImageWindow.h:400
DPoint ViewportToImage(const GenericPoint< T > &p) const
Definition: ImageWindow.h:2413
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:2739
void HideMask(bool hide=true)
Definition: ImageWindow.h:1012
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:2927
Rect GlobalToViewport(const Rect &r) const
Definition: ImageWindow.h:2703
bool IsSelection() const
View CurrentView() const
void DisableProofing(bool disable=true)
Definition: ImageWindow.h:1182
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:1586
void SetDynamicCursor(const char **xpm, int hx=0, int hy=0)
void SelectPreview(const IsoString &previewId)
Definition: ImageWindow.h:764
View CreatePreview(const Rect &r, const IsoString &previewId=IsoString())
Definition: ImageWindow.h:782
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:2152
static ImageWindow WindowById(const IsoString &id)
void HideTransparency()
Definition: ImageWindow.h:1905
int ViewportHeight() const
Definition: ImageWindow.h:2088
Point GlobalToViewport(const Point &p) const
Definition: ImageWindow.h:2691
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:2466
bool PreviewExists(const IsoString &previewId) const
Definition: ImageWindow.h:729
static void SetBackgroundBrush(background_brush brush, uint32 fgColor=0, uint32 bgColor=0)
bool IsAlphaChannelDisplayed() const
Definition: ImageWindow.h:1754
void EnableProofing(bool=true)
~ImageWindow() override
Definition: ImageWindow.h:420
void EnableGamutCheck(bool=true)
void InvertMask(bool invert=true)
Definition: ImageWindow.h:975
static bool IsDefaultICCProfileEmbeddingEnabledForRGBImages()
void ModifySelection(const Point &p, uint32 flags=0)
Definition: ImageWindow.h:2958
bool IsMaskVisible() const
Rect ViewportToGlobal(const Rect &r) const
Definition: ImageWindow.h:2670
bool HasPreviews() const
Definition: ImageWindow.h:698
bool IsVisible() const
void SetDynamicCursor(const Bitmap &bmp, int hx=0, int hy=0)
Point ViewportToGlobal(const Point &p) const
Definition: ImageWindow.h:2658
ImageWindow Mask() const
double ViewportScalarToImage(T d) const
Definition: ImageWindow.h:2511
void GetResolution(double &xRes, double &yRes, bool &metric) const
DRect ViewportToImage(const GenericRectangle< T > &r) const
Definition: ImageWindow.h:2426
static StringList SwapDirectories()
static void GetDefaultResolution(double &xRes, double &yRes, bool &metric)
Rect PreviewRect(const IsoString &previewId) const
bool IsTransparencyVisible() const
Definition: ImageWindow.h:1879
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:2343
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:1219
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:2125
static ProcessInterface * ActiveDynamicInterface()
int NumberOfPreviews() const
Rect ViewportUpdateRect() const
int ViewportWidth() const
Definition: ImageWindow.h:2078
Bitmap ViewportBitmap(int x0, int y0, int x1, int y1, uint32 flags=0) const
void UpdateImageRect(const pcl::DRect &r)
Definition: ImageWindow.h:2832
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:2597
mask_mode MaskMode() const
static void SelectMode(gui_mode mode)
void UpdateViewportRect(const Rect &r)
Definition: ImageWindow.h:2803
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:2143
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:826
void SetMask(ImageWindow &w, bool inverted=false)
void SelectPreview(View &)
static bool TerminateDynamicSession(bool closeInterface=true)
void DisableMask(bool disable=true)
Definition: ImageWindow.h:994
void UpdateMaskReferences()
void GlobalToViewport(int &x, int &y) const
void RegenerateImageRect(const pcl::DRect &r)
Definition: ImageWindow.h:2768
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:1147
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:2334
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:1967
transparency_mode TransparencyMode() const
Bitmap ViewportBitmap(const Rect &r, uint32 flags=0) const
Definition: ImageWindow.h:2893
void ViewportToImage(int &x, int &y) const
bool HasURL() const
Definition: ImageWindow.h:590
void SetViewportPosition(int x, int y)
View SelectedPreview() const
void SetZoomFactor(int z)
void SelectMainView()
Definition: ImageWindow.h:673
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:1526
bool CelestialToImage(double &ra, double &dec) const
bool ImageToCelestial(DPoint &pRD, const GenericPoint< T > &pI, bool rawRA=false) const
Definition: ImageWindow.h:1478
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