2000-07-31 12:30:10 +00:00
|
|
|
// -*- C++ -*-
|
2002-09-05 11:31:30 +00:00
|
|
|
/**
|
2002-02-27 09:59:52 +00:00
|
|
|
* \file GraphicsCacheItem.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.
|
2000-07-31 12:30:10 +00:00
|
|
|
*
|
2002-12-01 22:59:25 +00:00
|
|
|
* \author Baruch Even
|
|
|
|
* \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-02-27 09:59:52 +00:00
|
|
|
*
|
2003-07-21 21:30:57 +00:00
|
|
|
* The graphics cache is a container of lyx::graphics::CacheItems.
|
|
|
|
* Each lyx::graphics::CacheItem, defined here represents a separate image file.
|
2002-06-28 11:22:56 +00:00
|
|
|
*
|
|
|
|
* The routines here can be used to load the graphics file into memory at
|
2003-07-21 21:30:57 +00:00
|
|
|
* which point (status() == lyx::graphics::Loaded).
|
2002-06-28 11:22:56 +00:00
|
|
|
* The user is then free to access image() in order to copy it and to then
|
|
|
|
* transform the copy (rotate, scale, clip) and to generate the pixmap.
|
2002-02-27 09:59:52 +00:00
|
|
|
*
|
|
|
|
* The graphics cache supports fully asynchronous:
|
|
|
|
* file conversion to a loadable format;
|
|
|
|
* file loading.
|
|
|
|
*
|
2003-07-21 21:30:57 +00:00
|
|
|
* Whether you get that, of course, depends on lyx::graphics::Converter and
|
|
|
|
* on the lyx::graphics::Image-derived image class.
|
2002-02-27 09:59:52 +00:00
|
|
|
*/
|
2000-07-31 12:30:10 +00:00
|
|
|
|
|
|
|
#ifndef GRAPHICSCACHEITEM_H
|
|
|
|
#define GRAPHICSCACHEITEM_H
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
#include "GraphicsTypes.h"
|
2002-05-22 01:16:37 +00:00
|
|
|
|
2001-02-22 16:53:59 +00:00
|
|
|
#include <boost/utility.hpp>
|
2002-06-28 11:22:56 +00:00
|
|
|
#include <boost/scoped_ptr.hpp>
|
2002-06-25 15:59:10 +00:00
|
|
|
#include <boost/signals/signal0.hpp>
|
2000-08-10 13:15:05 +00:00
|
|
|
|
2003-09-07 21:25:37 +00:00
|
|
|
|
2002-02-27 09:59:52 +00:00
|
|
|
class InsetGraphics;
|
|
|
|
|
2003-07-04 08:23:23 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace graphics {
|
2000-08-08 09:18:39 +00:00
|
|
|
|
2002-06-28 11:22:56 +00:00
|
|
|
class Image;
|
|
|
|
class Converter;
|
|
|
|
|
2003-07-21 21:30:57 +00:00
|
|
|
/// A lyx::graphics::Cache item holder.
|
2002-06-28 11:22:56 +00:00
|
|
|
class CacheItem : boost::noncopyable {
|
2000-07-31 12:30:10 +00:00
|
|
|
public:
|
2000-08-14 15:31:16 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
CacheItem(std::string const & file);
|
2002-06-28 11:22:56 +00:00
|
|
|
|
|
|
|
/// Define an empty d-tor out-of-line to keep boost::scoped_ptr happy.
|
|
|
|
~CacheItem();
|
|
|
|
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const & filename() const;
|
2002-02-27 09:59:52 +00:00
|
|
|
|
|
|
|
/// It's in the cache. Now start the loading process.
|
2002-07-17 16:56:42 +00:00
|
|
|
void startLoading() const;
|
2002-02-27 09:59:52 +00:00
|
|
|
|
2002-07-18 14:01:42 +00:00
|
|
|
/** Monitor any changes to the file.
|
|
|
|
* There is no point monitoring the file before startLoading() is
|
|
|
|
* invoked.
|
|
|
|
*/
|
|
|
|
void startMonitoring() const;
|
|
|
|
///
|
|
|
|
bool monitoring() const;
|
|
|
|
/** Returns the check sum of filename() so that, for example, you can
|
|
|
|
* ascertain whether to output a new PostScript version of the file
|
|
|
|
* for a LaTeX run.
|
|
|
|
*/
|
|
|
|
unsigned long checksum() const;
|
|
|
|
|
2002-07-17 17:16:15 +00:00
|
|
|
/** Get the image associated with filename().
|
2002-06-28 11:22:56 +00:00
|
|
|
* If the image is not yet loaded, returns 0.
|
|
|
|
* This routine returns a pointer to const; if you want to modify it,
|
|
|
|
* create a copy and modify that.
|
2002-02-27 09:59:52 +00:00
|
|
|
*/
|
2002-06-28 11:22:56 +00:00
|
|
|
Image const * image() const;
|
2002-02-27 09:59:52 +00:00
|
|
|
|
2002-06-25 15:59:10 +00:00
|
|
|
/// How far have we got in loading the image?
|
2002-06-28 11:22:56 +00:00
|
|
|
ImageStatus status() const;
|
2002-02-27 09:59:52 +00:00
|
|
|
|
2002-07-17 16:56:42 +00:00
|
|
|
/** Connect and you'll be informed when the loading status of the image
|
|
|
|
* changes.
|
|
|
|
*/
|
|
|
|
typedef boost::signal0<void>::slot_type slot_type;
|
|
|
|
///
|
|
|
|
boost::signals::connection connect(slot_type const &) const;
|
2000-08-08 09:18:39 +00:00
|
|
|
|
2000-07-31 12:30:10 +00:00
|
|
|
private:
|
2002-06-28 11:22:56 +00:00
|
|
|
/// Use the Pimpl idiom to hide the internals.
|
|
|
|
class Impl;
|
2002-02-27 09:59:52 +00:00
|
|
|
|
2002-06-28 11:22:56 +00:00
|
|
|
/// The pointer never changes although *pimpl_'s contents may.
|
|
|
|
boost::scoped_ptr<Impl> const pimpl_;
|
2002-02-27 09:59:52 +00:00
|
|
|
};
|
|
|
|
|
2003-07-04 08:23:23 +00:00
|
|
|
} // namespace graphics
|
|
|
|
} // namespace lyx
|
2002-02-27 09:59:52 +00:00
|
|
|
|
|
|
|
#endif // GRAPHICSCACHEITEM_H
|