File: screen.h

package info (click to toggle)
epix 1.2.10-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 3,160 kB
  • sloc: cpp: 16,442; sh: 5,058; makefile: 198
file content (175 lines) | stat: -rw-r--r-- 4,905 bytes parent folder | download | duplicates (4)
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
/* 
 * screen.h -- ePiX::screen class
 *
 * This file is part of ePiX, a C++ library for creating high-quality 
 * figures in LaTeX 
 *
 * Version 1.1.18
 * Last Change: September 15, 2007
 */

/* 
 * Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
 * Andrew D. Hwang <rot 13 nujnat at zngupf dot ubylpebff dot rqh>
 * Department of Mathematics and Computer Science
 * College of the Holy Cross
 * Worcester, MA, 01610-2395, USA
 */

/*
 * ePiX is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * ePiX is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
 * License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with ePiX; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

/*
 * This file defines the screen class interface, a Cartesian rectangle
 * into which objects are drawn. Object-creating commands add to the
 * the "global" screen the_picture(). Users may create and activate
 * additional screens, then import their content to the_picture(). 
 *
 * Constructor:
 *   screen(P(a,c), P(b,d));  // corners of bounding box
 *
 * Markup functions:
 *   crop();         // remove elements outside bounding box
 *   crop_to(mask);  // or specified mask
 *   paste(screen);  // overlay contents of screen
 *   paste(screen, P(a,c), P(b,d));  // or inset into specified rectangle
 *
 * Decorations:
 *   border(Color, "1pt"); // set border color/width
 *   backing(Color);       // and backing color
 *
 * This file wraps the implementation, which is hidden from the user.
 */
#ifndef EPIX_SCREEN
#define EPIX_SCREEN

#include <string>

#include "triples.h"

namespace ePiX {

  class Color;
  class affine;
  class screen_data;
  class P;

  // global function
  void write(const std::string&);

  class screen {
    // There's no user-visible form for screen contents, so
    // we give these classes access to our implementation.
    friend class arrow_data;
    friend class label_data;
    friend class legend;
    friend class path_data;
    friend class picture_data;
    friend void write(const std::string&);

  public:
    screen();
    screen(const P&, const P&);

    screen(const screen&);
    screen& operator= (const screen&);
    ~screen();

    // Set mask; one named function for each type of screen_mask
    screen& crop_mask_rectangle(const P&, const P&);
    screen& crop_mask_ellipse(const P&, const P&);
    screen& crop_mask_diamond(const P&, const P&);

    screen& crop_mask_rectangle();
    screen& crop_mask_ellipse();
    screen& crop_mask_diamond();

    // return selected region
    screen extract(const P&, const P&) const;
    screen extract_diamond(const P&, const P&) const;
    screen extract_ellipse(const P&, const P&) const;

    // set flag only
    screen& set_crop(bool arg=true);

    // crop contents to current mask
    screen& crop();

    // inset and import
    screen& paste(const screen& child, const P& inset_sw, const P& inset_ne);
    screen& paste(const screen& child);

    screen& clear();

    // border(Color, length)?
    screen& border(const Color&, double);
    screen& border(const Color&, const std::string&);
    screen& backing(const Color&);

    screen& border();
    screen& backing();

    //// pass-through functions ////
    // affine operations on contents (not border, backing)
    screen&  apply(const affine& f);

    // convenience operators for single affine ops
    screen&   shift(const P& arg);

    // rotate by theta about ctr
    screen&  rotate(double theta, const P& ctr = P(0,0));

    // reflect in angle-theta line through ctr
    screen& reflect(double theta, const P& ctr = P(0,0));

    // scale coord direction(s) fixing ctr
    screen& h_scale(double, const P& ctr=P(0,0));
    screen& v_scale(double, const P& ctr=P(0,0));
    screen&   scale(double, const P& ctr=P(0,0));

    // shear, fixing ctr, e.g. h_shear(sc) : (x,y) -> (x+sc*y, y)
    screen&  h_shear(double sc, const P& ctr=P(0,0));
    screen&  v_shear(double sc, const P& ctr=P(0,0));

    P tr() const;
    P tl() const;
    P bl() const;
    P br() const;

    P  t() const;
    P  b() const;
    P  l() const;
    P  r() const;
    P  c() const;

    double h_min()  const;
    double h_max()  const;
    double h_size() const;
    double h_avg()  const;

    double v_min()  const;
    double v_max()  const;
    double v_size() const;
    double v_avg()  const;

  private:
    screen_data* m_screen;

  }; // end of class screen

} // end of namespace

#endif /* EPIX_SCREEN */