范文健康探索娱乐情感热点
投稿投诉
热点动态
科技财经
情感日志
励志美文
娱乐时尚
游戏搞笑
探索旅游
历史星座
健康养生
美丽育儿
范文作文
教案论文

Qt通过重写QGraphicItem实现绘制拖动旋转缩放椭圆

  本例程通过重写了一个类,继承自QGraphicItem,来实现了在qgraphicsScene上绘制、拖动、旋转、缩放椭圆
  效果如下:
  核心代码如下:
  mygraphicrectitem.h
  【领QT开发教程 学习资料,点击下方链接莬费领取↓↓ ,先码住不迷路~】
  点击→领取「链接」 1 #ifndef MYGRAPHICRECTITEM_H  2 #define MYGRAPHICRECTITEM_H  3 #include   4 #include   5 #include   6 #include   7 #include   8 #include   9 #include  10 #include  11 #include  12 #include  13 #include  14 enum STATE_FLAG{ 15     DEFAULT_FLAG=0, 16     MOV_LEFT_LINE,//标记当前为用户按下矩形的左边界区域 17     MOV_TOP_LINE,//标记当前为用户按下矩形的上边界区域 18     MOV_RIGHT_LINE,//标记当前为用户按下矩形的右边界区域 19     MOV_BOTTOM_LINE,//标记当前为用户按下矩形的下边界区域 20     MOV_RIGHTBOTTOM_RECT,//标记当前为用户按下矩形的右下角 21     MOV_RECT,//标记当前为鼠标拖动图片移动状态 22     ROTATE//标记当前为旋转状态 23 }; 24 enum SHAPE_TYPE{ 25     RECTANGLE=0, 26     CIRCLE 27 }; 28  29 class myGraphicRectItem:public QObject,public QGraphicsItem 30 { 31     Q_OBJECT 32 public: 33     SHAPE_TYPE m_ShapeType; 34     myGraphicRectItem(QGraphicsItem *parent = nullptr); 35     //myGraphicRectItem(QRectF m_OriginRect = QRectF(0,0,100,100)); 36     QRectF  boundingRect() const; 37     QPainterPath shape() const; 38     QPainterPath getCollideShape(); 39     ~myGraphicRectItem(); 40     void setRectSize(QRectF mrect,bool bResetRotateCenter = true); 41     void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); 42     void mousePressEvent(QGraphicsSceneMouseEvent *event); 43     void mouseMoveEvent(QGraphicsSceneMouseEvent *event); 44     void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); 45     void SetRotate(qreal RotateAngle); 46     QPointF getRotatePoint(QPointF ptCenter, QPointF ptIn, qreal angle);//获取旋转后的点 47     QList getRotatePoints(QPointF ptCenter,QList ptIns,qreal angle);//获取多个旋转后的点 48     QPolygonF getRotatePolygonFromRect(QPointF ptCenter,QRectF rectIn,qreal angle);//将矩形旋转之后返回多边形 49     QRectF getCrtPosRectToSceen(); 50     QPolygonF getCrtPolygonToScreen(); 51  52     QPointF getSmallRotateRectCenter(QPointF ptA,QPointF ptB);//获取旋转时候矩形正上方的旋转标记矩形 53     QRectF  getSmallRotateRect(QPointF ptA,QPointF ptB); 54     bool    m_bRotate; 55     qreal   m_RotateAngle; 56     QPointF m_RotateCenter; 57  58 private: 59     QRectF  m_oldRect; 60     QPolygonF m_oldRectPolygon; 61     QRectF  m_RotateAreaRect; 62     bool    m_bResize; 63     QPolygonF m_insicedPolygon; 64     QRectF  m_insicedRectf; 65     QPolygonF m_leftPolygon; 66     QRectF  m_leftRectf; 67     QPolygonF m_topPolygon; 68     QRectF  m_topRectf; 69     QPolygonF m_rightPolygon; 70     QRectF  m_rightRectf; 71     QPolygonF m_bottomPolygon; 72     QRectF  m_bottomRectf; 73     QRectF m_SmallRotateRect;//矩形顶部用来表示旋转的标记的矩形 74     QPolygonF m_SmallRotatePolygon;//矩形顶部用来表示旋转的标记的矩形旋转后形成的多边形 75 //    QPolygonF m_rbPolygon; 76 //    QRectF  m_rbRectf; 77     QPointF m_startPos; 78     STATE_FLAG m_StateFlag; 79     QPointF *pPointFofSmallRotateRect; 80 protected: 81  82 }; 83  84 #endif // MYGRAPHICRECTITEM_H
  mygraphicrectitem.cpp   1 #include "mygraphicrectitem.h"   2 #include    3 #include    4    5 myGraphicRectItem::myGraphicRectItem(QGraphicsItem *parent):   6     m_ShapeType(RECTANGLE),   7     m_bResize(false),   8     m_oldRect(0,0,100,100),   9     m_bRotate(false),  10     m_RotateAngle(0),  11     m_StateFlag(DEFAULT_FLAG)  12 {  13     //setParent(parent);  14     setRectSize(m_oldRect);  15     setToolTip("Click and drag me!");  //提示  16     setCursor(Qt::ArrowCursor);   //改变光标形状,手的形状  17     setFlag(QGraphicsItem::ItemIsMovable);  18     pPointFofSmallRotateRect = new QPointF[4];  19     SetRotate(0);  20     //setFlag(QGraphicsItem::ItemIsSelectable);//  21     setFlags(QGraphicsItem::ItemIsSelectable|QGraphicsItem::ItemIsMovable);  22 }  23   24 QRectF myGraphicRectItem::boundingRect() const//用来控制本item绘制区域  25 {  26     QPainterPath path;  27     path.addPolygon(m_oldRectPolygon);  28     path.addPolygon(m_SmallRotatePolygon);  29     return path.boundingRect();  30 }  31   32 QPainterPath myGraphicRectItem::shape() const//用来控制检测碰撞collide和鼠标点击hit响应区域  33 {  34     QPainterPath path;  35     path.addPolygon(m_oldRectPolygon);  36     path.addPolygon(m_SmallRotatePolygon);  37     return path;  38 }  39   40 QPainterPath myGraphicRectItem::getCollideShape()  41 {  42     QPainterPath path;  43     if(m_ShapeType==RECTANGLE)  44     {  45         path.addPolygon(m_oldRectPolygon);  46     }  47     else if(m_ShapeType == CIRCLE)  48     {  49         QPainterPath pathTemp;  50         pathTemp.addEllipse(m_oldRect);  51         QTransform trans;  52         trans.translate(m_RotateCenter.x(),m_RotateCenter.y());  53         trans.rotate(m_RotateAngle);//QTransform是绕(0,0)点旋转的,所以转之前要先平移到圆心,然后旋转,然后再平移回来  54         trans.translate(-m_RotateCenter.x(),-m_RotateCenter.y());  55         path = trans.map(pathTemp);  56     }  57     return path;  58 }  59   60 myGraphicRectItem::~myGraphicRectItem()  61 {  62     delete []pPointFofSmallRotateRect;  63     pPointFofSmallRotateRect = nullptr;  64 }  65   66 void myGraphicRectItem::setRectSize(QRectF mrect, bool bResetRotateCenter)  67 {  68     m_oldRect = mrect;  69     if(bResetRotateCenter)  70     {  71         m_RotateCenter.setX(m_oldRect.x()+m_oldRect.width()/2);  72         m_RotateCenter.setY(m_oldRect.y()+m_oldRect.height()/2);  73     }  74     m_oldRectPolygon = getRotatePolygonFromRect(m_RotateCenter,m_oldRect,m_RotateAngle);  75   76     m_insicedRectf = QRectF(m_oldRect.x()+8,m_oldRect.y()+8,m_oldRect.width()-16,m_oldRect.height()-16);  77     m_insicedPolygon =getRotatePolygonFromRect(m_RotateCenter,m_insicedRectf,m_RotateAngle);  78   79     m_leftRectf = QRectF(m_oldRect.x(),m_oldRect.y(),8,m_oldRect.height()-8);  80     m_leftPolygon = getRotatePolygonFromRect(m_RotateCenter,m_leftRectf,m_RotateAngle);  81   82     m_topRectf = QRectF(m_oldRect.x()+8,m_oldRect.y(),m_oldRect.width()-8,8);  83     m_topPolygon = getRotatePolygonFromRect(m_RotateCenter,m_topRectf,m_RotateAngle);  84   85     m_rightRectf = QRectF(m_oldRect.right()-8,m_oldRect.y()+8,8,m_oldRect.height()-16);  86     m_rightPolygon = getRotatePolygonFromRect(m_RotateCenter,m_rightRectf,m_RotateAngle);  87   88     m_bottomRectf = QRectF(m_oldRect.x(),m_oldRect.bottom()-8,m_oldRect.width()-8,8);  89     m_bottomPolygon = getRotatePolygonFromRect(m_RotateCenter,m_bottomRectf,m_RotateAngle);  90   91     m_SmallRotateRect = getSmallRotateRect(mrect.topLeft(),mrect.topRight());//矩形正上方的旋转标记矩形  92     m_SmallRotatePolygon = getRotatePolygonFromRect(m_RotateCenter,m_SmallRotateRect,m_RotateAngle);  93   94 }  95   96 void myGraphicRectItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)  97 {  98     QPen mPen;  99 //    if(this->isSelected()) 100 //    { 101 //        mPen= QPen(Qt::lightGray); 102 //    } 103 //    else 104 //    { 105         mPen= QPen(Qt::yellow); 106 //    } 107     painter->setPen(mPen); 108     if(m_ShapeType == RECTANGLE) 109     { 110         //绘制旋转后的矩形 111         painter->drawPolygon(m_oldRectPolygon); 112         //绘制旋转圆形 113         mPen.setWidth(2); 114         mPen.setColor(Qt::green); 115         painter->setPen(mPen); 116         QPointF pf = getSmallRotateRectCenter(m_oldRectPolygon[0],m_oldRectPolygon[1]); 117         QRectF rect = QRectF(pf.x()-10,pf.y()-10,20,20); 118         painter->drawEllipse(rect);//绘制圆形 119         painter->drawPoint(pf);//绘制点 120         //有重叠的情况 121         if(!this->scene()->collidingItems(this).isEmpty()) 122         { 123            QPainterPath path,pathOthers; 124            QList lstcolliItems = this->scene()->collidingItems(this); 125            int nColliNum = lstcolliItems.count(); 126            for(int i = 0;iscene()->collidingItems(this)[i]; 129                if(pTempItem->zValue()==0) 130                { 131                    QPainterPath tempPath = pTempItem->getCollideShape(); 132                    tempPath.translate(pTempItem->pos());//转换到view中的坐标 133                    pathOthers += tempPath;//记录与本item重叠的item的路径 134                } 135            } 136            path.addPolygon(m_oldRectPolygon); 137            path.translate(this->pos());//转换到view中的坐标 138            path &= pathOthers;//计算重叠部分的路径path 139            path.translate(-this->pos().x(),-this->pos().y());//转换回本Item中的坐标 140            QBrush brush(Qt::cyan); 141            mPen.setColor(Qt::blue); 142            painter->setPen(mPen); 143            painter->setBrush(brush); 144            painter->drawPath(path);//绘制重叠区域 145         } 146     } 147     else if(m_ShapeType == CIRCLE) 148     { 149 //        //绘制旋转后的矩形 150 //        painter->drawRect(m_oldRect); 151 //        painter->drawPolygon(m_oldRectPolygon); 152         //绘制旋转后的圆形 153         QTransform trans0; 154         QPainterPath path0; 155         trans0.translate(m_RotateCenter.x(),m_RotateCenter.y()); 156         trans0.rotate(m_RotateAngle,Qt::ZAxis); 157         trans0.translate(-m_RotateCenter.x(),-m_RotateCenter.y()); 158         path0.addEllipse(m_oldRect); 159         path0 = trans0.map(path0);//将pathTemp旋转m_RotateAngle角度 160         painter->drawPath(path0);//drawPolygon(m_oldRectPolygon); 161         //绘制旋转圆形标记 162         mPen.setWidth(2); 163         mPen.setColor(Qt::green); 164         painter->setPen(mPen); 165         QPointF pf = getSmallRotateRectCenter(m_oldRectPolygon[0],m_oldRectPolygon[1]); 166         QRectF rect = QRectF(pf.x()-10,pf.y()-10,20,20); 167         painter->drawEllipse(rect);//绘制圆形 168         painter->drawPoint(pf);//绘制点 169         //有重叠的情况 170         if(!this->scene()->collidingItems(this).isEmpty()) 171         { 172            QPainterPath path,pathOthers; 173            QList lstcolliItems = this->scene()->collidingItems(this); 174            int nColliNum = lstcolliItems.count(); 175            for(int i = 0;iscene()->collidingItems(this)[i]; 178                if(pTempItem->zValue()==0) 179                { 180                    QPainterPath tempPath = pTempItem->getCollideShape(); 181                    tempPath.translate(pTempItem->pos());//转换到view中的坐标 182                    pathOthers += tempPath;//记录与本item重叠的item的路径 183                } 184            } 185            QTransform trans; 186            //旋转的时候,QTransform是绕坐标轴的(0,0)点旋转的,所以先要平移到坐标轴0,0点,然后的旋转,然后移回到原来的位置 187            trans.translate(m_RotateCenter.x(),m_RotateCenter.y()); 188            trans.rotate(m_RotateAngle); 189            trans.translate(-m_RotateCenter.x(),-m_RotateCenter.y()); 190            path.addEllipse(m_oldRect); 191            path = trans.map(path);//将pathTemp旋转m_RotateAngle角度 192            path.translate(this->pos());//转换到view中的坐标 193            path &= pathOthers;//计算重叠部分的路径path 194            path.translate(-this->pos().x(),-this->pos().y());//转换回本Item中的坐标 195            QBrush brush(Qt::cyan); 196            mPen.setColor(Qt::blue); 197            painter->setPen(mPen); 198            painter->setBrush(brush); 199            painter->drawPath(path);//绘制重叠区域 200         } 201     } 202 //scene()->update(); 203 } 204  205 void myGraphicRectItem::mousePressEvent(QGraphicsSceneMouseEvent *event) 206 { 207     if(event->button()== Qt::LeftButton) 208     { 209         //setSelected(true); 210         m_startPos = event->pos();//鼠标左击时,获取当前鼠标在图片中的坐标, 211         if(m_SmallRotatePolygon.containsPoint(m_startPos,Qt::WindingFill))//旋转矩形 212         { 213             setCursor(Qt::PointingHandCursor); 214             m_StateFlag = ROTATE; 215         } 216         else if(m_insicedPolygon.containsPoint(m_startPos,Qt::WindingFill))//在矩形内框区域时按下鼠标,则可拖动图片 217         { 218             setCursor(Qt::ClosedHandCursor);   //改变光标形状,手的形状 219             m_StateFlag = MOV_RECT;//标记当前为鼠标拖动图片移动状态 220         } 221         else if(m_leftPolygon.containsPoint(m_startPos,Qt::WindingFill)) 222         { 223             setCursor(Qt::SizeHorCursor); 224             m_StateFlag = MOV_LEFT_LINE;//标记当前为用户按下矩形的左边界区域 225         } 226         else if(m_rightPolygon.containsPoint(m_startPos,Qt::WindingFill)) 227         { 228             setCursor(Qt::SizeHorCursor); 229             m_StateFlag = MOV_RIGHT_LINE;//标记当前为用户按下矩形的右边界区域 230         } 231         else if(m_topPolygon.containsPoint(m_startPos,Qt::WindingFill)) 232         { 233             setCursor(Qt::SizeVerCursor); 234             m_StateFlag = MOV_TOP_LINE;//标记当前为用户按下矩形的上边界区域 235         } 236         else if(m_bottomPolygon.containsPoint(m_startPos,Qt::WindingFill)) 237         { 238             setCursor(Qt::SizeVerCursor); 239             m_StateFlag = MOV_BOTTOM_LINE;//标记当前为用户按下矩形的下边界区域 240         } 241 //        else if(m_rbPolygon.containsPoint(m_startPos,Qt::WindingFill)) 242 //        { 243 //            setCursor(Qt::SizeFDiagCursor); 244 //            m_StateFlag = MOV_RIGHTBOTTOM_RECT;//标记当前为用户按下矩形的右下角 245 //        } 246         else 247         { 248             m_StateFlag = DEFAULT_FLAG; 249         } 250     } 251     else 252     { 253         QGraphicsItem::mousePressEvent(event); 254     } 255 } 256  257 void myGraphicRectItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) 258 { 259     if(m_StateFlag == ROTATE) 260     { 261        int nRotateAngle = atan2((event->pos().x()-m_RotateCenter.x()),(event->pos().y()-m_RotateCenter.y()))*180/M_PI; 262        SetRotate(180-nRotateAngle);        263        //qDebug()<pos() - m_startPos); 268         moveBy(point.x(), point.y()); 269         setRectSize(m_oldRect); 270         scene()->update(); 271     } 272     else if(m_StateFlag == MOV_LEFT_LINE) 273     { 274         QPointF pf = QPointF((m_oldRectPolygon.at(1).x()+m_oldRectPolygon.at(2).x())/2,((m_oldRectPolygon.at(1).y()+m_oldRectPolygon.at(2).y())/2)); 275         //计算到右侧边中点的距离 276         qreal dis = sqrt((event->pos().x()-pf.x())*(event->pos().x()-pf.x()) +(event->pos().y()-pf.y())*(event->pos().y()-pf.y())); 277         qreal dis2LT = sqrt((event->pos().x()-m_oldRectPolygon.at(0).x())*(event->pos().x()-m_oldRectPolygon.at(0).x()) +(event->pos().y()-m_oldRectPolygon.at(0).y())*(event->pos().y()-m_oldRectPolygon.at(0).y())); 278         qreal dis2RT = sqrt((event->pos().x()-m_oldRectPolygon.at(1).x())*(event->pos().x()-m_oldRectPolygon.at(1).x()) +(event->pos().y()-m_oldRectPolygon.at(1).y())*(event->pos().y()-m_oldRectPolygon.at(1).y())); 279         if(dis<16||dis2LT>dis2RT) 280         { 281             return; 282         } 283         else 284         { 285             QRectF newRect(m_oldRect); 286             newRect.setLeft(m_oldRect.right()-dis); 287             newRect.setRight(m_oldRect.right()); 288             setRectSize(newRect,false); 289             m_RotateCenter=QPointF((m_oldRectPolygon.at(0).x()+m_oldRectPolygon.at(2).x())/2,(m_oldRectPolygon.at(0).y()+m_oldRectPolygon.at(2).y())/2); 290             m_oldRect.moveCenter(m_RotateCenter); 291             setRectSize(m_oldRect); 292             scene()->update();//必须要用scene()->update(),不能用update();否则会出现重影 293         } 294     } 295     else if(m_StateFlag == MOV_TOP_LINE) 296     { 297         //底边中点 298         QPointF pf = QPointF((m_oldRectPolygon.at(2).x()+m_oldRectPolygon.at(3).x())/2,((m_oldRectPolygon.at(2).y()+m_oldRectPolygon.at(3).y())/2)); 299         //计算到底边中点的距离 300         qreal dis = sqrt((event->pos().x()-pf.x())*(event->pos().x()-pf.x()) +(event->pos().y()-pf.y())*(event->pos().y()-pf.y())); 301         qreal dis2LT = sqrt((event->pos().x()-m_oldRectPolygon.at(0).x())*(event->pos().x()-m_oldRectPolygon.at(0).x()) +(event->pos().y()-m_oldRectPolygon.at(0).y())*(event->pos().y()-m_oldRectPolygon.at(0).y())); 302         qreal dis2LB = sqrt((event->pos().x()-m_oldRectPolygon.at(3).x())*(event->pos().x()-m_oldRectPolygon.at(3).x()) +(event->pos().y()-m_oldRectPolygon.at(3).y())*(event->pos().y()-m_oldRectPolygon.at(3).y())); 303         if(dis<16||dis2LT>dis2LB) 304         { 305             return; 306         } 307         else 308         { 309             QRectF newRect(m_oldRect); 310             newRect.setTop(m_oldRect.bottom()-dis); 311             newRect.setBottom(m_oldRect.bottom()); 312             setRectSize(newRect,false); 313             m_RotateCenter=QPointF((m_oldRectPolygon.at(0).x()+m_oldRectPolygon.at(2).x())/2,(m_oldRectPolygon.at(0).y()+m_oldRectPolygon.at(2).y())/2); 314             m_oldRect.moveCenter(m_RotateCenter); 315             setRectSize(m_oldRect); 316             scene()->update();//必须要用scene()->update(),不能用update();否则会出现重影 317         } 318     } 319     else if(m_StateFlag == MOV_RIGHT_LINE) 320     { 321         QPointF pf = QPointF((m_oldRectPolygon.at(0).x()+m_oldRectPolygon.at(3).x())/2,((m_oldRectPolygon.at(0).y()+m_oldRectPolygon.at(3).y())/2)); 322         //计算到左侧边中点的距离 323         qreal dis = sqrt((event->pos().x()-pf.x())*(event->pos().x()-pf.x()) +(event->pos().y()-pf.y())*(event->pos().y()-pf.y())); 324         qreal dis2LT = sqrt((event->pos().x()-m_oldRectPolygon.at(0).x())*(event->pos().x()-m_oldRectPolygon.at(0).x()) +(event->pos().y()-m_oldRectPolygon.at(0).y())*(event->pos().y()-m_oldRectPolygon.at(0).y())); 325         qreal dis2RT = sqrt((event->pos().x()-m_oldRectPolygon.at(1).x())*(event->pos().x()-m_oldRectPolygon.at(1).x()) +(event->pos().y()-m_oldRectPolygon.at(1).y())*(event->pos().y()-m_oldRectPolygon.at(1).y())); 326         if(dis<16||dis2LTupdate();//必须要用scene()->update(),不能用update();否则会出现重影 340         } 341     } 342     else if(m_StateFlag == MOV_BOTTOM_LINE) 343     { 344         //顶边中点 345         QPointF pf = QPointF((m_oldRectPolygon.at(0).x()+m_oldRectPolygon.at(1).x())/2,((m_oldRectPolygon.at(0).y()+m_oldRectPolygon.at(1).y())/2)); 346         //计算到底边中点的距离 347         qreal dis = sqrt((event->pos().x()-pf.x())*(event->pos().x()-pf.x()) +(event->pos().y()-pf.y())*(event->pos().y()-pf.y())); 348         qreal dis2LT = sqrt((event->pos().x()-m_oldRectPolygon.at(0).x())*(event->pos().x()-m_oldRectPolygon.at(0).x()) +(event->pos().y()-m_oldRectPolygon.at(0).y())*(event->pos().y()-m_oldRectPolygon.at(0).y())); 349         qreal dis2LB = sqrt((event->pos().x()-m_oldRectPolygon.at(3).x())*(event->pos().x()-m_oldRectPolygon.at(3).x()) +(event->pos().y()-m_oldRectPolygon.at(3).y())*(event->pos().y()-m_oldRectPolygon.at(3).y())); 350         if(dis<16||dis2LTupdate();//必须要用scene()->update(),不能用update();否则会出现重影 364         } 365     } 366 } 367  368 void myGraphicRectItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) 369 { 370     setCursor(Qt::ArrowCursor); 371     if(m_StateFlag == MOV_RECT) 372     { 373         m_StateFlag = DEFAULT_FLAG; 374     } 375     else { 376         QGraphicsItem::mouseReleaseEvent(event); 377     } 378 } 379  380 void myGraphicRectItem::SetRotate(qreal RotateAngle) 381 { 382     m_bRotate = true; 383     m_RotateAngle = RotateAngle; 384     setRectSize(m_oldRect); 385     if(this->scene()!=nullptr) 386         this->scene()->update(); 387 } 388  389 QPointF myGraphicRectItem::getRotatePoint(QPointF ptCenter, QPointF ptIn, qreal angle) 390 { 391     double dx = ptCenter.x(); 392     double dy = ptCenter.y(); 393     double x = ptIn.x(); 394     double y = ptIn.y(); 395     double xx,yy; 396     xx = (x-dx)*cos(angle*M_PI/180)-(y-dy)*sin(angle*M_PI/180)+dx; 397     yy = (x-dx)*sin(angle*M_PI/180)+(y-dy)*cos(angle*M_PI/180)+dy; 398  399     return QPointF(xx,yy); 400 } 401  402 QList myGraphicRectItem::getRotatePoints(QPointF ptCenter, QList ptIns, qreal angle) 403 { 404     QList lstPt; 405     for(int i = 0;i vpt; 415     QPointF pf = getRotatePoint(ptCenter,rectIn.topLeft(),angle); 416     vpt.append(pf); 417     pf = getRotatePoint(ptCenter,rectIn.topRight(),angle); 418     vpt.append(pf); 419     pf = getRotatePoint(ptCenter,rectIn.bottomRight(),angle); 420     vpt.append(pf); 421     pf = getRotatePoint(ptCenter,rectIn.bottomLeft(),angle); 422     vpt.append(pf); 423     pf = getRotatePoint(ptCenter,rectIn.topLeft(),angle); 424     vpt.append(pf); 425     return QPolygonF(vpt); 426 } 427  428 QRectF myGraphicRectItem::getCrtPosRectToSceen() 429 { 430     QRectF retRect = QRectF(m_oldRect.x()+pos().x(),m_oldRect.y()+pos().y(),m_oldRect.width(),m_oldRect.height()); 431     return retRect; 432 } 433  434 QPolygonF myGraphicRectItem::getCrtPolygonToScreen() 435 { 436     QVector vpt; 437     for(int i = 0;iptA.y())//顺时针旋转0-180 467     { 468         qreal k = (ptA.x()-ptB.x())/(ptB.y()-ptA.y());//中垂线斜率 469         qreal b = (ptA.y()+ptB.y())/2-k*(ptA.x()+ptB.x())/2; 470         //求AB线中垂线上离AB中点20个像素的点C的坐标 471         x = 20*cos(atan(k))+ptCenter.x(); 472         y = k*x+b; 473     } 474     else if(ptB.y()
