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 LOCATOR_H 00011 #define LOCATOR_H 00012 00013 #include "ColorType.h" 00014 #include "LocationType.h" 00015 #include "EnumWrapper.h" 00016 #include "PlotObject.h" 00017 #include "TypesFile.h" 00018 00019 #include <string> 00020 00021 /** 00022 * Marks a specific location on a plot. 00023 * 00024 * The locator object can be used to pinpoint a particular location on a plot. A combination 00025 * of a horizontal line and vertical line are used to mark the location. A single horizontal 00026 * line or a single vertical line can also be drawn to mark a particular value along a single 00027 * plot axis. 00028 * 00029 * This subclass of Subject will notify upon the following conditions: 00030 * - The following methods are called: setLocation(), setStyle(), setColor(), 00031 * setLineWidth(), setLineStyle(). 00032 * - Everything else documented in PlotObject. 00033 * 00034 * @see PlotObject, Locator::LocatorStyle 00035 */ 00036 class Locator : public PlotObject 00037 { 00038 public: 00039 /** 00040 * Specifies how the locator is drawn. 00041 */ 00042 enum LocatorStyleEnum 00043 { 00044 HORIZONTAL_LOCATOR = 0x0001, /**< A single horizontal line is drawn along 00045 the x-axis */ 00046 VERTICAL_LOCATOR = 0x0002, /**< A single vertical line is drawn along the 00047 y-axis */ 00048 CROSSHAIR_LOCATOR = HORIZONTAL_LOCATOR | VERTICAL_LOCATOR /**< A horizonal line and vertical line are 00049 drawn, intersecting at the locator location*/ 00050 }; 00051 00052 /** 00053 * @EnumWrapper Locator::LocatorStyleEnum. 00054 */ 00055 typedef EnumWrapper<LocatorStyleEnum> LocatorStyle; 00056 00057 /** 00058 * Emitted with any<LocationType> when the locator position changes. 00059 */ 00060 SIGNAL_METHOD(Locator, LocationChanged) 00061 /** 00062 * Emitted with any<LocatorStyle> when the locator style changes. 00063 */ 00064 SIGNAL_METHOD(Locator, StyleChanged) 00065 /** 00066 * Emitted with any<std::pair<std::string,std::string> > when the locator 00067 * text changes, containing the new xText and yText as first and second 00068 * respectively. 00069 */ 00070 SIGNAL_METHOD(Locator, TextChanged) 00071 00072 /** 00073 * Sets the locator location. 00074 * 00075 * @param location 00076 * The new locator location. 00077 * 00078 * @param updateText 00079 * If true, the locator will update its text strings to reflect 00080 * the position of the locator. If false, it will leave them 00081 * unchanged. 00082 * 00083 * @notify This method will notify signalLocationChanged() with 00084 * any<LocationType>. 00085 */ 00086 virtual void setLocation(const LocationType& location, bool updateText = true) = 0; 00087 00088 /** 00089 * Returns the locator location. 00090 * 00091 * @return The current locator location. 00092 */ 00093 virtual LocationType getLocation() const = 0; 00094 00095 /** 00096 * Sets the locator text. 00097 * 00098 * @param xText 00099 * The new x text string. 00100 * 00101 * @param yText 00102 * The new y text string. 00103 * 00104 * @notify This method will notify signalTextChanged() with 00105 * any<std::pair<std::string,std::string> > containing the new 00106 * xText and yText as first and second respectively. 00107 */ 00108 virtual void setText(const std::string& xText, const std::string& yText) = 0; 00109 00110 /** 00111 * Retrieves the locator text strings. 00112 * 00113 * @param xText 00114 * The x text string. 00115 * 00116 * @param yText 00117 * The y text string. 00118 */ 00119 virtual void getText(std::string& xText, std::string& yText) const = 0; 00120 00121 /** 00122 * Sets the locator style. 00123 * 00124 * @param style 00125 * The new locator style. 00126 * 00127 * @see Locator::LocatorStyle 00128 * 00129 * @notify This method will notify signalStyleChanged() with 00130 * any<LocatorStyle>. 00131 */ 00132 virtual void setStyle(LocatorStyle style) = 0; 00133 00134 /** 00135 * Returns the locator style. 00136 * 00137 * @return The current locator style. 00138 */ 00139 virtual LocatorStyle getStyle() const = 0; 00140 00141 /** 00142 * Sets the locator color. 00143 * 00144 * @param locatorColor 00145 * The new locator color. Must be a valid color. 00146 * 00147 * @see ColorType::isValid() 00148 * 00149 * @notify This method will notify with Subject::signalModified(). 00150 */ 00151 virtual void setColor(const ColorType& locatorColor) = 0; 00152 00153 /** 00154 * Returns the locator color. 00155 * 00156 * @return The current locator color. 00157 */ 00158 virtual ColorType getColor() const = 0; 00159 00160 /** 00161 * Sets the locator line width. 00162 * 00163 * @param iWidth 00164 * The new locator line width. Cannot be zero. 00165 * 00166 * @notify This method will notify with Subject::signalModified(). 00167 */ 00168 virtual void setLineWidth(int iWidth) = 0; 00169 00170 /** 00171 * Returns the locator line width. 00172 * 00173 * @return The current locator line width. 00174 */ 00175 virtual int getLineWidth() const = 0; 00176 00177 /** 00178 * Sets the locator line style. 00179 * 00180 * @param lineStyle 00181 * The new locator line style. 00182 * 00183 * @see LineStyle 00184 * 00185 * @notify This method will notify with Subject::signalModified(). 00186 */ 00187 virtual void setLineStyle(LineStyle lineStyle) = 0; 00188 00189 /** 00190 * Returns the locator line style. 00191 * 00192 * @return The current locator line style. 00193 */ 00194 virtual LineStyle getLineStyle() const = 0; 00195 00196 protected: 00197 /** 00198 * This should be destroyed by calling PlotView::deleteObject. 00199 */ 00200 virtual ~Locator() {} 00201 }; 00202 00203 #endif