38#include "Configuration.h"
41#include <wx/zipstrm.h>
42#include <wx/wfstream.h>
43#include <wx/bmpbndl.h>
104 m_loadImageTask->Wait();
105 m_configuration = config; }
109 m_loadImageTask->Wait();
114 m_loadImageTask->Wait();
119 void GenerateInvalidBitmap();
121 wxString m_invalidBitmapMessage;
122 bool m_isInvalid =
false;
151 m_loadImageTask->Wait();
152 return m_loadFailureKind;
161 void GnuplotSource(wxString gnuplotFilename, wxString dataFilename,
193 const wxMemoryBuffer GetCompressedGnuplotSource();
196 const wxMemoryBuffer GetCompressedGnuplotData();
205 m_loadImageTask->Wait();
209 if (m_scaledBitmap.IsOk() &&
210 ((m_scaledBitmap.GetWidth() > 1) || (m_scaledBitmap.GetHeight() > 1)))
211 m_scaledBitmap.Create(1, 1);
214 m_svgBundle = wxBitmapBundle();
224 m_loadImageTask->Wait();
229 m_loadImageTask->Wait();
234 m_loadImageTask->Wait();
240 m_loadImageTask->Wait();
241 m_maxHeight = height;
281 m_loadImageTask->Wait();
290 bool HasGnuplotSource()
const {
return m_gnuplotSource_Compressed.GetDataLen() > 20;}
292 bool m_fromWxFS =
false;
294 wxMemoryBuffer m_gnuplotSource_Compressed;
296 wxMemoryBuffer m_gnuplotData_Compressed;
298 std::size_t m_originalWidth = 640;
300 std::size_t m_originalHeight = 480;
302 wxBitmap m_scaledBitmap;
304 wxString m_extension;
306 wxString m_gnuplotSource;
308 wxString m_gnuplotData;
310 mutable std::shared_ptr<BackgroundTask> m_loadImageTask;
311 void LoadImage_Backgroundtask(
stop_token stopToken,
316 std::shared_ptr<BackgroundTask> m_loadGnuplotSourceTask;
317 void LoadGnuplotSource_Backgroundtask(
320 void LoadGnuplotSource(wxInputStream *source);
321 void LoadGnuplotData(wxInputStream *data);
322 void LoadGnuplotSource_Backgroundtask_internal(
323 wxInputStream *source,
324 wxInputStream *data);
327 void LoadCompressedGnuplotSource_Backgroundtask(
stop_token stopToken,
335 wxMemoryBuffer ReadCompressedImage(
stop_token stopToken, wxInputStream *data);
337 void RecordDataUnavailable(
const wxString &message);
345 void RecordDecodeFailure(
const wxString &message,
bool missingCodec);
350 wxCoord m_maxWidth = -1;
352 wxCoord m_maxHeight = -1;
354 wxString m_imageName;
358 bool IsSvg()
const {
return m_extension == wxS(
"svgz"); }
366 const wxBitmapBundle &SvgBundle();
368 wxBitmap SvgBitmapAt(wxSize size);
370 wxBitmapBundle m_svgBundle;
Where the files a worksheet's XML refers to (images, gnuplot sources and data) can be read from.
A priority work-queue thread pool for offloading work to background threads.
Small compatibility shims for older toolchains and older wxWidgets.
The files a worksheet's XML refers to by name.
Definition: AttachmentSource.h:49
The configuration storage for the current worksheet.
Definition: Configuration.h:101
Manages an auto-scaling image.
Definition: Image.h:70
void SetMaxWidth(double width)
Set the maximum width this image shall be displayed with.
Definition: Image.h:232
double GetHeightList() const
The maximum height this image shall be displayed with.
Definition: Image.h:227
void LoadImage(const wxBitmap &bitmap)
"Loads" an image from a bitmap
Definition: Image.cpp:786
void Recalculate(double scale=1.0)
Can be called to specify a specific scale.
Definition: Image.cpp:999
int GetPPI() const
Return the image's resolution.
Definition: Image.h:107
wxString GnuplotSource()
Returns the gnuplot source file name of this image.
Definition: Image.cpp:516
const wxMemoryBuffer GetGnuplotSource()
Returns the gnuplot source of this image.
Definition: Image.cpp:406
std::size_t GetOriginalWidth() const
Returns the original width.
Definition: Image.cpp:203
std::size_t GetOriginalHeight() const
Returns the original height.
Definition: Image.cpp:210
static const wxString GetBadImageToolTip()
The tooltip to use wherever an image that's not Ok is shown.
Definition: Image.cpp:1092
long m_height
The height of the scaled image.
Definition: Image.h:262
const wxMemoryBuffer GetGnuplotData()
Returns the gnuplot data of this image.
Definition: Image.cpp:451
void CompressedGnuplotSource(wxString gnuplotFilename, wxString dataFilename, const AttachmentSource &attachments={})
Loads the compressed gnuplot source and data file for this image.
Definition: Image.cpp:279
long m_width
The width of the scaled image.
Definition: Image.h:260
wxString GetExtension() const
Returns the file name extension of the current image.
Definition: Image.cpp:805
void InvalidBitmap(const wxString &message=wxEmptyString)
Creates a bitmap showing an error message.
Definition: Image.cpp:707
LoadFailureKind GetLoadFailureKind() const
Blocks until this image's background load task (if any) has finished, then reports why it ended up in...
Definition: Image.h:149
const wxMemoryBuffer GetCompressedImage() const
Returns the original image in its compressed form.
Definition: Image.cpp:197
bool CanExportSVG() const
Can this image be exported in SVG format?
Definition: Image.h:279
bool HoldsSvgRendering() const
True while this SVG image keeps its parsed document and a rendering in memory.
Definition: Image.h:218
LoadFailureKind
Why the most recent load attempt left this image invalid, if it did.
Definition: Image.h:125
@ MissingCodec
Data was read fine, but this wxWidgets build has no decoder registered for the format at all (e....
@ DecodeFailed
Data was read fine and a decoder exists for the format (or it's an SVG, parsed by our own vendored co...
@ DataUnavailable
Raw data could never be obtained at all (file not found, empty wxmx entry, ...). Always a real failur...
static bool IsSafePath(const wxString &path)
Returns true if the path is in a safe (temporary) directory for deletion.
Definition: Image.cpp:1073
void SetPPI(int ppi)
Set the image's resolution.
Definition: Image.h:112
wxMemoryBuffer m_compressedImage
The image in its original compressed form.
Definition: Image.h:276
void SetMaxHeight(double height)
Set the maximum height this image shall be displayed with.
Definition: Image.h:238
wxSize ToImageFile(wxString filename)
Saves the image in its original form, or as .png if it originates in a bitmap.
Definition: Image.cpp:557
double GetMaxWidth() const
The maximum width this image shall be displayed with.
Definition: Image.h:222
wxBitmap GetBitmap(double scale=1.0)
Returns the bitmap being displayed with custom scale.
Definition: Image.cpp:627
wxString GnuplotData()
Returns the gnuplot data file name of this image.
Definition: Image.cpp:481
wxBitmap GetUnscaledBitmap()
Returns the image in its unscaled form.
Definition: Image.cpp:177
void ClearCache()
Temporarily forget the scaled image in order to save memory.
Definition: Image.h:202