Layer.h

Go to the documentation of this file.
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 LAYER_H
00011 #define LAYER_H
00012 
00013 #include "LocationType.h"
00014 #include "SessionItem.h"
00015 #include "Subject.h"
00016 #include "Serializable.h"
00017 #include "TypesFile.h"
00018 
00019 #include <string>
00020 #include <vector>
00021 
00022 class DataElement;
00023 class View;
00024 
00025 /**
00026  *  %Services to adjust characteristics of layers.
00027  *
00028  *  This abstract base class provides access to properties for all layers that can
00029  *  be displayed in a layer list.  This class contains accessor methods to set and
00030  *  get the layer name, and each subclass contains accessor methods specific to the
00031  *  layer type.
00032  *
00033  *  This subclass of Subject will notify upon the following conditions:
00034  *     - The following methods are called: setXScaleFactor(), setYScaleFactor(),
00035  *       setXOffset(), and setYOffset().
00036  *     - The DataElement for the layer posts a Subject::signalModified notification.
00037  *       Layer will then itself notify Subject::signalModified.
00038  *     - Everything else documented in Subject.
00039  *
00040  *  @see     LayerList
00041  */
00042 class Layer : public SessionItem, public Subject, public Serializable
00043 {
00044 public:
00045    /**
00046     *  Emitted with any<std::string> when the layer name changes.
00047     */
00048    SIGNAL_METHOD(Layer, NameChanged)
00049 
00050    /**
00051     *  Emitted when the layer extents change.
00052     */
00053    SIGNAL_METHOD(Layer, ExtentsModified)
00054 
00055    /**
00056     *  @copydoc SessionItem::getContextMenuActions()
00057     *
00058     *  @default The default implementation returns the context menu actions
00059     *           listed \ref layer "here".
00060     */
00061    virtual std::list<ContextMenuAction> getContextMenuActions() const = 0;
00062 
00063    /**
00064     *  Returns the layer type
00065     *
00066     *  @return  The layer type.
00067     */
00068    virtual LayerType getLayerType() const = 0;
00069 
00070    /**
00071     *  Returns the associated data element.
00072     *
00073     *  @return  The data element upon which the layer is based.
00074     */
00075    virtual DataElement* getDataElement() const = 0;
00076 
00077    /**
00078     * Determine if the DataElement within the Layer is unique to all layers.
00079     *
00080     * @return True if this is the only layer with the given DataElement,
00081     *         false otherwise.
00082     */
00083    virtual bool hasUniqueElement() const = 0;
00084    /**
00085     *  Returns the view in which the layer is displayed.
00086     *
00087     *  @return  A pointer to the view in which the layer is displayed.  NULL
00088     *           is returned if the layer is not displayed in a view.
00089     */
00090    virtual View* getView() const = 0;
00091 
00092    /**
00093     *  Links a layer with this layer.
00094     *
00095     *  This method establishes a link between this layer and another layer.  Linked layers
00096     *  are linked by action.  %Setting properties in a layer sets the same property values
00097     *  in linked layers.
00098     *
00099     *  @param   pLayer
00100     *           The layer to link with this layer.  Cannot be NULL and must be of the same
00101     *           layer type as this layer.
00102     *
00103     *  @return  <b>true</b> if the layer was successfully linked with this
00104     *           layer, otherwise <b>false</b>.
00105     */
00106    virtual bool linkLayer(Layer* pLayer) = 0;
00107 
00108    /**
00109     *  Retrieves layers linked with this layer.
00110     *
00111     *  @param   linkedLayers
00112     *           A reference to a vector that is populated with pointers to layers linked
00113     *           with this layer.  If no layers are linked, the vector is emptied.
00114     */
00115    virtual void getLinkedLayers(std::vector<Layer*>& linkedLayers) const = 0;
00116 
00117    /**
00118     *  Queries whether a layer is linked with this layer.
00119     *
00120     *  @param   pLayer
00121     *           The layer to query for linkage with this layer.
00122     *
00123     *  @return  <b>true</b> if the layer is linked with this layer; otherwise
00124     *           <b>false</b>.
00125     */
00126    virtual bool isLayerLinked(Layer* pLayer) const = 0;
00127 
00128    /**
00129     *  Breaks the link between this layer and a given layer.
00130     *
00131     *  @param   pLayer
00132     *           The layer to unlink with this layer.  Cannot be NULL.
00133     *
00134     *  @return  <b>true</b> if the layer was successfully unlinked with this
00135     *           layer; otherwise <b>false</b>.
00136     */
00137    virtual bool unlinkLayer(Layer* pLayer) = 0;
00138 
00139    /**
00140     *  Creates a new layer with the same settings and properties as this layer.
00141     *
00142     *  @param   layerName
00143     *           The name for the new layer.  If an empty string is passed in
00144     *           the name of this layer is used for the new layer.
00145     *  @param   bCopyElement
00146     *           Set this value to \b true to make a copy of this layer's
00147     *           element.  Set this value to \b false to use this layer's
00148     *           element in the new layer.
00149     *  @param   pElement
00150     *           If the element is also copied, this is the parent of the new
00151     *           element.  If the element is not being copied, this parameter
00152     *           is ignored.
00153     *
00154     *  @warning When copying Annotation and AOI layers, the data element is
00155     *           always copied so a new layer name or a parent element should be
00156     *           passed in.  If the layer name is empty and an Annotation or AOI
00157     *           element cannot be created because one already exists, the
00158     *           element will be created with a GUID as a name.  The layer name
00159     *           will be the name of this layer.
00160     *
00161     *  @return  A pointer to the new layer.  \b NULL is returned if an error
00162     *           occurs.
00163     */
00164    virtual Layer* copy(const std::string& layerName = std::string(), bool bCopyElement = false,
00165       DataElement* pElement = NULL) const = 0;
00166 
00167    /**
00168     *  Retrieves the layer extents in world coordinates.
00169     *
00170     *  %Layer extents are defined as the pixel coordinate range of all data
00171     *  in the data element being displayed by the layer.  The populated extent
00172     *  coordinates already account for layer scaling and offset values.
00173     *
00174     *  @param   minX
00175     *           The minimum coordinate value of the layer in the X dimension.
00176     *  @param   minY
00177     *           The minimum coordinate value of the layer in the Y dimension.
00178     *  @param   maxX
00179     *           The maximum coordinate value of the layer in the X dimension.
00180     *  @param   maxY
00181     *           The maximum coordinate value of the layer in the Y dimension.
00182     *
00183     *  @return  Returns \c true if the extents of the layer were successfully
00184     *           retrieved; otherwise returns \c false.
00185     *
00186     *  @see     View::getExtents()
00187     */
00188    virtual bool getExtents(double& minX, double& minY, double& maxX, double& maxY) = 0;
00189 
00190    /**
00191     *  Sets the X-dimension scale factor when drawing.
00192     *
00193     *  %Any scaling is applied before the offset is applied.
00194     *
00195     *  @param   xScaleFactor
00196     *           The factor by which the pixels in the X-dimension are scaled
00197     *           while drawing.  If this value is negative or zero, this method
00198     *           does nothing.
00199     *
00200     *  @notify  This method will notify signalExtentsModified() if the scale
00201     *           factor value changes.
00202     */
00203    virtual void setXScaleFactor(double xScaleFactor) = 0;
00204 
00205    /**
00206     *  Returns the X-dimension scale factor when drawing.
00207     *
00208     *  %Any scaling is applied before the offset is applied.
00209     *
00210     *  @return  The factor by which the pixels in the X-dimension are scaled
00211     *           while drawing.
00212     */
00213    virtual double getXScaleFactor() const = 0;
00214 
00215    /**
00216     *  Sets the Y-dimension scale factor when drawing.
00217     *
00218     *  %Any scaling is applied before the offset is applied.
00219     *
00220     *  @param   yScaleFactor
00221     *           The factor by which the pixels in the Y-dimension are scaled
00222     *           while drawing.  If this value is negative or zero, this method
00223     *           does nothing.
00224     *
00225     *  @notify  This method will notify signalExtentsModified() if the scale
00226     *           factor value changes.
00227     */
00228    virtual void setYScaleFactor(double yScaleFactor) = 0;
00229 
00230    /**
00231     *  Returns the Y-dimension scale factor when drawing.
00232     *
00233     *  %Any scaling is applied before the offset is applied.
00234     *
00235     *  @return  The factor by which the pixels in the Y-dimension are scaled
00236     *           while drawing.
00237     */
00238    virtual double getYScaleFactor() const = 0;
00239 
00240    /**
00241     * Get the X-coordinate offset from the view's coordinate system.
00242     *
00243     * Offsets are applied after scale factors.
00244     *
00245     * @return The X offset.
00246     */
00247    virtual double getXOffset() const = 0;
00248 
00249    /**
00250     * Set the X-coordinate offset from the view's coordinate system.
00251     *
00252     * Offsets are applied after scale factors.
00253     *
00254     * @param xOffset
00255     *        The X offset.
00256     *
00257     *  @notify This method will notify signalExtentsModified.
00258     */
00259    virtual void setXOffset(double xOffset) = 0;
00260 
00261    /**
00262     * Get the Y-coordinate offset from the view's coordinate system.
00263     *
00264     * Offsets are applied after scale factors.
00265     *
00266     * @return The Y offset.
00267     */
00268    virtual double getYOffset() const = 0;
00269 
00270    /**
00271     * Set the Y-coordinate offset from the view's coordinate system.
00272     *
00273     * Offsets are applied after scale factors.
00274     *
00275     * @param yOffset
00276     *        The Y offset.
00277     *
00278     *  @notify This method will notify signalExtentsModified.
00279     */
00280    virtual void setYOffset(double yOffset) = 0;
00281 
00282    /**
00283     * Translate from world coordinates to data coordinates for this layer.
00284     *
00285     * @param worldX
00286     *        The x-coordinate to translate from.
00287     * @param worldY
00288     *        The y-coordinate to translate from.
00289     * @param dataX
00290     *        The x-coordinate to translate to.
00291     * @param dataY
00292     *        The y-coordinate to translate to.
00293     */
00294    virtual void translateWorldToData(double worldX, double worldY, double &dataX, double &dataY) const = 0;
00295 
00296    /**
00297     * Translate from data coordinates to world coordinates for this layer.
00298     *
00299     * @param dataX
00300     *        The x-coordinate to translate from.
00301     * @param dataY
00302     *        The y-coordinate to translate from.
00303     * @param worldX
00304     *        The x-coordinate to translate to.
00305     * @param worldY
00306     *        The y-coordinate to translate to.
00307     */
00308    virtual void translateDataToWorld(double dataX, double dataY, double &worldX, double &worldY) const = 0;
00309 
00310    /**
00311     * Translate from screen coordinates to data coordinates for this layer.
00312     *
00313     * @param screenX
00314     *        The x-coordinate to translate from.
00315     * @param screenY
00316     *        The y-coordinate to translate from.
00317     * @param dataX
00318     *        The x-coordinate to translate to.
00319     * @param dataY
00320     *        The y-coordinate to translate to.
00321     *
00322     * @see View::translateScreenToWorld, translateWorldToData
00323     */
00324    virtual void translateScreenToData(double screenX, double screenY, double &dataX, double &dataY) const = 0;
00325 
00326    /**
00327     * Translate from data coordinates to screen coordinates for this layer.
00328     *
00329     * @param dataX
00330     *        The x-coordinate to translate from.
00331     * @param dataY
00332     *        The y-coordinate to translate from.
00333     * @param screenX
00334     *        The x-coordinate to translate to.
00335     * @param screenY
00336     *        The y-coordinate to translate to.
00337     *
00338     * @see translateDataToWorld, View::translateWorldToScreen
00339     */
00340    virtual void translateDataToScreen(double dataX, double dataY, double &screenX, double &screenY) const = 0;
00341 
00342    /**
00343     *  Queries whether the layer's data coordinate system is flipped from the
00344     *  screen coordinate system.
00345     *
00346     *  @param   dataLowerLeft
00347     *           A lower left data coordinate for which to perform the
00348     *           data-to-screen transformation.
00349     *  @param   dataUpperRight
00350     *           An upper right data coordinate for which to perform the
00351     *           data-to-screen transformation.
00352     *  @param   bHorizontalFlip
00353     *           This parameter is set to \c true if the data coordinate system
00354     *           is flipped about the y-axis relative to the screen coordinate
00355     *           system; otherwise the parameter is set to \c false.
00356     *  @param   bVerticalFlip
00357     *           This parameter is set to \c true if the data coordinate system
00358     *           is flipped about the x-axis relative to the screen coordinate
00359     *           system; otherwise the parameter is set to \c false.
00360     *
00361     *  @see     translateDataToScreen()
00362     */
00363    virtual void isFlipped(const LocationType& dataLowerLeft, const LocationType& dataUpperRight,
00364       bool& bHorizontalFlip, bool& bVerticalFlip) const = 0;
00365 
00366    /**
00367     *  Renames the layer to a given name.
00368     *
00369     *  @param   newName
00370     *           The new name for the layer, which must be unique within the
00371     *           layer list for the layer type.  This method does nothing and
00372     *           returns \c false if an empty string is passed in.
00373     *
00374     *  @return  Returns \c true if the layer was successfully renamed.  Returns
00375     *           \c false if another layer of the same type in the layer list
00376     *           already has the given name.
00377     *
00378     *  @see     LayerList::renameLayer()
00379     */
00380    virtual bool rename(const std::string& newName) = 0;
00381 
00382 protected:
00383    /**
00384     * This should be destroyed by calling SpatialDataView::deleteLayer.
00385     */
00386    virtual ~Layer() {}
00387 };
00388 
00389 #endif

Software Development Kit - Opticks 4.9.0 Build 16218