30 #include "../../core/PaperConfig.h"
31 #include "../../core/pattern/singleton/Context.h"
32 #include "../../core/Utils.h"
59 m_middleBlockSize = 5;
66 m_spacingLineText = 9.5;
72 QBrush brush = painter->brush();
74 QBrush bhWhite(QColor(255,255,255,255));
75 QBrush bhGreyBack(QColor(145,145,145,255));
76 QBrush bhGreyBox(QColor(180,180,180,255));
78 QPen pen(QColor(0,0,0,255));
81 zoomFactor = 1. / scale;
83 QPointF ll = view->mapToScene(0, view->height());
84 QPointF ur = view->mapToScene(view->width(), 0);
92 QRectF rfH(QPointF(ll.x(), ur.y()), QPointF(ur.x(), ur.y() - m_height * zoomFactor));
93 QRectF rfBackH(QPointF(ll.x() + (m_cornerSize * zoomFactor), ur.y()), QPointF(ur.x(), ur.y() - (m_height - 1.5) * zoomFactor));
94 QRectF rfPaperH(QPointF(0, ur.y()), QPointF(w, ur.y() - (m_height - 1.5) * zoomFactor));
95 QLineF rfLineH(QPointF(ll.x() + (m_cornerSize * zoomFactor), ur.y() - m_height * zoomFactor), QPointF(ur.x(), ur.y() - m_height * zoomFactor));
98 QRectF rfRectCorner(QPointF(ll.x(), ur.y()), QPointF(ll.x() + m_cornerSize * zoomFactor, ur.y() - m_height * zoomFactor));
101 painter->setPen(Qt::NoPen);
104 painter->setBrush(bhGreyBox);
105 painter->drawRect(rfH);
107 painter->setBrush(bhGreyBack);
108 painter->drawRect(rfBackH);
110 painter->setBrush(bhWhite);
111 painter->drawRect(rfPaperH);
113 painter->setBrush(brush);
116 painter->setPen(pen);
118 painter->drawLine(rfLineH);
127 painter->setFont(ft);
129 std::stringstream ss;
131 double llx = rfBackH.bottomLeft().x();
132 double lly = rfBackH.bottomLeft().y();
133 double urx = rfBackH.topRight().x();
140 for(
int i = (
int)llx ; i < (int) urx ; ++i)
142 if((i % (
int)(m_blockSize)) == 0)
144 box = QLineF(QPointF(i, y), QPointF(i, y + m_longLine * zoomFactor));
146 std::stringstream ss;
151 QPoint p = view->mapFromScene(QPointF((
double)i - (wtxt/2.), y + m_spacingLineText * zoomFactor));
154 painter->setMatrixEnabled(
false);
155 painter->drawText(p, ss.str().c_str());
156 painter->setMatrixEnabled(
true);
158 else if((i % (
int)(m_middleBlockSize)) == 0)
160 box = QLineF(QPointF(i, y), QPointF(i, y + m_mediumLine * zoomFactor));
162 else if((i % (
int)(m_smallBlockSize)) == 0)
164 box = QLineF(QPointF(i, y), QPointF(i, y + m_smallLine * zoomFactor));
167 painter->drawLine(box);
170 painter->setBrush(bhGreyBox);
171 painter->setPen(Qt::NoPen);
172 painter->drawRect(rfRectCorner);
Class responsible for paper setting. Size, orientation, custom size, etc.
virtual void textBoundingBox(double &w, double &h, std::string txt)
A method that calculates the height and width of a text.
virtual void drawRuler(QGraphicsView *view, QPainter *painter, double scale)
virtual ~HorizontalRuler()
static Context & getInstance()
It returns a reference to the singleton instance.
Utils * getUtils()
Returns pointer with functions to manipulate the canvas and conversion between projections.
virtual void getPaperSize(double &w, double &h)
Returns paper size. Height and Width.
PaperConfig * getPaperConfig() const
Returns paper setting.
double getZoomFactor()
Returns current zoom factor. Ex.: 0.5 (50%)
Utility class with functions to manipulate the canvas and conversion between projections.
Class that represents a horizontal ruler with the coordinate system in mm.