[QGIS Commit] r8805 - in branches/advanced_printing_branch/src/app: . composer

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu Jul 17 07:33:52 EDT 2008


Author: mhugent
Date: 2008-07-17 07:33:52 -0400 (Thu, 17 Jul 2008)
New Revision: 8805

Added:
   branches/advanced_printing_branch/src/app/composer/qgsticksscalebarstyle.cpp
   branches/advanced_printing_branch/src/app/composer/qgsticksscalebarstyle.h
Removed:
   branches/advanced_printing_branch/src/app/composer/qgsticksmiddlescalebarstyle.cpp
   branches/advanced_printing_branch/src/app/composer/qgsticksmiddlescalebarstyle.h
Modified:
   branches/advanced_printing_branch/src/app/CMakeLists.txt
   branches/advanced_printing_branch/src/app/composer/qgscomposerscalebar.cpp
Log:
Renamed ticksmiddle style to ticks style

Modified: branches/advanced_printing_branch/src/app/CMakeLists.txt
===================================================================
--- branches/advanced_printing_branch/src/app/CMakeLists.txt	2008-07-17 11:25:09 UTC (rev 8804)
+++ branches/advanced_printing_branch/src/app/CMakeLists.txt	2008-07-17 11:33:52 UTC (rev 8805)
@@ -72,7 +72,7 @@
   composer/qgsdoubleboxscalebarstyle.cpp
   composer/qgsnumericscalebarstyle.cpp
   composer/qgssingleboxscalebarstyle.cpp
-  composer/qgsticksmiddlescalebarstyle.cpp
+  composer/qgsticksscalebarstyle.cpp
   #composer/qgscomposervectorlegend.cpp
   composer/qgscomposerview.cpp
   composer/qgscomposition.cpp

Modified: branches/advanced_printing_branch/src/app/composer/qgscomposerscalebar.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposerscalebar.cpp	2008-07-17 11:25:09 UTC (rev 8804)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposerscalebar.cpp	2008-07-17 11:33:52 UTC (rev 8805)
@@ -20,7 +20,7 @@
 #include "qgsdoubleboxscalebarstyle.h"
 #include "qgsnumericscalebarstyle.h"
 #include "qgssingleboxscalebarstyle.h"
-#include "qgsticksmiddlescalebarstyle.h"
+#include "qgsticksscalebarstyle.h"
 #include "qgsrect.h"
 #include <QFontMetricsF>
 #include <QPainter>
