~ubuntu-branches/ubuntu/warty/xplanet/warty

« back to all changes in this revision

Viewing changes to libdisplay/DisplayBase.h

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2004-08-24 07:14:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040824071400-2dr4qnjbjmm8z3ia
Tags: 1.0.6-1ubuntu1
Build-depend: libtiff4-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/****************************************************************************
2
 
    Xplanet 0.94 - render an image of a planet into an X window
3
 
    Copyright (C) 2002 Hari Nair <hari@alumni.caltech.edu>
4
 
 
5
 
    This program is free software; you can redistribute it and/or modify
6
 
    it under the terms of the GNU General Public License as published by
7
 
    the Free Software Foundation; either version 2 of the License, or
8
 
    (at your option) any later version.
9
 
 
10
 
    This program is distributed in the hope that it will be useful,
11
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
    GNU General Public License for more details.
14
 
 
15
 
    You should have received a copy of the GNU General Public License
16
 
    along with this program; if not, write to the Free Software
17
 
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
 
****************************************************************************/
19
 
 
20
 
#ifndef DISPLAYBASE_H
21
 
#define DISPLAYBASE_H
22
 
 
23
 
#include <map>
24
 
#include <string>
25
 
using namespace std;
26
 
 
27
 
#include "checkfuncs.h"
28
 
 
29
 
#ifdef HAVE_LIBFREETYPE
30
 
#include <ft2build.h>
31
 
#include FT_FREETYPE_H
32
 
#endif
33
 
 
34
 
class Marker;
35
 
class ProjectionBase;
36
 
 
37
 
class DisplayBase
38
 
{
39
 
 public:
40
 
    static int getType();
41
 
 
42
 
    virtual ~DisplayBase();
43
 
 
44
 
    int getHeight();
45
 
    int getWidth();
46
 
 
47
 
// routines which must be defined in derived classes
48
 
    virtual const char *identifyMe() = 0;
49
 
    virtual void render(ProjectionBase *image) = 0;
50
 
 
51
 
// routines to be optionally overridden by derived classes
52
 
    virtual void initialize();
53
 
    virtual void drawMarker(Marker &m);
54
 
    virtual int getFontAscent();
55
 
    virtual int getFontDescent();
56
 
    virtual void getRGB(string color, unsigned char *RGB);
57
 
    virtual string getTempdir();
58
 
    virtual int getTextHeight(const string text);
59
 
    virtual int getTextWidth(const string text);
60
 
    virtual void setFont(string fontname);
61
 
    virtual void setFontSize(const int size);
62
 
 
63
 
 protected:
64
 
    int window_width, window_height;
65
 
    int window_area;
66
 
 
67
 
    unsigned char *png_alpha;
68
 
    unsigned char *rgb_data;
69
 
    unsigned char bg[3]; // background color for annotation
70
 
    unsigned char fg[3]; // foreground color for annotation
71
 
 
72
 
    void createLabel();
73
 
    void doAnnotation(ProjectionBase *image);
74
 
    void loadRGB();
75
 
    void setAlpha(unsigned char *c);
76
 
    void setImage(unsigned char *c);
77
 
 
78
 
// routines to be optionally overridden by derived classes
79
 
    virtual int fontExists(string &filename);
80
 
    virtual void drawCircle(const int x, const int y, const int r);
81
 
    virtual void drawImage(Marker &m);
82
 
    virtual void drawLabel(const string body_label, const string date_label,
83
 
                           const string illum_label, const string obs_label,
84
 
                           const string rotate_label, const string sun_label);
85
 
    virtual void drawOutlinedString(const int x, const int y, 
86
 
                                    const string text);
87
 
    virtual void printError(const string error);
88
 
    virtual void setColor(string color);
89
 
    virtual void setForeground(unsigned char *color);
90
 
    virtual void setPixel(const int x, const int y);
91
 
    virtual void setPixel(const int x, const int y, double opacity);
92
 
    virtual int getTextHeight();
93
 
 
94
 
 private:
95
 
#ifdef HAVE_LIBFREETYPE
96
 
    FT_Library library;
97
 
    FT_Face face; 
98
 
    int fontsize;
99
 
#endif
100
 
 
101
 
    unsigned char current_color[3];
102
 
    map<string, unsigned int> RGBColors;
103
 
 
104
 
    void drawText(const int x, const int y, const string text);
105
 
};
106
 
 
107
 
#endif