class PartSelection

Support class for selecting one or more Part object. More...

Full nameTSE3::App::PartSelection
Definition#include <PartSelection.h>
InheritsTSE3::Listener [public ], TSE3::Listener [public ], TSE3::Notifier [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Types

Public Methods


Detailed Description

The PartSelection class allows an Application to provide the facility to 'select' one or more TSE3::Part in a TSE3::Song. These TSE3::Part objects must be held in a TSE3::Track. As soon as a TSE3::Part is removed from a TSE3::Track, it is removed from the selection.

This behviour is useful when using the command history system in the TSE3::Cmd namespace where undoing a TSE3::Part add, for example, may cause a selected Part to be removed from the TSE3::Song.

Internally, the Parts are held in an STL vector of type . In order to get access to the contents of this vector, access is provided to it's iterator.

If you are using the iterators and performing any operations that may affect the PartSelection (i.e. removing a TSE3::Part from it's TSE3::Track and reinserting it elsewhere) then you will invalidate the iterator.

A method of avoiding this would be to, rather than iterate over each Part, to remove a Part from the head of the list, work on it, and place it into a second PartSelection. Do this for each Part in the PartSelection, and when finished, copy the new PartSelection into the old one.

Interaction with TrackSelection

You may want to use this selection utility in connection with the TrackSelection class to ensure that the user has only selected one type of object at any time.

To facilitate this, the PartSelection is a TrackSelectionListener. You can attach it to a TrackSelection object, and whenever the TrackSelection has a TSE3::Track selected the PartSelection will be cleared.

You will need to use an attach like this:


   PartSelection   ps;
   TrackSelection *ts = someTrackSelection();
   ps.TSE3::Listener::attachTo(ts);

See also: TSE3

 PartSelection ()

PartSelection

The PartSelection begins with no Part selected.

 ~PartSelection ()

~PartSelection

 PartSelection (const PartSelection &)

PartSelection

TSE3::Clock  earliest ()

earliest

[const]

Returns the earliest start time of any TSE3::Part in the selection.

If there is no selection, this will return -1.

Returns: Earliest TSE3::Part start time

TSE3::Clock  latest ()

latest

[const]

Returns the latest end time of any TSE3::Part in the selection.

If there is no selection, this will return -1.

Returns: Latest TSE3::Part start time

size_t  minTrack ()

minTrack

[const]

Returns the lowest TSE3::Track index that any selected TSE3::Part is in.

If there is no selection, this will return 0.

Returns: Lowest TSE3::Track index.

size_t  maxTrack ()

maxTrack

[const]

Returns the greatest TSE3::Track index that any selected TSE3::Part is in.

If there is no selection, this will return 0.

Returns: Greatest TSE3::Track index.

void  select (TSE3::Part *part, bool add)

select

Selects a TSE3::Part.

If the TSE3::Part is not in a TSE3::Track, it will not be selected.

Parameters:
partThe Part to select
addWhether to add the TSE3::Part to the selection (true) or to replace the current selection (false).

void  deselect (TSE3::Part *part)

deselect

Deselects a Part. If the Part is not selected, then nothing will happen.

Parameters:
partThe Part to deselect

void  clear ()

clear

Clears the entire selection.

void  selectAll (TSE3::Song *song)

selectAll

Selects all the TSE3::Part objects in the given TSE3::Song (this 'should' include any Parts alreadys selected!).

Parameters:
songTSE3::Song whose TSE3::Part objects are all to be selected

void  selectAll (TSE3::Track *track)

selectAll

Adds to the selection all the TSE3::Part objects in the given TSE3::Track.

Parameters:
trackTSE3::Track whose TSE3::Part objects are all to be selected

void  invert (TSE3::Song *song)

invert

Inverts the selection for all the TSE3::Part objects in the given TSE3::Song (i.e. all selected Parts are deselected and all deselected Parts are selected).

Parameters:
songTSE3::Song whose TSE3::Part objects are all to be inverted

void  selectBetween (TSE3::Song *song, TSE3::Clock start, TSE3::Clock end, bool inside = true)

selectBetween

Adds to the selection all the Parts which have a section lying either inside or outside the window between a start time and an end time.

Parameters:
songTSE3::Song whose TSE3::Part objects are all to be operated on
startStart of selection window
endEnd of selection window
insideIf true, select TSE3::Part objects between start and end, else select Parts NOT between these times

void  selectBetween (TSE3::Track *track, TSE3::Clock start, TSE3::Clock end, bool inside = true)

selectBetween

Adds to the selection all the Parts which have a section lying either inside or outside the window between a start time and an end time.

Parameters:
trackTSE3::Track whose TSE3::Part objects are all to be operated on
startStart of selection window
endEnd of selection window
insideIf true, select TSE3::Part objects between start and end, else select Parts NOT between these times

PartSelection & operator= (const PartSelection &)

operator=

Copy PartSelection contents.

Reimplemented from Listener.

size_t  size ()

size

[const]

Returns how many TSE3::Part objects are selected.

Returns: No of selected TSE3::Part objects

bool  isSelected (TSE3::Part *part)

isSelected

[const]

Returns whether a particular TSE3::Part is selected.

Parameters:
partThe TSE3::Part to run selection test on

Returns: Whether the TSE3::Part is selected

typedef std::vector<TSE3::Part*>::const_iterator iterator_t

iterator_t

Part * front ()

front

[const]

Returns the first item in the PartSelection, or zero if there are no selected Parts.

Returns: First selected TSE3::Part

Part * back ()

back

[const]

Returns the last item in the PartSelection, or zero if there are no selected Parts.

Returns: Last selected TSE3::Part

iterator_t  begin ()

begin

[const]

Returns an iterator pointing to the first TSE3::Part in this selection.

Returns: Iterator pointing to first selected TSE3::Part

iterator_t  end ()

end

[const]

Returns an iterator pointing to the last TSE3::Part in this selection.

Returns: Iterator pointing to last selected TSE3::Part

void  Part_StartAltered (Part *, Clock start)

Part_StartAltered

[virtual]

void  Part_EndAltered (Part *, Clock end)

Part_EndAltered

[virtual]

void  Part_Reparented (Part *)

Part_Reparented

[virtual]

void  Notifier_Deleted (Part *)

Notifier_Deleted

[virtual]

Reimplemented from Listener for internal purposes..

void  TrackSelection_Selected (TrackSelection *, TSE3::Track *, bool)

TrackSelection_Selected

[virtual]