15 #ifndef _gdrawingsurface_h 16 #define _gdrawingsurface_h 36 virtual void clear() = 0;
65 virtual void draw(
GObject* gobj,
double x,
double y);
77 virtual void draw(
GObject& gobj,
double x,
double y);
83 virtual void draw(QPainter* painter) = 0;
90 virtual void drawArc(
double x,
double y,
double width,
double height,
double start,
double sweep);
99 virtual void drawImage(
const string& filename,
double x = 0,
double y = 0);
113 virtual void drawLine(
double x0,
double y0,
double x1,
double y1);
127 virtual void drawOval(
double x,
double y,
double width,
double height);
153 virtual void drawPixel(
double x,
double y);
159 virtual void drawPixel(
double x,
double y,
int color);
165 virtual void drawPixel(
double x,
double y,
const string& color);
172 virtual void drawPolygon(std::initializer_list<double> coords);
179 virtual void drawPolygon(std::initializer_list<GPoint> points);
193 virtual void drawRect(
double x,
double y,
double width,
double height);
200 virtual void drawString(
const string& text,
double x,
double y);
207 virtual void fillArc(
double x,
double y,
double width,
double height,
double start,
double sweep);
223 virtual void fillOval(
double x,
double y,
double width,
double height);
230 virtual void fillPolygon(std::initializer_list<double> coords);
237 virtual void fillPolygon(std::initializer_list<GPoint> coords);
251 virtual void fillRect(
double x,
double y,
double width,
double height);
257 virtual int getARGB(
double x,
double y)
const;
310 virtual string
getFont()
const;
358 virtual int getPixel(
double x,
double y)
const = 0;
413 virtual int getRGB(
double x,
double y)
const;
464 virtual void repaintRegion(
int x,
int y,
int width,
int height) = 0;
515 virtual void setColor(
const string& color);
536 virtual void setFont(
const QFont& font);
543 virtual void setFont(
const string& font);
590 virtual void setPixel(
double x,
double y,
int rgb) = 0;
604 virtual void setPixel(
double x,
double y,
int r,
int g,
int b);
618 virtual void setPixel(
double x,
double y,
const string& color);
631 virtual void setPixelARGB(
double x,
double y,
int argb) = 0;
644 virtual void setPixelARGB(
double x,
double y,
int a,
int r,
int g,
int b);
653 virtual void setPixels(
const Grid<int>& pixels) = 0;
687 virtual void setRGB(
double x,
double y,
int rgb);
701 virtual void setRGB(
double x,
double y,
int r,
int g,
int b);
715 virtual void setRGB(
double x,
double y,
const string& color);
736 void checkBounds(
const string& member,
double x,
double y,
double width,
double height)
const;
741 void checkColor(
const string& member,
int rgb)
const;
746 void checkSize(
const string& member,
double width,
double height)
const;
781 void clear()
override;
783 void draw(
GObject* gobj,
double x,
double y)
override;
785 void draw(
GObject& gobj,
double x,
double y)
override;
786 void draw(QPainter* painter)
override;
787 int getPixel(
double x,
double y)
const override;
793 void repaintRegion(
int x,
int y,
int width,
int height)
override;
798 void setColor(
const string& color)
override;
801 void setFont(
const QFont& font)
override;
802 void setFont(
const string& font)
override;
804 void setPixel(
double x,
double y,
int rgb)
override;
805 void setPixel(
double x,
double y,
int r,
int g,
int b)
override;
806 void setPixelARGB(
double x,
double y,
int argb)
override;
807 void setPixelARGB(
double x,
double y,
int a,
int r,
int g,
int b)
override;
808 void setPixels(
const Grid<int>& pixels)
override;
813 virtual void ensureForwardTarget() = 0;
814 virtual void ensureForwardTargetConstHack()
const;
virtual Grid< int > getPixels() const =0
Returns all pixels of the surface as a Grid, where rows represent y values and columns represent x va...
virtual void conditionalRepaintRegion(int x, int y, int width, int height)
Repaints the given region of the interactor only if its contents have changed.
Definition: gdrawingsurface.cpp:71
virtual void setColor(int color)
Sets the current foreground outline color of the interactor as as RGB integer.
Definition: gdrawingsurface.cpp:375
virtual void initializeGObject(GObject &obj, bool filled=false)
Initializes a new graphical object to be drawn.
Definition: gdrawingsurface.cpp:314
virtual int getFillColorInt() const
Returns the current fill color of the interactor as an RGB integer.
Definition: gdrawingsurface.cpp:262
virtual void drawImage(string filename, double x=0, double y=0)
Draws an image loaded from the given file name onto the background pixel layer of this interactor at ...
Definition: gdrawingsurface.cpp:104
void checkSize(string member, double width, double height) const
Throws an error if the given width/height values are out of bounds.
Definition: gdrawingsurface.cpp:50
virtual void setFillColor(int color)
Sets the current fill color of the interactor as an RGB integer.
Definition: gdrawingsurface.cpp:405
virtual string getRGBString(double x, double y) const
Returns the color of the pixel at the given x/y coordinates of the background layer of the interactor...
Definition: gdrawingsurface.cpp:310
virtual int getColorInt() const
Returns the current foreground outline color of the interactor as an RGB integer. ...
Definition: gdrawingsurface.cpp:246
virtual string getBackground() const
Returns the current background color of the interactor as a string.
Definition: gdrawingsurface.cpp:222
virtual string getForeground() const
Returns the current foreground outline color of the interactor as a string.
Definition: gdrawingsurface.cpp:278
string _font
Definition: gdrawingsurface.h:725
int _fillColorInt
Definition: gdrawingsurface.h:728
virtual string getColor() const
Returns the current foreground outline color of the interactor as a string.
Definition: gdrawingsurface.cpp:238
virtual int getPixelARGB(double x, double y) const =0
Returns the color of the pixel at the given x/y coordinates of the background layer of the interactor...
GDrawingSurface is an abstract superclass for types that allow drawing shapes and pixels onto themsel...
Definition: gdrawingsurface.h:31
virtual void drawString(string text, double x, double y)
Draws a text string onto the background pixel layer of this interactor at the given x/y location in t...
Definition: gdrawingsurface.cpp:174
virtual void setLineStyle(GObject::LineStyle lineStyle)
Sets the current line style which will be used to draw outlines of shapes and lines.
Definition: gdrawingsurface.cpp:447
virtual string getFillColor() const
Returns the current fill color of the interactor as a string.
Definition: gdrawingsurface.cpp:254
virtual GPoint drawPolarLine(const GPoint &p0, double r, double theta)
Draws a line using polar coordinates onto the background pixel layer of this interactor in the curren...
Definition: gdrawingsurface.cpp:129
string _fillColor
Definition: gdrawingsurface.h:724
virtual void setForeground(int color)
Sets the current foreground outline color of the interactor as an RGB integer.
Definition: gdrawingsurface.cpp:439
virtual void setRepaintImmediately(bool autoRepaint)
Sets whether the interactor should repaint itself automatically whenever any change is made to its gr...
Definition: gdrawingsurface.cpp:475
virtual void fillOval(const GRectangle &bounds)
Draws a filled oval with the given bounding box onto the background pixel layer of this interactor at...
Definition: gdrawingsurface.cpp:186
virtual int getBackgroundInt() const
Returns the current background color of the interactor as an RGB integer.
Definition: gdrawingsurface.cpp:230
virtual void drawRect(const GRectangle &bounds)
Draws an unfilled rectangle of the given dimensions onto the background pixel layer of this interacto...
Definition: gdrawingsurface.cpp:164
void checkBounds(string member, double x, double y, double width, double height) const
Throws an error if the given x/y values are out of bounds.
Definition: gdrawingsurface.cpp:38
virtual Grid< int > getPixelsARGB() const =0
Returns all pixels of the background layer of the surface as a Grid, where rows represent y values an...
int _backgroundColorInt
Definition: gdrawingsurface.h:726
virtual string getPixelString(double x, double y) const
Returns the color of the pixel at the given x/y coordinates of the image as a string such as "#ff00cc...
Definition: gdrawingsurface.cpp:302
virtual void setBackground(int color)
Sets the current background color of the interactor as an RGB integer.
Definition: gdrawingsurface.cpp:357
virtual void repaintRegion(int x, int y, int width, int height)=0
Instructs the interactor to repaint the given region of pixel data.
virtual void drawPolygon(std::initializer_list< double > coords)
Draws an unfilled polygon containing the given points onto the background pixel layer of this interac...
Definition: gdrawingsurface.cpp:152
virtual void drawArc(double x, double y, double width, double height, double start, double sweep)
Draws an unfilled arc with the given attributes onto the background pixel layer of this interactor in...
Definition: gdrawingsurface.cpp:98
GObject::LineStyle _lineStyle
Definition: gdrawingsurface.h:729
virtual string getFont() const
Returns the current text font of the interactor as a font string.
Definition: gdrawingsurface.cpp:270
int _colorInt
Definition: gdrawingsurface.h:727
virtual void setAutoRepaint(bool autoRepaint)
Sets whether the interactor should repaint itself automatically whenever any change is made to its gr...
Definition: gdrawingsurface.cpp:349
string _color
Definition: gdrawingsurface.h:723
virtual void setRGB(double x, double y, int rgb)
Sets the color of the given x/y pixel in the background layer of the interactor to the given RGB valu...
Definition: gdrawingsurface.cpp:479
virtual int getARGB(double x, double y) const
Returns the pixel color data at the given x/y location, retaining alpha-channel transparency in the t...
Definition: gdrawingsurface.cpp:218
virtual void fillRect(const GRectangle &bounds)
Draws a filled rectangle of the given dimensions onto the background pixel layer of this interactor i...
Definition: gdrawingsurface.cpp:208
GDrawingSurface * _forwardTarget
Definition: gdrawingsurface.h:721
virtual int getForegroundInt() const
Returns the current foreground outline color of the interactor as an RGB integer. ...
Definition: gdrawingsurface.cpp:282
virtual GObject::LineStyle getLineStyle() const
Returns the current line style which will be used to draw outlines of shapes and lines.
Definition: gdrawingsurface.cpp:286
This class is the common superclass of all graphical objects that can be displayed on a graphical win...
Definition: gobjects.h:62
void checkColor(string member, int rgb) const
Throws an error if the given rgb value is not a valid color.
Definition: gdrawingsurface.cpp:42
double _lineWidth
Definition: gdrawingsurface.h:730
virtual void setPixelARGB(double x, double y, int argb)=0
Sets the color of the given x/y pixel in the background layer of the interactor to the given ARGB val...
LineStyle
Styles that can be used for the outline around various shapes.
Definition: gobjects.h:68
virtual void setLineWidth(double lineWidth)
Sets the thickness used when drawing outlines of shapes and lines.
Definition: gdrawingsurface.cpp:455
virtual void drawPixel(double x, double y)
Colors the given x/y pixel of the background layer of this interactor using the interactor's current ...
Definition: gdrawingsurface.cpp:140
virtual bool isAutoRepaint() const
Returns true if the interactor should repaint itself automatically whenever any change is made to its...
Definition: gdrawingsurface.cpp:332
virtual int getRGB(double x, double y) const
Returns the color of the pixel at the given x/y coordinates of the background layer of the interactor...
Definition: gdrawingsurface.cpp:306
GDrawingSurface()
Definition: gdrawingsurface.cpp:19
virtual int getPixel(double x, double y) const =0
Returns the color of the pixel at the given x/y coordinates of the background layer of the interactor...
virtual double getLineWidth() const
Returns the thickness used when drawing outlines of shapes and lines.
Definition: gdrawingsurface.cpp:294
virtual void fillPolygon(std::initializer_list< double > coords)
Draws a filled polygon containing the given points onto the background pixel layer of this interactor...
Definition: gdrawingsurface.cpp:196
virtual void fillArc(double x, double y, double width, double height, double start, double sweep)
Draws a filled arc with the given attributes onto the background pixel layer of this interactor in th...
Definition: gdrawingsurface.cpp:180
virtual bool isRepaintImmediately() const
Returns true if the interactor should repaint itself automatically whenever any change is made to its...
Definition: gdrawingsurface.cpp:340
virtual void setPixelsARGB(const Grid< int > &pixelsARGB)=0
Sets the color of the all pixels in the background layer of the interactor to the given ARGB values...
bool _autoRepaint
Definition: gdrawingsurface.h:731
This struct contains real-valued x, y, width, and height fields.
Definition: gtypes.h:289
virtual ~GDrawingSurface()
Definition: gdrawingsurface.cpp:34
virtual void setPixels(const Grid< int > &pixels)=0
Sets the color of the all pixels in the background layer of the interactor to the given RGB values...
virtual void drawLine(const GPoint &p0, const GPoint &p1)
Draws a line between the given two points onto the background pixel layer of this interactor at the g...
Definition: gdrawingsurface.cpp:109
virtual void drawOval(const GRectangle &bounds)
Draws an unfilled oval with the given bounding box onto the background pixel layer of this interactor...
Definition: gdrawingsurface.cpp:119
virtual void conditionalRepaint()
Repaints the interactor only if its contents have changed.
Definition: gdrawingsurface.cpp:61
virtual void draw(GObject *gobj)=0
Draws the given graphical object onto the background pixel layer of this interactor.
This struct contains real-valued x and y fields.
Definition: gtypes.h:198
string _backgroundColor
Definition: gdrawingsurface.h:722
virtual void repaint()=0
Instructs the interactor to redraw itself on the screen.
virtual void setPixel(double x, double y, int rgb)=0
Sets the color of the given x/y pixel in the background layer of the interactor to the given RGB valu...
virtual void clear()=0
Erases any pixel data from the drawing surface.