Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages

AxisWidget.h (Maintainer: Marc Sturm)

Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // --------------------------------------------------------------------------
00005 //                   OpenMS Mass Spectrometry Framework
00006 // --------------------------------------------------------------------------
00007 //  Copyright (C) 2003-2008 -- Oliver Kohlbacher, Knut Reinert
00008 //
00009 //  This library is free software; you can redistribute it and/or
00010 //  modify it under the terms of the GNU Lesser General Public
00011 //  License as published by the Free Software Foundation; either
00012 //  version 2.1 of the License, or (at your option) any later version.
00013 //
00014 //  This library is distributed in the hope that it will be useful,
00015 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 //  Lesser General Public License for more details.
00018 //
00019 //  You should have received a copy of the GNU Lesser General Public
00020 //  License along with this library; if not, write to the Free Software
00021 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 //
00023 // --------------------------------------------------------------------------
00024 // $Maintainer: Marc Sturm $
00025 // --------------------------------------------------------------------------
00026 
00027 #ifndef OPENMS_VISUAL_AXISWIDGET_H
00028 #define OPENMS_VISUAL_AXISWIDGET_H
00029 
00030 // QT
00031 #include <QtGui/QWidget>
00032 class QPaintEvent;
00033 
00034 // OpenMS
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 } // namespace OpenMS
00182 
00183 
00184 #endif
00185 

Generated Tue Apr 1 15:36:32 2008 -- using doxygen 1.5.4 OpenMS / TOPP 1.1