#ifndef CGAL_QT_POINT_TRANSLATION_WITH_INFO #define CGAL_QT_POINT_TRANSLATION_WITH_INFO #include namespace CGAL { namespace Qt { template class PointTranslationWithInfo : public PointTranslation { typedef PointTranslation Base; public: typedef typename DT::Face_handle Face_handle; typedef typename DT::Vertex_handle Vertex_handle; typedef typename DT::Point Point; typedef typename DT::Vertex::Info Info; PointTranslationWithInfo(const Translation& translation_, QGraphicsScene& scene_, DT * dt_, QObject* parent); const Info& info() const { return _info; } Info& info() { return _info; } protected: void mouseMoveEvent(QGraphicsSceneMouseEvent *event); bool eventFilter(QObject *obj, QEvent *event); virtual Vertex_handle insert_point(const Point& p); Info compute_info() const; void add_info(Vertex_handle v) const; void show_info(const QPointF& pos, Vertex_handle v) const; private: Info _info; }; template PointTranslationWithInfo::PointTranslationWithInfo(const Translation& translation_, QGraphicsScene& scene_, DT * dt_, QObject* parent) : Base(translation_, scene_, dt_, parent) { } template typename PointTranslationWithInfo::Info PointTranslationWithInfo::compute_info() const { return this->chosen_vertex->info() + info(); } template void PointTranslationWithInfo::add_info(Vertex_handle v) const { Info new_info = compute_info(); v->info().setString(new_info.toString()); } template void PointTranslationWithInfo::show_info(const QPointF& pos, Vertex_handle v) const { if(v == Vertex_handle()) { return; } const Info& vertex_info = this->chosen_vertex->info(); //QToolTip::showText(pos.toPoint(), QString::fromStdWString(vertex_info.toString())); } template typename PointTranslationWithInfo::Vertex_handle PointTranslationWithInfo::insert_point(const Point& p) { Vertex_handle v = Base::insert_point(p); add_info(v); return v; } template void PointTranslationWithInfo::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { Base::mouseMoveEvent(event); show_info(event->scenePos(), this->chosen_vertex); } template bool PointTranslationWithInfo::eventFilter(QObject *obj, QEvent *event) { if (event->type() == QEvent::GraphicsSceneMouseMove) { QGraphicsSceneMouseEvent *mouseEvent = static_cast(event); mouseMoveEvent(mouseEvent); return false; // do not eat move event! } return Base::eventFilter(obj, event); } } // namespace Qt } // namespace CGAL #endif // CGAL_QT_POINT_TRANSLATION_WITH_INFO