30 #include "../../core/pattern/mvc/ItemController.h"
31 #include "../core/Scene.h"
32 #include "../../core/pattern/mvc/Observable.h"
33 #include "../../../color/RGBAColor.h"
34 #include "../../../qt/widgets/Utils.h"
35 #include "../../../geometry/Envelope.h"
36 #include "../../../common/STLUtils.h"
37 #include "../../item/ScaleModel.h"
49 m_nameClass = std::string(this->metaObject()->className());
66 drawBackground(painter);
76 drawDoubleAlternatingScaleBar(painter);
80 drawAlternatingScaleBar(painter);
84 drawHollowScaleBar(painter);
91 if (option->state & QStyle::State_Selected)
93 drawSelection(painter);
99 QRectF boundRect = boundingRect();
104 std::string strUnit=
"(Km)";
125 double x1 = boundRect.bottomLeft().x();
127 QColor black(0, 0, 0, 255);
128 QColor white(255, 255, 255, 255);
129 QColor firstRect = black;
130 QColor secondRect = white;
132 QColor textColor(0, 0, 0, 255);
140 for( ; x1 < boundRect.topRight().x(); x1 += width)
142 if(x1+gapX >= boundRect.topRight().x())
145 double dx = boundRect.width() - x1;
149 painter->setPen(Qt::NoPen);
152 painter->setBrush(QBrush(secondRect));
153 newBoxSecond = QRectF(x1, boundRect.center().y() - gapY, gapX, gapY);
154 painter->drawRect(newBoxSecond);
157 painter->setBrush(QBrush(firstRect));
158 newBoxFirst = QRectF(x1, boundRect.center().y(), gapX, gapY);
159 painter->drawRect(newBoxFirst);
164 value += (spacing * mmToCm)/unit;
166 std::stringstream ss_value;
169 std::string s_value = ss_value.str();
171 painter->setPen(QPen(textColor));
172 QPointF coordText(x1, newBoxSecond.topLeft().y() - 5);
174 drawText(coordText, painter, ss_value.str());
176 changeColor = firstRect;
177 firstRect = secondRect;
178 secondRect = changeColor;
181 newBoxSecond = QRectF(boundRect.x(), boundRect.center().y() - gapY, boundRect.width(), gapY*2);
185 painter->setBrush(Qt::NoBrush);
186 painter->setPen(penBackground);
187 painter->drawRect(newBoxSecond);
190 double centerX = newBoxSecond.center().x();
191 painter->setPen(QPen(textColor));
193 QPointF coordText(centerX, boundRect.topLeft().y() + 1);
194 drawText(coordText, painter, strUnit);
201 QRectF boundRect = boundingRect();
206 std::string strUnit=
"(Km)";
227 double x1 = boundRect.bottomLeft().x();
229 QColor black(0, 0, 0, 255);
230 QColor white(255, 255, 255, 255);
231 QColor firstRect = black;
232 QColor secondRect = white;
234 QColor textColor(0, 0, 0, 255);
242 for( ; x1 < boundRect.topRight().x(); x1 += width)
244 if(x1+gapX >= boundRect.topRight().x())
247 double dx = boundRect.width() - x1;
251 painter->setPen(Qt::NoPen);
253 painter->setBrush(QBrush(secondRect));
254 newBoxSecond = QRectF(x1, boundRect.center().y() - gapY/2, gapX, gapY);
255 painter->drawRect(newBoxSecond);
261 value += (spacing * mmToCm)/unit;
263 std::stringstream ss_value;
266 std::string s_value = ss_value.str();
271 QPointF coordText(x1, newBoxSecond.topLeft().y() - 5);
273 drawText(coordText, painter, ss_value.str());
275 changeColor = firstRect;
276 firstRect = secondRect;
277 secondRect = changeColor;
280 newBoxSecond = QRectF(boundRect.x(), boundRect.center().y() - gapY/2, boundRect.width(), gapY);
284 painter->setBrush(Qt::NoBrush);
285 painter->setPen(penBackground);
286 painter->drawRect(newBoxSecond);
289 double centerX = newBoxSecond.center().x();
290 painter->setPen(QPen(textColor));
292 QPointF coordText(centerX, boundRect.topLeft().y() + 1);
293 drawText(coordText, painter, strUnit);
300 QRectF boundRect = boundingRect();
305 std::string strUnit=
"(Km)";
326 double x1 = boundRect.bottomLeft().x();
328 QColor black(0, 0, 0, 255);
329 QColor white(255, 255, 255, 255);
330 QColor firstRect = black;
331 QColor secondRect = white;
333 QColor textColor(0, 0, 0, 255);
344 for( ; x1 < boundRect.topRight().x(); x1 += width)
346 if(x1+gapX >= boundRect.topRight().x())
349 double dx = boundRect.width() - x1;
353 painter->setPen(Qt::NoPen);
355 painter->setBrush(QBrush(white));
356 newBoxSecond = QRectF(x1, boundRect.center().y() - gapY/2, gapX, gapY);
357 painter->drawRect(newBoxSecond);
361 QLineF lne(x1, boundRect.center().y(), gapX, boundRect.center().y());
362 painter->drawLine(lne);
367 value += (spacing * mmToCm)/unit;
369 std::stringstream ss_value;
372 std::string s_value = ss_value.str();
374 painter->setPen(QPen(textColor));
375 QPointF coordText(x1, newBoxSecond.topLeft().y() - 5);
377 drawText(coordText, painter, ss_value.str());
379 changeColor = firstRect;
380 firstRect = secondRect;
381 secondRect = changeColor;
385 newBoxSecond = QRectF(boundRect.x(), boundRect.center().y() - gapY/2, boundRect.width(), gapY);
388 painter->setBrush(Qt::NoBrush);
389 painter->setPen(penBackground);
390 painter->drawRect(newBoxSecond);
393 double centerX = newBoxSecond.center().x();
394 painter->setPen(QPen(textColor));
396 QPointF coordText(centerX, boundRect.topLeft().y() + 1);
397 drawText(coordText, painter, strUnit);
virtual EnumType * getAlternatingScaleBarType() const
Returns value that represents alternating scale bar type belonging to enumeration.
virtual double getScaleGapX()
Abstract class to represent an observable. "Model" part of MVC component.
virtual ~ScaleItem()
Destructor.
virtual void drawDoubleAlternatingScaleBar(QPainter *painter)
ScaleItem(ItemController *controller, Observable *o)
Constructor.
virtual void drawAlternatingScaleBar(QPainter *painter)
Abstract class to represent a controller. "Controller" part of MVC component. All classes representin...
Abstract class that represents a graphic item. This object is of type QGraphicsObject.
virtual EnumType * getDoubleAlternatingScaleBarType() const
Returns value that represents double alternating scale bar type belonging to enumeration.
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
Reimplemented from QGraphicsItem.
Class that represents a graphic scale of a map. Its coordinate system is the same of scene (millimete...
std::string m_nameClass
Class name.
virtual double getMapScale()
virtual EnumScaleType * getEnumScaleType()
Class to represent a scale type enumeration. Ex.: hollow scale bar, etc.
virtual EnumType * getHollowScaleBarType() const
Returns value that represents hollow scale bar type belonging to enumeration.
virtual double getScaleGapY()
virtual EnumType * getCurrentScaleType()
virtual void drawHollowScaleBar(QPainter *painter)
Class that represents a "Model" part of Scale MVC component. Its coordinate system is the same of sce...