SGL
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
GOval Class Reference

This graphical object subclass represents an oval inscribed in a rectangular box. More...

#include "gobjects.h"

Inheritance diagram for GOval:
GObject

Public Types

enum  LineStyle { LINE_NONE, LINE_SOLID, LINE_DASH, LINE_DOT, LINE_DASH_DOT, LINE_DASH_DOT_DOT }
 Styles that can be used for the outline around various shapes. More...
 

Public Member Functions

 GOval(double x=0, double y=0, double width=0, double height=0)
 Constructs a new oval inscribed in the specified rectangle. More...
 
bool contains(const GPoint &pt) const
 Returns true if the specified point is inside the object. More...
 
bool contains(double x, double y) const override
 Returns true if the specified point is inside the object. More...
 
GPoint getBottomRightLocation() const
 Returns the x/y coordinates of the bottom/right corner of the object. More...
 
double getBottomY() const
 Returns the y-coordinate of the bottom of the object. More...
 
GRectangle getBounds() const
 Returns the bounding box of this object, which is defined to be the smallest rectangle that covers everything drawn by the figure. More...
 
GPoint getCenterLocation() const
 Returns the x/y-coordinates of the center of the object. More...
 
double getCenterX() const
 Returns the x-coordinate of the center of the object. More...
 
double getCenterY() const
 Returns the y-coordinate of the center of the object. More...
 
string getColor() const
 Returns the color used to display this object. More...
 
string getFillColor() const
 Returns the color used to display the filled region of this object. More...
 
double getHeight() const
 Returns the height of this object, which is the same as the height of its bounding box. More...
 
LineStyle getLineStyle() const
 Returns the object's style such as solid or dashed. More...
 
double getLineWidth() const
 Returns the width of the line used to draw this object. More...
 
GPoint getLocation() const
 Returns the location of the top-left corner of object. More...
 
double getOpacity() const
 Returns how opaque (non-transparent) this object will appear from 0.0 (completely transparent) to 1.0 (completely opaque, default). More...
 
GCompoundgetParent() const
 Returns a pointer to the GCompound that contains this object. More...
 
double getRightX() const
 Returns the x-coordinate of the right side of the object. More...
 
GDimension getSize() const
 Returns the size of the object as a GDimension. More...
 
string getType() const override
 Returns the type of the object as a string, such as "GOval" or "GRect". More...
 
double getWidth() const
 Returns the width of this object, which is equal to the width of the bounding box. More...
 
double getX() const
 Returns the leftmost x-coordinate of the object. More...
 
double getY() const
 Returns the topmost y-coordinate of the object. More...
 
bool isFilled() const
 Returns true if the object is filled with color. More...
 
bool isTransformed() const
 Returns true if this object has been transformed by calling methods such as rotate() or scale() on it. More...
 
bool isVisible() const
 Returns true if this object is visible on screen. More...
 
void move(double dx, double dy)
 Moves the object on the screen using the displacements dx and dy. More...
 
void repaint()
 Instructs the object to redraw itself on screen. More...
 
void resetTransform()
 Undoes any previous scale/rotate transformations on this object. More...
 
void rotate(double theta)
 Transforms the object by rotating it theta degrees counterclockwise around its origin. More...
 
void scale(double sf)
 Scales the object by the specified scale factor. More...
 
void scale(double sx, double sy)
 Scales the object by the specified scale factors. More...
 
void sendBackward()
 Moves this object one step toward the back in the z dimension. More...
 
void sendForward()
 Moves this object one step toward the front in the z dimension. More...
 
void sendToBack()
 Moves this object to the back of the display in the z dimension. More...
 
void sendToFront()
 Moves this object to the front of the display in the z dimension. More...
 
void setBottomRightLocation(double x, double y)
 Sets the location of the bottom/right of this object. More...
 
void setBottomRightLocation(const GPoint &pt)
 Sets the location of the bottom/right of this object. More...
 
