qt_widget_get_point.h

来自「CGAL is a collaborative effort of severa」· C头文件 代码 · 共 86 行

H
86
字号
// Copyright (c) 1997-2000  Utrecht University (The Netherlands),// ETH Zurich (Switzerland), Freie Universitaet Berlin (Germany),// INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg// (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria),// and Tel-Aviv University (Israel).  All rights reserved.//// This file is part of CGAL (www.cgal.org); you can redistribute it and/or// modify it under the terms of the GNU Lesser General Public License as// published by the Free Software Foundation; version 2.1 of the License.// See the file LICENSE.LGPL distributed with CGAL.//// Licensees holding a valid commercial license may use this file in// accordance with the commercial license agreement provided with the software.//// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.//// $Source: /CVSROOT/CGAL/Packages/Qt_widget/include/CGAL/IO/Qt_widget_get_point.h,v $// $Revision: 1.16 $ $Date: 2003/11/21 11:36:25 $// $Name:  $//// Author(s)     : Laurent Rineau#ifndef CGAL_QT_WIDGET_GET_POINT_H#define CGAL_QT_WIDGET_GET_POINT_H#include <CGAL/IO/Qt_widget.h>#include <CGAL/IO/Qt_widget_layer.h>#include <qcursor.h>#ifndef CGAL_QT_WIDGET_GET_POINT_BUTTON#define CGAL_QT_WIDGET_GET_POINT_BUTTON Qt::LeftButton#endifnamespace CGAL {template <class R>class Qt_widget_get_point : public Qt_widget_layer{public:  typedef typename R::Point_2	Point;  typedef typename R::FT	FT;    Qt_widget_get_point(const QCursor c=QCursor(Qt::crossCursor),		      QObject* parent = 0, const char* name = 0) :    Qt_widget_layer(parent, name), cursor(c) {};  protected:  bool is_pure(Qt::ButtonState s){    if((s & Qt::ControlButton) ||       (s & Qt::ShiftButton) ||       (s & Qt::AltButton))      return 0;    else      return 1;  }  void mousePressEvent(QMouseEvent *e)  {    if(e->button() == CGAL_QT_WIDGET_GET_POINT_BUTTON       && is_pure(e->state()))    {      FT x, y;      widget->x_real(e->x(), x);      widget->y_real(e->y(), y);      widget->new_object(make_object(Point(x, y)));    }  };  void activating()  {    oldcursor = widget->cursor();    widget->setCursor(cursor);  };    void deactivating()  {    widget->setCursor(oldcursor);  };  QCursor cursor;  QCursor oldcursor;};} // namespace CGAL#endif // CGAL_QT_WIDGET_GET_POINT_H

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?