Fixed text file permissions
[snark14.git] / tools / Display / sd_line_t.cpp
1 /** @file sd_line_t.cpp
2     @package snark14Display
3     @author Bruno M. Carvalho and Deniz Sarioz
4     licensed under (open-source) QPL v1.0
5     which accompanies this distribution in the file QPL
6 */
7
8 /** Deniz, July 2004
9     classes relating to each 'line' to be plotted
10     includes conversion mechanisms from real coords to window coords
11     handles 'actual' plotting too
12 */
13
14 #include "sd_line_t.hpp"
15 #include <qpainter.h>
16
17
18 namespace sd_line_t {
19   // number of pixels left blank as buffer outside plot area. 
20   // X is both left and right, Y is both top and bot.
21   //  MUST be natural number and not too big.
22   int WIDTH  = 980;
23   int HEIGHT = 720;
24   int XWINPAD = 90;
25   //  int XWINPAD = 0;
26   int YWINPAD = 110;
27   //  int YWINPAD = 0;
28   int YAXISNOTCHLABELOFFSET = 38; // from y axis
29   int YAXISLABELOFFSET = 58;
30 //    // in addition to the padding above...
31   double Y_HALF_FUDGE_FACTOR = 0.03; // like 0.03
32 //    // fudge real Y-axis extrema on each side by this much.
33 //    // MUST be nonnegative.  can set to 0 if you don't want it to.
34   int X_HALF_FUDGE_INCREMENT = 1; // like 1
35 //    // how much to fudge the real x-axis on both side: MUST be natural number
36   
37   void drawBoundary(QPainter& P) { // boundary JUST OUTSIDE the actual paint area
38     // if PADDINGs are 0, should seem to do nothing
39     int LEFT=  sd_line_t::XWINPAD - 1;
40     int RIGHT= sd_line_t::WIDTH - sd_line_t::XWINPAD;
41     int TOP=   sd_line_t::YWINPAD - 1;
42     int BOT=   sd_line_t::HEIGHT - sd_line_t::YWINPAD;
43     P.setPen( Qt::black );
44     P.drawLine(LEFT , TOP, RIGHT, TOP); // (x1,y1,x2,y2)  >>inclusive<<
45     P.drawLine(RIGHT, TOP, RIGHT, BOT);
46     P.drawLine(RIGHT, BOT, LEFT , BOT);
47     P.drawLine(LEFT , BOT, LEFT , TOP);
48   } // --drawBoundary() in namespace sd_line_t
49   
50   /** don't wanna define it in QPainter to respect Qt library *
51    * puts a big ugly smudge of paint at (cx, cy) without changing Pen */
52   void drawBigPoint(QPainter& P, int cx, int cy) {
53     int x, y;
54     for(x = cx-1; x <= cx+1; x++) {
55       for(y = cy-1; y <= cy+1; y++) {
56         P.drawPoint(x, y);
57       }
58     }
59     P.drawPoint(cx-2,cy-2);
60     P.drawPoint(cx-2,cy+2);
61     P.drawPoint(cx+2,cy-2);
62     P.drawPoint(cx+2,cy+2);
63     P.drawPoint(cx,cy-2);
64     P.drawPoint(cx,cy+2);
65     P.drawPoint(cx-2,cy);
66     P.drawPoint(cx+2,cy);
67   } // --drawBigPoint() in namespace sd_line_t
68
69 }; // -- namespace sd_line_t, for now