void setBottomY(double y)
 Sets the location of the bottom y-coordinate of this object. More...
 
void setBounds(double x, double y, double width, double height)
 Changes the bounds of this object to the specified values. More...
 
void setBounds(const GRectangle &size)
 Changes the bounds of this object to the specified rectangle. More...
 
void setCenterLocation(double x, double y)
 Sets the location of the center of this object. More...
 
void setCenterLocation(const GPoint &pt)
 Sets the location of the center of this object. More...
 
void setCenterX(double x)
 Sets the x-coordinate of the center of this object. More...
 
void setCenterY(double y)
 Sets the y-coordinate of the center of this object. More...
 
void setColor(int r, int g, int b)
 Sets the color used to display this object. More...
 
void setColor(int rgb)
 Sets the color used to display this object. More...
 
void setColor(string color)
 Sets the color used to display this object. More...
 
void setFillColor(int r, int g, int b)
 Sets the color used to display the filled region of this object, if any. More...
 
void setFillColor(int rgb)
 Sets the color used to display the filled region of this object, if any. More...
 
void setFillColor(string color)
 Sets the color used to display the filled region of this object, if any. More...
 
void setFilled(bool flag)
 Sets the fill status for the object, where false is outlined and true is filled. More...
 
void setFont(const QFont &font)
 Changes the font used to display the object as specified by the given Qt font. More...
 
void setFont(string font)
 Changes the font used to display the object as specified by the string font, which has the following format: More...
 
void setForeground(int r, int g, int b)
 Sets the color used to display this object. More...
 
void setForeground(int rgb)
 Sets the color used to display this object. More...
 
void setForeground(string color)
 Sets the color used to display this object. More...
 
void setHeight(double height)
 Changes the height of this object to the specified height without changing its width. More...
 
void setLineStyle(LineStyle lineStyle)
 Sets the object's style such as solid (GObject::LINE_SOLID) or dashed (GObject::LINE_DASH). More...
 
void setLineWidth(double lineWidth)
 Sets the width of the line used to draw this object. More...
 
void setLocation(double x, double y)
 Sets the location of the top-left corner of this object to the specified coordinates. More...
 
void setLocation(const GPoint &pt)
 Sets the location of the top-left corner of this object to the specified point. More...
 
void setOpacity(double opacity)
 Sets how opaque (non-transparent) this object will appear from 0.0 (completely transparent) to 1.0 (completely opaque, default). More...
 
void setRightX(double x)
 Sets the location of the rightmost x-coordinate of this object. More...
 
void setSize(double width, double height)
 Changes the size of this object to the specified width and height. More...
 
void setSize(const GDimension &size)
 Changes the size of this object to the specified width and height. More...
 
void setVisible(bool flag)
 Sets whether this object is visible. More...
 
void setWidth(double width)
 Changes the width of this object to the specified width without changing its height. More...
 
void setX(double x)
 Sets the x location of the left side of this object. More...
 
void setY(double y)
 Sets the y location of the top of this object. More...
 
string toString() const
 Returns a printable representation of the object. More...
 

Static Public Member Functions

static bool isAntiAliasing()
 Returns whether we should globally anti-alias graphical objects. More...
 
static void setAntiAliasing(bool value)
 Globally turns on/off the anti-aliasing feature that smooths out the edges of onscreen shapes. More...
 

Protected Member Functions

string toStringExtra() const
 Returns a string containing any extra unique information about this type of graphical object. More...
 

Protected Attributes

QBrush _brush
 
string _color
 
int _colorInt
 
string _fillColor
 
int _fillColorInt
 
bool _fillFlag
 
string _font
 
double _height
 
LineStyle _lineStyle
 
double _lineWidth
 
double _opacity
 
GCompound_parent
 
QPen _pen
 
QTransform _transform
 
bool _transformed
 
bool _visible
 
double _width
 
double _x
 
double _y
 

Detailed Description

