30 #include "../canvas/MultiThreadMapDisplay.h" 
   38 #include <QtGui/QApplication> 
   39 #include <QtGui/QAction> 
   40 #include <QtGui/QMenu> 
   41 #include <QtGui/QMessageBox> 
   43 #include <QtGui/QPainter> 
   44 #include <QtGui/QColor> 
   45 #include <QtCore/QRect> 
   46 #include <QtGui/QWidget> 
   47 #include <QtGui/QColorDialog> 
   48 #include <QtGui/QFontDialog> 
   49 #include <QtGui/QInputDialog> 
   50 #include <QtGui/QMenu> 
   51 #include <QtGui/QAction> 
   53 #include <QtGui/QResizeEvent> 
   54 #include <QtGui/QBoxLayout> 
   55 #include <QtCore/QCoreApplication> 
   56 #include <QtCore/qmath.h> 
   59   te::qt::widgets::
Frame(df->getLayoutEditor(), f),
 
   62   m_font(QFont(
"Linux Libertine G")),
 
   64   m_labelColor(QColor(Qt::blue)),
 
   65   m_barColor(QColor(Qt::red)),
 
   71   m_tickCentralized(true),
 
   77   setWindowTitle(
"GraphicScaleFrame");
 
   78   setMouseTracking(
true);
 
   82   m_frameRect.moveCenter(QPointF(r.center().x(), r.center().y() - r.height() / 2 - 30));
 
   94   te::qt::widgets::
Frame(rhs.m_layoutEditor, rhs.windowFlags())
 
   97   setWindowTitle(
"GraphicScaleFrame");
 
   98   setMouseTracking(
true);
 
  141     setWindowTitle(
"GraphicScaleFrame");
 
  179     m_menu = 
