1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780
|
// 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.
//
// $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.2-branch/window/include/CGAL/IO/Postscript_file_stream.h $
// $Id: Postscript_file_stream.h 28567 2006-02-16 14:30:13Z lsaboret $
//
//
// Author(s) : Stefan Schirra
#ifndef CGAL_POSTSCRIPT_FILE_STREAM_H
#define CGAL_POSTSCRIPT_FILE_STREAM_H
#include <CGAL/LEDA_basic.h>
#include <CGAL/IO/Color.h>
#ifdef LEDA_PS_FILE_H
# error Internal CGAL error: <LEDA/ps_file.h> should not have been included yet
#else
# include <LEDA/basic.h>
# include <LEDA/list.h>
# include <LEDA/string.h>
# include <LEDA/stream.h>
# include <LEDA/point.h>
# include <LEDA/segment.h>
# include <LEDA/line.h>
# include <LEDA/circle.h>
# include <LEDA/polygon.h>
# if (__LEDA__ >= 400)
# include <LEDA/rectangle.h>
# endif // 400
# include <LEDA/color.h>
# include <LEDA/window.h>
# if (__LEDA__ >= 400)
# include <LEDA/rat_window.h>
# include <LEDA/geo_graph.h>
# endif // 400
# define private protected
# include <LEDA/ps_file.h>
# undef private
#endif // LEDA_PS_FILE_H
#include <CGAL/IO/cgal_logo.h>
CGAL_BEGIN_NAMESPACE
typedef CGAL_LEDA_SCOPE::ps_file leda_ps_file;
class Postscript_file_stream : public leda_ps_file
{
public:
Postscript_file_stream(double w,double h, leda_string name="CGAL_unnamed.ps")
: leda_ps_file(w/40.0, h/40.0, name)
{}
Postscript_file_stream(leda_string name="CGAL_unnamed.ps")
: leda_ps_file( name )
{ set_draw_bb(false); }
void display() {}
void display(int, int) {}
int read_mouse(double& , double& ) {return 1;}
leda_color set_fg_color(leda_color c) { return set_color(c); }
void set_font(const leda_string& ls) { set_text_font(ls); }
void change_rgb(const Color&);
bool is_in_colormode();
};
inline
void
Postscript_file_stream::change_rgb(const Color& c)
{
file << double(c.r())/255.0 << " "
<< double(c.g())/255.0 << " "
<< double(c.b())/255.0 << " srgb\n";
}
inline
bool
Postscript_file_stream::is_in_colormode()
{ return (outputmode== CGAL_LEDA_SCOPE::colored_mode); }
inline
Postscript_file_stream&
operator<<(Postscript_file_stream& w, const Color& c)
{
assert( w.is_in_colormode() );
w.change_rgb(c);
return w;
}
inline
void
cgalize(Postscript_file_stream& w)
{
w.set_line_width( 1);
}
inline
Postscript_file_stream*
create_demo_postscript_file_stream( float w = 512.0, float h = 512.0,
const char* str = "CGAL_unnamed.ps",
double x_extension = 1.0)
{
Postscript_file_stream* Wptr = new Postscript_file_stream( w, h, str);
cgalize( *Wptr);
double y_extension = x_extension * h / w;
Wptr->init(-x_extension, x_extension, -y_extension);
return Wptr;
}
inline
Postscript_file_stream*
create_and_display_demo_postscript_file_stream(float w = 512.0,
float h = 512.0, const char* str = "CGAL_unnamed.ps",
double x_extension = 1.0)
{
Postscript_file_stream* Wptr = new Postscript_file_stream( w, h, str);
cgalize( *Wptr);
double y_extension = x_extension * h / w;
Wptr->init(-x_extension, x_extension, -y_extension);
return Wptr;
}
#endif // CGAL_POSTSCRIPT_FILE_STREAM_H
// Each of the following operators is individually
// protected against multiple inclusion.
#ifdef CGAL_POINT_2_H
#ifndef CGAL_POSTSCRIPT_FILE_STREAM_POINT_2
#define CGAL_POSTSCRIPT_FILE_STREAM_POINT_2
template< class R >
Postscript_file_stream&
operator<<(Postscript_file_stream& 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 >
Postscript_file_stream&
operator>>(Postscript_file_stream& 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 >
Postscript_file_stream&
read(Postscript_file_stream& 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>
void
read_mouse_plus(Postscript_file_stream& 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_POSTSCRIPT_FILE_STREAM_POINT_2
#endif // CGAL_POINT_2_H
#ifdef CGAL_SEGMENT_2_H
#ifndef CGAL_POSTSCRIPT_FILE_STREAM_SEGMENT_2
#define CGAL_POSTSCRIPT_FILE_STREAM_SEGMENT_2
template< class R >
Postscript_file_stream&
operator<<(Postscript_file_stream& 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 >
Postscript_file_stream&
operator>>(Postscript_file_stream& 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 >
Postscript_file_stream&
read(Postscript_file_stream& 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_POSTSCRIPT_FILE_STREAM_SEGMENT_2
#endif // CGAL_SEGMENT_2_H
#ifdef CGAL_LINE_2_H
#ifndef CGAL_POSTSCRIPT_FILE_STREAM_LINE_2
#define CGAL_POSTSCRIPT_FILE_STREAM_LINE_2
template< class R >
Postscript_file_stream&
operator<<(Postscript_file_stream& 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 >
Postscript_file_stream&
operator>>(Postscript_file_stream& 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 >
Postscript_file_stream&
read(Postscript_file_stream& 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_POSTSCRIPT_FILE_STREAM_LINE_2
#endif //CGAL_LINE_2_H
#ifdef CGAL_RAY_2_H
#ifndef CGAL_POSTSCRIPT_FILE_STREAM_RAY_2
#define CGAL_POSTSCRIPT_FILE_STREAM_RAY_2
template< class R >
Postscript_file_stream&
operator<<(Postscript_file_stream& 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 >
Postscript_file_stream&
operator>>(Postscript_file_stream& 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 >
Postscript_file_stream&
read(Postscript_file_stream& 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_POSTSCRIPT_FILE_STREAM_RAY_2
#endif //CGAL_RAY_2_H
#ifdef CGAL_TRIANGLE_2_H
#ifndef CGAL_POSTSCRIPT_FILE_STREAM_TRIANGLE_2
#define CGAL_POSTSCRIPT_FILE_STREAM_TRIANGLE_2
template< class R >
Postscript_file_stream&
operator<<(Postscript_file_stream& 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());
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 >
Postscript_file_stream&
operator>>(Postscript_file_stream& w, Triangle_2<R>& t)
{
typedef typename R::RT RT;
double x,y;
int key = 0;
#if ( __LEDA__ < 362 )
w.state = 1;
#else
w.set_state( 1);
#endif // __LEDA__ < ...
leda_point first, second, third, p;
leda_drawing_mode save = w.set_mode(leda_xor_mode);
if ( !( w >> first)) { w.set_mode( save); return w; }
int save_but[8];
w.std_buttons(save_but);
key = w.read_mouse_seg( first.xcoord(), first.ycoord(), x, y);
if ( key == MOUSE_BUTTON(3))
{
w.set_buttons( save_but);
w.set_mode( save);
#if ( __LEDA__ < 362 )
w.state = 0;
#else
w.set_state( 0);
#endif // __LEDA__ < ...
return w;
}
else
{
w << leda_segment( first.xcoord(), first.ycoord(), x, y);
second = leda_point( x, y);
}
key = w.read_mouse_seg( second.xcoord(), second.ycoord(), x, y);
if ( key == MOUSE_BUTTON(3))
{
w << leda_segment( first, second );
w.set_buttons( save_but);
w.set_mode( save);
#if ( __LEDA__ < 362 )
w.state = 0;
#else
w.set_state( 0);
#endif // __LEDA__ < ...
return w;
}
else
{
w << leda_segment( second.xcoord(), second.ycoord(), x, y);
third = leda_point( x, y);
}
w << leda_segment( first, second );
w << leda_segment( second, third );
double x0 = first.xcoord();
double y0 = first.ycoord();
double x1 = second.xcoord();
double y1 = second.ycoord();
double x2 = third.xcoord();
double y2 = third.ycoord();
w.set_mode( save);
w.draw_segment(x0,y0, x1, y1);
w.draw_segment(x1,y1, x2, y2);
w.draw_segment(x2,y2, x0, y0);
t = Triangle_2<R>(Point_2<R>( RT(x0), RT(y0)),
Point_2<R>( RT(x1), RT(y1)),
Point_2<R>( RT(x2), RT(y2)));
return w;
}
template< class R >
Postscript_file_stream&
read(Postscript_file_stream& w, Triangle_2<R>& t)
{
typedef typename R::RT RT;
double x,y;
int key = 0;
#if ( __LEDA__ < 362 )
w.state = 1;
#else
w.set_state( 1);
#endif // __LEDA__ < ...
leda_point first, second, third, p;
leda_drawing_mode save = w.set_mode(leda_xor_mode);
if ( !( w >> first)) { w.set_mode( save); return w; }
int save_but[8];
w.std_buttons(save_but);
key = w.read_mouse_seg( first.xcoord(), first.ycoord(), x, y);
if ( key == MOUSE_BUTTON(3))
{
w.set_buttons( save_but);
w.set_mode( save);
#if ( __LEDA__ < 362 )
w.state = 0;
#else
w.set_state( 0);
#endif // __LEDA__ < ...
return w;
}
else
{
w << leda_segment( first.xcoord(), first.ycoord(), x, y);
second = leda_point( x, y);
}
key = w.read_mouse_seg( second.xcoord(), second.ycoord(), x, y);
if ( key == MOUSE_BUTTON(3))
{
w << leda_segment( first, second );
w.set_buttons( save_but);
w.set_mode( save);
#if ( __LEDA__ < 362 )
w.state = 0;
#else
w.set_state( 0);
#endif // __LEDA__ < ...
return w;
}
else
{
w << leda_segment( second.xcoord(), second.ycoord(), x, y);
third = leda_point( x, y);
}
w << leda_segment( first, second );
w << leda_segment( second, third );
double x0 = first.xcoord();
double y0 = first.ycoord();
double x1 = second.xcoord();
double y1 = second.ycoord();
double x2 = third.xcoord();
double y2 = third.ycoord();
w.set_mode( save);
t = Triangle_2<R>(Point_2<R>( RT(x0), RT(y0)),
Point_2<R>( RT(x1), RT(y1)),
Point_2<R>( RT(x2), RT(y2)));
return w;
}
#endif // CGAL_POSTSCRIPT_FILE_STREAM_TRIANGLE_2
#endif // CGAL_TRIANGLE_2_H
#ifdef CGAL_CIRCLE_2_H
#ifndef CGAL_POSTSCRIPT_FILE_STREAM_CIRCLE_2
#define CGAL_POSTSCRIPT_FILE_STREAM_CIRCLE_2
template< class R >
Postscript_file_stream&
operator<<(Postscript_file_stream& w, const Circle_2<R>& c)
{
double cx = CGAL::to_double(c.center().x()),
cy = CGAL::to_double(c.center().y()),
r = CGAL::to_double(c.squared_radius());
w.draw_circle(cx, cy , sqrt(r));
return w;
}
template< class R >
Postscript_file_stream&
operator>>(Postscript_file_stream& w, Circle_2<R>& c)
{
typedef typename R::RT RT;
double x,y;
int key = 0;
#if ( __LEDA__ < 362 )
w.state = 1;
#else
w.set_state( 1);
#endif // __LEDA__ < ...
leda_point p;
leda_drawing_mode save = w.set_mode(leda_xor_mode);
if ( !( w.read( p))) { w.set_mode( save); return w; }
double cx = p.xcoord();
double cy = p.ycoord();
Point_2<R> center = Point_2<R>( RT(cx), RT(cy));
int save_but[8];
w.std_buttons(save_but);
key = w.read_mouse_circle(cx, cy, x, y);
if ( key == MOUSE_BUTTON(3))
{
w.set_buttons( save_but);
w.set_mode( save);
#if ( __LEDA__ < 362 )
w.state = 0;
#else
w.set_state( 0);
#endif // __LEDA__ < ...
return w;
}
double dx = x - cx;
double dy = y - cy;
double sqr = dx*dx+dy*dy;
w.set_mode( save);
w.set_buttons( save_but);
w.draw_circle(cx, cy , sqrt(sqr));
c = Circle_2<R>(center, RT(sqr));
return w;
}
template< class R >
Postscript_file_stream&
read(Postscript_file_stream& w, Circle_2<R>& c)
{
typedef typename R::RT RT;
double x,y;
int key = 0;
#if ( __LEDA__ < 362 )
w.state = 1;
#else
w.set_state( 1);
#endif // __LEDA__ < ...
leda_point p;
leda_drawing_mode save = w.set_mode(leda_xor_mode);
if ( !( w.read( p))) { w.set_mode( save); return w; }
double cx = p.xcoord();
double cy = p.ycoord();
Point_2<R> center = Point_2<R>( RT(cx), RT(cy));
int save_but[8];
w.std_buttons(save_but);
key = w.read_mouse_circle(cx, cy, x, y);
if ( key == MOUSE_BUTTON(3))
{
w.set_buttons( save_but);
w.set_mode( save);
#if ( __LEDA__ < 362 )
w.state = 0;
#else
w.set_state( 0);
#endif // __LEDA__ < ...
return w;
}
double dx = x - cx;
double dy = y - cy;
double sqr = dx*dx+dy*dy;
w.set_mode( save);
w.set_buttons( save_but);
c = Circle_2<R>(center, RT(sqr));
return w;
}
#endif // CGAL_POSTSCRIPT_FILE_STREAM_CIRCLE_2
#endif // CGAL_CIRCLE_2_H
#ifdef CGAL_ISO_RECTANGLE_2_H
#ifndef CGAL_POSTSCRIPT_FILE_STREAM_ISO_RECTANGLE_2
#define CGAL_POSTSCRIPT_FILE_STREAM_ISO_RECTANGLE_2
template< class R >
Postscript_file_stream&
operator<<(Postscript_file_stream& w, const Iso_rectangle_2<R>& r)
{
double xmin = CGAL::to_double(r.min().x()),
ymin = CGAL::to_double(r.min().y()),
xmax = CGAL::to_double(r.max().x()),
ymax = CGAL::to_double(r.max().y());
w.draw_segment(xmin, ymin, xmax, ymin);
w.draw_segment(xmax, ymin, xmax, ymax);
w.draw_segment(xmax, ymax, xmin, ymax);
w.draw_segment(xmin, ymax, xmin, ymin);
return w;
}
template< class R >
Postscript_file_stream&
operator>>(Postscript_file_stream& w, Iso_rectangle_2<R>& r)
{
typedef typename R::RT RT;
double x,y;
int key = 0;
#if ( __LEDA__ < 362 )
w.state = 1;
#else
w.set_state( 1);
#endif // __LEDA__ < ...
leda_point first, second;
leda_drawing_mode save = w.set_mode(leda_xor_mode);
if ( !( w.read( first))) { w.set_mode( save); return w; }
int save_but[8];
w.std_buttons(save_but);
key = w.read_mouse_rect( first.xcoord(), first.ycoord(), x, y);
if ( key == MOUSE_BUTTON(3))
{
w.set_buttons( save_but);
w.set_mode( save);
#if ( __LEDA__ < 362 )
w.state = 0;
#else
w.set_state( 0);
#endif // __LEDA__ < ...
return w;
}
r = Iso_rectangle_2<R>(Point_2<R>( RT(first.xcoord()),
RT(first.ycoord())),
Point_2<R>( RT(x), RT(y)));
w.set_mode( save);
w.draw_rectangle( first.xcoord(), first.ycoord(), x, y);
w.set_buttons( save_but);
return w;
}
template< class R >
Postscript_file_stream&
read(Postscript_file_stream& w, Iso_rectangle_2<R>& r)
{
typedef typename R::RT RT;
double x,y;
int key = 0;
#if ( __LEDA__ < 362 )
w.state = 1;
#else
w.set_state( 1);
#endif // __LEDA__ < ...
leda_point first, second;
leda_drawing_mode save = w.set_mode(leda_xor_mode);
if ( !( w.read( first))) { w.set_mode( save); return w; }
int save_but[8];
w.std_buttons(save_but);
key = w.read_mouse_rect( first.xcoord(), first.ycoord(), x, y);
if ( key == MOUSE_BUTTON(3))
{
w.set_buttons( save_but);
w.set_mode( save);
#if ( __LEDA__ < 362 )
w.state = 0;
#else
w.set_state( 0);
#endif // __LEDA__ < ...
return w;
}
r = Iso_rectangle_2<R>(Point_2<R>( RT(first.xcoord()),
RT(first.ycoord())),
Point_2<R>( RT(x), RT(y)));
w.set_mode( save);
w.set_buttons( save_but);
return w;
}
#endif // CGAL_POSTSCRIPT_FILE_STREAM_ISO_RECTANGLE_2
#endif // CGAL_ISO_RECTANGLE_2_H
#ifdef CGAL_BBOX_2_H
#ifndef CGAL_POSTSCRIPT_FILE_STREAM_BBOX_2
#define CGAL_POSTSCRIPT_FILE_STREAM_BBOX_2
inline
Postscript_file_stream&
operator<<(Postscript_file_stream& w, const Bbox_2& b)
{
#if (__LEDA__ >= 400)
leda_line_style style = w.set_line_style(leda_dotted);
#else
line_style style = w.set_line_style(leda_dotted);
#endif // 400
double xmin = b.xmin(),
ymin = b.ymin(),
xmax = b.xmax(),
ymax = b.ymax();
w.draw_segment(xmin, ymin, xmax, ymin);
w.draw_segment(xmax, ymin, xmax, ymax);
w.draw_segment(xmax, ymax, xmin, ymax);
w.draw_segment(xmin, ymax, xmin, ymin);
w.set_line_style(style);
return w;
}
#endif // CGAL_POSTSCRIPT_FILE_STREAM_BBOX_2
#endif // CGAL_BBOX_2_H
CGAL_END_NAMESPACE
|