Panda3D
|
00001 // Filename: pnmPainter.h 00002 // Created by: drose (02Feb07) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef PNMPAINTER_H 00016 #define PNMPAINTER_H 00017 00018 #include "pandabase.h" 00019 00020 class PNMImage; 00021 00022 //////////////////////////////////////////////////////////////////// 00023 // Class : PNMPainter 00024 // Description : This class provides a number of convenient methods 00025 // for painting drawings directly into a PNMImage. 00026 // 00027 // It stores a pointer to the PNMImage you pass it, but 00028 // it does not take ownership of the object; you are 00029 // responsible for ensuring that the PNMImage does not 00030 // destruct during the lifetime of the PNMPainter 00031 // object. 00032 //////////////////////////////////////////////////////////////////// 00033 class EXPCL_PANDA_PNMIMAGE PNMPainter { 00034 PUBLISHED: 00035 PNMPainter(PNMImage &image, int xo = 0, int yo = 0); 00036 INLINE ~PNMPainter(); 00037 00038 INLINE void set_pen(PNMBrush *pen); 00039 INLINE PNMBrush *get_pen() const; 00040 INLINE void set_fill(PNMBrush *fill); 00041 INLINE PNMBrush *get_fill() const; 00042 00043 INLINE void draw_point(double x, double y); 00044 void draw_line(double xa, double ya, double xb, double yb); 00045 void draw_rectangle(double xa, double ya, double xb, double yb); 00046 00047 private: 00048 INLINE void draw_hline_point(int x, double xa, double ya, 00049 double xd, double yd, 00050 double pixel_scale); 00051 INLINE void draw_vline_point(int y, double xa, double ya, 00052 double xd, double yd, 00053 double pixel_scale); 00054 00055 private: 00056 PNMImage &_image; 00057 int _xo, _yo; 00058 00059 PT(PNMBrush) _pen; 00060 PT(PNMBrush) _fill; 00061 }; 00062 00063 #include "pnmPainter.I" 00064 00065 #endif