@@ -204,19 +204,20 @@
     }
   else if(styleName == tr("Line Ticks Middle") || styleName == tr("Line Ticks Down") || styleName == tr("Line Ticks Up"))
     {
-      mStyle = new QgsTicksMiddleScaleBarStyle(this);
-      /*if(styleName == tr("Line Ticks Middle"))
+      QgsTicksScaleBarStyle* tickStyle = new QgsTicksScaleBarStyle(this);
+      if(styleName == tr("Line Ticks Middle"))
 	{
-	  mStyle->setTickPosition(QgsTicksScaleBarStyle::MIDDLE);
+	  tickStyle->setTickPosition(QgsTicksScaleBarStyle::MIDDLE);
 	}
       else if(styleName == tr("Line Ticks Down"))
 	{
-	  mStyle->setTickPosition(QgsTicksScaleBarStyle::DOWN);
+	  tickStyle->setTickPosition(QgsTicksScaleBarStyle::DOWN);
 	}
       else if(styleName == tr("Line Ticks Up"))
 	{
-	  mStyle->setTickPosition(QgsTicksScaleBarStyle::UP);
-	  }*/
+	  tickStyle->setTickPosition(QgsTicksScaleBarStyle::UP);
+	}
+      mStyle = tickStyle;
     } 
   else if(styleName == tr("Numeric"))
     {

Deleted: branches/advanced_printing_branch/src/app/composer/qgsticksmiddlescalebarstyle.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgsticksmiddlescalebarstyle.cpp	2008-07-17 11:25:09 UTC (rev 8804)
+++ branches/advanced_printing_branch/src/app/composer/qgsticksmiddlescalebarstyle.cpp	2008-07-17 11:33:52 UTC (rev 8805)
@@ -1,88 +0,0 @@
-/***************************************************************************
-                            qgsticksmiddlescalebarstyle.cpp
-                            -------------------------------
-    begin                : June 2008
-    copyright            : (C) 2008 by Marco Hugentobler
-    email                : marco.hugentobler at karto.baug.ethz.ch
- ***************************************************************************/
-/***************************************************************************
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- ***************************************************************************/
-
-#include "qgsticksmiddlescalebarstyle.h"
-#include "qgscomposerscalebar.h"
-#include <QPainter>
-
-QgsTicksMiddleScaleBarStyle::QgsTicksMiddleScaleBarStyle(const QgsComposerScaleBar* bar): QgsScaleBarStyle(bar)
-{
-  mTickPosition = MIDDLE;
-}
-
-QgsTicksMiddleScaleBarStyle::QgsTicksMiddleScaleBarStyle(): QgsScaleBarStyle(0)
-{
-  mTickPosition = MIDDLE;
-}
-
-QgsTicksMiddleScaleBarStyle::~QgsTicksMiddleScaleBarStyle()
-{
-
-}
-
-QString QgsTicksMiddleScaleBarStyle::name() const
-{
-  return "Line Ticks Middle";
-}
-
-void QgsTicksMiddleScaleBarStyle::draw(QPainter* p) const
-{
-  if(!mScaleBar)
-    {
-      return;
-    }
-  double barTopPosition = mScaleBar->fontHeight() + mScaleBar->labelBarSpace() + mScaleBar->boxContentSpace();
-  double middlePosition = barTopPosition + mScaleBar->height()/2.0;
-  double bottomPosition = barTopPosition + mScaleBar->height();
-
-  p->save();
-  p->setPen(mScaleBar->pen());
-
-  QList<QPair<double, double> > segmentInfo;
-  mScaleBar->segmentPositions(segmentInfo);
-
-  QList<QPair<double, double> >::const_iterator segmentIt = segmentInfo.constBegin();
-  for(; segmentIt != segmentInfo.constEnd(); ++segmentIt)
-    {
-      p->drawLine(segmentIt->first, barTopPosition, segmentIt->first, barTopPosition + mScaleBar->height());
-      switch(mTickPosition)
-	{
-	case DOWN:
-	  p->drawLine(segmentIt->first, barTopPosition, segmentIt->first + mScaleBar->segmentMM(), barTopPosition);
-	  break;
-	case MIDDLE:
-	  p->drawLine(segmentIt->first, middlePosition, segmentIt->first + mScaleBar->segmentMM(), middlePosition); 
-	  break;
-	case UP:
-	  p->drawLine(segmentIt->first, bottomPosition, segmentIt->first + mScaleBar->segmentMM(), bottomPosition); 
-	  break;
-	}
-    }
-
-  //draw last tick
-  if(!segmentInfo.isEmpty())
-    {
-      double lastTickPositionX = segmentInfo.last().first + mScaleBar->segmentMM();
-      p->drawLine(lastTickPositionX, barTopPosition, lastTickPositionX, barTopPosition + mScaleBar->height());
-    }
-
-  p->restore();
-
-  //draw labels using the default method
-  drawLabels(p);
-}
-
-

Deleted: branches/advanced_printing_branch/src/app/composer/qgsticksmiddlescalebarstyle.h
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgsticksmiddlescalebarstyle.h	2008-07-17 11:25:09 UTC (rev 8804)
+++ branches/advanced_printing_branch/src/app/composer/qgsticksmiddlescalebarstyle.h	2008-07-17 11:33:52 UTC (rev 8805)
@@ -1,47 +0,0 @@
-/***************************************************************************
-                            qgsticksmiddlescalebarstyle.h
-                            -----------------------------
-    begin                : June 2008
-    copyright            : (C) 2008 by Marco Hugentobler
-    email                : marco.hugentobler at karto.baug.ethz.ch
- ***************************************************************************/
-/***************************************************************************
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- ***************************************************************************/
-
-#ifndef QGSTICKSMIDDLESCALEBARSTYLE_H
-#define QGSTICKSMIDDLESCALEBARSTYLE_H 
-
-#include "qgsscalebarstyle.h"
-
-class QgsTicksMiddleScaleBarStyle: public QgsScaleBarStyle
-{
-  public:
-  enum TickPosition
-    {
-      UP,
-      DOWN,
-      MIDDLE
-    };
-
-  QgsTicksMiddleScaleBarStyle(const QgsComposerScaleBar* bar);
-  ~QgsTicksMiddleScaleBarStyle();
-
-  QString name() const;
-
-  void draw(QPainter* p) const;
-
-  void setTickPosition(TickPosition p){mTickPosition = p;}
-
- private:
-  QgsTicksMiddleScaleBarStyle(); //forbidden
-
-  TickPosition mTickPosition;
-};
-
-#endif 

Copied: branches/advanced_printing_branch/src/app/composer/qgsticksscalebarstyle.cpp (from rev 8804, branches/advanced_printing_branch/src/app/composer/qgsticksmiddlescalebarstyle.cpp)
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgsticksscalebarstyle.cpp	                        (rev 0)
+++ branches/advanced_printing_branch/src/app/composer/qgsticksscalebarstyle.cpp	2008-07-17 11:33:52 UTC (rev 8805)
@@ -0,0 +1,88 @@
+/***************************************************************************
+                            qgsticksscalebarstyle.cpp
+                            -------------------------
+    begin                : June 2008
+    copyright            : (C) 2008 by Marco Hugentobler
+    email                : marco.hugentobler at karto.baug.ethz.ch
+ ***************************************************************************/
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#include "qgsticksscalebarstyle.h"
+#include "qgscomposerscalebar.h"
+#include <QPainter>
+
+QgsTicksScaleBarStyle::QgsTicksScaleBarStyle(const QgsComposerScaleBar* bar): QgsScaleBarStyle(bar)
+{
+  mTickPosition = MIDDLE;
+}
+
+QgsTicksScaleBarStyle::QgsTicksScaleBarStyle(): QgsScaleBarStyle(0)
+{
+  mTickPosition = MIDDLE;
+}
+
+QgsTicksScaleBarStyle::~QgsTicksScaleBarStyle()
+{
+
+}
+
+QString QgsTicksScaleBarStyle::name() const
+{
+  return "Line Ticks Middle";
+}
+
+void QgsTicksScaleBarStyle::draw(QPainter* p) const
+{
+  if(!mScaleBar)
+    {
+      return;
+    }
+  double barTopPosition = mScaleBar->fontHeight() + mScaleBar->labelBarSpace() + mScaleBar->boxContentSpace();
+  double middlePosition = barTopPosition + mScaleBar->height()/2.0;
+  double bottomPosition = barTopPosition + mScaleBar->height();
+
+  p->save();
+  p->setPen(mScaleBar->pen());
+
+  QList<QPair<double, double> > segmentInfo;
+  mScaleBar->segmentPositions(segmentInfo);
+
+  QList<QPair<double, double> >::const_iterator segmentIt = segmentInfo.constBegin();
+  for(; segmentIt != segmentInfo.constEnd(); ++segmentIt)
+    {
+      p->drawLine(segmentIt->first, barTopPosition, segmentIt->first, barTopPosition + mScaleBar->height());
+      switch(mTickPosition)
+	{
+	case DOWN:
+	  p->drawLine(segmentIt->first, barTopPosition, segmentIt->first + mScaleBar->segmentMM(), barTopPosition);
+	  break;
+	case MIDDLE:
+	  p->drawLine(segmentIt->first, middlePosition, segmentIt->first + mScaleBar->segmentMM(), middlePosition); 
+	  break;
+	case UP:
+	  p->drawLine(segmentIt->first, bottomPosition, segmentIt->first + mScaleBar->segmentMM(), bottomPosition); 
+	  break;
+	}
+    }
+
+  //draw last tick
+  if(!segmentInfo.isEmpty())
+    {
+      double lastTickPositionX = segmentInfo.last().first + mScaleBar->segmentMM();
+      p->drawLine(lastTickPositionX, barTopPosition, lastTickPositionX, barTopPosition + mScaleBar->height());
+    }
+
+  p->restore();
+
+  //draw labels using the default method
+  drawLabels(p);
+}
+
+

Copied: branches/advanced_printing_branch/src/app/composer/qgsticksscalebarstyle.h (from rev 8804, branches/advanced_printing_branch/src/app/composer/qgsticksmiddlescalebarstyle.h)
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgsticksscalebarstyle.h	                        (rev 0)
+++ branches/advanced_printing_branch/src/app/composer/qgsticksscalebarstyle.h	2008-07-17 11:33:52 UTC (rev 8805)
@@ -0,0 +1,47 @@
+/***************************************************************************
+                            qgsticksscalebarstyle.h
+                            -----------------------------
+    begin                : June 2008
+    copyright            : (C) 2008 by Marco Hugentobler
+    email                : marco.hugentobler at karto.baug.ethz.ch
+ ***************************************************************************/
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#ifndef QGSTICKSSCALEBARSTYLE_H
+#define QGSTICKSSCALEBARSTYLE_H 
+
+#include "qgsscalebarstyle.h"
+
+class QgsTicksScaleBarStyle: public QgsScaleBarStyle
+{
+  public:
+  enum TickPosition
+    {
+      UP,
+      DOWN,
+      MIDDLE
+    };
+
+  QgsTicksScaleBarStyle(const QgsComposerScaleBar* bar);
+  ~QgsTicksScaleBarStyle();
+
+  QString name() const;
+
+  void draw(QPainter* p) const;
+
+  void setTickPosition(TickPosition p){mTickPosition = p;}
+
+ private:
+  QgsTicksScaleBarStyle(); //forbidden
+
+  TickPosition mTickPosition;
+};
+
+#endif 



More information about the QGIS-commit mailing list