module DrawingTools;

from DeskDrawer import Overlay;

export Shape;

object ForeColor is Color;
object BackColor is Color;
object Color is integer;
object ShapeSelection is Shape;
object Alignment is LeftAlign, CenterAlign, RightAlign;

object LeftAlign;
object CenterAlign;
object RightAlign;

object OverlaySize is Dimension;

object Selection is
    components:  dimensions:Dimension*, shape:Shape;
    operations:  ;
    description:  (*
        A selection is a the object the user has selected to manipulate.  
        The selection consists of the shape the user has selected and the
        dimensions the user has selected within the shape.  The shape component
        should just be a pointer to the actual shape object.  *);
end Selection;

object Dimension is
    components:  CornerOne, CornerTwo;
    operations:  ;
    description:  (*
        A dimension represents two sets of X-Y Coordinates. *);
end Dimension;

object CornerOne is Coordinate;
object CornerTwo is Coordinate;

object Coordinate is
    components:  X, Y;
    operations:;
    description: (*
        X-Y Coordinates for a dimension. *);
end Coordinate;



object X is integer;
object Y is integer;

object Shape is
    components:  dimensions:ShapeLocation, color:Color;
    operations: ;
    description:  (*
        A shape is an object that belongs to an overlay.  A shape has a
        dimension.  ShapeDimension is how much space the shape takes up.*);
end Shape;

object ShapeLocation is Dimension;

object Text inherits from Shape
    components: TextFont, BGColor, TextSize, TextWords, Alignment;
    operations: ;
    description: (*
        Text has a Font, BGColor, TextSize and TextWords.  TextWords is the 
        string for the text object. *);
end Text;

object TextFont is string;
object BGColor is integer;
object TextSize is integer;
object TextWords is string;

object PaintStroke inherits from Shape
   components:  Dimension*;
   operations:;
   description:  (*
        A paint stroke has a set of X-Y coordinates that corresponds to pixels. *);
end PaintStroke;

object Line inherits from Shape
   components:  Dimension;
   operations:;
   description:  (*
      A line has two sets of X-Y coordinates that corresponds to the ends. *);
end Line;

object Rectangle inherits from Shape
   components:;
   operations:;
   description: (*
      A rectangle has a set of coordinates that corresponds to the corners. *);
end Rectangle;

object Circle inherits from Shape
   components:  Radius, CirCenter;
   operations: ;
   description: (*
      A circle has a radius, and center. *);
end Circle;
      
object Radius is integer;
object CirCenter is Coordinate;

object CustomShape inherits from Shape
   components:  Dimension*;
   operations: ;
   description: (*
      The custom shape tool is a collection of dimensions. *);
end CustomShape;


operation RectSelect
    inputs:  o:Overlay, s:Selection;
    outputs: s':Selection;
    precondition: (*None*);   
    postcondition: (* Shape selection is in the overlay *)
        (s'.shape in o.shapes);
    description:  (*
        Highlights a rectangular portion of an overlay for the user to
        manipulate.  *);
end RectSelect;

operation Lasso
    inputs:  o:Overlay, s:Selection;
    outputs: s':Selection;
    precondition: (*None*);   
    postcondition: (* Shape selection is in the overlay *)
        (s'.shape in o.shapes);
    description: (*
        Highlights a portion of an overlay for the user to mainpulate.  
        The selection is determined by the portion the user selects with
        the user's mouse. *);
end Lasso;

operation PolyLasso
    inputs:  o:Overlay, s:Selection;
    outputs: s':Selection;
    precondition: (*None*);   
    postcondition: (* Shape selection is in the overlay *)
        (s'.shape in o.shapes);
    description: (*
        Highlights a portion of an overlay for the user to mainpulate.  
        The selection is determined by the portion the user selects with
        the users mouse. *);
end PolyLasso;

operation ShapeSelect
    inputs:  o:Overlay, s:Selection;
    outputs: s':Selection;
    precondition: (*None*);   
    postcondition: (* Shape selection is in the overlay *)
        (s'.shape in o.shapes);
    description:  (*
        Highlights a shape the user selected so that the user can move, delete,
        or duplicate the shape. *);
end ShapeSelect;

operation Eraser
    inputs:  o:Overlay;
    outputs: o':Overlay;
    precondition: (* None *);
    postcondition: (* There are no shapes in the overlay *)
        #(o'.shapes) = 0;
    description:  (*
        Allows the user to clear an overlay. *);
end Eraser;
        
operation PaintBucket
    inputs:  o:Overlay, s:Selection, fc:ForeColor, os:OverlaySize;
    outputs: o':Overlay;
    precondition: (* if there is no selection, then the background of the 
            overlay changes.  In order to change the color of the overlay,
            it will change the selection to a custom shape with the size 
            of the entire overlay, and the color of the current foreground color.*)
        if (s = nil) then
            (s.shape.color = fc and
            s.shape.dimensions = os);
    postcondition: (* Paint object is in the ovleray *)
       s.shape in o'.shapes;
    description:  (*
        Allows the user to use the Paint Bucket tool. *);
end PaintBucket;
       
operation PaintBrush
    inputs: o:Overlay, ps:PaintStroke;    
    outputs: o':Overlay;
    precondition: (* None *);
    postcondition: (* PaintStroke is in the overlay *)
        exists (s in o'.shapes) s.<PaintStroke = ps;
    description:  (*
        Allows the user to use the Paint Brush tool. *);
end PaintBrush;

operation MakeText
    inputs: o:Overlay, te:Text;
    outputs: o':Overlay;
    precondition: (* None *);
    postcondition:  (* Text is in the overlay *)
        exists (s in o'.shapes) s.<Text = te;
    description:  (*
        Allows the user to create a textbox. *);
end MakeText;

operation DrawRectangle
    inputs:  Overlay, Rectangle;
    outputs: Overlay;
    precondition:  (* Coming Soon *);
    postcondition:  (* Coming Soon *);
    description:  (*
        Allows the user to draw a square. *);
end DrawRectangle;

operation DrawCircle
    inputs:  Overlay, Circle;
    outputs: Overlay;
    precondition:  (* Coming Soon *);
    postcondition:  (* Coming Soon *);
    description:  (*
        Allows the user to draw a circle. *);
end DrawCircle;
       
operation DrawCustomShape
    inputs:  Overlay, CustomShape;
    outputs: Overlay;
    precondition:  (* Coming Soon *);
    postcondition:  (* Coming Soon *);
    description:  (*
        Allows the user to draw a custom shape. *);
end DrawCustomShape;

operation ChangeAlignment
    inputs:  Overlay, Shape, Alignment;
    outputs: Overlay;
    precondition:  (* Coming Soon *);
    postcondition:  (* Coming Soon *);
    description:  (*
        Allows the user to change the text alignment of a TextBox shape. *);
end ChangeAlignment;

end DrawingTools;