2002-07-05 21:24:15 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
2003-08-23 00:17:00 +00:00
|
|
|
* \file PreviewLoader.h
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-07-05 21:24:15 +00:00
|
|
|
*
|
2002-12-01 22:59:25 +00:00
|
|
|
* \author Angus Leeming
|
2002-09-05 11:31:30 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-07-05 21:24:15 +00:00
|
|
|
*
|
2007-11-21 23:31:12 +00:00
|
|
|
* graphics::PreviewLoader collects latex snippets together. Then, on a
|
2003-08-23 00:17:00 +00:00
|
|
|
* startLoading() call, these are dumped to file and processed, converting
|
|
|
|
* each snippet to a separate bitmap image file. Once a bitmap file is ready
|
|
|
|
* to be loaded back into LyX, the PreviewLoader emits a signal to inform
|
|
|
|
* the initiating process.
|
2002-07-05 21:24:15 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PREVIEWLOADER_H
|
|
|
|
#define PREVIEWLOADER_H
|
|
|
|
|
2016-06-09 20:25:34 +00:00
|
|
|
#include <boost/signals2.hpp>
|
2015-06-10 17:21:27 +00:00
|
|
|
#include <QObject>
|
2002-07-05 21:24:15 +00:00
|
|
|
|
2009-12-17 15:21:08 +00:00
|
|
|
#include "ColorCode.h"
|
2002-07-05 21:24:15 +00:00
|
|
|
|
2003-07-04 08:23:23 +00:00
|
|
|
namespace lyx {
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
class Buffer;
|
|
|
|
|
2003-07-04 08:23:23 +00:00
|
|
|
namespace graphics {
|
2002-07-05 21:24:15 +00:00
|
|
|
|
|
|
|
class PreviewImage;
|
|
|
|
|
2015-06-10 17:21:27 +00:00
|
|
|
class PreviewLoader : public QObject {
|
|
|
|
Q_OBJECT
|
2002-07-05 21:24:15 +00:00
|
|
|
public:
|
|
|
|
/** We need buffer because we require the preamble to the
|
|
|
|
* LaTeX file.
|
|
|
|
*/
|
|
|
|
PreviewLoader(Buffer const & buffer);
|
|
|
|
///
|
|
|
|
~PreviewLoader();
|
|
|
|
|
|
|
|
/** Is there an image already associated with this snippet of LaTeX?
|
|
|
|
* If so, returns a pointer to it, else returns 0.
|
|
|
|
*/
|
2003-10-06 15:43:21 +00:00
|
|
|
PreviewImage const * preview(std::string const & latex_snippet) const;
|
2002-07-05 21:24:15 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
enum Status {
|
|
|
|
///
|
|
|
|
NotFound,
|
|
|
|
///
|
|
|
|
InQueue,
|
|
|
|
///
|
|
|
|
Processing,
|
|
|
|
///
|
|
|
|
Ready
|
|
|
|
};
|
|
|
|
|
|
|
|
/// How far have we got in loading the image?
|
2003-10-06 15:43:21 +00:00
|
|
|
Status status(std::string const & latex_snippet) const;
|
2002-07-17 16:56:42 +00:00
|
|
|
|
2002-07-05 21:24:15 +00:00
|
|
|
/// Add a snippet of LaTeX to the queue for processing.
|
2003-10-06 15:43:21 +00:00
|
|
|
void add(std::string const & latex_snippet) const;
|
2002-07-05 21:24:15 +00:00
|
|
|
|
|
|
|
/// Remove this snippet of LaTeX from the PreviewLoader.
|
2003-10-06 15:43:21 +00:00
|
|
|
void remove(std::string const & latex_snippet) const;
|
2002-07-17 16:56:42 +00:00
|
|
|
|
2002-07-05 21:24:15 +00:00
|
|
|
/** We have accumulated several latex snippets with status "InQueue".
|
|
|
|
* Initiate their transformation into bitmap images.
|
|
|
|
*/
|
2010-07-21 13:19:52 +00:00
|
|
|
void startLoading(bool wait = false) const;
|
2002-07-17 16:56:42 +00:00
|
|
|
|
|
|
|
/** Connect and you'll be informed when the bitmap image file
|
|
|
|
* has been created and is ready for loading through
|
2003-07-21 21:30:57 +00:00
|
|
|
* lyx::graphics::PreviewImage::image().
|
2002-07-17 16:56:42 +00:00
|
|
|
*/
|
2016-06-09 20:25:34 +00:00
|
|
|
typedef boost::signals2::signal<void(PreviewImage const &)> sig_type;
|
2004-09-26 14:19:47 +00:00
|
|
|
typedef sig_type::slot_type slot_type;
|
2002-07-17 16:56:42 +00:00
|
|
|
///
|
2016-06-09 20:25:34 +00:00
|
|
|
boost::signals2::connection connect(slot_type const &) const;
|
2002-07-05 21:24:15 +00:00
|
|
|
|
2002-07-17 16:56:42 +00:00
|
|
|
/** When PreviewImage has finished loading the image file into memory,
|
|
|
|
* it tells the PreviewLoader to tell the outside world
|
|
|
|
*/
|
|
|
|
void emitSignal(PreviewImage const &) const;
|
2002-07-05 21:24:15 +00:00
|
|
|
|
2002-08-02 16:30:58 +00:00
|
|
|
/// Which buffer owns this loader.
|
|
|
|
Buffer const & buffer() const;
|
2009-12-17 15:21:08 +00:00
|
|
|
/// The background color used
|
|
|
|
static ColorCode backgroundColor() { return Color_background; }
|
|
|
|
/// The foreground color used
|
|
|
|
static ColorCode foregroundColor() { return Color_preview; }
|
2002-08-02 16:30:58 +00:00
|
|
|
|
2014-10-18 13:30:58 +00:00
|
|
|
double displayPixelRatio() const ;
|
|
|
|
|
2015-06-10 17:21:27 +00:00
|
|
|
public Q_SLOTS:
|
|
|
|
///
|
|
|
|
void refreshPreviews();
|
|
|
|
|
2002-07-05 21:24:15 +00:00
|
|
|
private:
|
2007-11-21 23:31:12 +00:00
|
|
|
/// noncopyable
|
|
|
|
PreviewLoader(PreviewLoader const &);
|
|
|
|
void operator=(PreviewLoader const &);
|
|
|
|
|
2002-07-05 21:24:15 +00:00
|
|
|
/// Use the Pimpl idiom to hide the internals.
|
|
|
|
class Impl;
|
|
|
|
/// The pointer never changes although *pimpl_'s contents may.
|
2007-11-21 23:47:47 +00:00
|
|
|
Impl * const pimpl_;
|
2002-07-05 21:24:15 +00:00
|
|
|
};
|
|
|
|
|
2003-07-04 08:23:23 +00:00
|
|
|
} // namespace graphics
|
|
|
|
} // namespace lyx
|
2002-07-05 21:24:15 +00:00
|
|
|
|
|
|
|
#endif // PREVIEWLOADER_H
|