![]() |
WhirlyGlobe
1.2
A 3D interactive globe toolkit for iOS
|
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 #import "SelectionLayer.h" 00031 00032 namespace WhirlyGlobe 00033 { 00034 00036 static const int LabelDrawPriority=1000; 00037 00042 class LabelSceneRep : public Identifiable 00043 { 00044 public: 00045 LabelSceneRep(); 00046 ~LabelSceneRep() { } 00047 00048 float fade; // Fade interval, for deletion 00049 SimpleIDSet texIDs; // Textures we created for this 00050 SimpleIDSet drawIDs; // Drawables created for this 00051 SimpleIdentity selectID; // Selection rect 00052 }; 00053 typedef std::map<SimpleIdentity,LabelSceneRep *> LabelSceneRepMap; 00054 00055 } 00056 00063 @interface SingleLabel : NSObject 00064 { 00067 bool isSelectable; 00070 WhirlyGlobe::SimpleIdentity selectID; 00072 NSString *text; 00075 WhirlyGlobe::GeoCoord loc; 00078 NSDictionary *desc; 00080 WhirlyGlobe::SimpleIdentity iconTexture; 00081 } 00082 00083 @property (nonatomic,assign) bool isSelectable; 00084 @property (nonatomic,assign) WhirlyGlobe::SimpleIdentity selectID; 00085 @property (nonatomic,retain) NSString *text; 00086 @property (nonatomic,assign) WhirlyGlobe::GeoCoord loc; 00087 @property (nonatomic,retain) NSDictionary *desc; 00088 @property (nonatomic,assign) WhirlyGlobe::SimpleIdentity iconTexture; 00089 00093 - (bool)calcWidth:(float *)width height:(float *)height defaultFont:(UIFont *)font; 00094 00099 - (void)calcExtents:(NSDictionary *)topDesc corners:(Point3f *)pts norm:(Point3f *)norm; 00100 00101 @end 00102 00105 static const unsigned int LabelTextureAtlasSizeDefault = 512; 00106 00137 @interface LabelLayer : NSObject<WhirlyGlobeLayer> 00138 { 00139 WhirlyGlobeLayerThread *layerThread; 00140 WhirlyGlobe::GlobeScene *scene; 00141 00143 WGSelectionLayer *selectLayer; 00144 00146 WhirlyGlobe::LabelSceneRepMap labelReps; 00147 00148 unsigned int textureAtlasSize; 00149 } 00150 00152 @property (nonatomic,retain) WGSelectionLayer *selectLayer; 00153 00156 - (id)initWithTexAtlasSize:(unsigned int)textureAtlasSize; 00157 00159 - (void)startWithThread:(WhirlyGlobeLayerThread *)layerThread scene:(WhirlyGlobe::GlobeScene *)scene; 00160 00164 - (WhirlyGlobe::SimpleIdentity) addLabel:(NSString *)str loc:(WhirlyGlobe::GeoCoord)loc desc:(NSDictionary *)desc; 00165 00168 - (WhirlyGlobe::SimpleIdentity) addLabel:(SingleLabel *)label; 00169 00173 - (WhirlyGlobe::SimpleIdentity) addLabels:(NSArray *)labels desc:(NSDictionary *)desc; 00174 00176 - (WhirlyGlobe::SimpleIdentity) addLabels:(NSArray *)labels desc:(NSDictionary *)desc cacheName:(NSString *)cacheName; 00177 00179 - (WhirlyGlobe::SimpleIdentity) addLabelsFromCache:(NSString *)cacheName; 00180 00183 - (void)changeLabel:(WhirlyGlobe::SimpleIdentity)labelID desc:(NSDictionary *)dict; 00184 00187 - (DrawCost *)getCost:(WhirlyGlobe::SimpleIdentity)labelID; 00188 00190 - (void) removeLabel:(WhirlyGlobe::SimpleIdentity)labelId; 00191 00192 @end