|
Revision 13041, 2.5 kB
(checked in by robert, 14 months ago)
|
|
Ran script to remove trailing spaces and tabs
|
-
Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | #include "Exception.h" |
|---|
| 15 | #include "ImageLayer.h" |
|---|
| 16 | #include "Layer.h" |
|---|
| 17 | |
|---|
| 18 | #include <osgTerrain/TerrainTile> |
|---|
| 19 | |
|---|
| 20 | #include <osgDB/ReadFile> |
|---|
| 21 | |
|---|
| 22 | using namespace ive; |
|---|
| 23 | |
|---|
| 24 | void ImageLayer::write(DataOutputStream* out) |
|---|
| 25 | { |
|---|
| 26 | |
|---|
| 27 | out->writeInt(IVEIMAGELAYER); |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | osgTerrain::Layer* layer = dynamic_cast<osgTerrain::Layer*>(this); |
|---|
| 31 | if (layer) |
|---|
| 32 | ((ive::Layer*)(layer))->write(out); |
|---|
| 33 | else |
|---|
| 34 | out_THROW_EXCEPTION("ImageLayer::write(): Could not cast this osgLayer::ImageLayer to an osgTerrain::Layer."); |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | IncludeImageMode imMode = out->getIncludeImageMode(getImage()); |
|---|
| 38 | |
|---|
| 39 | if (getFileName().empty() && imMode==IMAGE_REFERENCE_FILE) imMode = IMAGE_INCLUDE_DATA; |
|---|
| 40 | |
|---|
| 41 | out->writeChar(imMode); |
|---|
| 42 | out->writeImage(imMode,getImage()); |
|---|
| 43 | |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | void ImageLayer::read(DataInputStream* in) |
|---|
| 47 | { |
|---|
| 48 | |
|---|
| 49 | int id = in->peekInt(); |
|---|
| 50 | if (id != IVEIMAGELAYER) |
|---|
| 51 | in_THROW_EXCEPTION("ImageLayer::read(): Expected ImageLayer identification."); |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | id = in->readInt(); |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | osgTerrain::Layer* layer = dynamic_cast<osgTerrain::Layer*>(this); |
|---|
| 58 | if (layer) |
|---|
| 59 | ((ive::Layer*)(layer))->read(in); |
|---|
| 60 | else |
|---|
| 61 | in_THROW_EXCEPTION("ImageLayer::read(): Could not cast this osgLayer::Layer to an osg::Group."); |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | bool deferExternalLayerLoading = osgTerrain::TerrainTile::getTileLoadedCallback().valid() ? |
|---|
| 65 | osgTerrain::TerrainTile::getTileLoadedCallback()->deferExternalLayerLoading() : false; |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | IncludeImageMode includeImg = (IncludeImageMode)in->readChar(); |
|---|
| 69 | |
|---|
| 70 | if (includeImg==IMAGE_REFERENCE_FILE && deferExternalLayerLoading) |
|---|
| 71 | { |
|---|
| 72 | setFileName(in->readString()); |
|---|
| 73 | } |
|---|
| 74 | else |
|---|
| 75 | { |
|---|
| 76 | setImage(in->readImage(includeImg)); |
|---|
| 77 | } |
|---|
| 78 | } |
|---|