SciFigs/NameLineLayer.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 : 2003-04-04
00022 **  Authors :
00023 **    Marc Wathelet
00024 **    Marc Wathelet (ULg, Liège, Belgium)
00025 **    Marc Wathelet (LGIT, Grenoble, France)
00026 **
00027 ***************************************************************************/
00028 
00029 #ifndef NAMELINELAYER_H
00030 #define NAMELINELAYER_H
00031 
00032 #include "LineLayer.h"
00033 #include "NameLine.h"
00034 
00035 namespace SciFigs {
00036 
00037 class NameLineLayerProperties;
00038 
00039 class SCIFIGS_EXPORT NameLineLayer : public LineLayer
00040 {
00041   Q_OBJECT
00042   Q_PROPERTY(bool showNames READ isShowNames WRITE setShowNames SCRIPTABLE true)
00043   Q_PROPERTY(QString font READ fontString WRITE setFontString SCRIPTABLE true)
00044 public:
00045   NameLineLayer(AxisWindow * parent=0);
00046   ~NameLineLayer();
00047 
00048   virtual const QString& xml_tagName() const {return xmlNameLineLayerTag;}
00049   static const QString xmlNameLineLayerTag;
00050 
00051   void setNames(int i, QVector<QString> * names);
00052 
00053   bool isShowNames() const {return _showNames;}
00054   void setShowNames(bool b) {_showNames=b;}
00055 
00056   QString fontString() const {return _textFont.toString();}
00057   void setFontString(QString fs) {_textFont.fromString(fs);}
00058 
00059   virtual bool hasProperties() {return true;}
00060   virtual void addProperties(PropertyProxy * pp);
00061   virtual void removeProperties(PropertyProxy * pp);
00062   virtual void properties(PropertyWidget * w) const;
00063   virtual void setProperty(uint wid, int pid, QVariant val);
00064 
00065   inline AbstractNameLine * addLine();
00066   inline AbstractNameLine * addLine(const Pen& pen, const Symbol& sym);
00067 
00068   inline AbstractNameLine * line(int i);
00069   inline const AbstractNameLine * line(int i) const;
00070 
00071   virtual Legend legend() const;
00072   virtual void setLegend(Legend legend);
00073 protected:
00074   virtual void paintData(const LayerPainterRequest& lp, QPainter& p, double dotpercm) const;
00075   virtual void paintText(const LayerPainterRequest& lp, double dotpercm);
00076 
00077   bool _showNames;
00078   QFont _textFont;
00079 
00080   static uint _tab;
00081 private:
00082   inline void drawLabel(QPainter& p, const QPainterPath& name, const Angle& angle, const QRectF& r, int baseLine) const;
00083   QList<QPainterPath> _textPaths;
00084   mutable QMutex _textPathsMutex;
00085 };
00086 
00087 inline AbstractNameLine * NameLineLayer::addLine()
00088 {
00089   return static_cast<AbstractNameLine *>(LineLayer::addLine());
00090 }
00091 
00092 inline AbstractNameLine * NameLineLayer::addLine(const Pen& pen, const Symbol& sym)
00093 {
00094   return static_cast<AbstractNameLine *>(LineLayer::addLine(pen, sym) );
00095 }
00096 
00097 inline AbstractNameLine * NameLineLayer::line(int i)
00098 {
00099   return static_cast<AbstractNameLine *>(LineLayer::line(i) );
00100 }
00101 
00102 inline const AbstractNameLine * NameLineLayer::line(int i) const
00103 {
00104   return static_cast<const AbstractNameLine *>(LineLayer::line(i) );
00105 }
00106 
00107 } // namespace SciFigs
00108 
00109 #endif // NAMELINELAYER_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines