PCL
SVG.h
Go to the documentation of this file.
1 // ____ ______ __
2 // / __ \ / ____// /
3 // / /_/ // / / /
4 // / ____// /___ / /___ PixInsight Class Library
5 // /_/ \____//_____/ PCL 2.7.0
6 // ----------------------------------------------------------------------------
7 // pcl/SVG.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_SVG_h
53 #define __PCL_SVG_h
54 
56 
57 #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
58 
59 #include <pcl/Defs.h>
60 
61 #include <pcl/ByteArray.h>
62 #include <pcl/Rectangle.h>
63 #include <pcl/UIObject.h>
64 
65 namespace pcl
66 {
67 
68 // ----------------------------------------------------------------------------
69 
80 class PCL_CLASS SVG : public UIObject
81 {
82 public:
83 
91  SVG( const String& filePath, int width = 0, int height = 0 );
92 
100  SVG( int width = 0, int height = 0 );
101 
105  ~SVG() override
106  {
107  }
108 
113  static SVG& Null();
114 
118  void GetDimensions( int& width, int& height ) const;
119 
123  void SetDimensions( int width, int height ) const;
124 
128  int Width() const
129  {
130  int w, dum; GetDimensions( w, dum ); return w;
131  }
132 
136  int Height() const
137  {
138  int dum, h; GetDimensions( dum, h ); return h;
139  }
140 
145  Rect Bounds() const
146  {
147  int w, h; GetDimensions( w, h ); return Rect( w, h );
148  }
149 
155  DRect ViewBox() const;
156 
168  void SetViewBox( double x0, double y0, double x1, double y1 );
169 
174  template <typename T>
176  {
177  SetViewBox( double( r.x0 ), double( r.y0 ), double( r.x1 ), double( r.y1 ) );
178  }
179 
183  int Resolution() const;
184 
188  void SetResolution( int r );
189 
195  String FilePath() const;
196 
203  ByteArray Data() const;
204 
208  String Title() const;
209 
217  void SetTitle( const String& title );
218 
223 
231  void SetDescription( const String& desc );
232 
237  bool IsPainting() const;
238 
239 protected:
240 
241  SVG( void* h ) : UIObject( h )
242  {
243  }
244 
245  void* CloneHandle() const override;
246 
247  friend class GraphicsContextBase;
248 };
249 
250 // ----------------------------------------------------------------------------
251 
252 } // pcl
253 
254 #endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION
255 
256 #endif // __PCL_SVG_h
257 
258 // ----------------------------------------------------------------------------
259 // EOF pcl/SVG.h - Released 2024-06-18T15:48:54Z
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
Base class of client-side interface classes to PixInsight graphics contexts
Definition: Graphics.h:208
Scalable Vector Graphics generation.
Definition: SVG.h:81
int Resolution() const
~SVG() override
Definition: SVG.h:105
void SetResolution(int r)
void SetViewBox(const GenericRectangle< T > &r)
Definition: SVG.h:175
void SetViewBox(double x0, double y0, double x1, double y1)
void GetDimensions(int &width, int &height) const
static SVG & Null()
SVG(int width=0, int height=0)
String Description() const
DRect ViewBox() const
String FilePath() const
bool IsPainting() const
Rect Bounds() const
Definition: SVG.h:145
void SetTitle(const String &title)
int Width() const
Definition: SVG.h:128
void SetDimensions(int width, int height) const
void SetDescription(const String &desc)
ByteArray Data() const
SVG(const String &filePath, int width=0, int height=0)
int Height() const
Definition: SVG.h:136
String Title() const
Unicode (UTF-16) string.
Definition: String.h:8113
Root base class for all user interface objects.
Definition: UIObject.h:95
PCL root namespace.
Definition: AbstractImage.h:77