00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef OPENMS_VISUAL_AXISWIDGET_H
00028 #define OPENMS_VISUAL_AXISWIDGET_H
00029
00030
00031 #include <QtGui/QWidget>
00032 class QPaintEvent;
00033
00034
00035 #include <OpenMS/CONCEPT/Types.h>
00036 #include <OpenMS/DATASTRUCTURES/String.h>
00037 #include <OpenMS/MATH/MISC/MathFunctions.h>
00038
00039 namespace OpenMS
00040 {
00052 class AxisWidget
00053 : public QWidget
00054 {
00055 Q_OBJECT
00056
00057 public:
00058
00060 typedef std::vector<std::vector<double> > GridVector;
00061
00063 static enum {TOP, BOTTOM, LEFT, RIGHT} ALIGNMENT_ENUM;
00064
00066 AxisWidget(UInt alignment, const char* legend="", QWidget* parent = 0);
00067
00069 virtual ~AxisWidget();
00070
00072 void setMargin(UInt size);
00073
00075 UInt margin();
00076
00078 void showLegend(bool show_legend);
00079
00081 bool isLegendShown() const;
00082
00088 const GridVector& gridLines();
00089
00091 void setGridLines(std::vector<double>&);
00092
00094 void setLogScale(bool is_log);
00095
00097 bool isLogScale();
00098
00100 void setLegend(const String& legend);
00101
00103 const String& getLegend();
00104
00106 void setInverseOrientation(bool inverse_orientation);
00107
00109 bool hasInverseOrientation();
00110
00112 void setAllowShortNumbers(bool short_nums = true);
00113
00115 inline double getAxisMinimum() const
00116 {
00117 return min_;
00118 }
00119
00121 inline double getAxisMaximum() const
00122 {
00123 return max_;
00124 }
00125
00127 inline void setPenWidth(int p)
00128 {
00129 pen_width_ = p;
00130 update();
00131 }
00132
00133 public slots:
00134
00136 void setAxisBounds(double min, double max);
00137
00139 void setTickLevel(UInt level);
00140
00141 protected:
00143 GridVector grid_line_;
00144
00146 bool is_log_;
00148 bool show_legend_;
00150 UInt alignment_;
00152 bool inverse_orientation_;
00154 UInt margin_;
00156 double min_;
00158 double max_;
00160 String legend_;
00162 UInt tick_level_;
00164 UInt pen_width_;
00165
00167 void paintEvent( QPaintEvent * );
00168
00170 inline double scale_(double x)
00171 {
00172 return (is_log_)? Math::round_decimal(pow(x,10),-8) : Math::round_decimal(x,-8);
00173 }
00174
00176 void getShortenedNumber_(QString& short_num, double number);
00177
00179 bool allow_short_numbers_;
00180 };
00181 }
00182
00183
00184 #endif
00185