The SimpleCxxLib package


#include "gobjects.h"

class GLine : public GObject

This graphical object subclass represents a line segment. For example, the following code adds lines that mark the diagonals of the graphics window:
   int main() {
      GWindow gw;
      cout << "This program draws the diagonals on the window." << endl;
      gw.add(new GLine(0, 0, gw.getWidth(), gw.getHeight()));
      gw.add(new GLine(0, gw.getHeight(), gw.getWidth(), 0));
      return 0;
   }
Constructor
GLine(x0, y0, x1, y1) Constructs a line segment from its endpoints.
Methods
getEndPoint() Returns the point at which the line ends.
getStartPoint() Returns the point at which the line starts.
setEndPoint(x, y) Sets the end point in the line to (xy), leaving the start point unchanged.
setStartPoint(x, y) Sets the initial point in the line to (xy), leaving the end point unchanged.

Constructor detail


GLine(double x0, double y0, double x1, double y1);
Constructs a line segment from its endpoints. The point (x0y0) defines the start of the line and the point (x1y1) defines the end.

Usage:

GLine *gline = new GLine(x0, y0, x1, y1);

Method detail


void setStartPoint(double x, double y);
Sets the initial point in the line to (xy), leaving the end point unchanged. This method is therefore different from setLocation, which moves both components of the line segment.

Usage:

line->setStartPoint(x, y);

GPoint getStartPoint() const;
Returns the point at which the line starts.

Usage:

GPoint pt = line->getStartPoint();

void setEndPoint(double x, double y);
Sets the end point in the line to (xy), leaving the start point unchanged. This method is therefore different from setLocation, which moves both components of the line segment.

Usage:

line->setEndPoint(x, y);

GPoint getEndPoint() const;
Returns the point at which the line ends.

Usage:

GPoint pt = line->getEndPoint();