new QMenu(
this);
 
  180     m_setTypeAction = m_menu->addAction(
"Set Type...");
 
  181     m_setFamilyAction = m_menu->addAction(
"Set Family...");
 
  182     m_setLabelColorAction = m_menu->addAction(
"Set Label Color...");
 
  183     m_setBarColorAction = m_menu->addAction(
"Set Bar Color...");
 
  184     m_setBarHeightAction = m_menu->addAction(
"Set Bar Height...");
 
  185     m_offsetOriginAction = m_menu->addAction(
"Offset Origin");
 
  186     m_offsetOriginAction->setCheckable(
true);
 
  187     m_offsetOriginAction->setChecked(m_offsetOrigin);
 
  188     m_setLabelAboveAction = m_menu->addAction(
"Label Above");
 
  189     m_setLabelAboveAction->setCheckable(
true);
 
  190     m_setLabelAboveAction->setChecked(m_labelAbove);
 
  191     m_setUnitAboveAction = m_menu->addAction(
"Unit Above");
 
  192     m_setUnitAboveAction->setCheckable(
true);
 
  193     m_setUnitAboveAction->setChecked(m_unitAbove);
 
  194     m_setUnitAction = m_menu->addAction(
"Set Unit...");
 
  195     m_setDivisionsAction = m_menu->addAction(
"Set Number Of Divisions...");
 
  196     m_setSubDivisionsAction = m_menu->addAction(
"Set Number Of Subdivisions...");
 
  197     m_setStepAction = m_menu->addAction(
"Set Step...");
 
  198     m_showTooTipAction = m_menu->addAction(
"Show Tooltip");
 
  199     m_showTooTipAction->setCheckable(
true);
 
  200     m_showTooTipAction->setChecked(m_showToolTip);
 
  205   QPainter painter(
this);
 
  206   painter.drawPixmap(0, 0, m_pixmap);
 
  226   m_pixmap.fill(Qt::transparent);
 
  243   if(m_labelLengths.empty())
 
  246   QMatrix m = m_layoutEditor->getMatrixPaperViewToVp();
 
  247   QMatrix matrix(m.m11(), m.m12(), m.m21(), m.m22(), -m_frameRect.left()* m.m11(), -m_frameRect.bottom() * m.m22());
 
  248   QPainter painter(&m_pixmap);
 
  249   painter.setBrush(Qt::NoBrush);
 
  250   painter.setPen(m_labelColor);
 
  251   painter.setFont(m_font);
 
  253   double conv = m_dataFrame->getDataUnitToMilimeter();
 
  254   double toKm = conv / 1000000;
 
  257   double textHeight = m_labelHeight * .9;
 
  259   for(
int i = 0; i <= m_divisions; ++i)
 
  261     QString s = m_labels[i];
 
  264       p = matrix.map(QPointF(m_barRect.left() - m_labelLengths[i] / 2. + m_stepmm * (double)i, m_barRect.bottom() + m_space)).toPoint();
 
  266       p = matrix.map(QPointF(m_barRect.left() - m_labelLengths[i] / 2. + m_stepmm * (double)i, m_barRect.top() - m_space - textHeight)).toPoint();
 
  268     painter.drawText(p, s);
 
  273     p = matrix.map(QPointF(m_barRect.left() - m_subDivisionLabelLength / 2. + m_stepmm/2., m_barRect.bottom() + m_space)).toPoint();
 
  275     p = matrix.map(QPointF(m_barRect.left() - m_subDivisionLabelLength / 2. + m_stepmm/2., m_barRect.top() - m_space - textHeight)).toPoint();
 
  277   painter.drawText(p, m_subDivisionString);
 
  281   if(m_labelAbove && m_unitAbove)
 
  282     y = m_barRect.bottom() + m_space + textHeight + m_space;
 
  283   else if(m_labelAbove && m_unitAbove == 
false)
 
  284     y = m_barRect.top() - m_space - textHeight + 1; 
 
  285   else if(m_labelAbove == 
false && m_unitAbove == 
false)
 
  286     y = m_barRect.top() - m_space - textHeight - m_space - textHeight + 1; 
 
  287   else if(m_labelAbove == 
false && m_unitAbove)
 
  288     y = m_barRect.bottom() + m_space + 1; 
 
  290   QRectF rt = painter.boundingRect(QRect(0, 0, 100000, 100000), Qt::AlignLeft, m_unit);
 
  291   rt = matrix.inverted().mapRect(rt);
 
  292   double x = m_barRect.center().x() - rt.width() / 2;
 
  294   p = matrix.map(QPointF(x, y)).toPoint();
 
  295   painter.setPen(m_labelColor);
 
  296   painter.drawText(p, m_unit);
 
  301   QMatrix m = m_layoutEditor->getMatrixPaperViewToVp();
 
  302   QMatrix matrix(m.m11(), m.m12(), m.m21(), m.m22(), -m_frameRect.left()* m.m11(), -m_frameRect.bottom() * m.m22());
 
  303   QPainter painter(&m_pixmap);
 
  304   painter.setBrush(Qt::NoBrush);
 
  306   double subStep = m_stepmm / (double)m_subDivisions;
 
  309   painter.setPen(m_barColor);
 
  312   if(m_tickCentralized)
 
  314     p1 = matrix.map(QPointF(m_barRect.left(), m_barRect.center().y())).toPoint();
 
  315     p2 = matrix.map(QPointF(m_barRect.right(), m_barRect.center().y())).toPoint();
 
  316     y1 = m_barRect.center().y() - m_subTickSize / 2.;
 
  317     y2 = m_barRect.center().y() + m_subTickSize / 2.;
 
  323       p1 = matrix.map(QPointF(m_barRect.left(), m_barRect.top())).toPoint();
 
  324       p2 = matrix.map(QPointF(m_barRect.right(), m_barRect.top())).toPoint();
 
  325       y1 = m_barRect.top();
 
  326       y2 = m_barRect.top() + m_subTickSize;
 
  330       p1 = matrix.map(QPointF(m_barRect.left(), m_barRect.bottom())).toPoint();
 
  331       p2 = matrix.map(QPointF(m_barRect.right(), m_barRect.bottom())).toPoint();
 
  332       y1 = m_barRect.bottom() - m_subTickSize;
 
  333       y2 = m_barRect.bottom() + m_subTickSize;
 
  336   painter.drawLine(p1, p2);
 
  339   for(
int i = 0; i < m_subDivisions; ++i)
 
  341     p1 = matrix.map(QPointF(m_barRect.left() + subStep * (double)i, y1)).toPoint();
 
  342     p2 = matrix.map(QPointF(m_barRect.left() + subStep * (double)i, y2)).toPoint();
 
  343     painter.drawLine(p1, p2);
 
  347   painter.setPen(Qt::black);
 
  348   for(
int i = 1; i <= m_divisions; ++i)
 
  350     p1 = matrix.map(QPointF(m_barRect.left() + m_stepmm * (double)i, m_barRect.top())).toPoint();
 
  351     p2 = matrix.map(QPointF(m_barRect.left() + m_stepmm * (double)i, m_barRect.bottom())).toPoint();
 
  352     painter.drawLine(p1, p2);
 
  359   QMatrix m = m_layoutEditor->getMatrixPaperViewToVp();
 
  360   QMatrix matrix(m.m11(), m.m12(), m.m21(), m.m22(), -m_frameRect.left()* m.m11(), -m_frameRect.bottom() * m.m22());
 
  361   QPainter painter(&m_pixmap);
 
  362   painter.setBrush(Qt::NoBrush);
 
  363   painter.setPen(m_barColor);
 
  365   double subStep = m_stepmm / (double)m_subDivisions;
 
  368   for(
int i = 0; i < m_subDivisions; ++i)
 
  370     p1 = matrix.map(QPointF(m_barRect.left() + subStep * (double)i, m_barRect.top())).toPoint();
 
  371     p2 = matrix.map(QPointF(m_barRect.left() + subStep * (double)i, m_barRect.bottom())).toPoint();
 
  372     painter.drawLine(p1, p2);
 
  376   for(
int i = 1; i <= m_divisions; ++i)
 
  378     p1 = matrix.map(QPointF(m_barRect.left() + m_stepmm * (double)i, m_barRect.top())).toPoint();
 
  379     p2 = matrix.map(QPointF(m_barRect.left() + m_stepmm * (double)i, m_barRect.bottom())).toPoint();
 
  380     painter.drawLine(p1, p2);
 
  384   for(
int i = 0; i < m_subDivisions; ++i)
 
  389       p1 = matrix.map(QPointF(m_barRect.left() + subStep * (double)i, m_barRect.bottom())).toPoint();
 
  390       p2 = matrix.map(QPointF(m_barRect.left() + subStep * (double)ii, m_barRect.bottom())).toPoint();
 
  394       p1 = matrix.map(QPointF(m_barRect.left() + subStep * (double)i, m_barRect.top())).toPoint();
 
  395       p2 = matrix.map(QPointF(m_barRect.left() + subStep * (double)ii, m_barRect.top())).toPoint();
 
  397     painter.drawLine(p1, p2);
 
  401   for(
int i = 1; i < m_divisions; ++i)
 
  404     if((m_subDivisions % 2) == 0)
 
  408         p1 = matrix.map(QPointF(m_barRect.left() + m_stepmm * (double)i, m_barRect.bottom())).toPoint();
 
  409         p2 = matrix.map(QPointF(m_barRect.left() + m_stepmm * (double)ii, m_barRect.bottom())).toPoint();
 
  413         p1 = matrix.map(QPointF(m_barRect.left() + m_stepmm * (double)i, m_barRect.top())).toPoint();
 
  414         p2 = matrix.map(QPointF(m_barRect.left() + m_stepmm * (double)ii, m_barRect.top())).toPoint();
 
  421         p1 = matrix.map(QPointF(m_barRect.left() + m_stepmm * (double)i, m_barRect.bottom())).toPoint();
 
  422         p2 = matrix.map(QPointF(m_barRect.left() + m_stepmm * (double)ii, m_barRect.bottom())).toPoint();
 
  426         p1 = matrix.map(QPointF(m_barRect.left() + m_stepmm * (double)i, m_barRect.top())).toPoint();
 
  427         p2 = matrix.map(QPointF(m_barRect.left() + m_stepmm * (double)ii, m_barRect.top())).toPoint();
 
  430     painter.drawLine(p1, p2);
 
  437   QMatrix m = m_layoutEditor->getMatrixPaperViewToVp();
 
  438   QMatrix matrix(m.m11(), m.m12(), m.m21(), m.m22(), -m_frameRect.left()* m.m11(), -m_frameRect.bottom() * m.m22());
 
  439   QPainter painter(&m_pixmap);
 
  441   double subStep = m_stepmm / (double)m_subDivisions;
 
  444   painter.setBrush(m_barColor);
 
  445   painter.setPen(Qt::NoPen);
 
  446   QRectF raux = m_barRect;
 
  449   for(
int i = 0; i < m_subDivisions; i+=2)
 
  451     raux.setLeft(m_barRect.left() + subStep * (double)i);
 
  452     raux.setWidth(subStep);
 
  453     r = matrix.mapRect(raux).toRect();
 
  459   if((m_subDivisions) % 2)
 
  461   for(
int i = ii; i < m_divisions; i+=2)
 
  463     raux.setLeft(m_barRect.left() + m_stepmm * (double)i);
 
  464     raux.setWidth(m_stepmm);
 
  465     r = matrix.mapRect(raux).toRect();
 
  470   painter.setBrush(Qt::NoBrush);
 
  471   painter.setPen(Qt::black);
 
  472   for(
int i = 1; i < m_subDivisions; ++i)
 
  474     p1 = matrix.map(QPointF(m_barRect.left() + subStep * (double)i, m_barRect.top())).toPoint();
 
  475     p2 = matrix.map(QPointF(m_barRect.left() + subStep * (double)i, m_barRect.bottom())).toPoint();
 
  476     painter.drawLine(p1, p2);
 
  480   for(
int i = 1; i < m_divisions; ++i)
 
  482     p1 = matrix.map(QPointF(m_barRect.left() + m_stepmm * (double)i, m_barRect.top())).toPoint();
 
  483     p2 = matrix.map(QPointF(m_barRect.left() + m_stepmm * (double)i, m_barRect.bottom())).toPoint();
 
  484     painter.drawLine(p1, p2);
 
  488   p1 = matrix.map(QPointF(m_barRect.left(), m_barRect.center().y())).toPoint();
 
  489   p2 = matrix.map(QPointF(m_barRect.right(), m_barRect.center().y())).toPoint();
 
  490   painter.drawLine(p1, p2);
 
  493   r = matrix.mapRect(m_barRect).toRect();
 
  500   QMatrix m = m_layoutEditor->getMatrixPaperViewToVp();
 
  501   QMatrix matrix(m.m11(), m.m12(), m.m21(), m.m22(), -m_frameRect.left()* m.m11(), -m_frameRect.bottom() * m.m22());
 
  502   QPainter painter(&m_pixmap);
 
  504   double subStep = m_stepmm / (double)m_subDivisions;
 
  507   painter.setBrush(m_barColor);
 
  508   painter.setPen(Qt::NoPen);
 
  509   QRectF raux = m_barRect;
 
  512   for(
int i = 0; i < m_subDivisions; i++)
 
  514     raux.setLeft(m_barRect.left() + subStep * (double)i);
 
  515     raux.setWidth(subStep);
 
  517       raux.setTop(m_barRect.center().y());
 
  519       raux.setTop(m_barRect.top());
 
  520     raux.setHeight(m_barRect.height() / 2.);
 
  522     r = matrix.mapRect(raux).toRect();
 
  527   if((m_subDivisions % 2) == 0)
 
  529     for(
int i = 1; i < m_divisions; i++)
 
  531       raux.setLeft(m_barRect.left() + m_stepmm * (double)i);
 
  532       raux.setWidth(m_stepmm);
 
  534         raux.setTop(m_barRect.center().y());
 
  536         raux.setTop(m_barRect.top());
 
  537       raux.setHeight(m_barRect.height() / 2.);
 
  539       r = matrix.mapRect(raux).toRect();
 
  545     for(
int i = 1; i < m_divisions; i++)
 
  547       raux.setLeft(m_barRect.left() + m_stepmm * (double)i);
 
  548       raux.setWidth(m_stepmm);
 
  550         raux.setTop(m_barRect.center().y());
 
  552         raux.setTop(m_barRect.top());
 
  553       raux.setHeight(m_barRect.height() / 2.);
 
  555       r = matrix.mapRect(raux).toRect();
 
  561   painter.setBrush(Qt::NoBrush);
 
  562   painter.setPen(Qt::black);
 
  563   for(
int i = 1; i < m_subDivisions; ++i)
 
  565     p1 = matrix.map(QPointF(m_barRect.left() + subStep * (double)i, m_barRect.top())).toPoint();
 
  566     p2 = matrix.map(QPointF(m_barRect.left() + subStep * (double)i, m_barRect.bottom())).toPoint();
 
  567     painter.drawLine(p1, p2);
 
  571   for(
int i = 1; i < m_divisions; ++i)
 
  573     p1 = matrix.map(QPointF(m_barRect.left() + m_stepmm * (double)i, m_barRect.top())).toPoint();
 
  574     p2 = matrix.map(QPointF(m_barRect.left() + m_stepmm * (double)i, m_barRect.bottom())).toPoint();
 
  575     painter.drawLine(p1, p2);
 
  579   p1 = matrix.map(QPointF(m_barRect.left(), m_barRect.center().y())).toPoint();
 
  580   p2 = matrix.map(QPointF(m_barRect.right(), m_barRect.center().y())).toPoint();
 
  581   painter.drawLine(p1, p2);
 
  584   r = matrix.mapRect(m_barRect).toRect();
 
  591   QPointF center = m_frameRect.center();
 
  593   labelLengthCalculation();
 
  594   if(m_labelLengths.empty())
 
  597   double mmFrameHeight = m_labelHeight + m_labelHeight + 2 * m_space + m_barRect.height();
 
  598   double mmFrameWidth = m_labelLengths[0] / 2. + m_stepmm * (double)m_divisions + m_labelLengths[m_divisions-1] / 2.;
 
  600   double x = m_labelLengths[0] / 2.;
 
  601   double bw = mmFrameWidth - m_labelLengths[0] / 2. - m_labelLengths[m_divisions-1] / 2.;
 
  602   double bh = m_barRect.height();
 
  605   if(m_labelAbove == 
false && m_unitAbove == 
false)
 
  606     y = m_labelHeight + m_space + m_labelHeight + m_space;
 
  607   else if(m_labelAbove == 
true && m_unitAbove == 
false)
 
  608     y = m_labelHeight + m_space;
 
  609   else if(m_labelAbove == 
false  && m_unitAbove == 
true)
 
  610     y = m_labelHeight + m_space;
 
  611   else if(m_labelAbove == 
true && m_unitAbove == 
true)
 
  614   m_frameRect = QRectF(0, 0, mmFrameWidth + 2, mmFrameHeight); 
 
  615   m_frameRect.moveCenter(center);
 
  617   m_barRect = QRectF(x + m_frameRect.left(), y + m_frameRect.top(), bw, bh);
 
  619   QMatrix matrix = m_layoutEditor->getMatrixPaperViewToVp();
 
  620   QRect widgetRect = matrix.mapRect(m_frameRect).toRect();
 
  623   resize(widgetRect.size());
 
  624   move(widgetRect.left(), widgetRect.top());
 
  626   m_pixmap = QPixmap(widgetRect.width(), widgetRect.height());
 
  628   calculateSelectionPoints();
 
  634   QRect rec = m_pixmap.rect();
 
  636   double pw = rec.width();
 
  637   double ph = rec.height();
 
  638   int ipw = qRound(pw);
 
  639   int iph = qRound(ph);
 
  640   int ipw2 = qRound(pw/2.);
 
  641   int iph2 = qRound(ph/2.);
 
  652   int iw2 = qRound(w/2.);
 
  653   int ih2 = qRound(h/2.);
 
  654   m_recSel1 = QRect(0, 0, iw, ih);
 
  655   m_recSel2 = QRect(ipw2 - iw2, 0, iw, ih);
 
  656   m_recSel3 = QRect(ipw - iw, 0, iw, ih);
 
  657   m_recSel4 = QRect(ipw - iw, iph2 - ih2, iw, ih);
 
  658   m_recSel5 = QRect(ipw - iw, iph - ih, iw, ih);
 
  659   m_recSel6 = QRect(ipw2 - iw2, iph - ih, iw, ih);
 
  660   m_recSel7 = QRect(0, iph - ih, iw, ih);
 
  661   m_recSel8 = QRect(0, iph2 - ih2, iw, ih);
 
  663   m_recSel10 = QRect(0, 0, ipw, iph);
 
  667   setPointSize(m_pointSize);
 
  670   QPainter painter(&pix);
 
  671   painter.setFont(m_font);
 
  674   QRectF rt = painter.boundingRect(QRect(0, 0, 100000, 100000), Qt::AlignLeft, s);
 
  675   m_barRect.setX(rt.width() / 2.);
 
  679   QMatrix matrix = m_layoutEditor->getMatrixPaperViewToVp();
 
  680   m_labelLengths.clear();
 
  681   std::vector<QString>::iterator it;
 
  682   for(it = m_labels.begin(); it != m_labels.end(); ++it)
 
  685     rt = painter.boundingRect(QRect(0, 0, 100000, 100000), Qt::AlignLeft, s);
 
  686     rt = matrix.inverted().mapRect(rt);
 
  687     m_labelLengths.push_back(rt.width());
 
  690   rt = painter.boundingRect(QRect(0, 0, 100000, 100000), Qt::AlignLeft, m_subDivisionString);
 
  691   rt = matrix.inverted().mapRect(rt);
 
  692   m_subDivisionLabelLength = rt.width();
 
  693   m_labelHeight = rt.height();
 
  698   double conv = m_dataFrame->getDataUnitToMilimeter();
 
  699   m_toKm = conv / 1000000;
 
  702     QMessageBox::warning (
this, 
"Projection Error", 
"Parece que tem algo errado na projeção do dado");
 
  707   if(m_unit == 
"Kilometers")
 
  709   else if(m_unit == 
"Meters")
 
  711   else if(m_unit == 
"Miles")
 
  713   else if(m_unit == 
"Leagues")
 
  715   else if(m_unit == 
"Inches")
 
  716     m_kmToUnit = 39370.0787;
 
  717   else if(m_unit == 
"Feet")
 
  718     m_kmToUnit = 3280.8399;
 
  719   else if(m_unit == 
"Hand")
 
  720     m_kmToUnit = 9842.5197;
 
  721   else if(m_unit == 
"Fingers")
 
  722     m_kmToUnit = 44994.3757;
 
  723   else if(m_unit == 
"Nautic Miles")
 
  725   else if(m_unit == 
"Nautic Fathom")
 
  726     m_kmToUnit = 546.8066;
 
  727   else if(m_unit == 
"Decimal Degrees")
 
  728     m_kmToUnit = .009178;
 
  729   else if(m_unit == 
"Yards")
 
  730     m_kmToUnit = 1093.6133;
 
  731   else if(m_unit == 
"Fourlongs")
 
  733   else if(m_unit == 
"Chains")
 
  734     m_kmToUnit = 49.7097;
 
  735   else if(m_unit == 
"Marathons")
 
  738     m_kmToUnit = 1000000/conv;
 
  740   double ww = m_dataFrame->getMapDisplay()->getExtent().getWidth();
 
  741   double widthUnit = ww * m_toKm * m_kmToUnit;
 
  744     findNiceStep(.75 * widthUnit / m_divisions);
 
  747   double w = m_dataFrame->getFrameRect().width();
 
  748   m_stepmm = m_step * w / (ww * m_toKm * m_kmToUnit);
 
  753     if(((
int)m_step)%2 == 1)
 
  761     double v = atof(s.c_str());
 
  763     QString qs(s.c_str());
 
  764     QChar c = qs[qs.length()-1];
 
  765     if(c == 
'0' || c == 
'2' || c == 
'4' || c == 
'6' || c == 
'8')
 
  771   m_subDivisionString = s.c_str();
 
  777     QString qs = s.c_str();
 
  778     m_labels.push_back(qs);
 
  779     m_labels.push_back(
"0");
 
  782     m_labels.push_back(
"0");
 
  784   for(
int i = 1; i <= m_divisions; ++i)
 
  786     double v = m_step * i;
 
  788     QString qs = s.c_str();
 
  790     m_labels.push_back(qs);
 
  797   bool fineRound = 
