WhirlyGlobe  1.1
A 3D interactive globe toolkit for ios
/Users/sjg/iPhone/WhirlyGlobe/WhirlyGlobeSrc/WhirlyGlobeLib/include/LabelLayer.h
00001 /*
00002  *  LabelLayer.h
00003  *  WhirlyGlobeLib
00004  *
00005  *  Created by Steve Gifford on 2/7/11.
00006  *  Copyright 2011 mousebird consulting
00007  *
00008  *  Licensed under the Apache License, Version 2.0 (the "License");
00009  *  you may not use this file except in compliance with the License.
00010  *  You may obtain a copy of the License at
00011  *  http://www.apache.org/licenses/LICENSE-2.0
00012  *
00013  *  Unless required by applicable law or agreed to in writing, software
00014  *  distributed under the License is distributed on an "AS IS" BASIS,
00015  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016  *  See the License for the specific language governing permissions and
00017  *  limitations under the License.
00018  *
00019  */
00020 
00021 #import <math.h>
00022 #import <set>
00023 #import <map>
00024 #import "Identifiable.h"
00025 #import "Drawable.h"
00026 #import "DataLayer.h"
00027 #import "LayerThread.h"
00028 #import "TextureAtlas.h"
00029 #import "DrawCost.h"
00030 
00031 namespace WhirlyGlobe 
00032 {
00033 
00035 static const int LabelDrawPriority=1000;
00036 
00041 class LabelSceneRep : public Identifiable
00042 {
00043 public:
00044     LabelSceneRep() { }
00045     ~LabelSceneRep() { }
00046     
00047     SimpleIDSet texIDs;  // Textures we created for this
00048     SimpleIDSet drawIDs; // Drawables created for this
00049 };
00050 typedef std::map<SimpleIdentity,LabelSceneRep *> LabelSceneRepMap;
00051         
00052 }
00053 
00060 @interface SingleLabel : NSObject
00061 {
00063     NSString *text;
00066     WhirlyGlobe::GeoCoord loc;
00069     NSDictionary *desc;
00071     WhirlyGlobe::SimpleIdentity iconTexture;  
00072 }
00073 
00074 @property (nonatomic,retain) NSString *text;
00075 @property (nonatomic,assign) WhirlyGlobe::GeoCoord loc;
00076 @property (nonatomic,retain) NSDictionary *desc;
00077 @property (nonatomic,assign) WhirlyGlobe::SimpleIdentity iconTexture;
00078 
00082 - (bool)calcWidth:(float *)width height:(float *)height defaultFont:(UIFont *)font;
00083 
00088 - (void)calcExtents:(NSDictionary *)topDesc corners:(Point3f *)pts norm:(Point3f *)norm;
00089 
00090 @end
00091 
00093 static const unsigned int LabelTextureAtlasSize = 512;
00094 
00123 @interface LabelLayer : NSObject<WhirlyGlobeLayer>
00124 {
00125         WhirlyGlobeLayerThread *layerThread;
00126         WhirlyGlobe::GlobeScene *scene;
00127 
00129     WhirlyGlobe::LabelSceneRepMap labelReps;
00130 }
00131 
00133 - (void)startWithThread:(WhirlyGlobeLayerThread *)layerThread scene:(WhirlyGlobe::GlobeScene *)scene;
00134 
00138 - (WhirlyGlobe::SimpleIdentity) addLabel:(NSString *)str loc:(WhirlyGlobe::GeoCoord)loc desc:(NSDictionary *)desc;
00139 
00143 - (WhirlyGlobe::SimpleIdentity) addLabels:(NSArray *)labels desc:(NSDictionary *)desc;
00146 - (WhirlyGlobe::SimpleIdentity) addLabel:(SingleLabel *)label;
00147 
00150 - (void)changeLabel:(WhirlyGlobe::SimpleIdentity)labelID desc:(NSDictionary *)dict;
00151 
00154 - (DrawCost *)getCost:(WhirlyGlobe::SimpleIdentity)labelID;
00155 
00157 - (void) removeLabel:(WhirlyGlobe::SimpleIdentity)labelId;
00158 
00159 @end