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 GRAPHICLAYER_H 00011 #define GRAPHICLAYER_H 00012 00013 #include "Layer.h" 00014 #include "LocationType.h" 00015 #include "ColorType.h" 00016 #include "ConfigurationSettings.h" 00017 #include "TypesFile.h" 00018 00019 #include <list> 00020 #include <string> 00021 00022 class GraphicObject; 00023 00024 /** 00025 * Adjusts the properties of a Graphic layer. 00026 * 00027 * A graphic layer consists of a list of graphic objects. 00028 * Each graphic object is individually selectable and can have 00029 * its properties set. %Setting a given property sets that property 00030 * on each currently selected object and sets the value that all 00031 * future objects will use as a default for that property. 00032 * 00033 * This subclass of Subject will notify upon the following conditions: 00034 * - The following methods are called: addObject(), removeObject(), 00035 * selectObject(), deselectObject(), selectAllObjects(), 00036 * deselectAllObjects(), groupSelection(), ungroupSelection(), pushBack(), 00037 * popFront(), clearSelection(). 00038 * - Objects are added through the GUI. 00039 * - Objects are deleted through the GUI. 00040 * - Objects are manipulated through the GUI (rotation, moved handles). 00041 * - Everything else documented in Layer. 00042 * 00043 * @see Layer 00044 */ 00045 class GraphicLayer : public Layer 00046 { 00047 public: 00048 SETTING(Alpha, GraphicLayer, double, 1.0); 00049 SETTING(Apex, GraphicLayer, double, 0.5); 00050 SETTING(ArcRegion, GraphicLayer, ArcRegion, ARC_CENTER) 00051 SETTING(Border, GraphicLayer, bool, false) 00052 SETTING(Fill, GraphicLayer, bool, false) 00053 SETTING(FillColor, GraphicLayer, ColorType, ColorType()) 00054 SETTING(FillStyle, GraphicLayer, FillStyle, SOLID_FILL) 00055 SETTING(LineColor, GraphicLayer, ColorType, ColorType()) 00056 SETTING(LineScaled, GraphicLayer, bool, false) 00057 SETTING(LineStyle, GraphicLayer, LineStyle, SOLID_LINE) 00058 SETTING(LineWidth, GraphicLayer, unsigned int, 0) 00059 SETTING(HatchStyle, GraphicLayer, SymbolType, SOLID) 00060 SETTING(Rotation, GraphicLayer, double, 0.0) 00061 SETTING(StartAngle, GraphicLayer, double, 0.0) 00062 SETTING(StopAngle, GraphicLayer, double, 0.0) 00063 SETTING(SymbolName, GraphicLayer, std::string, "") 00064 SETTING(SymbolSize, GraphicLayer, unsigned int, 1) 00065 SETTING(TextColor, GraphicLayer, ColorType, ColorType()) 00066 SETTING(TextFont, GraphicLayer, std::string, "") 00067 SETTING(TextFontSize, GraphicLayer, unsigned int, 12) 00068 SETTING(TextBold, GraphicLayer, bool, false) 00069 SETTING(TextItalics, GraphicLayer, bool, false) 00070 SETTING(TextUnderline, GraphicLayer, bool, false) 00071 SETTING(UnitSystem, GraphicLayer, UnitSystem, UNIT_KM) 00072 00073 /** 00074 * Emitted with any<list<GraphicObject*> > when the list of selected objects changes. 00075 */ 00076 SIGNAL_METHOD(GraphicLayer, ObjectsSelected) 00077 00078 /** 00079 * Emitted with boost::any<GraphicObject*> when an object completes insertion 00080 * through GUI manipulation. The GraphicObject will be the object which 00081 * was inserted, but may be NULL if the object is invalid or otherwise 00082 * not included in the layer. 00083 */ 00084 SIGNAL_METHOD(GraphicLayer, ObjectInsertionCompleted); 00085 00086 /** 00087 * Adds a new graphic object to the layer. 00088 * 00089 * This method adds a new graphic object to the layer with the given type. The 00090 * object is selected, displaying selection nodes representing the object's 00091 * bounding rectangle. 00092 * 00093 * NOTE: A TRAIL_OBJECT should not be added by plug-in code. It is for internal Core 00094 * use only by the OverviewWindow. 00095 * 00096 * @param objectType 00097 * The type of graphic object to add. 00098 * 00099 * @return A pointer to the new graphic object. NULL is returned if an error 00100 * occurred. 00101 * 00102 * @notify This method will notify Subject::signalModified. 00103 * 00104 * @see removeObject() 00105 */ 00106 virtual GraphicObject* addObject(const GraphicObjectType& objectType) = 0; 00107 00108 /** 00109 * Removes an graphic object from the layer. 00110 * 00111 * @param pObject 00112 * The graphic object to remove. 00113 * @param bDelete 00114 * This flag should be set to TRUE to delete the object. If it is 00115 * FALSE, the object is not deleted. 00116 * 00117 * @return TRUE if the object was successfully removed, otherwise FALSE. 00118 * 00119 * @notify This method will notify Subject::signalModified. 00120 * 00121 * @see addObject() 00122 */ 00123 virtual bool removeObject(GraphicObject* pObject, bool bDelete) = 0; 00124 00125 /** 00126 * Retrieves all graphic objects in the layer. 00127 * 00128 * @param objects 00129 * A reference to a list that is filled with pointers to all 00130 * graphic objects in the layer. %Any pointers previously 00131 * contained in the list are removed. 00132 * 00133 * @see getSelectedObjects() 00134 */ 00135 virtual void getObjects(std::list<GraphicObject*>& objects) const = 0; 00136 00137 /** 00138 * Retrieves graphic objects of a given type in the layer. 00139 * 00140 * @param objectType 00141 * The type of graphic object to get. 00142 * @param objects 00143 * A reference to a list that is filled with pointers to all 00144 * graphic objects of the given type in the layer. %Any 00145 * pointers previously contained in the list are removed. 00146 * 00147 * @see getSelectedObjects() 00148 */ 00149 virtual void getObjects(const GraphicObjectType& objectType, 00150 std::list<GraphicObject*>& objects) const = 0; 00151 00152 /** 00153 * Returns the number of graphic objects in the layer. 00154 * 00155 * @return The total number of graphic objects in the layer. 00156 */ 00157 virtual unsigned int getNumObjects() const = 0; 00158 00159 /** 00160 * Returns the number of graphic objects of a given type in the layer. 00161 * 00162 * @param objectType 00163 * The type of object to query for the number of objects contained in the layer. 00164 * 00165 * @return The number of annotation objects of the given type in the layer. 00166 */ 00167 virtual unsigned int getNumObjects(const GraphicObjectType& objectType) const = 0; 00168 00169 /** 00170 * Returns a graphic object with the given name. 00171 * 00172 * If more than one graphic object has the given name, 00173 * an arbitrary object will be returned. 00174 * 00175 * @param name 00176 * The name of the graphic object to retrieve. 00177 * 00178 * @return A graphic object with the specified name 00179 * or NULL if no such object exists. 00180 */ 00181 virtual GraphicObject* getObjectByName(const std::string &name) const = 0; 00182 00183 /** 00184 * Selects a graphic object and displays its selection nodes. 00185 * 00186 * This method sets the annotation object as selected and creates selection nodes based 00187 * on the object's bounding rectangle. Some objects have white square nodes. These 00188 * are the bounding box handles to resize the object. Some object have yellow diamond nodes 00189 * which can be used to move object points within the current bounding box. 00190 * 00191 * @param pObject 00192 * The graphic object to select. The pointer cannot be NULL. 00193 * 00194 * @return TRUE if the object was successfully selected, otherwise FALSE. 00195 * 00196 * @notify This method will notify signalObjectsSelected. 00197 * 00198 * @see selectAllObjects(), deselectObject() 00199 */ 00200 virtual bool selectObject(GraphicObject* pObject) = 0; 00201 00202 /** 00203 * Selects all graphic objects on the layer. 00204 * 00205 * @notify This method will notify signalObjectsSelected. 00206 * 00207 * @see selectObject(), deselectAllObjects() 00208 */ 00209 virtual void selectAllObjects() = 0; 00210 00211 /** 00212 * Queries whether an graphic object is selected. 00213 * 00214 * @param pObject 00215 * The graphic object to query for its selection state. 00216 * 00217 * @return TRUE if the given object is selected, otherwise FALSE. 00218 * 00219 * @see selectObject(), deselectObject() 00220 */ 00221 virtual bool isObjectSelected(GraphicObject* pObject) const = 0; 00222 00223 /** 00224 * Fills a list with the selected graphic objects. 00225 * 00226 * @param selectedObjects 00227 * A reference to a list that is filled with pointers to all 00228 * selected graphic objects. %Any pointers previously 00229 * contained in the list are removed. 00230 * 00231 * @see getNumSelectedObjects(), getObjects() 00232 */ 00233 virtual void getSelectedObjects(std::list<GraphicObject*>& selectedObjects) const = 0; 00234 00235 /** 00236 * Fills a list with the selected graphic objects. 00237 * 00238 * @param objectType 00239 * The type of object for which to retrieve selected objects 00240 * contained in the layer. 00241 * @param selectedObjects 00242 * A reference to a list that is filled with pointers to all 00243 * selected graphic objects. %Any pointers previously 00244 * contained in the list are removed. 00245 * 00246 * @see getNumSelectedObjects(), getObjects() 00247 */ 00248 virtual void getSelectedObjects(const GraphicObjectType& objectType, 00249 std::list<GraphicObject*>& selectedObjects) const = 0; 00250 00251 /** 00252 * Returns the number of currently selected graphic objects. 00253 * 00254 * This method is equivalent to calling size() on the list filled by 00255 * getSelectedObjects(). 00256 * 00257 * @return The number of currently selected graphic objects. 00258 * 00259 * @see getSelectedObjects() 00260 */ 00261 virtual unsigned int getNumSelectedObjects() const = 0; 00262 00263 /** 00264 * Returns the number of currently selected graphic objects of a given type. 00265 * 00266 * @param objectType 00267 * The type of object to query for the number of selected objects contained 00268 * in the layer. 00269 * 00270 * @return The number of currently selected annotation objects of the given type. 00271 */ 00272 virtual unsigned int getNumSelectedObjects(const GraphicObjectType& objectType) const = 0; 00273 00274 /** 00275 * Deselects a graphic object. 00276 * 00277 * This method deselects a graphic object by effectively hiding its selection 00278 * nodes. 00279 * 00280 * @param pObject 00281 * The graphic object to deselect. The pointer cannot be NULL. 00282 * 00283 * @return TRUE if the item was successfully deselected, otherwise FALSE. 00284 * 00285 * @notify This method will notify signalObjectsSelected 00286 * 00287 * @see deselectAllObjects(), selectObject() 00288 */ 00289 virtual bool deselectObject(GraphicObject* pObject) = 0; 00290 00291 /** 00292 * Delete selected objects from the layer. 00293 * 00294 * @see selectAllObjects(), selectObject() 00295 */ 00296 virtual void deleteSelectedObjects() = 0; 00297 00298 /** 00299 * Clear the layer by deleting all objects in the layer. 00300 */ 00301 virtual void clear() = 0; 00302 00303 /** 00304 * Deselects all graphic objects on the layer. 00305 * 00306 * @notify This method will notify signalObjectsSelected. 00307 * 00308 * @see selectAllObjects(), selectObject() 00309 */ 00310 virtual void deselectAllObjects() = 0; 00311 00312 /** 00313 * Groups the objects currently selected into a single group. 00314 * 00315 * @notify This method will notify Subject::signalModified. 00316 * 00317 * @see ungroupSelection() 00318 */ 00319 virtual void groupSelection() = 0; 00320 00321 /** 00322 * Ungroups the objects in selected groups into individual objects. 00323 * The objects will all be selected after the ungroup. 00324 * 00325 * @notify This method will notify Subject::signalModified. 00326 * 00327 * @see groupSelection() 00328 */ 00329 virtual void ungroupSelection() = 0; 00330 00331 /** 00332 * Unselects all currently selected objects. 00333 * 00334 * @notify This method will notify signalObjectsSelected. 00335 * 00336 * @see deselectAllObjects() 00337 */ 00338 virtual void clearSelection() = 0; 00339 00340 /** 00341 * Brings the currently selected objects to the front of the layer. 00342 * It leaves the order of the selected objects unchanged relative to 00343 * each other. 00344 * 00345 * @notify This method will notify Subject::signalModified. 00346 * 00347 * @see pushBack() 00348 */ 00349 virtual void popFront() = 0; 00350 00351 /** 00352 * Sends the currently selected objects to the back of the layer. 00353 * It leaves the order of the selected objects unchanged relative to 00354 * each other. 00355 * 00356 * @notify This method will notify Subject::signalModified. 00357 * 00358 * @see popFront() 00359 */ 00360 virtual void pushBack() = 0; 00361 00362 /** 00363 * Queries whether graphic object name labels are currently drawn. 00364 * 00365 * @return True if labels are currently drawn, otherwise false. 00366 * 00367 * @see setShowLabels() 00368 */ 00369 virtual bool getShowLabels() const = 0; 00370 00371 /** 00372 * Sets whether to draw name labels for each graphic object. 00373 * 00374 * This method specifies whether to draw a label for the graphic object 00375 * name that is set with the GraphicObject::setName() method. This 00376 * setting is not serialized with the layer. 00377 * 00378 * @param bShowLabels 00379 * Determines whether or not to show the labels. 00380 * 00381 * @see getShowLabels() 00382 */ 00383 virtual void setShowLabels(bool bShowLabels) = 0; 00384 00385 /** 00386 * Correct the coordinate for whatever snapping may be required. 00387 * 00388 * GraphicLayer does not perform any correction. 00389 * 00390 * @param coord 00391 * Coordinate to correct. 00392 * 00393 * @return The corrected coordinate. 00394 */ 00395 virtual LocationType correctCoordinate(const LocationType &coord) const = 0; 00396 00397 /** 00398 * Queries whether the layer is locked or graphic objects can be 00399 * rotated or moved. 00400 * 00401 * @return True if the layer is locked, otherwise false. 00402 * 00403 * @see setLayerLocked() 00404 */ 00405 virtual bool getLayerLocked() const = 0; 00406 00407 /** 00408 * Sets whether to allow rotation or movement for graphic objects in the layer. 00409 * 00410 * This method specifies whether to allow the annotation objects in the layer to 00411 * be rotated or moved. This setting is not serialized with the layer. 00412 * 00413 * @param bLocked 00414 * Determines whether or not to lock the layer. 00415 * 00416 * @notify This method will notify signalModified(). 00417 * 00418 * @see getLayerLocked() 00419 */ 00420 virtual void setLayerLocked(bool bLocked) = 0; 00421 00422 /** 00423 * Sets the graphic object that will be created when the user adds a new 00424 * object with the mouse. 00425 * 00426 * This method provides a means for objects to set the created graphic 00427 * object for only this layer. This value is reset when the user selects a 00428 * new graphic object on the toolbar. 00429 * 00430 * @param type 00431 * The graphic object to create. 00432 * 00433 * @see DesktopServices::setAoiSelectionTool(), 00434 * DesktopServices::setAnnotationObject() 00435 */ 00436 virtual void setCurrentGraphicObjectType(GraphicObjectType type) = 0; 00437 00438 /** 00439 * Returns the graphic object that will be created when the user adds a 00440 * new object with the mouse. 00441 * 00442 * @return The graphic object that will be created when the user adds a 00443 * new object. This value may be different than the return value 00444 * of DesktopServices::getAoiSelectionTool() or 00445 * DesktopServices::getAnnotationObject() if the 00446 * setCurrentGraphicObjectType() method was called and the user 00447 * has not selected a new object type on the toolbar. 00448 */ 00449 virtual GraphicObjectType getCurrentGraphicObjectType() const = 0; 00450 00451 /** 00452 * Tests an input scene coordinate location to see if a graphic object 00453 * exists at that location. 00454 * 00455 * This method first searches selected objects and then searches all 00456 * graphic objects in the layer. 00457 * 00458 * @param sceneCoord 00459 * The scene coordinate to test for the existence of a graphic 00460 * object. 00461 * 00462 * @return A pointer to the first (topmost) graphic object found at the 00463 * input scene coordinate location. \c NULL is returned if no 00464 * graphic objects exist at the given location. 00465 */ 00466 virtual GraphicObject* hit(LocationType sceneCoord) const = 0; 00467 00468 protected: 00469 /** 00470 * This should be destroyed by calling SpatialDataView::deleteLayer. 00471 */ 00472 virtual ~GraphicLayer() {} 00473 }; 00474 00475 #endif