false;
 
  804     double fat = newStep / m_step;
 
  805     if(fat > .95 && fat < 1.05)
 
  813   double vstep = newStep;
 
  835   if(mult == 1 && dv >= 1)
 
  846   if(fineRound == 
false) 
 
  848     vstep = qRound(v) * fator;
 
  852         vstep = qRound(v+1) * fator;
 
  854     else if(increase == 2)
 
  857         vstep = qRound(v-1) * fator;
 
  862     vstep = qRound(v * 10) * fator / 10;
 
  863     double delta = fator / 10;
 
  869     else if(increase == 2)
 
  875     if(div == 1 && mult == 1)
 
  883   m_step = atof(st.c_str());
 
  888   m_pointSize = pointSize;
 
  890   QMatrix matrix = m_layoutEditor->getMatrixPaperViewToVp();
 
  891   double h = m_pointSize * 25.4 / 72.;
 
  892   double vtam = h * matrix.m11();
 
  893   int ps = qRound(vtam);
 
  897   m_font.setPixelSize(ps);
 
  972   return m_subTickSize;
 
  982   return m_tickCentralized;
 
  987   m_tickCentralized = b;
 
 1012   return m_subDivisions;
 
 1042   if(mouseEvent->buttons() == Qt::LeftButton)
 
 1044     QPoint p = mouseEvent->pos();
 
 1047     m_copyAuxFrameRect = QRect();
 
 1048     m_layoutEditor->raiseDraftLayoutEditor();
 
 1050   else if(mouseEvent->buttons() == Qt::RightButton)
 
 1052     QPoint gp = mouseEvent->globalPos();
 
 1053     if(m_selected == 10)
 
 1055       QAction* action = m_menu->exec(gp);
 
 1056       if(action == m_setTypeAction)
 
 1058       else if(action == m_setFamilyAction)
 
 1060       else if(action == m_setLabelColorAction)
 
 1061         setLabelColorAction();
 
 1062       else if(action == m_setBarColorAction)
 
 1063         setBarColorAction();
 
 1064       else if(action == m_setBarHeightAction)
 
 1065         setBarHeightAction();
 
 1066       else if(action == m_offsetOriginAction)
 
 1067         setOffsetOriginAction();
 
 1068       else if(action == m_setLabelAboveAction)
 
 1069         setLabelAboveAction();
 
 1070       else if(action == m_setUnitAboveAction)
 
 1071         setUnitAboveAction();
 
 1072       else if(action == m_setUnitAction)
 
 1074       else if(action == m_setDivisionsAction)
 
 1075         setDivisionsAction();
 
 1076       else if(action == m_setSubDivisionsAction)
 
 1077         setSubDivisionsAction();
 
 1078       else if(action == m_setStepAction)
 
 1080       else if(action == m_showTooTipAction)
 
 1081         setShowTooTipAction();
 
 1088   QPoint p = mouseEvent->pos();
 
 1089   QPoint gp = mouseEvent->globalPos();
 
 1091   if(mouseEvent->buttons() == Qt::NoButton)
 
 1096     getSelectionPoint(p);
 
 1101       showSelectionPoints();
 
 1102       toolTip(gp, 
"Selection");
 
 1103       if(m_selected == 10 && m_layoutEditor->getFrameSelected() != 
this)
 
 1104         m_layoutEditor->setFrameSelected(
this);
 
 1109   else if(mouseEvent->buttons() == Qt::LeftButton)
 
 1112     QPoint p = mouseEvent->pos();
 
 1113     QPoint d = m_pressPoint - p;
 
 1114     QMatrix matrix = m_layoutEditor->getMatrix();
 
 1115     m_auxFrameRect = matrix.mapRect(m_frameRect).toRect();
 
 1122         m_layoutEditor->insertCopy2Undo(m_dataFrame);
 
 1127         m_auxFrameRect = QRect(m_auxFrameRect.left(), m_auxFrameRect.top(), m_auxFrameRect.width() - d.x(), m_auxFrameRect.height());
 
 1128       else if(m_selected == 8) 
 
 1129         m_auxFrameRect = QRect(m_auxFrameRect.left() - d.x(), m_auxFrameRect.top(), m_auxFrameRect.width() + d.x(), m_auxFrameRect.height());
 
 1131         m_auxFrameRect.moveCenter(m_auxFrameRect.center() - d);
 
 1141   if(mouseEvent->button() == Qt::LeftButton)
 
 1143     QPoint p = mouseEvent->pos();
 
 1145     if(m_pressPoint != p && m_selected != 0)
 
 1149       QPixmap* pixmap = m_layoutEditor->getDraftPixmap();
 
 1150       pixmap->fill(Qt::transparent);
 
 1151       QMatrix matrix = m_layoutEditor->getMatrix();
 
 1152       QRectF r(m_auxFrameRect.left(), m_auxFrameRect.top(), m_auxFrameRect.width(), m_auxFrameRect.height());
 
 1153       double w = m_frameRect.width();
 
 1154       m_frameRect = matrix.inverted().mapRect(r);
 
 1155       double nw = m_frameRect.width();
 
 1156       m_layoutEditor->lowerDraftLayoutEditor();
 
 1158       if(m_selected == 4 || m_selected == 8)
 
 1160         bool fineRound = 
