leda_window.h

来自「CGAL is a collaborative effort of severa」· C头文件 代码 · 共 820 行 · 第 1/2 页

H
820
字号
// Copyright (c) 1999  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/window/include/CGAL/IO/leda_window.h,v $// $Revision: 1.15 $ $Date: 2004/02/20 13:05:14 $// $Name:  $//// Author(s)     : Andreas Fabri//                 Stefan Schirra #ifndef CGAL_LEDA_WINDOW_H#define CGAL_LEDA_WINDOW_H#include <CGAL/basic.h>#include <CGAL/IO/Color.h>#include <LEDA/window.h>#include <CGAL/IO/cgal_logo.h>CGAL_BEGIN_NAMESPACE// #if ( __LEDA__ < 360 )// #define leda_window window// #define leda_color  color// #endif#if ( __LEDA__ < 361 )#define leda_black black#define leda_dotted dotted#define leda_xor_mode xor_mode#define leda_blue blue#define leda_red red#endif#if (( __LEDA__ < 362 ) || defined(NOTEBOOK))#define  leda_drawing_mode  drawing_mode#endif#define Str(x)     #x#define Xstr(x)    Str(x)#define OP         CGAL CGAL_VERSIONtypedef leda_window        Window_stream;inlineleda_window&operator<<(leda_window& w, const Color& c){  w.set_fg_color(leda_color(c.red(), c.green(), c.blue()));  return w;}inlinevoidcgalize(leda_window& w){  w.set_frame_label(Xstr(OP));  w.set_icon_label("CGAL");  w.set_line_width( 2);  w.set_icon_pixrect( w.create_pixrect(cgal_logo));}inlineleda_window*create_demo_window( float w = 512.0, float h = 512.0,                         const char* str = "CGAL",                         double x_extension = 1.0){#if __LEDA__ >= 420  leda_window* Wptr = new leda_window((int) w, (int) h);#else  leda_window* Wptr = new leda_window( w, h);#endif  cgalize( *Wptr);  double y_extension = x_extension * h / w;  Wptr->init(-x_extension, x_extension, -y_extension);  Wptr->set_frame_label( str);  return Wptr;}inlineleda_window*create_and_display_demo_window(float w = 512.0, float h = 512.0,                                    const char* str = "CGAL",                                    double x_extension = 1.0){#if __LEDA__ >= 420  leda_window* Wptr = new leda_window( (int) w, (int) h);#else  leda_window* Wptr = new leda_window( w, h);#endif  cgalize( *Wptr);  double y_extension = x_extension * h / w;  Wptr->init(-x_extension, x_extension, -y_extension);  Wptr->set_frame_label( str);  Wptr->display();  return Wptr;}CGAL_END_NAMESPACE#endif // CGAL_LEDA_WINDOW_HCGAL_BEGIN_NAMESPACE//  Each of the following operators is individually//  protected against multiple inclusion.#ifdef CGAL_POINT_2_H#ifndef CGAL_LEDA_WINDOW_POINT_2#define CGAL_LEDA_WINDOW_POINT_2template< class R >leda_window&operator<<(leda_window& w, const Point_2<R>& p){  double x = CGAL::to_double(p.x());  double y = CGAL::to_double(p.y());  w.draw_point(x,y);    return w;}template< class R >leda_window&operator>>(leda_window& w, Point_2<R>& p){  typedef typename R::RT RT;  leda_point l_p;  leda_drawing_mode save = w.set_mode(leda_xor_mode);  if (w >> l_p)  {      double x = l_p.xcoord();      double y = l_p.ycoord();      w << l_p;      w.set_mode( save);       w.draw_point(x,y);            p = Point_2<R>( RT(x), RT(y));  }  else  {      w.set_mode( save);  }  return w;}template< class R >leda_window&read(leda_window& w, Point_2<R>& p){  typedef typename R::RT RT;  leda_point l_p;  if (w >> l_p)  {      double x = l_p.xcoord();      double y = l_p.ycoord();      p = Point_2<R>( RT(x), RT(y));  }  return w;}template <class R>voidread_mouse_plus(leda_window& w, Point_2<R>& p, int& button){  typedef typename R::RT RT;  double x, y;  button = w.read_mouse(x,y);  w.draw_point(x,y);    p = Point_2<R>(RT(x), RT(y));}#endif // CGAL_LEDA_WINDOW_POINT_2#endif // CGAL_POINT_2_H#ifdef CGAL_SEGMENT_2_H#ifndef CGAL_LEDA_WINDOW_SEGMENT_2#define CGAL_LEDA_WINDOW_SEGMENT_2template< class R >leda_window&operator<<(leda_window& w, const Segment_2<R>& s){  w.draw_segment(CGAL::to_double(s.source().x()),                 CGAL::to_double(s.source().y()),                 CGAL::to_double(s.target().x()),                 CGAL::to_double(s.target().y()));  return w;}template< class R >leda_window&operator>>(leda_window& w, Segment_2<R>& s){  typedef  typename R::RT  RT;  leda_segment l_s;  leda_drawing_mode save = w.set_mode(leda_xor_mode);  if ( w.read( l_s))  {      double x1 = l_s.xcoord1();      double y1 = l_s.ycoord1();      double x2 = l_s.xcoord2();      double y2 = l_s.ycoord2();      w.set_mode( save);      w.draw_segment(x1,y1, x2, y2);      s = Segment_2<R>(Point_2<R>( RT(x1), RT(y1)),                            Point_2<R>( RT(x2), RT(y2)));  }  else  {      w.set_mode( save);  }  return w;}template< class R >leda_window&read(leda_window& w, Segment_2<R>& s){  typedef  typename R::RT  RT;  leda_segment l_s;  if ( w.read( l_s))  {      double x1 = l_s.xcoord1();      double y1 = l_s.ycoord1();      double x2 = l_s.xcoord2();      double y2 = l_s.ycoord2();      s = Segment_2<R>(Point_2<R>( RT(x1), RT(y1)),                            Point_2<R>( RT(x2), RT(y2)));  }  return w;}#endif // CGAL_LEDA_WINDOW_SEGMENT_2#endif // CGAL_SEGMENT_2_H#ifdef CGAL_LINE_2_H#ifndef CGAL_LEDA_WINDOW_LINE_2#define CGAL_LEDA_WINDOW_LINE_2template< class R >leda_window&operator<<(leda_window& w, const Line_2<R>& l){  Point_2<R> p1 = l.point(),                  p2 = p1 + l.direction().vector();  w.draw_line(CGAL::to_double(p1.x()), CGAL::to_double(p1.y()),              CGAL::to_double(p2.x()), CGAL::to_double(p2.y()));  return w;}template< class R >leda_window&operator>>(leda_window& w, Line_2<R>& l){  typedef  typename R::RT  RT;  leda_segment l_s;  leda_drawing_mode save = w.set_mode(leda_xor_mode);  if ( w.read( l_s))  {      double x1 = l_s.xcoord1();      double y1 = l_s.ycoord1();      double x2 = l_s.xcoord2();      double y2 = l_s.ycoord2();      w.set_mode( save);      w.draw_line(x1,y1, x2, y2);      l = Line_2<R>(Point_2<R>( RT(x1), RT(y1)),                         Point_2<R>( RT(x2), RT(y2)));  }  else  {      w.set_mode( save);  }  return w;}template< class R >leda_window&read(leda_window& w, Line_2<R>& l){  typedef  typename R::RT  RT;  leda_segment l_s;  if ( w.read( l_s))  {      double x1 = l_s.xcoord1();      double y1 = l_s.ycoord1();      double x2 = l_s.xcoord2();      double y2 = l_s.ycoord2();      l = Line_2<R>(Point_2<R>( RT(x1), RT(y1)),                         Point_2<R>( RT(x2), RT(y2)));  }  return w;}#endif // CGAL_LEDA_WINDOW_LINE_2#endif //CGAL_LINE_2_H#ifdef CGAL_RAY_2_H#ifndef CGAL_LEDA_WINDOW_RAY_2#define CGAL_LEDA_WINDOW_RAY_2template< class R >leda_window&operator<<(leda_window& w, const Ray_2<R>& r){  Point_2<R> p = r.point(0);  Point_2<R> q = r.point(1);  w.draw_ray(CGAL::to_double(p.x()),             CGAL::to_double(p.y()),             CGAL::to_double(q.x()),             CGAL::to_double(q.y()));  return w;}template< class R >leda_window&operator>>(leda_window& w, Ray_2<R>& r){  typedef  typename R::RT  RT;  leda_segment l_s;  leda_drawing_mode save = w.set_mode(leda_xor_mode);  if ( w.read( l_s))  {      double x1 = l_s.xcoord1();      double y1 = l_s.ycoord1();      double x2 = l_s.xcoord2();      double y2 = l_s.ycoord2();      w.set_mode( save);      r = Ray_2<R>(Point_2<R>( RT(x1), RT(y1)),                        Point_2<R>( RT(x2), RT(y2)));      w << r;  }  else  {      w.set_mode( save);  }  return w;}template< class R >leda_window&read(leda_window& w, Ray_2<R>& r){  typedef  typename R::RT  RT;  leda_segment l_s;  if ( w.read( l_s))  {      double x1 = l_s.xcoord1();      double y1 = l_s.ycoord1();      double x2 = l_s.xcoord2();      double y2 = l_s.ycoord2();      r = Ray_2<R>(Point_2<R>( RT(x1), RT(y1)),                        Point_2<R>( RT(x2), RT(y2)));  }  return w;}#endif // CGAL_LEDA_WINDOW_RAY_2#endif //CGAL_RAY_2_H#ifdef CGAL_TRIANGLE_2_H#ifndef CGAL_LEDA_WINDOW_TRIANGLE_2#define CGAL_LEDA_WINDOW_TRIANGLE_2template< class R >leda_window&operator<<(leda_window& w, const Triangle_2<R>& t){  double x0 = CGAL::to_double(t.vertex(0).x()),         y0 = CGAL::to_double(t.vertex(0).y()),         x1 = CGAL::to_double(t.vertex(1).x()),         y1 = CGAL::to_double(t.vertex(1).y()),         x2 = CGAL::to_double(t.vertex(2).x()),         y2 = CGAL::to_double(t.vertex(2).y());  leda_color cl = w.get_fill_color();    if (cl != leda_invisible) { // draw filled triangle ...    w.draw_filled_triangle(leda_point(x0,y0),                            leda_point(x1,y1),                            leda_point(x2,y2), cl);   }	 	 	   w.draw_segment(x0, y0, x1, y1);  w.draw_segment(x1, y1, x2, y2);  w.draw_segment(x2, y2, x0, y0);  return w;}template< class R >leda_window&

⌨️ 快捷键说明

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