00001 /* 00002 * The information in this file is 00003 * Copyright(c) 2007 Ball Aerospace & Technologies Corporation 00004 * and is subject to the terms and conditions of the 00005 * GNU Lesser General Public License Version 2.1 00006 * The license text is available from 00007 * http://www.gnu.org/licenses/lgpl.html 00008 */ 00009 00010 #ifndef LAYERLIST_H 00011 #define LAYERLIST_H 00012 00013 #include "LocationType.h" 00014 #include "Subject.h" 00015 #include "TypesFile.h" 00016 00017 #include <string> 00018 #include <vector> 00019 00020 class DataElement; 00021 class Layer; 00022 class RasterElement; 00023 00024 /** 00025 * Manages layers associated with a raster data set. 00026 * 00027 * The layer list manages layers associated with a data set. The 00028 * layer list is contained within a spatial data view to provide access to 00029 * draw the layers. 00030 * 00031 * This subclass of Subject will notify upon the following conditions: 00032 * - A Layer is added to the list. 00033 * - A Layer is removed from the list. 00034 * - The list changes what RasterElement it is associated with. 00035 * - Everything documented in Subject. 00036 * 00037 * @see RasterElement, SpatialDataView 00038 */ 00039 class LayerList : public Subject 00040 { 00041 public: 00042 /** 00043 * Emitted with boost::any<Layer*> when a layer is added. 00044 */ 00045 SIGNAL_METHOD(LayerList, LayerAdded) 00046 00047 /** 00048 * Emitted with boost::any<Layer*> when a layer is deleted from the list. 00049 */ 00050 SIGNAL_METHOD(LayerList, LayerDeleted) 00051 00052 /** 00053 * Returns the primary RasterElement associated with the list. 00054 * 00055 * @return The primary RasterElement associated with the list. NULL is 00056 * returned if there is no primary RasterElement. 00057 * 00058 * @see RasterElement 00059 */ 00060 virtual RasterElement* getPrimaryRasterElement() const = 0; 00061 00062 /** 00063 * Queries whether the list contains a given layer. 00064 * 00065 * @param pLayer 00066 * The layer to query for its existence. Cannot be NULL. 00067 * 00068 * @return TRUE if the layer is contained in the list, otherwise FALSE. 00069 */ 00070 virtual bool containsLayer(Layer* pLayer) const = 0; 00071 00072 /** 00073 * Retrieves a layer in the list. 00074 * 00075 * @param layerType 00076 * The layer type. 00077 * @param pElement 00078 * The data element used as the basis for drawing the layer. 00079 * 00080 * @return A pointer to the existing layer, which can be safely cast to a 00081 * derived layer class according to its layer type. NULL is 00082 * returned if a layer with the given parameters does not exist in 00083 * the list. 00084 * 00085 * @see getLayers() 00086 */ 00087 virtual Layer* getLayer(const LayerType& layerType, const DataElement* pElement) const = 0; 00088 00089 /** 00090 * Retrieves a layer in the list. 00091 * 00092 * @param layerType 00093 * The layer type. 00094 * @param pElement 00095 * The data element used as the basis for drawing the layer. If 00096 * \c NULL is passed in, the layer with the given name and type is 00097 * returned. 00098 * @param layerName 00099 * The layer name. If the name is empty, the name of the data 00100 * element is used. 00101 * 00102 * @return A pointer to the existing layer, which can be safely cast to a 00103 * derived layer class according to its layer type. \c NULL is 00104 * returned if a layer with the given parameters does not exist in 00105 * the list. 00106 * 00107 * @see getLayers() 00108 */ 00109 virtual Layer* getLayer(const LayerType& layerType, const DataElement* pElement, 00110 const std::string& layerName) const = 0; 00111 00112 /** 00113 * Retrieves all layers of a given type in the list. 00114 * 00115 * @param layerType 00116 * The layer type. 00117 * @param layers 00118 * A vector that is populated with pointers to the layers of the 00119 * given type contained in the list. 00120 * 00121 * @deprecated 00122 * This method is deprecated and may be removed in a future 00123 * version.\ Use getLayers(LayerType) const instead, which returns 00124 * a vector by value. 00125 */ 00126 virtual void getLayers(LayerType layerType, std::vector<Layer*>& layers) const = 0; 00127 00128 /** 00129 * Retrieves all layers in the list. 00130 * 00131 * @param layers 00132 * A vector that is populated with pointers to all layers 00133 * contained in the list. 00134 * 00135 * @deprecated 00136 * This method is deprecated and may be removed in a future 00137 * version.\ Use getLayers() const instead, which returns a vector 00138 * by value. 00139 */ 00140 virtual void getLayers(std::vector<Layer*>& layers) const = 0; 00141 00142 /** 00143 * Retrieves all layers in the list. 00144 * 00145 * @return A vector containing pointers to all layers in the list. 00146 * 00147 * @see getLayers(const LocationType&) const, 00148 * getLayers(LayerType) const, 00149 * getLayers(LayerType, const LocationType&) const 00150 */ 00151 virtual std::vector<Layer*> getLayers() const = 0; 00152 00153 /** 00154 * Retrieves all layers at a given pixel coordinate in the list. 00155 * 00156 * @param worldCoord 00157 * The pixel coordinate in world coordinates. 00158 * 00159 * @return A vector containing pointers to the layers in the list whose 00160 * extents include the given pixel coordinate. 00161 * 00162 * @see getLayers() const, 00163 * getLayers(LayerType) const, 00164 * getLayers(LayerType, const LocationType&) const, 00165 * Layer::getExtents() 00166 */ 00167 virtual std::vector<Layer*> getLayers(const LocationType& worldCoord) const = 0; 00168 00169 /** 00170 * Retrieves all layers of a given type in the list. 00171 * 00172 * @param layerType 00173 * The layer type. 00174 * 00175 * @return A vector containing pointers to the layers of the given type 00176 * in the list. 00177 * 00178 * @see getLayers()const, 00179 * getLayers(const LocationType&) const, 00180 * getLayers(LayerType, const LocationType&) const 00181 */ 00182 virtual std::vector<Layer*> getLayers(LayerType layerType) const = 0; 00183 00184 /** 00185 * Retrieves all layers of a given type at a given pixel coordinate in the 00186 * list. 00187 * 00188 * @param layerType 00189 * The layer type. 00190 * @param worldCoord 00191 * The pixel coordinate in world coordinates. 00192 * 00193 * @return A vector containing pointers to the layers of the given type 00194 * in the list whose extents include the given pixel coordinate. 00195 * 00196 * @see getLayers() const, 00197 * getLayers(LayerType) const, 00198 * getLayers(const LocationType&) const, 00199 * Layer::getExtents() 00200 */ 00201 virtual std::vector<Layer*> getLayers(LayerType layerType, const LocationType& worldCoord) const = 0; 00202 00203 /** 00204 * Returns the number of layers in the list of a given type. 00205 * 00206 * @param layerType 00207 * The layer type for which to get the number of layers contained 00208 * in the list. 00209 * 00210 * @return The number of layers contained in the list of the given type. 00211 * 00212 * @see getNumLayers() const, 00213 * getNumLayers(const LocationType&) const, 00214 * getNumLayers(LayerType, const LocationType&) const 00215 */ 00216 virtual unsigned int getNumLayers(LayerType layerType) const = 0; 00217 00218 /** 00219 * Returns the total number of layers in the list. 00220 * 00221 * @return The total number of layers contained in the list. 00222 * 00223 * @see getNumLayers(LayerType) const, 00224 * getNumLayers(const LocationType&) const, 00225 * getNumLayers(LayerType, const LocationType&) const 00226 */ 00227 virtual unsigned int getNumLayers() const = 0; 00228 00229 /** 00230 * Returns the number of layers in the list at a given pixel coordinate. 00231 * 00232 * @param worldCoord 00233 * The pixel coordinate in world coordinates. 00234 * 00235 * @return The number of layers contained in the list whose extents include 00236 * the given pixel coordinate. 00237 * 00238 * @see getNumLayers() const, 00239 * getNumLayers(LayerType) const, 00240 * getNumLayers(LayerType, const LocationType&) const, 00241 * Layer::getExtents() 00242 */ 00243 virtual unsigned int getNumLayers(const LocationType& worldCoord) const = 0; 00244 00245 /** 00246 * Returns the number of layers of a given type at a given pixel coordinate 00247 * in the list. 00248 * 00249 * @param layerType 00250 * The layer type. 00251 * @param worldCoord 00252 * The pixel coordinate in world coordinates. 00253 * 00254 * @return The number of layers contained in the list of the given type 00255 * whose extents include the given pixel coordinate. 00256 * 00257 * @see getNumLayers() const, 00258 * getNumLayers(LayerType) const, 00259 * getNumLayers(const LocationType&) const, 00260 * Layer::getExtents() 00261 */ 00262 virtual unsigned int getNumLayers(LayerType layerType, const LocationType& worldCoord) const = 0; 00263 00264 /** 00265 * Renames a layer to a user-defined name. 00266 * 00267 * This method prompts the user to select a new layer name and renames 00268 * the layer. The user selected name is guaranteed to be unique within 00269 * the layer list for the layer type. 00270 * 00271 * @param pLayer 00272 * The layer to rename, which must be contained within the layer 00273 * list. This method does nothing and returns \c false if \c NULL 00274 * is passed in. 00275 * 00276 * @return Returns \c true if the layer was successfully renamed. Returns 00277 * \c false if the layer does not exist in the layer list or if the 00278 * user cancels the dialog to select a new name. 00279 * 00280 * @see renameLayer(Layer*, const std::string&) const, Layer::rename() 00281 */ 00282 virtual bool renameLayer(Layer* pLayer) const = 0; 00283 00284 /** 00285 * Renames a layer to a given name. 00286 * 00287 * @param pLayer 00288 * The layer to rename, which must be contained within the layer 00289 * list. This method does nothing and returns \c false if \c NULL 00290 * is passed in. 00291 * @param newName 00292 * The new name for the layer, which must be unique within the 00293 * layer list for the layer type. This method does nothing and 00294 * returns \c false if an empty string is passed in. 00295 * 00296 * @return Returns \c true if the layer was successfully renamed. Returns 00297 * \c false if another layer of the same type in the layer list 00298 * already has the given name. 00299 * 00300 * @see renameLayer(Layer*) const, Layer::rename() 00301 */ 00302 virtual bool renameLayer(Layer* pLayer, const std::string& newName) const = 0; 00303 00304 protected: 00305 /** 00306 * A plug-in cannot create this object, it can only retrieve an already existing 00307 * object from SpatialDataView::getLayerList. The SpatialDataView will manage any instances 00308 * of this object. 00309 */ 00310 virtual ~LayerList() {} 00311 }; 00312 00313 #endif