This graphical object subclass represents an oval inscribed in a rectangular box.

Member Enumeration Documentation

◆ LineStyle

enum LineStyle
inherited

Styles that can be used for the outline around various shapes.

Call setLineStyle on a GObject and pass one of these values.

Enumerator
LINE_NONE 
LINE_SOLID 
LINE_DASH 
LINE_DOT 
LINE_DASH_DOT 
LINE_DASH_DOT_DOT 

Constructor & Destructor Documentation

◆ GOval()

GOval ( double  x = 0,
double  y = 0,
double  width = 0,
double  height = 0 
)

Constructs a new oval inscribed in the specified rectangle.

By default, the oval is positioned at the origin, but you can pass coordinates x and y.

Member Function Documentation

◆ contains() [1/2]

bool contains ( const GPoint pt) const
virtualinherited

Returns true if the specified point is inside the object.

◆ contains() [2/2]

bool contains ( double  x,
double  y 
) const
overridevirtual

Returns true if the specified point is inside the object.

Reimplemented from GObject.

◆ getBottomRightLocation()

GPoint getBottomRightLocation ( ) const
virtualinherited

Returns the x/y coordinates of the bottom/right corner of the object.

◆ getBottomY()

double getBottomY ( ) const
virtualinherited

Returns the y-coordinate of the bottom of the object.

Equivalent to the top y-coordinate plus the object's height.

◆ getBounds()

GRectangle getBounds ( ) const
virtualinherited

Returns the bounding box of this object, which is defined to be the smallest rectangle that covers everything drawn by the figure.

The coordinates of this rectangle do not necessarily match the location returned by getLocation. Given a GText object, for example, getLocation returns the coordinates of the point on the baseline at which the string begins; the getBounds method, by contrast, returns a rectangle that covers the entire window area occupied by the string.

Reimplemented in GText, GPolygon, GLine, GCompound, and GArc.

◆ getCenterLocation()

GPoint getCenterLocation ( ) const
virtualinherited

Returns the x/y-coordinates of the center of the object.

Equivalent to the top/left plus half the object's size.

◆ getCenterX()

double getCenterX ( ) const
virtualinherited

Returns the x-coordinate of the center of the object.

Equivalent to the top/left plus half the object's width.

◆ getCenterY()

double getCenterY ( ) const
virtualinherited

Returns the y-coordinate of the center of the object.

Equivalent to the top/left plus half the object's height.

◆ getColor()

string getColor ( ) const
virtualinherited

Returns the color used to display this object.

This color is always returned as a string in the form "#rrggbb", where rr, gg, and bb are the red, green, and blue components of the color, expressed as two-digit hexadecimal values.

◆ getFillColor()

string getFillColor ( ) const
virtualinherited

Returns the color used to display the filled region of this object.

If none has been set, returns the empty string.

◆ getHeight()

double getHeight ( ) const
virtualinherited

Returns the height of this object, which is the same as the height of its bounding box.

Reimplemented in GPolygon, and GLine.

◆ getLineStyle()

GObject::LineStyle getLineStyle ( ) const
virtualinherited

Returns the object's style such as solid or dashed.

◆ getLineWidth()

double getLineWidth ( ) const
virtualinherited

Returns the width of the line used to draw this object.

Returns
default 1

◆ getLocation()

GPoint getLocation ( ) const
virtualinherited

Returns the location of the top-left corner of object.

◆ getOpacity()

double getOpacity ( ) const
virtualinherited

Returns how opaque (non-transparent) this object will appear from 0.0 (completely transparent) to 1.0 (completely opaque, default).

◆ getParent()

GCompound * getParent ( ) const
virtualinherited

Returns a pointer to the GCompound that contains this object.

Every GWindow is initialized to contain a single GCompound that is aligned with the window. Adding objects to the window adds them to that GCompound, which means that every object you add to the window has a parent. Calling getParent on the top-level GCompound returns nullptr.

◆ getRightX()

double getRightX ( ) const
virtualinherited

Returns the x-coordinate of the right side of the object.

Equivalent to the left x-coordinate plus the object's width.

◆ getSize()

GDimension getSize ( ) const
virtualinherited

Returns the size of the object as a GDimension.

◆ getType()

string getType ( ) const
overridevirtual

Returns the type of the object as a string, such as "GOval" or "GRect".

Each GObject subtype must override this method.

Implements GObject.

◆ getWidth()

double getWidth ( ) const
virtualinherited

Returns the width of this object, which is equal to the width of the bounding box.

Reimplemented in GPolygon, and GLine.

◆ getX()

double getX ( ) const
virtualinherited

Returns the leftmost x-coordinate of the object.

◆ getY()

double getY ( ) const
virtualinherited

Returns the topmost y-coordinate of the object.

◆ isAntiAliasing()

bool isAntiAliasing ( )
staticinherited

Returns whether we should globally anti-alias graphical objects.

On by default.

◆ isFilled()

bool isFilled ( ) const
virtualinherited

Returns true if the object is filled with color.

◆ isTransformed()

bool isTransformed ( ) const
virtualinherited

Returns true if this object has been transformed by calling methods such as rotate() or scale() on it.

Certain operations (such as setSize) cannot be performed after a graphical object has been transformed.

◆ isVisible()

bool isVisible ( ) const
virtualinherited

Returns true if this object is visible on screen.

◆ move()

void move ( double  dx,
double  dy 
)
virtualinherited

Moves the object on the screen using the displacements dx and dy.

◆ repaint()

void repaint ( )
virtualinherited

Instructs the object to redraw itself on screen.

Reimplemented in GCompound.

◆ resetTransform()

void resetTransform ( )
virtualinherited

Undoes any previous scale/rotate transformations on this object.

◆ rotate()

void rotate ( double  theta)
virtualinherited

Transforms the object by rotating it theta degrees counterclockwise around its origin.

After calling this method on a graphical object, isTransformed will return true for that object unless you subsequently call resetTransform on it.

◆ scale() [1/2]

void scale ( double  sf)
virtualinherited

Scales the object by the specified scale factor.

This form scales the object by sf in both dimensions, so that invoking gobj->scale(2); doubles the size of the object. After calling this method on a graphical object, isTransformed will return true for that object unless you subsequently call resetTransform on it.

◆ scale() [2/2]

void scale ( double  sx,
double  sy 
)
virtualinherited

Scales the object by the specified scale factors.

For example, gobj->scale(2, 2); doubles the size of the object. This form applies independent scale factors to the x and y dimensions. After calling this method on a graphical object, isTransformed will return true for that object unless you subsequently call resetTransform on it.

◆ sendBackward()

void sendBackward ( )
inherited

Moves this object one step toward the back in the z dimension.

If it was already at the back of the stack, nothing happens.

◆ sendForward()

void sendForward ( )
inherited

Moves this object one step toward the front in the z dimension.

If it was already at the front of the stack, nothing happens.

◆ sendToBack()

void sendToBack ( )
inherited

Moves this object to the back of the display in the z dimension.

By moving it to the back, this object will appear to be behind the other graphical objects on the display and may be obscured by other objects in front.

◆ sendToFront()

void sendToFront ( )
inherited

Moves this object to the front of the display in the z dimension.

By moving it to the front, this object will appear to be on top of the other graphical objects on the display and may hide any objects that are further back.

◆ setAntiAliasing()

void setAntiAliasing ( bool  value)
staticinherited

Globally turns on/off the anti-aliasing feature that smooths out the edges of onscreen shapes.

On by default. Does not repaint any onscreen objects when called; you must do this yourself.

◆ setBottomRightLocation() [1/2]

void setBottomRightLocation ( double  x,
double  y 
)
virtualinherited

Sets the location of the bottom/right of this object.

◆ setBottomRightLocation() [2/2]

