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(
const wxString& gnuplotFilename,
const 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;
303 m_loadImageTask->Wait();
312 bool HasGnuplotSource()
const {
return m_gnuplotSource_Compressed.GetDataLen() > 20;}
314 bool m_fromWxFS =
false;
316 wxMemoryBuffer m_gnuplotSource_Compressed;
318 wxMemoryBuffer m_gnuplotData_Compressed;
320 std::size_t m_originalWidth = 640;
322 std::size_t m_originalHeight = 480;
324 wxBitmap m_scaledBitmap;
326 wxString m_extension;
328 wxString m_gnuplotSource;
330 wxString m_gnuplotData;
332 mutable std::shared_ptr<BackgroundTask> m_loadImageTask;
333 void LoadImage_Backgroundtask(
const stop_token& stopToken,
338 std::shared_ptr<BackgroundTask> m_loadGnuplotSourceTask;
339 void LoadGnuplotSource_Backgroundtask(
341 const wxString& gnuplotFile,
const wxString& dataFile,
const AttachmentSource& attachments);
342 void LoadGnuplotSource(wxInputStream *source);
343 void LoadGnuplotData(wxInputStream *data);
344 void LoadGnuplotSource_Backgroundtask_internal(
345 wxInputStream *source,
346 wxInputStream *data);
349 void LoadCompressedGnuplotSource_Backgroundtask(
const stop_token& stopToken,
350 const wxString& sourcefile,
351 const wxString& datafile,
357 wxMemoryBuffer ReadCompressedImage(
const stop_token& stopToken, wxInputStream *data);
359 void RecordDataUnavailable(
const wxString &message);
367 void RecordDecodeFailure(
const wxString &message,
bool missingCodec);
372 wxCoord m_maxWidth = -1;
374 wxCoord m_maxHeight = -1;
376 double m_userScale = 1.0;
378 bool m_fitToWindow =
true;
380 wxString m_imageName;
384 bool IsSvg()
const {
return m_extension == wxS(
"svgz"); }
392 const wxBitmapBundle &SvgBundle();
394 wxBitmap SvgBitmapAt(wxSize size);
396 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:102
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:788
void Recalculate(double scale=1.0)
Can be called to specify a specific scale.
Definition: Image.cpp:1001
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:518
const wxMemoryBuffer GetGnuplotSource()
Returns the gnuplot source of this image.
Definition: Image.cpp:408
std::size_t GetOriginalWidth() const
Returns the original width.
Definition: Image.cpp:205
std::size_t GetOriginalHeight() const
Returns the original height.
Definition: Image.cpp:212
static const wxString GetBadImageToolTip()
The tooltip to use wherever an image that's not Ok is shown.
Definition: Image.cpp:1101
long m_height
The height of the scaled image.
Definition: Image.h:284
const wxMemoryBuffer GetGnuplotData()
Returns the gnuplot data of this image.
Definition: Image.cpp:453
void CompressedGnuplotSource(wxString gnuplotFilename, wxString dataFilename, const AttachmentSource &attachments={})
Loads the compressed gnuplot source and data file for this image.
Definition: Image.cpp:281
long m_width
The width of the scaled image.
Definition: Image.h:282
wxString GetExtension() const
Returns the file name extension of the current image.
Definition: Image.cpp:807
void InvalidBitmap(const wxString &message=wxEmptyString)
Creates a bitmap showing an error message.
Definition: Image.cpp:709
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:199
bool CanExportSVG() const
Can this image be exported in SVG format?
Definition: Image.h:301
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:1082
bool GetFitToWindow() const
Is this image shrunk to fit into the window?
Definition: Image.h:262
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:298
void SetMaxHeight(double height)
Set the maximum height this image shall be displayed with.
Definition: Image.h:238
void SetUserScale(double scale)
Sets the factor GetUserScale() returns; values <= 0 are ignored.
Definition: Image.h:252
void SetFitToWindow(bool fit)
Sets what GetFitToWindow() returns.
Definition: Image.h:264
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:629
wxString GnuplotData()
Returns the gnuplot data file name of this image.
Definition: Image.cpp:483
wxSize ToImageFile(const wxString &filename)
Saves the image in its original form, or as .png if it originates in a bitmap.
Definition: Image.cpp:559
wxBitmap GetUnscaledBitmap()
Returns the image in its unscaled form.
Definition: Image.cpp:179
void ClearCache()
Temporarily forget the scaled image in order to save memory.
Definition: Image.h:202
double GetUserScale() const
The factor the user wants this image displayed larger or smaller with.
Definition: Image.h:250