美国一母亲抱5岁儿子跳下瀑布悬崖落差27。5米男孩奇迹生还近日,美国纽约州,一名34岁女子抱着5岁的儿子从尼亚加拉瀑布的一处景点跳下。所跳地点悬崖高约27。5米,女子当场死亡。5岁小男孩奇迹生还但头部受伤严重,获救后被紧急送往儿童医院做了特斯拉温州事故疑点,狂飙中明明多次避让,为何刹车灯却不亮?电视剧狂飙让人回味无穷,但是现实版狂飙却看得人触目惊心。2月17日,浙江温州一辆特斯拉狂飙的视频刷爆网络,引起热烈讨论。视频开始,只见一辆Model3从桥后方以相当高的时速冲出,落特斯拉回应温州事故致1死1伤非常难过,又是特斯拉事故我就想问,刹车能不能刹住,再多的只能,也得刹住啊,像我骑自行车的都知道,有事刹车,刹不住得赶紧维修驾驶员技术没毛病,极致的走位躲避车辆行人,最后选择装公交车很明智。一系列操作不是十温州特斯拉车祸,驾驶员已经尽力,撞击公交车是绝望中的冷静2月17号特斯拉的一场车祸,非常惨烈,一辆特斯拉车疯了一般在温州瑞安塘下镇撞上了私家车和公交车后才停了下来。上次听说特斯拉的新闻还是赛车手林志颖出车祸的事,其他都是特斯拉销量爆棚的网传温州特斯拉狂飙!造成惨烈车祸2月17日下午,温州瑞安塘下镇发生一起惨重事故。一辆特斯拉Model3高速行驶,在停车前撞上了一辆私家车和一辆公交车。事故发生的地方叫塘厦镇。即便它仅是一个县级市下的城镇,不过它是成绩之外,体育活动是进入美国名校的第二大标准尽管每年都有无数的招生官强调美国大学录取注重学生的个性发展,正如前耶鲁招生官LIoydPeterson所说美国大学招生是一门艺术,并没有标准的统一的录取公式。但是,从普林斯顿评论与俄罗斯取得关键大胜,美国表态耐人寻味,冲突给中国启示不小截至目前,俄乌冲突已经整整打了一年时间,尽管在冲突初期俄军势如破竹直推基辅,但在随后的西方援助下,乌军顺利开展了反攻,并且一度将俄军打退至第聂伯河左岸,最终形成了长达4个月的僵持局距地仅4。2光年,发现可能存在生命的类地行星?是另一个地球吗?头条创作挑战赛如今,发现系外行星已经不是什么稀奇事儿了,截止到2015年,人类已发现并确认的系外行星就达1876颗。但是发现可能存在生命的类地行星,还是让人兴奋不已的,这意味着这颗光伏已上天!航天强国间展开太空光伏角逐!我国已启动逐日行动!100年来,人们一直梦想着将大量的太阳能电池板送入太空,并将能量发射到地球上。与地面上的间歇性可再生能源不同,这些轨道面板将始终沐浴在明亮的阳光下,并有可能提供持续的电力供应。如今木卫二地表有什么?探测器传回真实画面,科学家看后感觉不可思议在阅读此文前,麻烦您点击一下关注,既方便您进行讨论与分享,又给您带来不一样的参与感,感谢您的支持。如果要问在整个宇宙中,人类最感兴趣的话题是什么,那一定是寻找地外生命。除了那些跟地星空有约丨今年为何会有闰二月?2月20日,癸卯兔年二月初一,而在这个二月之后还紧跟着一个闰二月。两个农历二月共计59天。中国天文学会会员天津市天文学会理事杨婧介绍,农历是我国传统历法,是一种阴阳合历。阴历是以月
陶红挺有贵妇范,穿红色蕾丝连衣裙配卷发,丰满身材很有韵味成熟女人的穿搭和年轻女孩子当然是不一样的,到了四五十岁的年龄阶段,穿衣搭配就应该优雅知性,所以大家可以来看一看女明星陶红的穿搭,作为中年女人的她在气质这方面可是非常出众的,这一次穿刘涛新剧杀青造型吸睛,白色飘带衬衫搭配半身裙,气质很出众头条创作挑战赛刘涛的演技很不错,不少观众都喜欢看她的影视作品,尤其是霸道女总裁的戏份,刘涛更是拿捏到位。那么,剧荒的粉丝们,是不是都在期待她的新作品呢?这不,她的新剧做自己的光杀青奥尼尔晒肌肉照!50岁风采不减,新女友曝光,娇小可爱型日前,NBA传奇中锋沙奎尔奥尼尔在个人社交媒体上晒出了大量的健身照片,引起不少球迷的关注。从这些照片中不难看出,奥尼尔现在的身材管理比球员时期好太多了,肌肉线条清晰可见。球员时期的没想到佟丽娅身材这么有料?穿低胸连衣裙秀曲线,像换了个人似的虽然现在大家都觉得瘦才是美,可实际上一昧追求瘦不意味着就是美,瘦而不柴才是大家追求的身材。像佟丽娅她的身材就让非常多的人感到羡慕,这一次佟丽娅穿上着时髦的低胸连衣裙,秀出了她的纤细金卡戴珊晒美照,与一众超模争艳,42岁身材仍傲人,韵味十足金卡戴珊在社交媒体上晒出自己的美照,与一众超模争艳。照片中,金卡戴珊和一众超模们都穿着粉红色的长裙,非常的惊艳。金卡戴珊坐在C位,妥妥的主角。相比另外3位超模的长裙,金卡戴珊的长裙五帝是哪五位帝王?一文带你全面了解五帝时代与文明的形成中华文明的形成与发展经历了长期的历史过程。从一万年前开始萌芽到距今五千年的五帝时代,产生了很多新的元素。例如陶器的发明和发展原始村落的形成原始农业的产生城市雏形的出现等等,这些新元外媒美国芯片时代开始落幕了众所周知,半导体产业在上世纪五十年代起源于美国,其本土接连诞生了英特尔高通英伟达AMD等一大批领跑业内的顶尖科技巨头,美国也一直掌握着全球芯片市场的话语权。虽然美本土制造业的大举外下调业绩预期富士康称尽快恢复郑州工厂全面生产CNMO新闻众所周知,富士康是苹果主要的代工厂之一,得益于iPhone手机的热销,每年富士康都能赚得盆满钵满。不过,近期富士康郑州工厂因疫情生产受限。对此,富士康方面表示,将尽快恢在古代那个没有植发的时代古人秃了会怎么办?在现代,由于熬夜工作学习等压力,难免会出现掉发秃顶的状况,一般们会戴戴假发遮住秃了的头顶,要是家庭好一点的人可以去植发。那么在古代那个没有植发的时代,古人秃顶该怎么办?是让它一直秃1964年,赵宗礼驾登陆艇起义归来,奖600两黄金,官至少将退休1964年10月4日晚,福建沿海海面波涛汹涌,海浪一波又一波涌向岸边,拍打着海岸。突然,一艘艇身上标有1279字样的国民党海军登陆艇驶进了厦门港。艇上,站着一个中等身材的中年人,他看图学习丨让湿地公园成为人民群众共享的绿色空间湿地公约第十四届缔约方大会2022年11月5日在中国武汉和瑞士日内瓦两地拉开帷幕。这是我国首次承办湿地公约缔约方大会。大会以珍爱湿地人与自然和谐共生为主题。湿地被称为地球之肾,是全