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 PLOTSET_H 00011 #define PLOTSET_H 00012 00013 #include "SessionItem.h" 00014 #include "Subject.h" 00015 #include "TypesFile.h" 00016 00017 #include <string> 00018 #include <vector> 00019 00020 class PlotWidget; 00021 class QWidget; 00022 class View; 00023 00024 /** 00025 * A collection of plots in a single widget. 00026 * 00027 * A plot set provides a grouping of plots within a single widget. A plot set 00028 * displays individual plots on tabs along the bottom of the widget. Each tab 00029 * contains a single plot widget. 00030 * 00031 * To display multiple plot set widgets within a single widget, see the 00032 * PlotSetGroup class. 00033 * 00034 * This subclass of Subject will notify upon the following conditions: 00035 * - The following methods are called: setName(), setAssociatedView(), 00036 * createPlot(), setCurrentPlot(), deletePlot(), clear() 00037 * - Everything else documented in Subject. 00038 * 00039 * @see PlotSetGroup, PlotWidget 00040 */ 00041 class PlotSet : public SessionItem, public Subject 00042 { 00043 public: 00044 /** 00045 * Emitted when the plot set is renamed with boost::any<std::string> 00046 * containing the new plot set name. 00047 * 00048 * @see setName() 00049 */ 00050 SIGNAL_METHOD(PlotSet, Renamed) 00051 00052 /** 00053 * Emitted when a view is associated with the plot set with 00054 * boost::any<\link View\endlink*> containing a pointer to the newly 00055 * associated view. 00056 * 00057 * @see setAssociatedView() 00058 */ 00059 SIGNAL_METHOD(PlotSet, ViewAssociated) 00060 00061 /** 00062 * Emitted when a plot widget is added to the plot set with 00063 * boost::any<\link PlotWidget\endlink*> containing a pointer to the plot 00064 * widget that is being added. 00065 * 00066 * @see createPlot() 00067 */ 00068 SIGNAL_METHOD(PlotSet, PlotAdded) 00069 00070 /** 00071 * Emitted when a plot widget is activated with 00072 * boost::any<\link PlotWidget\endlink*> containing a pointer to the newly 00073 * activated plot widget. 00074 * 00075 * @see setCurrentPlot() 00076 */ 00077 SIGNAL_METHOD(PlotSet, Activated) 00078 00079 /** 00080 * Emitted when a plot widget is deleted from the plot set with 00081 * boost::any<\link PlotWidget\endlink*> containing a pointer to the plot 00082 * widget that is being deleted. 00083 * 00084 * @see deletePlot(), clear() 00085 */ 00086 SIGNAL_METHOD(PlotSet, PlotDeleted) 00087 00088 /** 00089 * Sets the plot set name. 00090 * 00091 * @param name 00092 * The new plot set name. This method does nothing if an empty 00093 * string is passed in. 00094 * 00095 * @notify This method will notify signalRenamed() with 00096 * boost::any<std::string> containing the new plot set name. 00097 */ 00098 virtual void setName(const std::string& name) = 0; 00099 00100 /** 00101 * Returns the Qt widget pointer for this plot set widget. 00102 * 00103 * @return A non-const pointer to the Qt widget containing the plot set. 00104 * 00105 * @see getWidget() const 00106 */ 00107 virtual QWidget* getWidget() = 0; 00108 00109 /** 00110 * Returns the Qt widget pointer for this plot set widget. 00111 * 00112 * @return A const pointer to the Qt widget containing the plot set. 00113 * 00114 * @see getWidget() 00115 */ 00116 virtual const QWidget* getWidget() const = 0; 00117 00118 /** 00119 * Creates a new plot in the plot set. 00120 * 00121 * This method creates an empty plot and adds it to plot set. 00122 * 00123 * @param plotName 00124 * The plot name. 00125 * @param plotType 00126 * The plot type. 00127 * 00128 * @return A pointer to the created plot. \c NULL is returned if an error 00129 * occurred and the plot could not be created. 00130 * 00131 * @notify This method will notify signalPlotAdded() with 00132 * boost::any<\link PlotWidget\endlink*> containing a pointer to 00133 * the plot widget that is created. 00134 */ 00135 virtual PlotWidget* createPlot(const std::string& plotName, const PlotType& plotType) = 0; 00136 00137 /** 00138 * Retrieves the plot with a given name. 00139 * 00140 * @param plotName 00141 * The plot name. 00142 * 00143 * @return A pointer to the plot. \c NULL is returned if no plot exists 00144 * with the given name in the plot set. 00145 * 00146 * @see getPlots(), getCurrentPlot() 00147 */ 00148 virtual PlotWidget* getPlot(const std::string& plotName) const = 0; 00149 00150 /** 00151 * Retrieves plots of a given type contained in the plot set. 00152 * 00153 * @param plotType 00154 * The plot type. 00155 * @param plots 00156 * A vector to contain pointers to the plots in the plot set. The vector is 00157 * emptied if the plot set does not contain any plots of the given type. 00158 * 00159 * @see getPlot(), getCurrentPlot() 00160 */ 00161 virtual void getPlots(const PlotType& plotType, std::vector<PlotWidget*>& plots) const = 0; 00162 00163 /** 00164 * Retrieves all plots contained in the plot set. 00165 * 00166 * @param plots 00167 * A vector to contain pointers to the plots in the plot set. The vector is 00168 * emptied if the plot set does not contain any plots. 00169 * 00170 * @see getPlot(), getCurrentPlot() 00171 */ 00172 virtual void getPlots(std::vector<PlotWidget*>& plots) const = 0; 00173 00174 /** 00175 * Returns the number of plots in the plot set. 00176 * 00177 * @return The number of plots in the plot set. 00178 */ 00179 virtual unsigned int getNumPlots() const = 0; 00180 00181 /** 00182 * Queries whether a plot exists in the plot set. 00183 * 00184 * @param pPlot 00185 * The plot to query for its existence. 00186 * 00187 * @return Returns \c true if the plot is contained in the plot set; 00188 * otherwise returns \c false. 00189 */ 00190 virtual bool containsPlot(PlotWidget* pPlot) const = 0; 00191 00192 /** 00193 * Sets the active plot in the plot set. 00194 * 00195 * @param pPlot 00196 * The plot to make the active plot. This method does nothing if 00197 * \c NULL is passed in. 00198 * 00199 * @return Returns \c true if the plot was successfully activated; 00200 * otherwise returns \c false. 00201 * 00202 * @notify This method will notify signalActivated() with 00203 * boost::any<\link PlotWidget\endlink*> containing a pointer to 00204 * the newly activated plot widget. 00205 */ 00206 virtual bool setCurrentPlot(PlotWidget* pPlot) = 0; 00207 00208 /** 00209 * Returns the active plot for the plot set. 00210 * 00211 * @return A pointer to the active plot. \c NULL is returned if the plot 00212 * set does not contain any plots. 00213 * 00214 * @see getPlot() 00215 */ 00216 virtual PlotWidget* getCurrentPlot() const = 0; 00217 00218 /** 00219 * Renames a plot in the plot set with a given name. 00220 * 00221 * @param pPlot 00222 * The plot to rename. This method does nothing if \c NULL is 00223 * passed in. 00224 * @param newPlotName 00225 * The new plot name, which appears on the tab. The name cannot 00226 * have the same name as another plot in the plot set. This method 00227 * does nothing if an empty string is passed in. 00228 * 00229 * @return Returns \c true if the plot was successfully renamed. Returns 00230 * \c false if the plot does not exist or the new name is the same 00231 * as that of another plot. 00232 * 00233 * @notify This method will notify View::signalRenamed() with 00234 * boost::any<std::string> containing the new plot name. 00235 * 00236 * @see renamePlot(PlotWidget*) 00237 */ 00238 virtual bool renamePlot(PlotWidget* pPlot, const std::string& newPlotName) = 0; 00239 00240 /** 00241 * Deletes a plot in the plot set. 00242 * 00243 * @param pPlot 00244 * The plot to delete. This method does nothing if \c NULL is 00245 * passed in. 00246 * 00247 * @return Returns \c true if the plot was successfully deleted from this 00248 * plot set; otherwise returns \c false. 00249 * 00250 * @notify This method will notify signalPlotDeleted() with 00251 * boost::any<\link PlotWidget\endlink*> containing a pointer to 00252 * the plot widget that is being deleted. 00253 */ 00254 virtual bool deletePlot(PlotWidget* pPlot) = 0; 00255 00256 /** 00257 * Removes all plots from the plot set. 00258 * 00259 * @notify This method will notify signalPlotDeleted() with 00260 * boost::any<\link PlotWidget\endlink*> containing a pointer to 00261 * the plot widget that is being deleted for each plot removed from 00262 * the set. 00263 */ 00264 virtual void clear() = 0; 00265 00266 /** 00267 * Associates a view with the plot set. 00268 * 00269 * This method associates a view with the plot set. When a view is 00270 * associated with the plot set, plots are added and removed as layers are 00271 * created and destroyed in the view. 00272 * 00273 * @warning If the associated view is deleted, the plot set is also deleted 00274 * automatically. 00275 * 00276 * @param pView 00277 * The view to associate with plot set. If \e pView is \c NULL, 00278 * the plot set does not have an associated view. 00279 * 00280 * @notify This method will notify signalViewAssociated() with 00281 * boost::any<\link View\endlink*> containing a pointer to the 00282 * newly associated view. 00283 */ 00284 virtual void setAssociatedView(View* pView) = 0; 00285 00286 /** 00287 * Returns the view associated with the plot set. 00288 * 00289 * @return A non-const pointer to the view currently associated with the 00290 * plot set. \c NULL is returned if no view is associated. 00291 * 00292 * @see setAssociatedView(), getAssociatedView() const 00293 */ 00294 virtual View* getAssociatedView() = 0; 00295 00296 /** 00297 * Returns the view associated with the plot set. 00298 * 00299 * @return A const pointer to the view currently associated with the plot 00300 * set. \c NULL is returned if no view is associated. 00301 * 00302 * @see setAssociatedView(), getAssociatedView() 00303 */ 00304 virtual const View* getAssociatedView() const = 0; 00305 00306 /** 00307 * Renames a plot in the plot set with a user-defined name. 00308 * 00309 * This method prompts the user to select a new name for the given plot and 00310 * renames the plot. 00311 * 00312 * @param pPlot 00313 * The plot to rename. This method does nothing if \c NULL is 00314 * passed in. 00315 * 00316 * @return The new plot name, which is guaranteed to be unique for all 00317 * plots in the plot set. An empty string is returned if the user 00318 * cancels the process. 00319 * 00320 * @notify This method will notify View::signalRenamed() with 00321 * boost::any<std::string> containing the new plot name chosen by 00322 * the user. 00323 * 00324 * @see renamePlot(PlotWidget*, const std::string&) 00325 */ 00326 virtual std::string renamePlot(PlotWidget* pPlot) = 0; 00327 00328 protected: 00329 /** 00330 * The plot set should be destroyed only if it is not owned by a parent 00331 * widget by calling DesktopServices::deletePlotSet(). 00332 */ 00333 virtual ~PlotSet() 00334 {} 00335 }; 00336 00337 #endif