false;
 
 1161         double fat = nw / w;
 
 1162         if(fat > .95 && fat < 1.05)
 
 1165         double newStep = m_step * fat;
 
 1166         findNiceStep(newStep);
 
 1170       m_layoutEditor->draw();
 
 1172       if(m_selected != 10)
 
 1174         QPoint c = getCenterSelected();
 
 1175         cursor().setPos(mapToGlobal(c));
 
 1176         QMouseEvent e1(QEvent::MouseButtonPress, c, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
 
 1177         QApplication::sendEvent(
this, &e1);
 
 1179       showSelectionPoints();
 
 1186   if(QApplication::overrideCursor() || m_dragging)
 
 1189   m_layoutEditor->setFrameSelected(
this);
 
 1204   m_layoutEditor->setFrameSelected(0);
 
 1213   QPixmap* pixmap = m_layoutEditor->getDraftPixmap();
 
 1214   QPainter painter(pixmap);
 
 1215   painter.translate(m_layoutEditor->getVerticalRulerWidth(), m_layoutEditor->getHorizontalRulerWidth());
 
 1216   painter.setBrush(Qt::NoBrush);
 
 1217   painter.setPen(Qt::red);
 
 1220   if(m_copyAuxFrameRect.isValid())
 
 1222     painter.setCompositionMode(QPainter::CompositionMode_DestinationOut);
 
 1223     painter.drawRect(m_copyAuxFrameRect);
 
 1227   painter.setCompositionMode(QPainter::CompositionMode_DestinationOver);
 
 1228   painter.drawRect(m_auxFrameRect);
 
 1231   m_copyAuxFrameRect = m_auxFrameRect;
 
 1233   m_layoutEditor->update();
 
 1240   m_pixmap.fill(Qt::transparent);
 
 1243   QPainter painter(&m_pixmap);
 
 1245   painter.setPen(Qt::blue);
 
 1246   painter.setBrush(QColor(0, 0, 255, 24));
 
 1247   painter.drawRect(QRect(m_recSel10.left(), m_recSel10.top(), m_recSel10.width()-1, m_recSel10.height()-1));  
 
 1250   painter.setBrush(QColor(0, 0, 255, 150));
 
 1251   painter.drawRect(m_recSel4);
 
 1252   painter.drawRect(m_recSel8);
 
 1259   m_pixmap.fill(Qt::transparent);
 
 1270   if(m_recSel4.contains(p, Qt::OddEvenFill))
 
 1272   else if(m_recSel8.contains(p, Qt::OddEvenFill))
 
 1274   else if(m_recSel10.contains(p, Qt::OddEvenFill))
 
 1285     c = m_recSel4.center();
 
 1286   else if(m_selected == 8)
 
 1287     c = m_recSel8.center();
 
 1288   else if(m_selected == 10)
 
 1289     c = m_recSel10.center();
 
 1298   if(m_selected == 10)
 
 1299     cursor.setShape(Qt::SizeAllCursor);
 
 1300   else if(m_selected == 4 || m_selected == 8)
 
 1301     cursor.setShape(Qt::SizeHorCursor);
 
 1303   if(QApplication::overrideCursor())
 
 1305     if(QApplication::overrideCursor()->shape() != cursor.shape())
 
 1307       while(QApplication::overrideCursor())
 
 1308         QApplication::restoreOverrideCursor();
 
 1309       if(cursor.shape() != Qt::ArrowCursor)
 
 1310         QApplication::setOverrideCursor(cursor);
 
 1313   else if(cursor.shape() != Qt::ArrowCursor)
 
 1314     QApplication::setOverrideCursor(cursor);
 
 1320   if(m_showToolTip == 
false)
 
 1322     QToolTip::hideText();
 
 1326   if(type == 
"Selection")
 
 1328     if(m_selected == 4 || m_selected == 8)
 
 1329       QToolTip::showText(p, 
"Drag to Change Step", 
this);
 
 1330     else if(m_selected == 10)
 
 1331       QToolTip::showText(p, 
"Drag to Move", 
this);
 
 1333       QToolTip::hideText();
 
 1340   int i = QInputDialog::getInt(
this, tr(
"Configure Type"),
 
 1341                               tr(
"Graphic Scale Type:"), m_type, 1, 4, 1, &ok);
 
 1354   f.setPointSize(m_pointSize);
 
 1356   QFont font = QFontDialog::getFont(&ok, f, 
this);
 
 1360     m_pointSize = font.pointSize();
 
 1361     setPointSize(m_pointSize);
 
 1369   QColor cor = QColorDialog::getColor(m_labelColor, 
this, 
"Label Color");
 
 1380   QColor cor = QColorDialog::getColor(m_labelColor, 
this, 
"Label Color");
 
 1392   int i = QInputDialog::getInt(
this, tr(
"Configure Bar Height"),
 
 1393                               tr(
"Bar Height:"), qRound(m_barRect.height()), 2, 20, 1, &ok);
 
 1396     m_barRect.setHeight(i);
 
 1404   if(m_offsetOriginAction->isChecked() != m_offsetOrigin)
 
 1406     m_offsetOrigin = m_offsetOriginAction->isChecked();
 
 1414   if(m_setLabelAboveAction->isChecked() != m_labelAbove)
 
 1416     m_labelAbove = m_setLabelAboveAction->isChecked();
 
 1424   if(m_setUnitAboveAction->isChecked() != m_unitAbove)
 
 1426     m_unitAbove = m_setUnitAboveAction->isChecked();
 
 1435   items << tr(
"Kilometers") << tr(
"Meters") << tr(
"Decimal Degrees") << tr(
"Miles") << \
 
 1436     tr(
"Leagues") << tr(
"Inches") << tr(
"Feet") << tr(
"Hand") << tr(
"Fingers") << \
 
 1437     tr(
"Nautic Miles") << tr(
"Nautic Fathom") << tr(
"Yards") << tr(
"Fourlongs") << \
 
 1438     tr(
"Chains") << tr(
"Marathons") << tr(
"Unknow");
 
 1441   for(current = 0; current < items.size(); current++)
 
 1443     if(m_unit == items[current])
 
 1448   QString item = QInputDialog::getItem(
this, tr(
"Set Unit"),
 
 1449                                           tr(
"Unit:"), items, current, 
false, &ok);
 
 1451   if(ok && item.isEmpty() == 
false && item != m_unit)
 
 1463   int i = QInputDialog::getInt(
this, tr(
"Set Number Of Divisions"),
 
 1464                               tr(
"Number Of Divisions:"), m_divisions, 2, 10, 1, &ok);
 
 1479   int i = QInputDialog::getInt(
this, tr(
"Set Number Of Subdivisions"),
 
 1480                               tr(
"Number Of Subdivisions:"), m_subDivisions, 2, 10, 1, &ok);
 
 1493                               tr(
"Step Distance:"), m_step, 0, 2147483647, 1, &ok);
 
 1504   if(m_showTooTipAction->isChecked() != m_showToolTip)
 
 1506     m_showToolTip = m_setUnitAboveAction->isChecked();
 
 1507     showToolTip(m_showToolTip);
 
void hideSelectionPoints()
 
void setLabelAboveAction()
 
virtual ~GraphicScaleFrame()
 
QPoint getCenterSelected()
 
std::vector< QString > m_labels
 
void findNiceStep(double newStep=0)
 
void setDivisionsAction()
 
This file contains include headers for the Vector Geometry model of TerraLib. 
 
void setUnit(const QString &)
 
GraphicScaleFrame(te::qt::widgets::DataFrame *df, Qt::WindowFlags f=Qt::Widget)
 
void setDataFrame(te::qt::widgets::DataFrame *df)
 
QString m_subDivisionString
 
std::vector< double > m_labelLengths
 
void setTickCentralized(bool)
 
void leaveEvent(QEvent *)
 
te::qt::widgets::DataFrame * getDataFrame()
 
GraphicScaleFrame & operator=(const GraphicScaleFrame &rhs)
 
void showSelectionPoints()
 
void mousePressEvent(QMouseEvent *)
 
void setBarColor(const QColor &)
 
This file contains include headers for the Layout module. 
 
double m_subDivisionLabelLength
 
void setSubTickSize(double)
 
void setFont(const QFont &)
 
void paintEvent(QPaintEvent *event)
 
A canvas built on top of Qt. 
 
void setShowTooTipAction()
 
void setSubDivisionsAction()
 
void mouseMoveEvent(QMouseEvent *)
 
void setOffsetOriginAction()
 
void setBarRect(const QRectF &)
 
void getSelectionPoint(const QPoint &p)
 
void calculateSelectionPoints()
 
void labelLengthCalculation()
 
std::string Convert2String(boost::int16_t value)
It converts a short integer value to a string. 
 
te::qt::widgets::DataFrame * m_dataFrame
 
void toolTip(const QPoint &, const QString &)
 
void setBarHeightAction()
 
This file contains include headers for the TerraLib Common Runtime module. 
 
Frame & operator=(const Frame &rhs)
 
void enterEvent(QEvent *)
 
void setLabelColor(const QColor &)
 
double getDouble(const std::string &value, std::vector< std::string > &sVector)
 
void setSubDivisions(int)
 
void setLabelColorAction()
 
void setUnitAboveAction()
 
void mouseReleaseEvent(QMouseEvent *)