|
@@ -5,7 +5,8 @@ xodrscenfunc::xodrscenfunc()
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-std::vector<QGraphicsPathItem *> xodrscenfunc::GetRoadParkingItem(RoadDigit *prd)
|
|
|
|
|
|
+std::vector<QGraphicsPathItem *> xodrscenfunc::GetRoadParkingItem(RoadDigit *prd,std::vector<QGraphicsTextItem *> & xvectortext,
|
|
|
|
+ std::vector<QGraphicsPathItem *> & xvectormarkgraph)
|
|
{
|
|
{
|
|
std::vector<QGraphicsPathItem *> xvectorgrapath;
|
|
std::vector<QGraphicsPathItem *> xvectorgrapath;
|
|
std::vector<iv::ParkingPoint> * pvectorpark = prd->GetParkingPoint();
|
|
std::vector<iv::ParkingPoint> * pvectorpark = prd->GetParkingPoint();
|
|
@@ -26,7 +27,66 @@ std::vector<QGraphicsPathItem *> xodrscenfunc::GetRoadParkingItem(RoadDigit *prd
|
|
pitem->setPen(QPen(Qt::darkGray,0.001));
|
|
pitem->setPen(QPen(Qt::darkGray,0.001));
|
|
xvectorgrapath.push_back(pitem);
|
|
xvectorgrapath.push_back(pitem);
|
|
|
|
|
|
|
|
+ QGraphicsTextItem * pitemtext = new QGraphicsTextItem;
|
|
|
|
|
|
|
|
+ pitemtext->setPlainText(pvectorpark->at(i).strtext.data());
|
|
|
|
+ QRectF xrect = pitemtext->boundingRect();
|
|
|
|
+ QFont font = pitemtext->font();
|
|
|
|
+ font.setPixelSize(100.0);
|
|
|
|
+// font.setPixelSize(1); // 像素大小
|
|
|
|
+ // font.setItalic(false); // 斜体
|
|
|
|
+ // font.setUnderline(false); // 下划线
|
|
|
|
+ pitemtext->setFont(font);
|
|
|
|
+ // pitemtext->setFont(QFont("华文琥珀",10));
|
|
|
|
+ pitemtext->setDefaultTextColor(QColor(255,255,255));
|
|
|
|
+ pitemtext->setFlags(QGraphicsItem::ItemIsMovable|QGraphicsItem::ItemIsSelectable);
|
|
|
|
+ double fScale = 0.01;
|
|
|
|
+ pitemtext->setScale(fScale);
|
|
|
|
+ xrect = pitemtext->boundingRect();
|
|
|
|
+ qDebug("rect height: %f",xrect.height());
|
|
|
|
+ double fwidth = xrect.width() * fScale;
|
|
|
|
+ double fheight = xrect.height()*fScale;
|
|
|
|
+ double ftemx = fwidth * (-0.5);
|
|
|
|
+ double ftemy = fheight * 0.5;
|
|
|
|
+
|
|
|
|
+ double fparkhdg = pvectorpark->at(i).mfHdg;
|
|
|
|
+ double fposx = ftemx*cos(fparkhdg)-ftemy*sin(fparkhdg);
|
|
|
|
+ double fposy = ftemx*sin(fparkhdg)+ftemy*cos(fparkhdg);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// pitemtext->setDefaultTextColor(QColor(0, 160, 230)); // 文本色
|
|
|
|
+ pitemtext->setDefaultTextColor(Qt::white);
|
|
|
|
+ pitemtext->setRotation(pvectorpark->at(i).mfHdg *(-1.0)*180.0/M_PI);
|
|
|
|
+ pitemtext->setPos(pvectorpark->at(i).mParkingCenterXY.mX + fposx,(pvectorpark->at(i).mParkingCenterXY.mY+fposy)*(-1));
|
|
|
|
+ xvectortext.push_back(pitemtext);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for(i=0;i<lsize;i++)
|
|
|
|
+ {
|
|
|
|
+ std::vector<std::vector<iv::ParkingXY>> xvectormark = pvectorpark->at(i).mParkingMark;
|
|
|
|
+ unsigned int j;
|
|
|
|
+ for(j=0;j<xvectormark.size();j++)
|
|
|
|
+ {
|
|
|
|
+ QPainterPath xpath;
|
|
|
|
+ if(xvectormark.at(j).size()<4)
|
|
|
|
+ {
|
|
|
|
+ std::cout<<"Park Mark size < 4"<<std::endl;
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ xpath.moveTo(xvectormark.at(j).at(0).mX,xvectormark.at(j).at(0).mY*(-1));
|
|
|
|
+ xpath.lineTo(xvectormark.at(j).at(1).mX,xvectormark.at(j).at(1).mY*(-1));
|
|
|
|
+ xpath.lineTo(xvectormark.at(j).at(2).mX,xvectormark.at(j).at(2).mY*(-1));
|
|
|
|
+ xpath.lineTo(xvectormark.at(j).at(3).mX,xvectormark.at(j).at(3).mY*(-1));
|
|
|
|
+ xpath.closeSubpath();
|
|
|
|
+ QGraphicsPathItem * pitem = new QGraphicsPathItem;
|
|
|
|
+ pitem->setPath(xpath);
|
|
|
|
+ pitem->setBrush(Qt::yellow);
|
|
|
|
+ pitem->setPen(QPen(Qt::white,0.001));
|
|
|
|
+ xvectormarkgraph.push_back(pitem);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return xvectorgrapath;
|
|
return xvectorgrapath;
|
|
}
|
|
}
|