Updraft  1.0
Open source glider flight visualisation tool.
Updraft::TaskData Class Reference

This class encapsulates all data related to one task. More...

#include <taskdata.h>

List of all members.

Public Member Functions

virtual ~TaskData ()
QString toXml () const
TaskPointgetTaskPoint (int position)
 Find and return TaskPoint on specified position.
const TaskPointgetTaskPoint (int position) const
 Same as non-const getTaskPoint()
bool fromXml (const QString &serialized)
 Tries to parse xml file.
bool insertTaskPoint (TaskPoint *taskPoint, int position)
 Inserts new TaskPoint.
void moveTaskPoint (int from, int to)
 Changes position of TaskPoint in sequence.
void deleteTaskPoint (int position)
 Deletes TaskPoint on desired position.
int size () const
 Return number of task points in this declaration.
void setAddTaskPointButton (int position)
 Set the information about the checked add TaskPoint button.
int getAddTaskPointButton () const
 Get the currently checked add TaskPoint button.
qreal totalDistance () const
 Return length between all turn points in meters.
qreal officialDistance () const
 Return the FAI official length of the track.
bool isClosed () const
 Return true if the task is a closed course.
bool isFaiTriangle () const
 Return true if the task is a valid FAI triangle.
qreal distance (int i, int j) const
 Returns shortest distance from turn point i to turn point j.
qreal distanceAzimuth (int i, int j, qreal *azimuth) const
 Returns shortest distance from turn point i to turn point j and optionally azimuths i to j and j to i.

Private Types

typedef QVector< TaskPoint * > PointsContainer

Private Member Functions

 TaskData ()
 Only DataHistory objects can create TaskData.
qreal distanceReduction (int i) const
 Return the distance reduction of this task point caused by the use of FAI cylinders.
float faiTriangleDistance () const
 Calculate official distance, or -1 if the task is not a FAI triangle.
 TaskData (const TaskData &taskData)
 Only DataHistory objects can make copies of TaskData.

Private Attributes

PointsContainer taskPoints
 Ordered sequence of TaskPoints.
int selectedAddButton
 Selected add TaskPoint button in the gui.

Friends

class DataHistory

Detailed Description

This class encapsulates all data related to one task.

It can be used only with DataHistory and TaskFile. These three classes together form a Memento design pattern.


Member Typedef Documentation

typedef QVector<TaskPoint*> Updraft::TaskData::PointsContainer [private]

Constructor & Destructor Documentation

Updraft::TaskData::TaskData ( ) [inline, private]

Only DataHistory objects can create TaskData.

Updraft::TaskData::TaskData ( const TaskData taskData) [private]

Only DataHistory objects can make copies of TaskData.


Member Function Documentation

void Updraft::TaskData::deleteTaskPoint ( int  position)

Deletes TaskPoint on desired position.

Parameters:
positionposition of target TaskPoint
qreal Updraft::TaskData::distance ( int  i,
int  j 
) const

Returns shortest distance from turn point i to turn point j.

Doesn't do any checks on the values i,j.

Returns:
Length of shortest path from i-th to j-th turn point
qreal Updraft::TaskData::distanceAzimuth ( int  i,
int  j,
qreal *  azimuth 
) const

Returns shortest distance from turn point i to turn point j and optionally azimuths i to j and j to i.

Doesn't do any checks on the values i,j.

Parameters:
iIndex of the first turn-point
jIndex of the second turn-point
[out]azimuthazimuth from point i to j
Returns:
Length of shortest path from i-th to j-th turn point
qreal Updraft::TaskData::distanceReduction ( int  i) const [private]

Return the distance reduction of this task point caused by the use of FAI cylinders.

This reduction must be used twice for task points inside the track (that are entered and left).

float Updraft::TaskData::faiTriangleDistance ( ) const [private]

Calculate official distance, or -1 if the task is not a FAI triangle.

bool Updraft::TaskData::fromXml ( const QString &  serialized)

Tries to parse xml file.

If it fails, TaskData is empty.

Parameters:
serializedstring with xml file content
Returns:
True on success, otherwise false.

Get the currently checked add TaskPoint button.

Find and return TaskPoint on specified position.

This function serves for both reading and editing of TaskPoint.

Parameters:
positionposition of TaskPoint in sequence
Returns:
Pointer to a task point on desired position If position is out of range, it returns NULL.
const TaskPoint * Updraft::TaskData::getTaskPoint ( int  position) const

Same as non-const getTaskPoint()

bool Updraft::TaskData::insertTaskPoint ( TaskPoint taskPoint,
int  position 
)

Inserts new TaskPoint.

All TaskPoints are deleted in ~TaskData.

Parameters:
positiontarget position of TaskPoint in sequence
taskPointThe task point to be inserted If position is invalid, TaskPoint is appended to end of sequence.

Return true if the task is a closed course.

This function accepts a endpoints located at most 500 m from start points. This is a bit broader definition than FAI rules has, but shouldn't be too much trouble.

Return true if the task is a valid FAI triangle.

void Updraft::TaskData::moveTaskPoint ( int  from,
int  to 
)

Changes position of TaskPoint in sequence.

Parameters:
fromposition of desired TaskPoint
todestination position If "to" is invalid position, TaskPoint is moved to end of sequence.

Return the FAI official length of the track.

Set the information about the checked add TaskPoint button.

Parameters:
positionnew position of the checked TaskPoint button
int Updraft::TaskData::size ( ) const [inline]

Return number of task points in this declaration.

Return length between all turn points in meters.

QString Updraft::TaskData::toXml ( ) const
Returns:
Xml text representation of TaskData

Friends And Related Function Documentation

friend class DataHistory [friend]

Member Data Documentation

Selected add TaskPoint button in the gui.

If it is -1, it means that no button is selected

Ordered sequence of TaskPoints.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines