18 #ifndef _gdrawingsurface_h 19 #define _gdrawingsurface_h 40 virtual void clear() = 0;
69 virtual void draw(
GObject* gobj,
double x,
double y);
81 virtual void draw(
GObject& gobj,
double x,
double y);
87 virtual void draw(QPainter* painter) = 0;
94 virtual void drawArc(
double x,
double y,
double width,
double height,
double start,
double sweep);
103 virtual void drawImage(
const string& filename,
double x = 0,
double y = 0);
117 virtual void drawLine(
double x0,
double y0,
double x1,
double y1);
131 virtual void drawOval(
double x,
double y,
double width,
double height);
157 virtual void drawPixel(
double x,
double y);
163 virtual void drawPixel(
double x,
double y,
int color);
169 virtual void drawPixel(
double x,
double y,
const string& color);
176 virtual void drawPolygon(std::initializer_list<double> coords);
183 virtual void drawPolygon(std::initializer_list<GPoint> points);
197 virtual void drawRect(
double x,
double y,
double width,
double height);
204 virtual void drawString(
const string& text,
double x,
double y);
211 virtual void fillArc(
double x,
double y,
double width,
double height,
double start,
double sweep);
227 virtual void fillOval(
double x,
double y,
double width,
double height);
234 virtual void fillPolygon(std::initializer_list<double> coords);
241 virtual void fillPolygon(std::initializer_list<GPoint> coords);
255 virtual void fillRect(
double x,
double y,
double width,
double height);
261 virtual int getARGB(
double x,
double y)
const;
314 virtual string
getFont()
const;
362 virtual int getPixel(
double x,
double y)
const = 0;
385 virtual std::vector<std::vector<int>>
getPixels()
const = 0;
403 virtual std::vector<std::vector<int>>
getPixelsARGB()
const = 0;
438 virtual int getRGB(
double x,
double y)
const;
489 virtual void repaintRegion(
int x,
int y,
int width,
int height) = 0;
540 virtual void setColor(
const string& color);
561 virtual void setFont(
const QFont& font);
568 virtual void setFont(
const string& font);
615 virtual void setPixel(
double x,
double y,
int rgb) = 0;
629 virtual void setPixel(
double x,
double y,
int r,
int g,
int b);
643 virtual void setPixel(
double x,
double y,
const string& color);
656 virtual void setPixelARGB(
double x,
double y,
int argb) = 0;
669 virtual void setPixelARGB(
double x,
double y,
int a,
int r,
int g,
int b);
679 virtual void setPixels(
int** pixels,
int width = -1,
int height = -1) = 0;
689 virtual void setPixels(
const std::vector<std::vector<int>>& pixels) = 0;
699 virtual void setPixelsARGB(
int** pixelsARGB,
int width = -1,
int height = -1) = 0;
709 virtual void setPixelsARGB(
const std::vector<std::vector<int>>& pixelsARGB) = 0;
734 virtual void setRGB(
double x,
double y,
int rgb);
748 virtual void setRGB(
double x,
double y,
int r,
int g,
int b);
762 virtual void setRGB(
double x,
double y,
const string& color);
783 void checkBounds(
const string& member,
double x,
double y,
double width,
double height)
const;
788 void checkColor(
const string& member,
int rgb)
const;
793 void checkSize(
const string& member,
double width,
double height)
const;
828 void clear()
override;
829 void draw(
GObject* gobj)
override;
830 void draw(
GObject* gobj,
double x,
double y)
override;
831 void draw(
GObject& gobj)
override;
832 void draw(
GObject& gobj,
double x,
double y)
override;
833 void draw(QPainter* painter)
override;
834 int getPixel(
double x,
double y)
const override;
835 int getPixelARGB(
double x,
double y)
const override;
836 std::vector<std::vector<int>> getPixels()
const override;
837 int** getPixelsArray()
const override;
838 std::vector<std::vector<int>> getPixelsARGB()
const override;
839 int** getPixelsArrayARGB()
const override;
840 bool isAutoRepaint()
const override;
842 void repaintRegion(
int x,
int y,
int width,
int height)
override;
843 void setAutoRepaint(
bool autoRepaint)
override;
844 void setBackground(
int color)
override;
845 void setBackground(
const string& color)
override;
846 void setColor(
int color)
override;
847 void setColor(
const string& color)
override;
848 void setFillColor(
int color)
override;
849 void setFillColor(
const string& color)
override;
850 void setFont(
const QFont& font)
override;
851 void setFont(
const string& font)
override;
852 void setLineWidth(
double lineWidth)
override;
853 void setPixel(
double x,
double y,
int rgb)
override;
854 void setPixel(
double x,
double y,
int r,
int g,
int b)
override;
855 void setPixelARGB(
double x,
double y,
int argb)
override;
856 void setPixelARGB(
double x,
double y,
int a,
int r,
int g,
int b)
override;
857 void setPixels(
int** pixels,
int width = -1,
int height = -1)
override;
858 void setPixels(
const std::vector<std::vector<int>>& pixels)
override;
859 void setPixelsARGB(
int** pixelsARGB,
int width = -1,
int height = -1)
override;
860 void setPixelsARGB(
const std::vector<std::vector<int>>& pixelsARGB)
override;
861 void setRepaintImmediately(
bool repaintImmediately)
override;
864 virtual void ensureForwardTarget() = 0;
865 virtual void ensureForwardTargetConstHack()
const;
string _font
Definition: gdrawingsurface.h:772
This struct contains real-valued x, y, width, and height fields.
Definition: gtypes.h:293
virtual int getForegroundInt() const
Returns the current foreground outline color of the interactor as an RGB integer. ...
Definition: gdrawingsurface.cpp:287
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:315
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...
virtual string getFillColor() const
Returns the current fill color of the interactor as a string.
Definition: gdrawingsurface.cpp:259
virtual double getLineWidth() const
Returns the thickness used when drawing outlines of shapes and lines.
Definition: gdrawingsurface.cpp:299
virtual void conditionalRepaint()
Repaints the interactor only if its contents have changed.
Definition: gdrawingsurface.cpp:66
virtual int getFillColorInt() const
Returns the current fill color of the interactor as an RGB integer.
Definition: gdrawingsurface.cpp:267
string _fillColor
Definition: gdrawingsurface.h:771
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:109
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:311
virtual string getFont() const
Returns the current text font of the interactor as a font string.
Definition: gdrawingsurface.cpp:275
virtual void repaint()=0
Instructs the interactor to redraw itself on the screen.
bool _autoRepaint
Definition: gdrawingsurface.h:778
string _backgroundColor
Definition: gdrawingsurface.h:769
GDrawingSurface * _forwardTarget
Definition: gdrawingsurface.h:768
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 ~GDrawingSurface()
Definition: gdrawingsurface.cpp:39
LineStyle
Styles that can be used for the outline around various shapes.
Definition: gobjects.h:72
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:213
GDrawingSurface is an abstract superclass for types that allow drawing shapes and pixels onto themsel...
Definition: gdrawingsurface.h:35
virtual bool isAutoRepaint() const
Returns true if the interactor should repaint itself automatically whenever any change is made to its...
Definition: gdrawingsurface.cpp:337
virtual string getBackground() const
Returns the current background color of the interactor as a string.
Definition: gdrawingsurface.cpp:227
void repaint()
Issues a request to update the most recently created graphics window.
Definition: gwindow.cpp:1360
This class is the common superclass of all graphical objects that can be displayed on a graphical win...
Definition: gobjects.h:66
virtual int ** getPixelsArray() const =0
Returns all pixels of the surface as a heap-allocated 2D array, where the first index represents the ...
int _colorInt
Definition: gdrawingsurface.h:774
virtual void setLineWidth(double lineWidth)
Sets the thickness used when drawing outlines of shapes and lines.
Definition: gdrawingsurface.cpp:460
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:307
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:185
void checkColor(string member, int rgb) const
Throws an error if the given rgb value is not a valid color.
Definition: gdrawingsurface.cpp:47
virtual bool isRepaintImmediately() const
Returns true if the interactor should repaint itself automatically whenever any change is made to its...
Definition: gdrawingsurface.cpp:345
virtual void setAutoRepaint(bool autoRepaint)
Sets whether the interactor should repaint itself automatically whenever any change is made to its gr...
Definition: gdrawingsurface.cpp:354
virtual void setColor(int color)
Sets the current foreground outline color of the interactor as as RGB integer.
Definition: gdrawingsurface.cpp:380
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:134
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:124
GDrawingSurface()
Definition: gdrawingsurface.cpp:24
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:169
virtual std::vector< std::vector< int > > getPixels() const =0
Returns all pixels of the surface as a nested STL vector of vectors, where the first index represents...
virtual void draw(GObject *gobj)=0
Draws the given graphical object onto the background pixel layer of this interactor.
virtual int getColorInt() const
Returns the current foreground outline color of the interactor as an RGB integer. ...
Definition: gdrawingsurface.cpp:251
virtual int ** getPixelsArrayARGB() const =0
Returns all pixels of the background layer of the surface as a heap-allocated 2D array, where the first index represents the x value and the second index represents the y value.
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:114
virtual void setPixelsARGB(int **pixelsARGB, int width=-1, int height=-1)=0
Sets the color of the all pixels in the background layer of the interactor to the given ARGB values...
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:76
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:484
string _color
Definition: gdrawingsurface.h:770
virtual GObject::LineStyle getLineStyle() const
Returns the current line style which will be used to draw outlines of shapes and lines.
Definition: gdrawingsurface.cpp:291
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:201
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...
virtual void clear()=0
Erases any pixel data from the drawing surface.
virtual void setForeground(int color)
Sets the current foreground outline color of the interactor as an RGB integer.
Definition: gdrawingsurface.cpp:444
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:191
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:43
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:55
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:145
virtual string getColor() const
Returns the current foreground outline color of the interactor as a string.
Definition: gdrawingsurface.cpp:243
GObject::LineStyle _lineStyle
Definition: gdrawingsurface.h:776
virtual void setBackground(int color)
Sets the current background color of the interactor as an RGB integer.
Definition: gdrawingsurface.cpp:362
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:179
double _lineWidth
Definition: gdrawingsurface.h:777
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:223
virtual string getForeground() const
Returns the current foreground outline color of the interactor as a string.
Definition: gdrawingsurface.cpp:283
virtual void setRepaintImmediately(bool autoRepaint)
Sets whether the interactor should repaint itself automatically whenever any change is made to its gr...
Definition: gdrawingsurface.cpp:480
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 setLineStyle(GObject::LineStyle lineStyle)
Sets the current line style which will be used to draw outlines of shapes and lines.
Definition: gdrawingsurface.cpp:452
int _backgroundColorInt
Definition: gdrawingsurface.h:773
virtual std::vector< std::vector< int > > getPixelsARGB() const =0
Returns all pixels of the background layer of the surface as a nested STL vector of vectors...
This struct contains real-valued x and y fields.
Definition: gtypes.h:202
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:103
int _fillColorInt
Definition: gdrawingsurface.h:775
virtual void initializeGObject(GObject &obj, bool filled=false)
Initializes a new graphical object to be drawn.
Definition: gdrawingsurface.cpp:319
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 setPixels(int **pixels, int width=-1, int height=-1)=0
Sets the color of the all pixels in the background layer of the interactor to the given RGB values...
virtual int getBackgroundInt() const
Returns the current background color of the interactor as an RGB integer.
Definition: gdrawingsurface.cpp:235
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:157
virtual void setFillColor(int color)
Sets the current fill color of the interactor as an RGB integer.
Definition: gdrawingsurface.cpp:410