static inline SHPObject* apply(Polygon const& polygon) { int const n = geometry::num_points(polygon); int const ring_count = 1 + geometry::num_interior_rings(polygon); boost::scoped_array<double> x(new double[n]); boost::scoped_array<double> y(new double[n]); boost::scoped_array<int> parts(new int[ring_count]); int ring = 0; int offset = 0; process_polygon(polygon, x.get(), y.get(), parts.get(), offset, ring); return ::SHPCreateObject(SHPT_POLYGON, -1, ring_count, parts.get(), NULL, n, x.get(), y.get(), NULL, NULL); }
// 鼠标按下捕获器 void CDrawWin::mousePressEvent(QMouseEvent* event) { switch(m_curMenuStatus) { case MENU_STATUS_NONE: { qDebug() << __func__ << " " << __LINE__ ; bool bHit,bCtrlHit; m_curShape = HitTest(event,bHit,bCtrlHit); if(m_curShape != NULL) { if(bCtrlHit) { QApplication::setOverrideCursor(Qt::PointingHandCursor); }else { if(bHit) { QApplication::setOverrideCursor(Qt::ClosedHandCursor); } } m_curShape->mousePressEvent(event); } } break; case MENU_STATUS_LINE: { process_line(event); } break; case MENU_STATUS_CIRCLE: { process_circle(event); } break; case MENU_STATUS_RECTANGE: { qDebug() << __func__ << " " << __LINE__ ; process_rectangle(event); } break; case MENU_STATUS_POLYGON: { qDebug() << __func__ << " " << __LINE__ ; process_polygon(event); } break; case MENU_STATUS_ANGLE: { process_angle(event); } break; case MENU_STATIS_DEL: { bool bHit,bCtrlHit; m_curShape = HitTest(event,bHit,bCtrlHit); if(m_curShape != NULL) { if(m_curShape == m_shapeList[0]) { QMessageBox msgBox; msgBox.setText("Can not delete the scale."); msgBox.exec(); break; } if(bHit) { if(m_curShape == m_shapeList[m_shapeList.size() - 1]) { m_shapeList.pop_back(); QApplication::setOverrideCursor(Qt::ArrowCursor); update(); }else { QVector<CShape*>::iterator it = m_shapeList.begin(); for(;it != m_shapeList.end();it++) { if((*it) == m_curShape) { m_shapeList.erase(it); QApplication::setOverrideCursor(Qt::ArrowCursor); update(); } } } } } } break; } }