Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

CutTool Class Reference

A Tool subclass used to remove objects from the canvas. More...

Inheritance diagram for CutTool:

Tool Object List of all members.

Public Methods

 CutTool ()
void start ()
 When the tool is first selected, it removes all currently-selected objects from the canvas by using Drawing's Selection class and the provided iteration functions.

int mouseClick (const Position &pos)
 When the mouse is clicked, it figures out which object was clicked and removes it from the canvas.

void stop ()
 called when another tool is selected


Static Public Attributes

CutTool::Factory factory

Detailed Description

A Tool subclass used to remove objects from the canvas.


Constructor & Destructor Documentation

CutTool::CutTool   [inline]
 

00009 : Tool("cut-button.bmp") {}


Member Function Documentation

int CutTool::mouseClick const Position &    pos [inline, virtual]
 

When the mouse is clicked, it figures out which object was clicked and removes it from the canvas.

Implements Tool.

00035                                       {
00036     if (DrawElement* e = drawing->get_contents()->find_hit(pos)) {
00037       drawing->get_contents()->remove_element(e);
00038       delete e;
00039       return 1;
00040     }
00041     return 0;
00042   }

void CutTool::start   [inline, virtual]
 

When the tool is first selected, it removes all currently-selected objects from the canvas by using Drawing's Selection class and the provided iteration functions.

A list of all selected objects is built, and then they are all removed at once; otherwise the iterator would become invalid.

Implements Tool.

00017                {
00018     Drawing::Selection begin = drawing->begin_selection(),
00019       end = drawing->end_selection();
00020     vector<DrawElement*> elems;
00021     for (Drawing::Selection i = begin; i != end; ++i) {
00022       elems.push_back(*i);
00023     }
00024     for (vector<DrawElement*>::iterator i = elems.begin();
00025          i != elems.end(); ++i) {
00026       drawing->remove_selection(*i);
00027       drawing->get_contents()->remove_element(*i);
00028       delete (*i);
00029     }
00030   }

void CutTool::stop   [inline, virtual]
 

called when another tool is selected

Implements Tool.

00044 {}


Member Data Documentation

CutTool::Factory CutTool::factory [static]
 


The documentation for this class was generated from the following file:
Generated on Fri Nov 8 10:52:28 2002 for Draw by doxygen1.2.17