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 PLOTVIEW_H 00011 #define PLOTVIEW_H 00012 00013 #include "ConfigurationSettings.h" 00014 #include "OrthographicView.h" 00015 #include "TypesFile.h" 00016 00017 #include <list> 00018 00019 class AnnotationLayer; 00020 class Gridlines; 00021 class Locator; 00022 class PlotObject; 00023 00024 /** 00025 * Displays plot objects. 00026 * 00027 * The plot view provides the means to display one or more plot objects. Plot 00028 * objects can be added and removed from the view and can also be selected and 00029 * deselected. 00030 * 00031 * The plot view defines the following mouse modes, where the name given is the name 00032 * populated by MouseMode::getName(): 00033 * - AnnotationMode 00034 * - LocatorMode 00035 * - PanMode 00036 * - SelectionMode 00037 * - ZoomBoxMode 00038 * 00039 * The annotation mouse mode allows users to add annotation objects to the 00040 * plot. Objects can be added programatically via an annotation layer that is 00041 * accessible by calling the getAnnotationLayer() method. 00042 * 00043 * For the locator mouse mode, the view contains a default Locator object to display 00044 * on the plot. When this mouse mode is active, the default behavior is to display 00045 * the locator when the left mouse button is pressed and to hide the locator when the 00046 * left mouse button is released. Access to the locator to change its properties is 00047 * provided with the getMouseLocator() method. 00048 * 00049 * This subclass of Subject will notify upon the following conditions: 00050 * - The following methods are called: addObject(), deleteObject(), selectObjects(), 00051 * selectObject(), deleteSelectedObjects(). 00052 * - Everything else documented in OrthographicView. 00053 * 00054 * @see PlotObject 00055 */ 00056 class PlotView : public OrthographicView 00057 { 00058 public: 00059 SETTING(ClassificationMarkingPositions, PlotView, PositionType, CENTER) 00060 00061 /** 00062 * Emitted with any<PlotObject*> when an object is added to the plot. 00063 */ 00064 SIGNAL_METHOD(PlotView, ObjectAdded); 00065 00066 /** 00067 * Emitted with any<PlotObject*> when an object is deleted from the plot. 00068 */ 00069 SIGNAL_METHOD(PlotView, ObjectDeleted); 00070 00071 /** 00072 * Emitted with any<pair<PlotObject*,bool> > when an object is selected or deselected in the plot. 00073 */ 00074 SIGNAL_METHOD(PlotView, ObjectSelected); 00075 00076 /** 00077 * Returns the plot type. 00078 * 00079 * @return The plot type. 00080 * 00081 * @see PlotType 00082 */ 00083 virtual PlotType getPlotType() const = 0; 00084 00085 /** 00086 * Creates a new object but doesn't add it to the plot. 00087 * 00088 * This method creates a new object of the given type. 00089 * The object can be created as a primary object or secondary 00090 * object. A primary plot object is one that appears in the foreground of 00091 * the plot and has an entry in the legend. Most objects added to a plot 00092 * will be primary objects, but sometimes objects such as gridlines can be 00093 * created as secondary objects so that they will not be included with the 00094 * main data objects in the plot. 00095 * 00096 * @param objectType 00097 * The type of plot object to add. 00098 * @param bPrimary 00099 * Set this value to TRUE to create a primary object or FALSE to 00100 * create a secondary object. 00101 * 00102 * @return A pointer to the new plot object. NULL is returned if an error 00103 * occurred and the object could not be added. 00104 */ 00105 virtual PlotObject* createObject(const PlotObjectType& objectType, bool bPrimary) = 0; 00106 00107 /** 00108 * Adds a new object to the plot. 00109 * 00110 * This method adds a new object of the given type to the plot with the 00111 * given type. The object can be created as a primary object or secondary 00112 * object. A primary plot object is one that appears in the foreground of 00113 * the plot and has an entry in the legend. Most objects added to a plot 00114 * will be primary objects, but sometimes objects such as gridlines can be 00115 * created as secondary objects so that they will not be included with the 00116 * main data objects in the plot. 00117 * 00118 * @param objectType 00119 * The type of plot object to add. 00120 * @param bPrimary 00121 * Set this value to TRUE to create a primary object or FALSE to 00122 * create a secondary object. 00123 * 00124 * @return A pointer to the new plot object. NULL is returned if an error 00125 * occurred and the object could not be added. 00126 * 00127 * @notify This method will notify signalObjectAdded() with 00128 * any<PlotObject*>. 00129 */ 00130 virtual PlotObject* addObject(const PlotObjectType& objectType, bool bPrimary) = 0; 00131 00132 /** 00133 * Retrieves all objects in the plot. 00134 * 00135 * @param objects 00136 * A list that is populated with pointers to all objects in the 00137 * plot. 00138 */ 00139 virtual void getObjects(std::list<PlotObject*>& objects) const = 0; 00140 00141 /** 00142 * Retrieves objects in the plot of a given type. 00143 * 00144 * @param objectType 00145 * The plot object type for which to retrieve the current objects. 00146 * @param objects 00147 * A list that is populated with pointers to all objects in the 00148 * plot of the given type. 00149 */ 00150 virtual void getObjects(const PlotObjectType& objectType, std::list<PlotObject*>& objects) const = 0; 00151 00152 /** 00153 * Queries whether an object exists in this plot. 00154 * 00155 * @param pObject 00156 * The object for which to query the plot. 00157 * 00158 * @return TRUE if this plot contains the object, otherwise FALSE. 00159 */ 00160 virtual bool containsObject(PlotObject* pObject) const = 0; 00161 00162 /** 00163 * Returns the number of objects in the plot. 00164 * 00165 * @return The total number of objects in the plot. 00166 */ 00167 virtual unsigned int getNumObjects() const = 0; 00168 00169 /** 00170 * Removes an object from the plot and deletes it. 00171 * 00172 * @param pObject 00173 * The annotation object to delete. 00174 * 00175 * @return TRUE if the object was successfully removed and deleted, 00176 * otherwise FALSE. 00177 * 00178 * @see clear() 00179 * 00180 * @notify This method will notify signalObjectDeleted() with 00181 * any<PlotObject*>. 00182 */ 00183 virtual bool deleteObject(PlotObject* pObject) = 0; 00184 00185 /** 00186 * Removes all objects from the plot. 00187 */ 00188 virtual void clear() = 0; 00189 00190 /** 00191 * Moves a given object to the front of the plot. 00192 * 00193 * This method repositions the given object to be the topmost object in the 00194 * plot. 00195 * 00196 * @param pObject 00197 * The object to move to the front of the plot. 00198 * 00199 * @see moveObjectToBack() 00200 */ 00201 virtual bool moveObjectToFront(PlotObject* pObject) = 0; 00202 00203 /** 00204 * Moves a given object to the back of the plot. 00205 * 00206 * This method repositions the given object to be the bottommost object in the 00207 * plot. If the object is a primary object, it will still be on top of any 00208 * secondary objects. 00209 * 00210 * @param pObject 00211 * The object to move to the back of the plot. 00212 * 00213 * @see moveObjectToFront() 00214 */ 00215 virtual bool moveObjectToBack(PlotObject* pObject) = 0; 00216 00217 /** 00218 * Selects or deselects an object in the plot. 00219 * 00220 * This method sets a given plot object as selected and may alter how the object 00221 * is drawn in the plot. This is done mainly for user feedback that the object 00222 * is selected. For some objects, like the histogram, selecting the object does 00223 * nothing. 00224 * 00225 * @param pObject 00226 * The plot object to select. Cannot be NULL. 00227 * @param bSelect 00228 * Set this value to TRUE to select the object or FALSE to deselect the 00229 * object. 00230 * 00231 * @return TRUE if the object was successfully selected or deselected, otherwise 00232 * FALSE. 00233 * 00234 * @see selectObjects() 00235 * 00236 * @notify This method will notify signalObjectSelected() with 00237 * any<pair<PlotObject*,bool> >. 00238 */ 00239 virtual bool selectObject(PlotObject* pObject, bool bSelect) = 0; 00240 00241 /** 00242 * Selects or deselects multiple objects in the plot. 00243 * 00244 * @param objects 00245 * The plot objects to select. 00246 * @param bSelect 00247 * Set this value to TRUE to select the objects or FALSE to deselect the 00248 * objects. 00249 * 00250 * @see selectObject() 00251 * 00252 * @notify This method will notify signalObjectSelected() with 00253 * any<pair<PlotObject*,bool> > for each object selected or 00254 * deselected. 00255 */ 00256 virtual void selectObjects(const std::list<PlotObject*>& objects, bool bSelect) = 0; 00257 00258 /** 00259 * Selects or deselects all objects in the plot. 00260 * 00261 * @param bSelect 00262 * Set this value to TRUE to select the objects or FALSE to deselect the 00263 * objects. 00264 * 00265 * @see selectObject() 00266 * 00267 * @notify This method will notify signalObjectSelected() with 00268 * any<pair<PlotObject*,bool> > for each object selected or 00269 * deselected. 00270 */ 00271 virtual void selectObjects(bool bSelect) = 0; 00272 00273 /** 00274 * Retrieves the currently selected objects on the plot. 00275 * 00276 * @param selectedObjects 00277 * A list that is populated with pointers to selected plot objects. 00278 * @param filterVisible 00279 * True if selectedObjects should contain only visible objects. 00280 * 00281 * @see getNumSelectedObjects() 00282 */ 00283 virtual void getSelectedObjects(std::list<PlotObject*>& selectedObjects, bool filterVisible) const = 0; 00284 00285 /** 00286 * Returns the number of selected objects in the plot. 00287 * 00288 * @param filterVisible 00289 * True if the count should only include visible objects 00290 * 00291 * @return The number of selected objects in the plot. 00292 */ 00293 virtual unsigned int getNumSelectedObjects(bool filterVisible) const = 0; 00294 00295 /** 00296 * Removes all selected objects from the plot and deletes them. 00297 * 00298 * @param filterVisible 00299 * True if it should delete only visible selected objects. 00300 * 00301 * @see deleteObject() 00302 * 00303 * @notify This method will notify signalObjectDeleted() with 00304 * any<PlotObject*> for each object deleted. 00305 */ 00306 virtual void deleteSelectedObjects(bool filterVisible) = 0; 00307 00308 /** 00309 * Set the selection mode for this plot. 00310 * 00311 * @param mode 00312 * The new selection mode. 00313 */ 00314 virtual void setSelectionMode(PlotSelectionModeType mode) = 0; 00315 00316 /** 00317 * Get the selection mode for this plot. 00318 * 00319 * @return The current selection mode. 00320 */ 00321 virtual PlotSelectionModeType getSelectionMode() const = 0; 00322 00323 /** 00324 * Get the selection display mode for this plot. 00325 * 00326 * @return The current selection mode. 00327 */ 00328 virtual PointSelectionDisplayType getSelectionDisplayMode() const = 0; 00329 00330 /** 00331 * Set the selection display mode for this plot. 00332 * 00333 * @param mode 00334 * The new selection mode. 00335 */ 00336 virtual void setSelectionDisplayMode(PointSelectionDisplayType mode) = 0; 00337 00338 /** 00339 * Returns the annotation layer for the plot. 00340 * 00341 * The annotation layer is drawn on top of the data objects and the 00342 * gridlines. The layer can be modified, but ownership remains with the 00343 * plot view. 00344 * 00345 * @return A pointer to the annotation layer. 00346 */ 00347 virtual AnnotationLayer* getAnnotationLayer() const = 0; 00348 00349 /** 00350 * Returns the mouse locator object used in the "LocatorMode" mouse mode. 00351 * 00352 * @return A pointer to the locator object. 00353 */ 00354 virtual Locator* getMouseLocator() = 0; 00355 00356 /** 00357 * Returns read-only access to the mouse locator object used in the 00358 * "LocatorMode" mouse mode. 00359 * 00360 * @return A const pointer to the locator object. The locator object 00361 * represented by the returned pointer should not be modified. To 00362 * modify the values, call the non-const version of 00363 * getMouseLocator(). 00364 */ 00365 virtual const Locator* getMouseLocator() const = 0; 00366 00367 /** 00368 * Translate from world coordinates to data coordinates for this plot. 00369 * 00370 * @param worldX 00371 * World x-coordinate 00372 * @param worldY 00373 * World y-coordinate 00374 * @param dataX 00375 * X-coordinate of the plot 00376 * @param dataY 00377 * Y-coordinate of the plot 00378 */ 00379 virtual void translateWorldToData(double worldX,double worldY, double& dataX, double& dataY) const = 0; 00380 00381 /** 00382 * Translate from data coordinates to world coordinates for this plot. 00383 * 00384 * @param dataX 00385 * X-coordinate of the plot 00386 * @param dataY 00387 * Y-coordinate of the plot 00388 * @param worldX 00389 * World x-coordinate 00390 * @param worldY 00391 * World y-coordinate 00392 */ 00393 virtual void translateDataToWorld(double dataX, double dataY, double& worldX, double& worldY) const = 0; 00394 00395 /** 00396 * Translate from screen coordinates to data coordinates for this plot. 00397 * 00398 * @param screenX 00399 * Screen x-coordinate 00400 * @param screenY 00401 * Screen y-coordinate 00402 * @param dataX 00403 * X-coordinate of the plot 00404 * @param dataY 00405 * Y-coordinate of the plot 00406 */ 00407 virtual void translateScreenToData(double screenX, double screenY, double& dataX, double& dataY) const = 0; 00408 00409 /** 00410 * Translate from data coordinates to screen coordinates for this plot. 00411 * 00412 * @param dataX 00413 * X-coordinate of the plot 00414 * @param dataY 00415 * Y-coordinate of the plot 00416 * @param screenX 00417 * Screen x-coordinate 00418 * @param screenY 00419 * Screen y-coordinate 00420 */ 00421 virtual void translateDataToScreen(double dataX, double dataY, double& screenX, double& screenY) const = 0; 00422 00423 /** 00424 * Enables or disables shading when displaying pointset lines. 00425 * 00426 * @param shading 00427 * Set to true to enable GL_SMOOTH shading when drawing pointset lines. The default 00428 * is to disable shading (GL_FLAT). 00429 */ 00430 virtual void setEnableShading( bool shading ) = 0; 00431 00432 /** 00433 * Returns true if shading is enabled, otherwise false. 00434 * 00435 * @return True if shading is enabled, otherwise false. 00436 */ 00437 virtual bool isShadingEnabled() const = 0; 00438 00439 /** 00440 * Sets a margin around the overall plot extents. 00441 * 00442 * The plot extents as returned by getExtents() is calculated based on the 00443 * extents of all primary plot objects it contains. An additional amount 00444 * can be added to the plot extents by specifying a margin factor that is 00445 * multiplied to the data range of the object extents. For example a 00446 * margin factor of 0.01 subtracts one percent of the data range from the 00447 * minimum value and adds one percent of the data range to the maximum 00448 * value. 00449 * 00450 * Calling this method sets the margin for both X and Y dimensions. 00451 * 00452 * The default margin factor is 0.0. 00453 * 00454 * @param marginFactor 00455 * The factor that should be multiplied by the data range to use 00456 * as additional margin around the plot objects. If the given 00457 * value is less than zero, the margin factor is set to 0.0. 00458 */ 00459 virtual void setExtentsMargin(double marginFactor) = 0; 00460 00461 /** 00462 * Returns the margin around the overall plot extents. 00463 * 00464 * @return The factor that is multiplied by the data range to use 00465 * as additional margin around the plot objects. 00466 * 00467 * @see setExtentsMargin() 00468 */ 00469 virtual double getExtentsMargin() const = 0; 00470 00471 protected: 00472 /** 00473 * This object should be destroyed by calling DesktopServices::deleteView(). 00474 */ 00475 virtual ~PlotView() {} 00476 }; 00477 00478 #endif