void setBottomRightLocation ( const GPoint pt)
virtualinherited

Sets the location of the bottom/right of this object.

◆ setBottomY()

void setBottomY ( double  y)
virtualinherited

Sets the location of the bottom y-coordinate of this object.

◆ setBounds() [1/2]

void setBounds ( double  x,
double  y,
double  width,
double  height 
)
virtualinherited

Changes the bounds of this object to the specified values.

◆ setBounds() [2/2]

void setBounds ( const GRectangle size)
virtualinherited

Changes the bounds of this object to the specified rectangle.

◆ setCenterLocation() [1/2]

void setCenterLocation ( double  x,
double  y 
)
virtualinherited

Sets the location of the center of this object.

◆ setCenterLocation() [2/2]

void setCenterLocation ( const GPoint pt)
virtualinherited

Sets the location of the center of this object.

◆ setCenterX()

void setCenterX ( double  x)
virtualinherited

Sets the x-coordinate of the center of this object.

◆ setCenterY()

void setCenterY ( double  y)
virtualinherited

Sets the y-coordinate of the center of this object.

◆ setColor() [1/3]

void setColor ( int  r,
int  g,
int  b 
)
virtualinherited

Sets the color used to display this object.

See gcolor.h for more detail about how to specify colors.

Equivalent to setForeground.

Parameters
rredness from 0-255
ggreenness from 0-255
bblueness from 0-255

◆ setColor() [2/3]

void setColor ( int  rgb)
virtualinherited

Sets the color used to display this object.

See gcolor.h for more detail about how to specify colors.

Equivalent to setForeground.

Parameters
rgban RGB integer value such as 0x7700ff

◆ setColor() [3/3]

void setColor ( string   color)
virtualinherited

Sets the color used to display this object.

See gcolor.h for more detail about how to specify colors.

Equivalent to setForeground.

Parameters
colorcolor string such as "#7700ff" or "purple"

◆ setFillColor() [1/3]

void setFillColor ( int  r,
int  g,
int  b 
)
virtualinherited

Sets the color used to display the filled region of this object, if any.

As a side effect, sets this object to be filled (setFilled(true)). See gcolor.h for more detail about how to specify colors. If an empty string is passed, sets filled to false.

Parameters
rredness from 0-255
ggreenness from 0-255
bblueness from 0-255

◆ setFillColor() [2/3]

void setFillColor ( int  rgb)
virtualinherited

Sets the color used to display the filled region of this object, if any.

As a side effect, sets this object to be filled (setFilled(true)). See gcolor.h for more detail about how to specify colors.

Parameters
rgban RGB integer value such as 0x7700ff

◆ setFillColor() [3/3]

void setFillColor ( string   color)
virtualinherited

Sets the color used to display the filled region of this object, if any.

As a side effect, sets this object to be filled (setFilled(true)). See gcolor.h for more detail about how to specify colors. If an empty string is passed, sets filled to false.

Parameters
colorcolor string such as "#7700ff" or "purple"

◆ setFilled()

void setFilled ( bool  flag)
virtualinherited

Sets the fill status for the object, where false is outlined and true is filled.

◆ setFont() [1/2]

void setFont ( const QFont &  font)
virtualinherited

Changes the font used to display the object as specified by the given Qt font.

See gfont.h for more detail about how to specify fonts.

Reimplemented in GText.

◆ setFont() [2/2]

void setFont ( string   font)
virtualinherited

Changes the font used to display the object as specified by the string font, which has the following format:

"family-style-size"

where both style and size are optional. If any of these elements are missing or specified as an asterisk, the existing value is retained. See gfont.h for more detail about how to specify fonts.

Reimplemented in GText.

◆ setForeground() [1/3]

void setForeground ( int  r,
int  g,
int  b 
)
virtualinherited

Sets the color used to display this object.

See gcolor.h for more detail about how to specify colors.

Equivalent to setColor.

