wxMaxima
Loading...
Searching...
No Matches
BitmapOut.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 BITMAPOUT_H
24#define BITMAPOUT_H
25
26#include "OutCommon.h"
27#include <functional>
28
34//cppcheck-suppress ODR
35class BitmapOut final
36{
37public:
45 explicit BitmapOut(const Configuration * const *configuration, double scale = 1);
47 explicit BitmapOut(const Configuration * const *configuration, std::unique_ptr<Cell> &&tree, double scale = 1, long maxSize = -1);
48 ~BitmapOut();
49
58 bool Render(std::unique_ptr<Cell> &&tree, long int maxSize = -1);
59
69 static constexpr long CLIPBOARD_MAX_PIXELS = 32000000;
70
82 static wxBitmap RenderForClipboard(const Configuration * const *configuration,
83 const std::function<std::unique_ptr<Cell>()> &cells,
84 double scale);
85
87 bool IsOk() const { return m_isOk; }
88
93 wxSize ToFile(const wxString &file);
94
96 wxBitmap GetBitmap() const { return m_bmp; }
97
98 std::unique_ptr<wxBitmapDataObject> GetDataObject() const;
99
101 bool ToClipboard() const;
102
103private:
104 std::unique_ptr<Cell> m_tree;
105 OutCommon m_cmn;
106 wxBitmap m_bmp;
107 wxMemoryDC m_dc;
108 bool m_isOk = false;
109
110 bool Layout(long int maxSize = -1);
111 void Draw();
112};
113
114#endif // BITMAPOUT_H
This is the header for common code used by various file output modules that render cells to files.
Renders portions of the work sheet (including 2D maths) as bitmap.
Definition: BitmapOut.h:36
wxSize ToFile(const wxString &file)
Exports this bitmap to a file.
Definition: BitmapOut.cpp:157
static constexpr long CLIPBOARD_MAX_PIXELS
The largest bitmap, in pixels, that is put on the clipboard.
Definition: BitmapOut.h:69
bool ToClipboard() const
Copies the bitmap representation of the list of cells that was passed to SetData()
Definition: BitmapOut.cpp:199
wxBitmap GetBitmap() const
Returns the bitmap representation of the list of cells that was passed to SetData()
Definition: BitmapOut.h:96
bool Render(std::unique_ptr< Cell > &&tree, long int maxSize=-1)
Renders tree as bitmap.
Definition: BitmapOut.cpp:63
static wxBitmap RenderForClipboard(const Configuration *const *configuration, const std::function< std::unique_ptr< Cell >()> &cells, double scale)
Draws cells as a bitmap for the clipboard.
Definition: BitmapOut.cpp:120
bool IsOk() const
Returns whether the tree rendering succeeded.
Definition: BitmapOut.h:87
The configuration storage for the current worksheet.
Definition: Configuration.h:101
A collection of common code used in rendering the cells to a non-default output, e....
Definition: OutCommon.h:43