SciFigs/AxisWindow.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of SciFigs.
00004 **
00005 **  This library is free software; you can redistribute it and/or
00006 **  modify it under the terms of the GNU Lesser General Public
00007 **  License as published by the Free Software Foundation; either
00008 **  version 2.1 of the License, or (at your option) any later version.
00009 **
00010 **  This file is distributed in the hope that it will be useful, but WITHOUT
00011 **  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 **  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00013 **  License for more details.
00014 **
00015 **  You should have received a copy of the GNU Lesser General Public
00016 **  License along with this library; if not, write to the Free Software
00017 **  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00018 **
00019 **  See http://www.geopsy.org for more information.
00020 **
00021 **  Created : 2002-04-17
00022 **  Authors :
00023 **    Marc Wathelet
00024 **    Marc Wathelet (ULg, Liège, Belgium)
00025 **    Marc Wathelet (LGIT, Grenoble, France)
00026 **
00027 ***************************************************************************/
00028 
00029 #ifndef AXISWINDOW_H
00030 #define AXISWINDOW_H
00031 
00032 #include "SciFigsDLLExport.h"
00033 #include "GraphicObject.h"
00034 #include "GraphContent.h"
00035 
00036 namespace SciFigs {
00037 
00038 class GraphContentLayer;
00039 
00040 class SCIFIGS_EXPORT AxisWindow : public GraphicObject
00041 {
00042   Q_OBJECT
00043   // Kept only to avoid warning on loading old files
00044   Q_PROPERTY(QString gridLines READ dummyPropertyString WRITE setDummyProperty STORED false)
00045   Q_PROPERTY(QString printLineWeight READ dummyPropertyString WRITE setDummyProperty STORED false)
00046   Q_PROPERTY(QString printBitmap READ dummyPropertyString WRITE setDummyProperty STORED false)
00047 public:
00048   AxisWindow(QWidget *parent=0, Qt::WFlags f=0);
00049   ~AxisWindow();
00050 
00051   virtual const QString& xml_tagName() const {return xmlAxisWindowTag;}
00052   static const QString xmlAxisWindowTag;
00053 
00054   virtual void polish();
00055   GraphContent * graphContent() const {return _content;}
00056 
00057   // Updates all sub childs
00058   void updateScrollBars();
00059   virtual int* scaleFonts(double factor);
00060   virtual void restoreScaleFonts(int* tmp);
00061   virtual void print(QPainter& p, double dotpercm, int x0Sheet, int y0Sheet, bool mask);
00062 
00063   Axis * xAxis() const {return _xAxis;}
00064   Axis * yAxis() const {return _yAxis;}
00065 
00066   void setHorizontalLine(int l);
00067   void setVerticalLine(int l);
00068 
00069   void swapAxes();
00070   void alignHScales(AxisWindow * ref, double atReal);
00071   void alignVScales(AxisWindow * ref, double atReal);
00072 
00073   virtual void addProperties(PropertyProxy * pp);
00074   virtual void removeProperties(PropertyProxy * pp);
00075 
00076   bool isZoomed() const {return !_zoomRects.isEmpty();}
00077 
00078   virtual void xml_polish(XML_POLISH_ARGS);
00079 public slots:
00080   virtual void update();
00081   virtual void deepUpdate();
00082   void zoomIn(double rx1, double ry1, double rx2, double ry2);
00083   void zoomOut();
00084   void browse(QRect& r);
00085   void setMapScale(double rx1, double ry1, double rx2, double ry2);
00086   void updateExternalGeometry();
00087   void updateInternalGeometry();
00088   virtual void updateGeometry();
00089   void checkZoomRects();
00090 private slots:
00091   void xScrollChanged(int val);
00092   void yScrollChanged(int val);
00093 protected:
00094   virtual void xml_writeChildren(XML_WRITECHILDREN_ARGS) const;
00095   virtual XMLMember xml_member(XML_MEMBER_ARGS);
00096 private:
00097   void calcFromTotalSize(double dotpercm, double totalWidth,
00098                           double totalHeight, double& xWidth, double& yHeight,
00099                           QPainter * p=0) const;
00100   void calcSize(double dotpercm, double& xWidth, double& xHeight,
00101                  double& yWidth, double& yHeight,
00102                  double xOffset, double yOffset, QPainter * p=0) const;
00103   void calcScreenSize(double dotpercm, int& xWidth, int& yHeight,
00104                        int xOffset, int yOffset);
00105   void setAxisGeometry(double dotpercm);
00106   void setAxisGeometry(int xWidth, int yWidth, int xHeight, int yHeight);
00107   // Events Handlers
00108   void resizeEvent (QResizeEvent * e);
00109   void updateMask();
00110   // Calculates a common rounded scale from precise scale given by startAt
00111   double commonScale(double startAt);
00112 
00113   // Stack for last zoom rectangles, used by 'Unzoom'
00114   QVector<Rect> _zoomRects;
00115   // Child widgets:
00116   Axis * _xAxis;
00117   Axis * _yAxis;
00118   QScrollBar * _xSBar;
00119   QScrollBar * _ySBar;
00120   GraphContent * _content;
00121   static uint _categoryXAxis, _categoryYAxis;
00122 };
00123 
00124 } // namespace SciFigs
00125 
00126 #endif // AXISWINDOW_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines