wxMaxima
SVGout.h
1 // -*- mode: c++; c-file-style: "linux"; c-basic-offset: 2; indent-tabs-mode: nil -*-
2 //
3 // Copyright (C) 2004-2015 Andrej Vodopivec <andrej.vodopivec@gmail.com>
4 // Copyright (C) 2015 Gunter Königsmann <wxMaxima@physikbuch.de>
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 //
21 // SPDX-License-Identifier: GPL-2.0+
22 
23 #ifndef SVGOUT_H
24 #define SVGOUT_H
25 
26 #include "OutCommon.h"
27 #include "precomp.h"
28 #include <wx/dcsvg.h>
29 #include <memory>
30 
31 /* Renders portions of the work sheet (including 2D maths) as svg.
32 
33  This is used for exporting HTML with embedded maths as a scalable vector
34  graphics and for them on the clipboard
35  */
36 class Svgout final
37 {
38 public:
41  explicit Svgout(Configuration **configuration, const wxString &filename = {}, double scale = 1.0);
42  explicit Svgout(Configuration **configuration, std::unique_ptr<Cell> &&tree,
43  const wxString &filename = {}, double scale = 1.0);
44  ~Svgout();
45 
51  wxSize Render(std::unique_ptr<Cell> &&tree);
52 
53  wxSize GetSize() const { return m_size; }
54  bool IsOk() const { return m_isOk; }
55 
57  bool ToClipboard();
58 
60  std::unique_ptr<wxCustomDataObject> GetDataObject();
61 
62 private:
63  std::unique_ptr<Cell> m_tree;
64  OutCommon m_cmn;
65  wxSVGFileDC m_recalculationDc;
66  wxSize m_size = wxDefaultSize;
67  bool m_isOk = false;
68 
75  wxString m_CWD;
76 
77  bool Layout();
78 };
79 
80 #endif // SVGOUT_H
Svgout::ToClipboard
bool ToClipboard()
Copies the svg representation of the list of cells that was passed to SetData()
Definition: SVGout.cpp:107
Svgout
Definition: SVGout.h:36
Svgout::Svgout
Svgout(Configuration **configuration, const wxString &filename={}, double scale=1.0)
Definition: SVGout.cpp:38
OutCommon
Definition: OutCommon.h:42
Configuration
Definition: Configuration.h:83
Svgout::Render
wxSize Render(std::unique_ptr< Cell > &&tree)
Definition: SVGout.cpp:68
OutCommon.h
Svgout::GetDataObject
std::unique_ptr< wxCustomDataObject > GetDataObject()
Returns the svg representation in a format that can be placed on the clipBoard.
Definition: SVGout.cpp:102