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 AXIS_H 00011 #define AXIS_H 00012 00013 #include "ColorType.h" 00014 #include "TypesFile.h" 00015 00016 #include <string> 00017 #include <vector> 00018 00019 class Font; 00020 class QWidget; 00021 00022 /** 00023 * Displays plot values along a scale. 00024 * 00025 * The Axis widget calculates values according to a scale type and displays 00026 * values along the scale with tick marks. In the PlotWidget, axis widgets 00027 * are positioned around a PlotView to show the currently displayed area of 00028 * the plot. 00029 * 00030 * This interface provides access to associate a title with the axis and to 00031 * change its text properties and to define the scale that is used to 00032 * calculate the axis values. 00033 * 00034 * @see PlotWidget 00035 */ 00036 class Axis 00037 { 00038 public: 00039 /** 00040 * Returns the Qt widget that displays the axis. 00041 * 00042 * This method returns the Qt widget that displays the axis. This can be 00043 * used to add the axis to a custom dialog or widget if it is not already 00044 * contained in a PlotWidget. 00045 * 00046 * @return A pointer to the Qt widget that displays the axis. 00047 */ 00048 virtual QWidget* getWidget() = 0; 00049 00050 /** 00051 * Returns the axis position. 00052 * 00053 * The axis poisition is the position where the axis should be displayed 00054 * relative to a plot view. It defines how the tick marks are drawn and 00055 * how the text is oriented. 00056 * 00057 * @return The axis position. 00058 */ 00059 virtual AxisPosition getPosition() const = 0; 00060 00061 /** 00062 * Sets the title text. 00063 * 00064 * @param title 00065 * The new title text. 00066 */ 00067 virtual void setTitle(const std::string& title) = 0; 00068 00069 /** 00070 * Returns the title text. 00071 * 00072 * @return The current title. An empty string is returned if a title has 00073 * not yet been set. 00074 */ 00075 virtual std::string getTitle() const = 0; 00076 00077 /** 00078 * Sets the font for the title text. 00079 * 00080 * @param font 00081 * The new title font. 00082 */ 00083 virtual void setTitleFont(const Font& font) = 0; 00084 00085 /** 00086 * Returns read-only access to the title text font. 00087 * 00088 * @return The current title text font. To modify the font values, call 00089 * setTitleFont() instead. 00090 */ 00091 virtual const Font& getTitleFont() const = 0; 00092 00093 /** 00094 * Sets the title text color. 00095 * 00096 * @param titleColor 00097 * The new title text color. 00098 */ 00099 virtual void setTitleColor(const ColorType& titleColor) = 0; 00100 00101 /** 00102 * Returns the title color. 00103 * 00104 * @return The current title text color. A valid color is returned even 00105 * if the title is empty. 00106 */ 00107 virtual ColorType getTitleColor() const = 0; 00108 00109 /** 00110 * Sets the axis scale type. 00111 * 00112 * @param scaleType 00113 * The new scale type. 00114 */ 00115 virtual void setScaleType(ScaleType scaleType) = 0; 00116 00117 /** 00118 * Returns the axis scale type. 00119 * 00120 * @return The scale type. 00121 */ 00122 virtual ScaleType getScaleType() const = 0; 00123 00124 /** 00125 * Sets the minimum and maximum values. 00126 * 00127 * @param dMin 00128 * The new minimum value. 00129 * @param dMax 00130 * The new maximum value. 00131 */ 00132 virtual void setValueRange(double dMin, double dMax) = 0; 00133 00134 /** 00135 * Returns the minimum axis value. 00136 * 00137 * @return The minimum value of the axis. 00138 */ 00139 virtual double getMinimumValue() const = 0; 00140 00141 /** 00142 * Returns the maximum axis value. 00143 * 00144 * @return The maximum value of the axis. 00145 */ 00146 virtual double getMaximumValue() const = 0; 00147 00148 /** 00149 * Returns the values of all major tick mark locations. 00150 * 00151 * @return The major tick mark values. The values are guaranteed to be 00152 * between the minimum and maximum value inclusive. 00153 * 00154 * @see getMinorTickLocations(), getMinimumValue(), getMaximumValue() 00155 */ 00156 virtual std::vector<double> getMajorTickLocations() const = 0; 00157 00158 /** 00159 * Returns the values of all minor tick mark locations. 00160 * 00161 * @return The minor tick mark values. The values are guaranteed to be 00162 * between the minimum and maximum value inclusive. 00163 * 00164 * @see getMajorTickLocations(), getMinimumValue(), getMaximumValue() 00165 */ 00166 virtual std::vector<double> getMinorTickLocations() const = 0; 00167 00168 /** 00169 * Sets the maximum number of major tick marks along the axis scale. 00170 * 00171 * This method sets the maximum number of major tick marks to display along 00172 * the axis scale. Calling this method recalculates the scale based on the 00173 * current minimum and maximum values. 00174 * 00175 * @param numTicks 00176 * The new maximum number of major tick marks. 00177 * 00178 * @see setMaxNumMinorTicks() 00179 */ 00180 virtual void setMaxNumMajorTicks(int numTicks) = 0; 00181 00182 /** 00183 * Sets the maximum number of minor tick marks along the axis scale. 00184 * 00185 * This method sets the maximum number of minor tick marks to display 00186 * between each major tick mark along the axis scale. Calling this method 00187 * recalculates the scale based on the current minimum and maximum values. 00188 * 00189 * @param numTicks 00190 * The new maximum number of minor tick marks. 00191 * 00192 * @see setMaxNumMajorTicks() 00193 */ 00194 virtual void setMaxNumMinorTicks(int numTicks) = 0; 00195 00196 /** 00197 * Returns the maximum number of major tick marks along the axis scale. 00198 * 00199 * This method returns the maximum number of major tick marks that are 00200 * displayed between the minimum and maximum value. The default value is 00201 * ten. 00202 * 00203 * @return The maximum value of major tick marks. 00204 */ 00205 virtual int getMaxNumMajorTicks() const = 0; 00206 00207 /** 00208 * Returns the maximum number of minor tick marks along the axis scale. 00209 * 00210 * This method returns the maximum number of minor tick marks that are 00211 * displayed between each major tick mark along the axis scale. The 00212 * default value is four. 00213 * 00214 * @return The maximum value of minor tick marks. 00215 */ 00216 virtual int getMaxNumMinorTicks() const = 0; 00217 00218 /** 00219 * Sets the format for the value text labels. 00220 * 00221 * This method sets the display format for the value text labels displayed 00222 * at the major tick mark locations. This method can be called to set a 00223 * desired precision or to enforce or prevent scientific notation on the 00224 * value labels. 00225 * 00226 * @param labelFormat 00227 * The new text format for the values, whose syntax is identical 00228 * to the format string provided to sprintf() in the standard C++ 00229 * library. 00230 */ 00231 virtual void setLabelFormat(const std::string& labelFormat) = 0; 00232 00233 /** 00234 * Returns the format for the value text labels. 00235 * 00236 * This method returns the display format for the value text labels 00237 * displayed at the major tick mark locations. 00238 * 00239 * @return The text format for the values, whose syntax is identical to 00240 * the format string provided to sprintf() in the standard C++ 00241 * library. 00242 */ 00243 virtual std::string getLabelFormat() const = 0; 00244 00245 protected: 00246 /** 00247 * This object should be destroyed by calling DesktopServices::deleteAxis(). 00248 */ 00249 virtual ~Axis() {} 00250 }; 00251 00252 #endif