Parameters
rredness from 0-255
ggreenness from 0-255
bblueness from 0-255

◆ setForeground() [2/3]

void setForeground ( int  rgb)
virtualinherited

Sets the color used to display this object.

See gcolor.h for more detail about how to specify colors.

Equivalent to setColor.

Parameters
rgban RGB integer value such as 0x7700ff

◆ setForeground() [3/3]

void setForeground ( string   color)
virtualinherited

Sets the color used to display this object.

See gcolor.h for more detail about how to specify colors.

Equivalent to setColor.

Parameters
colorcolor string such as "#7700ff" or "purple"

◆ setHeight()

void setHeight ( double  height)
virtualinherited

Changes the height of this object to the specified height without changing its width.

◆ setLineStyle()

void setLineStyle ( GObject::LineStyle  lineStyle)
virtualinherited

Sets the object's style such as solid (GObject::LINE_SOLID) or dashed (GObject::LINE_DASH).

◆ setLineWidth()

void setLineWidth ( double  lineWidth)
virtualinherited

Sets the width of the line used to draw this object.

The default line width is 1.

◆ setLocation() [1/2]

void setLocation ( double  x,
double  y 
)
virtualinherited

Sets the location of the top-left corner of this object to the specified coordinates.

◆ setLocation() [2/2]

void setLocation ( const GPoint pt)
virtualinherited

Sets the location of the top-left corner of this object to the specified point.

◆ setOpacity()

void setOpacity ( double  opacity)
virtualinherited

Sets how opaque (non-transparent) this object will appear from 0.0 (completely transparent) to 1.0 (completely opaque, default).

Exceptions
ErrorExceptionif opacity is out of range [0.0, 1.0]

◆ setRightX()

void setRightX ( double  x)
virtualinherited

Sets the location of the rightmost x-coordinate of this object.

◆ setSize() [1/2]

void setSize ( double  width,
double  height 
)
virtualinherited

Changes the size of this object to the specified width and height.

◆ setSize() [2/2]

void setSize ( const GDimension size)
virtualinherited

Changes the size of this object to the specified width and height.

◆ setVisible()

void setVisible ( bool  flag)
virtualinherited

Sets whether this object is visible.

Graphical objects are initially visible when created.

◆ setWidth()

void setWidth ( double  width)
virtualinherited

Changes the width of this object to the specified width without changing its height.

◆ setX()

void setX ( double  x)
virtualinherited

Sets the x location of the left side of this object.

◆ setY()

void setY ( double  y)
virtualinherited

Sets the y location of the top of this object.

◆ toString()

string toString ( ) const
virtualinherited

Returns a printable representation of the object.

Reimplemented in GCompound.

◆ toStringExtra()

string toStringExtra ( ) const
protectedvirtualinherited

Returns a string containing any extra unique information about this type of graphical object.

Reimplemented in GText, GRoundRect, GPolygon, GLine, GImage, and GArc.

Member Data Documentation

◆ _brush

QBrush _brush
protectedinherited

◆ _color

string _color
protectedinherited

◆ _colorInt

int _colorInt
protectedinherited

◆ _fillColor

string _fillColor
protectedinherited

◆ _fillColorInt

int _fillColorInt
protectedinherited

◆ _fillFlag

bool _fillFlag
protectedinherited

◆ _font

string _font
protectedinherited

◆ _height

double _height
protectedinherited

◆ _lineStyle

LineStyle _lineStyle
protectedinherited

◆ _lineWidth

double _lineWidth
protectedinherited

◆ _opacity

double _opacity
protectedinherited

◆ _parent

GCompound* _parent
protectedinherited

◆ _pen

QPen _pen
protectedinherited

◆ _transform

QTransform _transform
protectedinherited

◆ _transformed

bool _transformed
protectedinherited

◆ _visible

bool _visible
protectedinherited

◆ _width

double _width
protectedinherited

◆ _x

double _x
protectedinherited

◆ _y

double _y
protectedinherited