Derived classes

All GrafEdit commands have Do, DoBegin, DoIncrement, DoEnd, Undo, and Redo functions implemented, and are provided an MCanvasSelection by the GrafEdit framework. In all cases, Undo restores the original state of all affected canvas graphics by saving the graphics prior to changing them and later replacing the changed graphics with the original graphics.

To use a GrafEdit command, you need to construct it and call special setter functions as described in the following sections. Everything else is done by the GrafEdit framework.

Adopt command

    TAdoptCanvasGraphicCmd( MCanvasGraphic* adoptGraphic, Boolean adoptAtFront = TRUE);
The constructor for this command adopts the specified canvas graphic into the canvas representation associated with the selection.

Delete command

    TDeleteCanvasGraphicCmd();
This command deletes all canvas graphics in the selection from the associated canvas representation. Undo adopts deleted graphics into the representation in their original locations and order from front to back with respect to other graphics.

Fill color command

      TSetCanvasGraphicFillColorCmd( const TColor& );
      virtual void SetColor( const TColor& );
The constructor for this command sets the fill color of all canvas graphics in the selection. When no color is specified, the command has no effect. This class has a SetColor function that allows the fill color to be set incrementally (for example, by a slider) and undone in a single step. SetColor sets the color for each increment.

Frame color command

      TSetCanvasGraphicFrameColorCmd( const TColor& );
      virtual void SetColor( const TColor& );
The constructor for this command sets the frame color of all graphics in the selection. If a color is not specified, the command has no effect. This class has a SetColor function that allows the frame color to be set incrementally (for example, by a slider) and undone in a single step. SetColor sets the color for each increment.

Line width command

      TSetCanvasGraphicLineWidthCmd( GCoordinate width );
      virtual void SetWidth( GCoordinate width );
The constructor for this command sets the line width for all graphics in the selection. The default width is 1.0 in world coordinate units. This class has a SetWidth function that allows the line width to be set incrementally (for example, by a slider) and undone in a single step. SetWidth sets the line width for each increment.

Scale command

      TScaleCanvasGraphicCmd( const TGPoint& centerOfScale );
      TScaleCanvasGraphicCmd( const TGPoint& scaleFactor, const TGPoint& centerOfScale );
      virtual void SetScaleFactor( const TGPoint& centerOfScale );
This command scales all canvas graphics in the current selection by the specified scale factor around the specified center of scale. These values are set in the constructor. The scale factor is a TGPoint where fX is a horizontal scale factor and fY is the vertical scale factor. A scale factor of (2,2) multiplies the graphics by 2 vertically and horizontally. The default scale factor is (1,1) and the default center of scale is (0,0).

TScaleCanvasGraphicCmd has a SetScaleFactor function that allows the scale factor to be set incrementally (for example, by a slider) and undone in a single step. SetScaleFactor sets the scale factor for each increment. The center of scale can be set only once in the constructor.

Rotate command

      TRotateCanvasGraphicCmd( const TGPoint& centerOfRotation );
      TRotateCanvasGraphicCmd( const TGPoint& angle, const TGPoint& centerOfRotation );
      virtual void SetAngle( const TGPoint& centerOfRotation );
This command rotates all graphics in the current selection by a specified number of degrees around a specified center of rotation. These values are set in the constructor. The default angle is (0.0) and the default center is (0,0).

TRotateCanvasGraphicCmd has a SetAngle function that allows the angle to be set incrementally (for example, by a slider) and undone in a single step. SetAngle sets the angle for each increment. The center of rotation can be set only once in the constructor.

Translate command

      TTranslateCanvasGraphicCmd( const TGPoint& offset );
      virtual void SetOffset( const TGPoint& offset );
This command translates (moves) all graphics in the current selection by a specified value. The value is a TGPoint where fX is the horizontal offset and fY is the vertical offset. Offsets are relative to the origin and the default offset is (0,0). This class has a SetOffset function that allows the offset to be set incrementally for interactive direct manipulation such as when the user moves a graphic with the mouse.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker