PCL
ImageWindow.h
Go to the documentation of this file.
1 // ____ ______ __
2 // / __ \ / ____// /
3 // / /_/ // / / /
4 // / ____// /___ / /___ PixInsight Class Library
5 // /_/ \____//_____/ PCL 02.01.12.0947
6 // ----------------------------------------------------------------------------
7 // pcl/ImageWindow.h - Released 2019-04-30T16:30:41Z
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-2019 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 (http://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;
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 
236 namespace UndoFlag
237 {
238  /*
239  * ### TODO: PCL 2.x: Get rid of all project depencies on UndoFlags.
240  */
241  enum mask_type
242  {
243  DefaultMode = 0x00000000, // Save pixel data, astrometric solution and previews
244  PixelData = 0x00000001, // Save pixel data
245  RGBWS = 0x00000002, // RGB Working Space data
246  ICCProfile = 0x00000004, // ICC profile
247  Keywords = 0x00000008, // %FITS keywords
248  //Metadata = 0x00000010, // ### DEPRECATED - Keep unused for now, for compatibility with existing projects
249  FormatData = 0x00000020, // Format-specific data
250  ImageId = 0x00000040, // %Image identifier
251  Resolution = 0x00000080, // %Image resolution
252  AstrometricSolution = 0x00000100, // Save the current astrometric solution
253  All = 0x000FFFFF, // Save all data items
254  ExcludePreviews = 0x80000000, // Don't save state of previews
255  ExcludeMaskRelations = 0x40000000 // Don't save masking dependencies
256  };
257 }
258 
264 
265 // ----------------------------------------------------------------------------
266 
267 #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
268 
269 // ----------------------------------------------------------------------------
270 
280 class PCL_CLASS ImageWindow : public UIObject
281 {
282 public:
283 
288  typedef ImageMode::value_type gui_mode;
289 
295  typedef DisplayChannel::value_type display_channel;
296 
302  typedef MaskMode::value_type mask_mode;
303 
309  typedef BackgroundBrush::value_type background_brush;
310 
316  typedef TransparencyMode::value_type transparency_mode;
317 
322  ImageWindow() = default;
323 
369  ImageWindow( int width, int height, int numberOfChannels = 1,
370  int bitsPerSample = 32, bool floatSample = true, bool color = false,
371  bool initialProcessing = true,
372  const IsoString& id = IsoString() );
373 
374  ImageWindow( int width, int height, int numberOfChannels,
375  int bitsPerSample, bool floatSample, bool color,
376  bool initialProcessing,
377  const IsoString::ustring_base& id ) :
378  ImageWindow( width, height, numberOfChannels, bitsPerSample, floatSample, color, initialProcessing, IsoString( id ) )
379  {
380  }
381 
393  ImageWindow( const ImageWindow& w ) : UIObject( w )
394  {
395  }
396 
400  ImageWindow( ImageWindow&& x ) : UIObject( std::move( x ) )
401  {
402  }
403 
411  virtual ~ImageWindow()
412  {
413  }
414 
426  ImageWindow& operator =( const ImageWindow& window )
427  {
428  Assign( window );
429  return *this;
430  }
431 
435  ImageWindow& operator =( ImageWindow&& x )
436  {
437  Transfer( x );
438  return *this;
439  }
440 
446  static ImageWindow& Null();
447 
522  static Array<ImageWindow> Open( const String& url,
523  const IsoString& id = IsoString(),
524  const IsoString& formatHints = IsoString(),
525  bool asCopy = false,
526  bool allowMessages = true );
527 
528  template <class S1, class S2>
529  static Array<ImageWindow> Open( const String& url,
530  const S1& id,
531  const S2& formatHints,
532  bool asCopy = false,
533  bool allowMessages = true )
534  {
535  return Open( url, IsoString( id ), IsoString( formatHints ), asCopy, allowMessages );
536  }
537 
543  bool IsNew() const;
544 
557  bool IsACopy() const;
558 
568  String FilePath() const;
569 
575  String FileURL() const;
576 
581  bool HasURL() const
582  {
583  return !FileURL().IsEmpty();
584  }
585 
590  ImageOptions FileInfo() const;
591 
597  size_type ModifyCount() const;
598 
603  bool IsModified() const
604  {
605  return ModifyCount() > 0;
606  }
607 
628  bool Close();
629 
637  void ForceClose();
638 
645  View MainView() const;
646 
654  View CurrentView() const;
655 
659  void SelectView( View& );
660 
665  {
666  View v( MainView() ); SelectView( v );
667  }
668 
672  void PurgeProperties();
673 
678  bool IsValidView( const View& ) const;
679 
683  int NumberOfPreviews() const;
684 
689  bool HasPreviews() const
690  {
691  return NumberOfPreviews() > 0;
692  }
693 
699  Array<View> Previews() const;
700 
708  View PreviewById( const IsoString& previewId ) const;
709 
710  View PreviewById( const IsoString::ustring_base& previewId ) const
711  {
712  return PreviewById( IsoString( previewId ) );
713  }
714 
720  bool PreviewExists( const IsoString& previewId ) const
721  {
722  return !IsNull() && !PreviewById( previewId ).IsNull();
723  }
724 
725  bool PreviewExists( const IsoString::ustring_base& previewId ) const
726  {
727  return PreviewExists( IsoString( previewId ) );
728  }
729 
741  View SelectedPreview() const;
742 
748  void SelectPreview( View& );
749 
755  void SelectPreview( const IsoString& previewId )
756  {
757  View v( PreviewById( previewId ) ), SelectPreview( v );
758  }
759 
760  void SelectPreview( const IsoString::ustring_base& previewId )
761  {
762  SelectPreview( IsoString( previewId ) );
763  }
764 
773  View CreatePreview( const Rect& r, const IsoString& previewId = IsoString() )
774  {
775  return CreatePreview( r.x0, r.y0, r.x1, r.y1, previewId );
776  }
777 
778  View CreatePreview( const Rect& r, const IsoString::ustring_base& previewId )
779  {
780  return CreatePreview( r, IsoString( previewId ) );
781  }
782 
802  View CreatePreview( int x0, int y0, int x1, int y1, const IsoString& previewId = IsoString() );
803 
804  View CreatePreview( int x0, int y0, int x1, int y1, const IsoString::ustring_base& previewId )
805  {
806  return CreatePreview( x0, y0, x1, y1, IsoString( previewId ) );
807  }
808 
817  void ModifyPreview( const IsoString& previewId, const Rect& r, const IsoString& newId = IsoString() )
818  {
819  ModifyPreview( previewId, r.x0, r.y0, r.x1, r.y1, newId );
820  }
821 
822  void ModifyPreview( const IsoString::ustring_base& previewId, const Rect& r )
823  {
824  ModifyPreview( IsoString( previewId ), r );
825  }
826 
827  void ModifyPreview( const IsoString::ustring_base& previewId, const Rect& r, const IsoString::ustring_base& newId )
828  {
829  ModifyPreview( IsoString( previewId ), r, IsoString( newId ) );
830  }
831 
854  void ModifyPreview( const IsoString& previewId, int x0, int y0, int x1, int y1,
855  const IsoString& newId = IsoString() );
856 
857  void ModifyPreview( const IsoString::ustring_base& previewId, int x0, int y0, int x1, int y1 )
858  {
859  ModifyPreview( IsoString( previewId ), x0, y0, x1, y1 );
860  }
861 
862  void ModifyPreview( const IsoString::ustring_base& previewId, int x0, int y0, int x1, int y1,
863  const IsoString::ustring_base& newId )
864  {
865  ModifyPreview( IsoString( previewId ), x0, y0, x1, y1, IsoString( newId ) );
866  }
867 
875  Rect PreviewRect( const IsoString& previewId ) const;
876 
877  Rect PreviewRect( const IsoString::ustring_base& previewId ) const
878  {
879  return PreviewRect( IsoString( previewId ) );
880  }
881 
891  void DeletePreview( const IsoString& previewId );
892 
893  void DeletePreview( const IsoString::ustring_base& previewId )
894  {
895  DeletePreview( IsoString( previewId ) );
896  }
897 
904  void DeletePreviews();
905 
917  void GetSampleFormat( int& bitsPerSample, bool& floatSample ) const;
918 
932  void SetSampleFormat( int bitsPerSample, bool floatSample );
933 
938  ImageWindow Mask() const;
939 
948  void SetMask( ImageWindow& w, bool inverted = false );
949 
953  void RemoveMask()
954  {
955  SetMask( Null() );
956  }
957 
961  bool IsMaskInverted() const;
962 
966  void InvertMask( bool invert = true )
967  {
968  ImageWindow mask = Mask();
969  SetMask( mask, invert );
970  }
971 
975  bool IsMaskEnabled() const;
976 
980  void EnableMask( bool = true );
981 
985  void DisableMask( bool disable = true )
986  {
987  EnableMask( !disable );
988  }
989 
993  bool IsMaskVisible() const;
994 
998  void ShowMask( bool = true );
999 
1003  void HideMask( bool hide = true )
1004  {
1005  ShowMask( !hide );
1006  }
1007 
1019  bool IsMaskCompatible( const ImageWindow& );
1020 
1025  bool HasMaskReferences() const;
1026 
1034  void RemoveMaskReferences();
1035 
1041  void UpdateMaskReferences();
1042 
1050  void GetRGBWS( RGBColorSystem& rgbws ) const;
1051 
1058  void SetRGBWS( const RGBColorSystem& rgbws );
1059 
1067  bool UsingGlobalRGBWS() const;
1068 
1075  void UseGlobalRGBWS();
1076 
1089  static void GetGlobalRGBWS( RGBColorSystem& rgbws );
1090 
1101  static void SetGlobalRGBWS( const RGBColorSystem& rgbws );
1102 
1106  bool IsColorManagementEnabled() const;
1107 
1127  void EnableColorManagement( bool = true );
1128 
1138  void DisableColorManagement( bool disable = true )
1139  {
1140  EnableColorManagement( !disable );
1141  }
1142 
1147  bool IsProofingEnabled() const;
1148 
1162  void EnableProofing( bool = true );
1163 
1173  void DisableProofing( bool disable = true )
1174  {
1175  EnableProofing( !disable );
1176  }
1177 
1182  bool IsGamutCheckEnabled() const;
1183 
1197  void EnableGamutCheck( bool = true );
1198 
1210  void DisableGamutCheck( bool disable = true )
1211  {
1212  EnableGamutCheck( !disable );
1213  }
1214 
1232  void SetColorManagementFeatures( bool cmEnabled, bool proofing, bool gamutCheck );
1233 
1240  bool GetICCProfile( ICCProfile& icc ) const;
1241 
1252  void SetICCProfile( const ICCProfile& icc );
1253 
1264  void SetICCProfile( const String& filePath );
1265 
1276  void DeleteICCProfile();
1277 
1283  FITSKeywordArray Keywords() const;
1284 
1295  bool GetKeywords( FITSKeywordArray& keywords ) const
1296  {
1297  keywords = Keywords();
1298  return !keywords.IsEmpty();
1299  }
1300 
1311  void SetKeywords( const FITSKeywordArray& keywords );
1312 
1316  void ResetKeywords();
1317 
1323  bool HasAstrometricSolution() const;
1324 
1345  bool RegenerateAstrometricSolution( bool allowGUIMessages = true, bool notify = true );
1346 
1359  void ClearAstrometricSolution( bool notify = true );
1360 
1374  void UpdateAstrometryMetadata( bool notify = true );
1375 
1394  void GetResolution( double& xRes, double& yRes, bool& metric ) const;
1395 
1410  void SetResolution( double xRes, double yRes, bool metric = false );
1411 
1425  void SetResolution( double r, bool metric = false )
1426  {
1427  SetResolution( r, r, metric );
1428  }
1429 
1451  static void GetDefaultResolution( double& xRes, double& yRes, bool& metric );
1452 
1465  static bool IsDefaultICCProfileEmbeddingEnabledForRGBImages();
1466 
1479  static bool IsDefaultICCProfileEmbeddingEnabledForGrayscaleImages();
1480 
1491  static bool IsDefaultThumbnailEmbeddingEnabled();
1492 
1503  static bool IsDefaultPropertiesEmbeddingEnabled();
1504 
1518  static StringList SwapDirectories();
1519 
1542  static bool SetSwapDirectories( const StringList& directories );
1543 
1558  static int CursorTolerance();
1559 
1566  static gui_mode CurrentMode();
1567 
1578  static void SelectMode( gui_mode mode );
1579 
1586  display_channel CurrentChannel() const;
1587 
1593  {
1594  return CurrentChannel() >= DisplayChannel::Alpha;
1595  }
1596 
1607  {
1608  return CurrentChannel() - DisplayChannel::Alpha;
1609  }
1610 
1625  void SelectChannel( display_channel c );
1626 
1632  mask_mode MaskMode() const;
1633 
1642  void SetMaskMode( mask_mode mode );
1643 
1666  static background_brush GetBackgroundBrush( uint32& fgColor, uint32& bgColor );
1667 
1691  static void SetBackgroundBrush( background_brush brush, uint32 fgColor = 0, uint32 bgColor = 0 );
1692 
1699  transparency_mode TransparencyMode() const;
1700 
1708  RGBA TransparencyColor() const;
1709 
1718  {
1719  return TransparencyMode() != pcl::TransparencyMode::Hide;
1720  }
1721 
1734  void SetTransparencyMode( transparency_mode mode, RGBA color = 0 );
1735 
1744  {
1745  SetTransparencyMode( pcl::TransparencyMode::Hide );
1746  }
1747 
1793  void SetViewport( double cx, double cy, int zoom = 0 );
1794 
1805  void SetViewport( const DPoint& center, int zoom = 0 )
1806  {
1807  SetViewport( center.x, center.y, zoom );
1808  }
1809 
1819  void FitWindow();
1820 
1830  void ZoomToFit( bool allowMagnification = true );
1831 
1838  int ZoomFactor() const;
1839 
1847  void SetZoomFactor( int z );
1848 
1855  void ZoomIn()
1856  {
1857  int z = ZoomFactor() + 1;
1858  SetZoomFactor( (z > 0) ? z : +1 );
1859  }
1860 
1867  void ZoomOut()
1868  {
1869  int z = ZoomFactor() - 1;
1870  SetZoomFactor( (z > 0 || z < -1) ? z : -2 );
1871  }
1872 
1887  void GetViewportSize( int& width, int& height ) const;
1888 
1892  int ViewportWidth() const
1893  {
1894  int w, dum;
1895  GetViewportSize( w, dum );
1896  return w;
1897  }
1898 
1902  int ViewportHeight() const
1903  {
1904  int dum, h;
1905  GetViewportSize( dum, h );
1906  return h;
1907  }
1908 
1918  Point ViewportPosition() const;
1919 
1929  void SetViewportPosition( int x, int y );
1930 
1939  void SetViewportPosition( const Point& p )
1940  {
1941  SetViewportPosition( p.x, p.y );
1942  }
1943 
1951  Rect VisibleViewportRect() const;
1952 
1958  {
1959  return VisibleViewportRect().Width();
1960  }
1961 
1967  {
1968  return VisibleViewportRect().Height();
1969  }
1970 
1974  bool IsVisible() const;
1975 
1979  void Show();
1980 
1984  void Hide();
1985 
1989  bool IsIconic() const;
1990 
1994  void Iconize();
1995 
1999  void Deiconize();
2000 
2010  void BringToFront();
2011 
2022  void SendToBack();
2023 
2032  static bool IsDynamicSessionActive();
2033 
2048  static ProcessInterface* ActiveDynamicInterface();
2049 
2064  static bool TerminateDynamicSession( bool closeInterface = true );
2065 
2084  void SetDynamicCursor( const char** xpm, int hx = 0, int hy = 0 );
2085 
2098  void SetDynamicCursor( const char** xpm, const Point& p )
2099  {
2100  SetDynamicCursor( xpm, p.x, p.y );
2101  }
2102 
2125  void SetDynamicCursor( const Bitmap& bmp, int hx = 0, int hy = 0 );
2126 
2135  void SetDynamicCursor( const Bitmap& bmp, const Point& p )
2136  {
2137  SetDynamicCursor( bmp, p.x, p.y );
2138  }
2139 
2145  {
2146  SetDynamicCursor( Bitmap::Null() );
2147  }
2148 
2153  Bitmap DynamicCursorBitmap() const;
2154 
2161  Point DynamicCursorHotSpot() const;
2162 
2192  double DisplayPixelRatio() const;
2193 
2200  void ViewportToImage( int& x, int& y ) const;
2201 
2206  void ViewportToImage( double& x, double& y ) const;
2207 
2213  template <typename T>
2215  {
2216  DPoint p1 = p;
2217  ViewportToImage( p1.x, p1.y );
2218  return p1;
2219  }
2220 
2226  template <typename T>
2228  {
2229  DRect r1 = r;
2230  ViewportToImage( r1.x0, r1.y0 );
2231  ViewportToImage( r1.x1, r1.y1 );
2232  return r1;
2233  }
2234 
2246  void ViewportToImage( Point* p, size_type n ) const;
2247 
2257  void ViewportToImage( DPoint* p, size_type n ) const;
2258 
2266  template <typename T>
2268  {
2269  ViewportToImage( a.Begin(), a.Length() );
2270  }
2271 
2285  void ViewportScalarToImage( int* d, size_type n ) const;
2286 
2297  void ViewportScalarToImage( double* d, size_type n ) const;
2298 
2304  double ViewportScalarToImage( double d ) const;
2305 
2311  template <typename T>
2312  double ViewportScalarToImage( T d ) const
2313  {
2314  return ViewportScalarToImage( double( d ) );
2315  }
2316 
2323  void ImageToViewport( int& x, int& y ) const;
2324 
2329  void ImageToViewport( double& x, double& y ) const;
2330 
2340  template <typename T>
2342  {
2343  GenericPoint<T> p1 = p;
2344  ImageToViewport( p1.x, p1.y );
2345  return p1;
2346  }
2347 
2357  template <typename T>
2359  {
2360  GenericRectangle<T> r1 = r;
2361  ImageToViewport( r1.x0, r1.y0 );
2362  ImageToViewport( r1.x1, r1.y1 );
2363  return r1;
2364  }
2365 
2377  void ImageToViewport( Point* p, size_type n ) const;
2378 
2388  void ImageToViewport( DPoint* p, size_type n ) const;
2389 
2397  template <typename T>
2399  {
2400  ImageToViewport( a.Begin(), a.Length() );
2401  }
2402 
2416  void ImageScalarToViewport( int* d, size_type n ) const;
2417 
2428  void ImageScalarToViewport( double* d, size_type n ) const;
2429 
2438  int ImageScalarToViewport( int ) const;
2439 
2445  double ImageScalarToViewport( double ) const;
2446 
2453  void ViewportToGlobal( int& x, int& y ) const;
2454 
2459  Point ViewportToGlobal( const Point& p ) const
2460  {
2461  Point p1 = p;
2462  ViewportToGlobal( p1.x, p1.y );
2463  return p1;
2464  }
2465 
2471  Rect ViewportToGlobal( const Rect& r ) const
2472  {
2473  Rect r1 = r;
2474  ViewportToGlobal( r1.x0, r1.y0 );
2475  ViewportToGlobal( r1.x1, r1.y1 );
2476  return r1;
2477  }
2478 
2485  void GlobalToViewport( int& x, int& y ) const;
2486 
2492  Point GlobalToViewport( const Point& p ) const
2493  {
2494  Point p1 = p;
2495  GlobalToViewport( p1.x, p1.y );
2496  return p1;
2497  }
2498 
2504  Rect GlobalToViewport( const Rect& r ) const
2505  {
2506  Rect r1 = r;
2507  GlobalToViewport( r1.x0, r1.y0 );
2508  GlobalToViewport( r1.x1, r1.y1 );
2509  return r1;
2510  }
2511 
2520  void Reset()
2521  {
2522  SetZoomFactor( ZoomFactor() );
2523  }
2524 
2530  void Regenerate();
2531 
2540  void RegenerateViewportRect( const Rect& r )
2541  {
2542  RegenerateViewportRect( r.x0, r.y0, r.x1, r.y1 );
2543  }
2544 
2559  void RegenerateViewportRect( int x0, int y0, int x1, int y1 );
2560 
2570  {
2571  RegenerateImageRect( r.x0, r.y0, r.x1, r.y1 );
2572  }
2573 
2588  void RegenerateImageRect( double x0, double y0, double x1, double y1 );
2589 
2594  void UpdateViewport();
2595 
2604  void UpdateViewportRect( const Rect& r )
2605  {
2606  UpdateViewportRect( r.x0, r.y0, r.x1, r.y1 );
2607  }
2608 
2623  void UpdateViewportRect( int x0, int y0, int x1, int y1 );
2624 
2633  void UpdateImageRect( const pcl::DRect& r )
2634  {
2635  UpdateImageRect( r.x0, r.y0, r.x1, r.y1 );
2636  }
2637 
2653  void UpdateImageRect( double x0, double y0, double x1, double y1 );
2654 
2658  bool HasPendingUpdates() const;
2659 
2678  void CommitPendingUpdates();
2679 
2684  Rect ViewportUpdateRect() const;
2685 
2694  Bitmap ViewportBitmap( const Rect& r, uint32 flags = 0 ) const
2695  {
2696  return ViewportBitmap( r.x0, r.y0, r.x1, r.y1, flags );
2697  }
2698 
2718  Bitmap ViewportBitmap( int x0, int y0, int x1, int y1, uint32 flags = 0 ) const;
2719 
2728  void BeginSelection( const Point& p, uint32 flags = 0 )
2729  {
2730  BeginSelection( p.x, p.y, flags );
2731  }
2732 
2749  void BeginSelection( int x, int y, uint32 flags = 0 );
2750 
2759  void ModifySelection( const Point& p, uint32 flags = 0 )
2760  {
2761  ModifySelection( p.x, p.y, flags );
2762  }
2763 
2777  void ModifySelection( int x, int y, uint32 flags = 0 );
2778 
2782  void UpdateSelection();
2783 
2787  void CancelSelection();
2788 
2792  void EndSelection();
2793 
2803  Rect SelectionRect( uint32* flags = nullptr ) const;
2804 
2809  bool IsSelection() const;
2810 
2816  static ImageWindow WindowById( const IsoString& id );
2817 
2818  static ImageWindow WindowById( const IsoString::ustring_base& id )
2819  {
2820  return WindowById( IsoString( id ) );
2821  }
2822 
2828  static ImageWindow WindowByFilePath( const String& filePath );
2829 
2840  static ImageWindow ActiveWindow();
2841 
2849  static Array<ImageWindow> AllWindows( bool includeIconicWindows = true );
2850 
2851 private:
2852 
2853  ImageWindow( void* h ) : UIObject( h )
2854  {
2855  }
2856 
2857  friend class View;
2858  friend class ProcessInstance; // for IsMaskable()
2859  friend class ProcessContextDispatcher;
2860  friend class InternalWindowEnumerator;
2861 };
2862 
2863 // ----------------------------------------------------------------------------
2864 
2865 #endif // !__PCL_BUILDING_PIXINSIGHT_APPLICATION
2866 
2867 } // pcl
2868 
2869 #endif // __PCL_ImageWindow_h
2870 
2871 // ----------------------------------------------------------------------------
2872 // EOF pcl/ImageWindow.h - Released 2019-04-30T16:30:41Z
Client-side interface to a PixInsight Bitmap object.
Definition: Bitmap.h:158
ImageWindow(ImageWindow &&x)
Definition: ImageWindow.h:400
uint32 RGBA
Definition: Color.h:92
Format-independent fundamental image stream options.
Definition: ImageOptions.h:97
int VisibleViewportWidth() const
Definition: ImageWindow.h:1957
int ViewportWidth() const
Definition: ImageWindow.h:1892
A collection of history data item specifiers.
A generic point in the two-dimensional space.
Definition: Point.h:99
void DisableColorManagement(bool disable=true)
Definition: ImageWindow.h:1138
bool HasPreviews() const
Definition: ImageWindow.h:689
DisplayChannel::value_type display_channel
Definition: ImageWindow.h:295
void HideMask(bool hide=true)
Definition: ImageWindow.h:1003
Point GlobalToViewport(const Point &p) const
Definition: ImageWindow.h:2492
MaskMode::value_type mask_mode
Definition: ImageWindow.h:302
PCL root namespace.
Definition: AbstractImage.h:76
void HideTransparency()
Definition: ImageWindow.h:1743
void DisableProofing(bool disable=true)
Definition: ImageWindow.h:1173
void UpdateViewportRect(const Rect &r)
Definition: ImageWindow.h:2604
DPoint ViewportToImage(const GenericPoint< T > &p) const
Definition: ImageWindow.h:2214
A colorimetrically defined RGB working color space.
A type-safe collection of enumerated flags.
Definition: Flags.h:84
bool IsEmpty() const
Definition: String.h:785
Bitmap ViewportBitmap(const Rect &r, uint32 flags=0) const
Definition: ImageWindow.h:2694
Root base class for all user interface objects.
Definition: UIObject.h:94
void SetDynamicCursor(const Bitmap &bmp, const Point &p)
Definition: ImageWindow.h:2135
DRect ViewportToImage(const GenericRectangle< T > &r) const
Definition: ImageWindow.h:2227
Client-side interface to a PixInsight process interface window.
bool IsAlphaChannelDisplayed() const
Definition: ImageWindow.h:1592
component x1
Horizontal coordinate of the lower right corner.
Definition: Rectangle.h:334
Rect GlobalToViewport(const Rect &r) const
Definition: ImageWindow.h:2504
Rect ViewportToGlobal(const Rect &r) const
Definition: ImageWindow.h:2471
A generic rectangle in the two-dimensional space.
Definition: Rectangle.h:313
size_t size_type
Definition: Defs.h:545
64-bit floating-point rectangle in the R^2 space.
int VisibleViewportHeight() const
Definition: ImageWindow.h:1966
ImageWindow(const ImageWindow &w)
Definition: ImageWindow.h:393
void ModifyPreview(const IsoString &previewId, const Rect &r, const IsoString &newId=IsoString())
Definition: ImageWindow.h:817
void SelectPreview(const IsoString &previewId)
Definition: ImageWindow.h:755
Unicode (UTF-16) string.
Definition: String.h:7911
void ViewportToImage(Array< GenericPoint< T > > &a) const
Definition: ImageWindow.h:2267
component x
Abscissa (horizontal, or X-axis coordinate).
Definition: Point.h:111
void SetResolution(double r, bool metric=false)
Definition: ImageWindow.h:1425
Platform-independent information on file and directory items.
Definition: FileInfo.h:73
void UpdateImageRect(const pcl::DRect &r)
Definition: ImageWindow.h:2633
void SelectMainView()
Definition: ImageWindow.h:664
bool IsValidMainViewMode(value_type m)
Definition: ImageWindow.h:135
double ViewportScalarToImage(T d) const
Definition: ImageWindow.h:2312
A high-level interface to ICC color profiles.
Definition: ICCProfile.h:234
void RegenerateViewportRect(const Rect &r)
Definition: ImageWindow.h:2540
GenericPoint< T > ImageToViewport(const GenericPoint< T > &p) const
Definition: ImageWindow.h:2341
bool IsNull() const
Definition: UIObject.h:113
static Bitmap & Null()
Dynamic list of Unicode (UTF-16) strings.
void DisableGamutCheck(bool disable=true)
Definition: ImageWindow.h:1210
TransparencyMode::value_type transparency_mode
Definition: ImageWindow.h:316
bool IsValidPreviewMode(value_type m)
Definition: ImageWindow.h:126
Point ViewportToGlobal(const Point &p) const
Definition: ImageWindow.h:2459
virtual ~ImageWindow()
Definition: ImageWindow.h:411
ImageMode::value_type gui_mode
Definition: ImageWindow.h:288
Generic dynamic array.
Definition: Array.h:99
void RegenerateImageRect(const pcl::DRect &r)
Definition: ImageWindow.h:2569
bool HasURL() const
Definition: ImageWindow.h:581
void ImageToViewport(Array< GenericPoint< T > > &a) const
Definition: ImageWindow.h:2398
int ViewportHeight() const
Definition: ImageWindow.h:1902
void SetViewportPosition(const Point &p)
Definition: ImageWindow.h:1939
component x0
Horizontal coordinate of the upper left corner.
Definition: Rectangle.h:332
int CurrentAlphaChannel() const
Definition: ImageWindow.h:1606
High-level interface to a PixInsight view object.
Definition: View.h:167
void InvertMask(bool invert=true)
Definition: ImageWindow.h:966
bool GetKeywords(FITSKeywordArray &keywords) const
Definition: ImageWindow.h:1295
64-bit floating-point point in the R^2 space.
bool IsTransparencyVisible() const
Definition: ImageWindow.h:1717
32-bit integer point on the plane.
void ResetDynamicCursor()
Definition: ImageWindow.h:2144
bool PreviewExists(const IsoString &previewId) const
Definition: ImageWindow.h:720
GenericRectangle< T > ImageToViewport(const GenericRectangle< T > &r) const
Definition: ImageWindow.h:2358
bool IsModified() const
Definition: ImageWindow.h:603
component y0
Vertical coordinate of the upper left corner.
Definition: Rectangle.h:333
High-level interface to a process instance.
component y
Ordinate (vertical, or Y-axis coordinate).
Definition: Point.h:112
void DisableMask(bool disable=true)
Definition: ImageWindow.h:985
void BeginSelection(const Point &p, uint32 flags=0)
Definition: ImageWindow.h:2728
unsigned int uint32
Definition: Defs.h:602
View CreatePreview(const Rect &r, const IsoString &previewId=IsoString())
Definition: ImageWindow.h:773
32-bit integer rectangle on the plane.
void SetDynamicCursor(const char **xpm, const Point &p)
Definition: ImageWindow.h:2098
void ModifySelection(const Point &p, uint32 flags=0)
Definition: ImageWindow.h:2759
High-level interface to an image window object in the PixInsight core application.
Definition: ImageWindow.h:280
component y1
Vertical coordinate of the lower right corner.
Definition: Rectangle.h:335
Dynamic array of FITS header keywords.
void SetViewport(const DPoint &center, int zoom=0)
Definition: ImageWindow.h:1805
BackgroundBrush::value_type background_brush
Definition: ImageWindow.h:309
Eight-bit string (ISO/IEC-8859-1 or UTF-8 string)
Definition: String.h:5387