2015-10-22 22:14:53 +08:00
|
|
|
/* -*-c++-*-
|
2007-06-12 22:20:16 +08:00
|
|
|
*
|
|
|
|
* OpenSceneGraph example, osgphotoalbum.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
2003-12-23 05:05:10 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef IMAGEREADERWRITER_H
|
|
|
|
#define IMAGEREADERWRITER_H
|
|
|
|
|
|
|
|
#include <osgDB/ReadFile>
|
|
|
|
#include <osgDB/WriteFile>
|
|
|
|
#include <osgDB/ImageOptions>
|
|
|
|
|
2004-11-23 23:29:52 +08:00
|
|
|
#include <OpenThreads/ScopedLock>
|
2007-02-24 00:31:34 +08:00
|
|
|
#include <OpenThreads/ReentrantMutex>
|
2004-11-23 23:29:52 +08:00
|
|
|
|
2003-12-23 05:05:10 +08:00
|
|
|
#include "PhotoArchive.h"
|
|
|
|
|
2015-10-22 22:14:53 +08:00
|
|
|
#define SERIALIZER() OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(_serializerMutex)
|
2004-11-23 23:29:52 +08:00
|
|
|
|
2003-12-23 05:05:10 +08:00
|
|
|
class ImageReaderWriter : public osgDB::ReaderWriter
|
|
|
|
{
|
|
|
|
public:
|
2015-10-22 22:14:53 +08:00
|
|
|
|
2003-12-23 05:05:10 +08:00
|
|
|
ImageReaderWriter();
|
2015-10-22 22:14:53 +08:00
|
|
|
|
2004-10-26 18:31:52 +08:00
|
|
|
virtual const char* className() const { return "ImageReader"; }
|
2003-12-23 05:05:10 +08:00
|
|
|
|
2003-12-24 07:55:06 +08:00
|
|
|
void addPhotoArchive(PhotoArchive* archive) { _photoArchiveList.push_back(archive); }
|
2003-12-23 05:05:10 +08:00
|
|
|
|
2004-11-23 23:29:52 +08:00
|
|
|
std::string insertReference(const std::string& fileName, unsigned int res, float width, float height, bool backPage)
|
|
|
|
{
|
|
|
|
SERIALIZER();
|
2004-11-24 07:45:41 +08:00
|
|
|
return const_cast<ImageReaderWriter*>(this)->local_insertReference(fileName, res, width, height, backPage);
|
2004-11-23 23:29:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual ReadResult readNode(const std::string& fileName, const Options* options) const
|
|
|
|
{
|
|
|
|
SERIALIZER();
|
2004-11-24 07:45:41 +08:00
|
|
|
return const_cast<ImageReaderWriter*>(this)->local_readNode(fileName, options);
|
2004-11-23 23:29:52 +08:00
|
|
|
}
|
2003-12-23 05:05:10 +08:00
|
|
|
|
2015-10-22 22:14:53 +08:00
|
|
|
|
2003-12-23 05:05:10 +08:00
|
|
|
protected:
|
|
|
|
|
2004-11-23 23:29:52 +08:00
|
|
|
std::string local_insertReference(const std::string& fileName, unsigned int res, float width, float height, bool backPage);
|
|
|
|
|
|
|
|
ReadResult local_readNode(const std::string& fileName, const Options*);
|
|
|
|
|
2007-02-24 00:31:34 +08:00
|
|
|
mutable OpenThreads::ReentrantMutex _serializerMutex;
|
2003-12-23 05:05:10 +08:00
|
|
|
|
|
|
|
struct DataReference
|
|
|
|
{
|
|
|
|
DataReference();
|
|
|
|
DataReference(const std::string& fileName, unsigned int res, float width, float height,bool backPage);
|
|
|
|
DataReference(const DataReference& rhs);
|
|
|
|
|
|
|
|
std::string _fileName;
|
|
|
|
unsigned int _resolutionX;
|
|
|
|
unsigned int _resolutionY;
|
|
|
|
osg::Vec3 _center;
|
2015-10-22 22:14:53 +08:00
|
|
|
osg::Vec3 _maximumWidth;
|
2003-12-23 05:05:10 +08:00
|
|
|
osg::Vec3 _maximumHeight;
|
2015-10-22 22:14:53 +08:00
|
|
|
unsigned int _numPointsAcross;
|
2003-12-23 05:05:10 +08:00
|
|
|
unsigned int _numPointsUp;
|
|
|
|
bool _backPage;
|
|
|
|
};
|
2015-10-22 22:14:53 +08:00
|
|
|
|
|
|
|
osg::ref_ptr<osg::Image> readImage_Archive(DataReference& dr, float& s,float& t);
|
|
|
|
|
|
|
|
osg::ref_ptr<osg::Image> readImage_DynamicSampling(DataReference& dr, float& s,float& t);
|
2003-12-23 05:05:10 +08:00
|
|
|
|
2003-12-24 07:55:06 +08:00
|
|
|
typedef std::map< std::string,DataReference > DataReferenceMap;
|
|
|
|
typedef std::vector< osg::ref_ptr<PhotoArchive> > PhotoArchiveList;
|
2003-12-23 05:05:10 +08:00
|
|
|
|
|
|
|
DataReferenceMap _dataReferences;
|
2003-12-24 07:55:06 +08:00
|
|
|
PhotoArchiveList _photoArchiveList;
|
2003-12-23 05:05:10 +08:00
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|