TextLayer Class Reference

#include <TextLayer.h>

Inherits SingleColourLayer.

Inheritance diagram for TextLayer:

Inheritance graph
[legend]
Collaboration diagram for TextLayer:

Collaboration graph
[legend]
List of all members.

Detailed Description

Definition at line 28 of file TextLayer.h.

Public Types

enum  VerticalPosition { PositionTop, PositionMiddle, PositionBottom }
enum  SnapType { SnapLeft, SnapRight, SnapNearest, SnapNeighbouring }
enum  ColourSignificance {
  ColourAbsent, ColourIrrelevant, ColourDistinguishes, ColourAndBackgroundSignificant,
  ColourHasMeaningfulValue
}
enum  PropertyType {
  ToggleProperty, RangeProperty, ValueProperty, ColourProperty,
  UnitsProperty, InvalidProperty
}
typedef QString PropertyName
typedef std::vector< PropertyNamePropertyList

Public Slots

virtual void setProperty (const PropertyName &, int value)
 Set a property.
virtual void setProperty (QString nameString, QString valueString)
 Set a property using a fuzzy match.
void showLayer (View *, bool show)
virtual void setPropertyWithCommand (const PropertyName &, int value)
 Set a property using a command, supporting undo and redo.
virtual void setPropertyWithCommand (QString nameString, QString valueString)
 As above, but using a command.

Signals

void modelChanged ()
void modelChanged (size_t startFrame, size_t endFrame)
void modelCompletionChanged ()
void modelAlignmentCompletionChanged ()
void modelReplaced ()
void layerParametersChanged ()
void layerParameterRangesChanged ()
void layerMeasurementRectsChanged ()
void layerNameChanged ()
void verticalZoomChanged ()
void propertyChanged (PropertyContainer::PropertyName)

Public Member Functions

 TextLayer ()
virtual void paint (View *v, QPainter &paint, QRect rect) const
virtual QString getFeatureDescription (View *v, QPoint &) const
virtual bool snapToFeatureFrame (View *v, int &frame, size_t &resolution, SnapType snap) const
 !! too much overlap with TimeValueLayer/TimeInstantLayer
virtual void drawStart (View *v, QMouseEvent *)
virtual void drawDrag (View *v, QMouseEvent *)
virtual void drawEnd (View *v, QMouseEvent *)
virtual void eraseStart (View *v, QMouseEvent *)
virtual void eraseDrag (View *v, QMouseEvent *)
virtual void eraseEnd (View *v, QMouseEvent *)
virtual void editStart (View *v, QMouseEvent *)
virtual void editDrag (View *v, QMouseEvent *)
virtual void editEnd (View *v, QMouseEvent *)
virtual void moveSelection (Selection s, size_t newStartFrame)
virtual void resizeSelection (Selection s, Selection newSize)
virtual void deleteSelection (Selection s)
virtual void copy (View *v, Selection s, Clipboard &to)
virtual bool paste (View *v, const Clipboard &from, int frameOffset, bool interactive)
 Paste from the given clipboard onto the layer at the given frame offset.
virtual bool editOpen (View *, QMouseEvent *)
 Open an editor on the item under the mouse (e.g.
virtual const ModelgetModel () const
void setModel (TextModel *model)
virtual PropertyList getProperties () const
 Get a list of the names of all the supported properties on this container.
virtual QString getPropertyLabel (const PropertyName &) const
virtual PropertyType getPropertyType (const PropertyName &) const
virtual int getPropertyRangeAndValue (const PropertyName &, int *min, int *max, int *deflt) const
virtual QString getPropertyValueLabel (const PropertyName &, int value) const
virtual void setProperty (const PropertyName &, int value)
virtual bool isLayerScrollable (const View *v) const
 This should return true if the layer can safely be scrolled automatically by a given view (simply copying the existing data and then refreshing the exposed area) without altering its meaning.
virtual bool isLayerEditable () const
 This should return true if the layer can be edited by the user.
virtual int getCompletion (View *) const
 Return the proportion of background work complete in drawing this view, as a percentage -- in most cases this will be the value returned by pointer from a call to the underlying model's isReady(int *) call.
virtual bool getValueExtents (float &min, float &max, bool &logarithmic, QString &unit) const
 Return the minimum and maximum values for the y axis of the model in this layer, as well as whether the layer is configured to use a logarithmic y axis display.
virtual void toXml (QTextStream &stream, QString indent="", QString extraAttributes="") const
 Convert the layer's data (though not those of the model it refers to) into XML for file output.
void setProperties (const QXmlAttributes &attributes)
 Set the particular properties of a layer (those specific to the subclass) from a set of XML attributes.
virtual void setBaseColour (int)
virtual int getBaseColour () const
virtual bool hasLightBackground () const
virtual ColourSignificance getLayerColourSignificance () const
 This should return the degree of meaning associated with colour in this layer.
virtual QPixmap getLayerPresentationPixmap (QSize size) const
virtual QString getPropertyLabel (const PropertyName &) const =0
 Return the human-readable (and i18n'ised) name of a property.
virtual PropertyType getPropertyType (const PropertyName &) const
 Return the type of the given property, or InvalidProperty if the property is not supported on this container.
virtual QString getPropertyGroupName (const PropertyName &) const
virtual QString getPropertyGroupName (const PropertyName &) const
 If this property has something in common with other properties on this container, return a name that can be used to group them (in order to save screen space, for example).
virtual int getPropertyRangeAndValue (const PropertyName &, int *min, int *max, int *deflt) const
 Return the minimum and maximum values for the given property and its current value in this container.
virtual QString getPropertyValueLabel (const PropertyName &, int value) const
 If the given property is a ValueProperty, return the display label to be used for the given value for that property.
virtual RangeMappergetNewPropertyRangeMapper (const PropertyName &) const
virtual RangeMappergetNewPropertyRangeMapper (const PropertyName &) const
 If the given property is a RangeProperty, return a new RangeMapper object mapping its integer range onto an underlying floating point value range for human-intelligible display, if appropriate.
virtual void setDefaultColourFor (View *v)
virtual ModelgetModel ()
virtual const ZoomConstraintgetZoomConstraint () const
 Return a zoom constraint object defining the supported zoom levels for this layer.
virtual bool supportsOtherZoomLevels () const
 Return true if this layer can handle zoom levels other than those supported by its zoom constraint (presumably less efficiently or accurately than the officially supported zoom levels).
virtual VerticalPosition getPreferredTimeRulerPosition () const
virtual VerticalPosition getPreferredFrameCountPosition () const
virtual QString getPropertyContainerIconName () const
virtual QString getPropertyContainerName () const
virtual void setPresentationName (QString name)
virtual QString getLayerPresentationName () const
virtual int getVerticalScaleWidth (View *, QPainter &) const
virtual void paintVerticalScale (View *, QPainter &, QRect) const
virtual bool getCrosshairExtents (View *, QPainter &, QPoint, std::vector< QRect > &) const
virtual void paintCrosshairs (View *, QPainter &, QPoint) const
virtual void paintMeasurementRects (View *, QPainter &, bool showFocus, QPoint focusPoint) const
virtual bool nearestMeasurementRectChanged (View *, QPoint prev, QPoint now) const
virtual void measureStart (View *, QMouseEvent *)
virtual void measureDrag (View *, QMouseEvent *)
virtual void measureEnd (View *, QMouseEvent *)
virtual void measureDoubleClick (View *, QMouseEvent *)
virtual bool haveCurrentMeasureRect () const
virtual void deleteCurrentMeasureRect ()
virtual bool isLayerOpaque () const
 This should return true if the layer completely obscures any underlying layers.
virtual void setObjectName (const QString &name)
virtual void toBriefXml (QTextStream &stream, QString indent="", QString extraAttributes="") const
 Produce XML containing the layer's ID and type.
virtual void addMeasurementRect (const QXmlAttributes &)
 Add a measurement rectangle from the given XML attributes (presumably taken from a measurement element).
virtual void setLayerDormant (const View *v, bool dormant)
 Indicate that a layer is not currently visible in the given view and is not expected to become visible in the near future (for example because the user has explicitly removed or hidden it).
virtual bool isLayerDormant (const View *v) const
 Return whether the layer is dormant (i.e.
virtual PlayParametersgetPlayParameters ()
virtual bool needsTextLabelHeight () const
virtual bool hasTimeXAxis () const
virtual bool getDisplayExtents (float &, float &) const
 Return the minimum and maximum values within the displayed range for the y axis, if only a subset of the whole range of the model (returned by getValueExtents) is being displayed.
virtual bool setDisplayExtents (float, float)
 Set the displayed minimum and maximum values for the y axis to the given range, if supported.
virtual bool getXScaleValue (const View *v, int x, float &value, QString &unit) const
 Return the value and unit at the given x coordinate in the given view.
virtual bool getYScaleValue (const View *, int, float &, QString &) const
 Return the value and unit at the given y coordinate in the given view.
virtual bool getYScaleDifference (const View *v, int y0, int y1, float &diff, QString &unit) const
 Return the difference between the values at the given y coordinates in the given view, and the unit of the difference.
virtual int getVerticalZoomSteps (int &) const
 Get the number of vertical zoom steps available for this layer.
virtual int getCurrentVerticalZoomStep () const
 Get the current vertical zoom step.
virtual void setVerticalZoomStep (int)
 Set the vertical zoom step.
virtual RangeMappergetNewVerticalZoomRangeMapper () const
 Create and return a range mapper for vertical zoom step values.
virtual QString getPropertyIconName (const PropertyName &) const
 Return an icon for the property, if any.
virtual QString toXmlString (QString indent="", QString extraAttributes="") const
 Convert this exportable object to XML in a string.

Static Public Member Functions

static QString encodeEntities (QString)
static QString encodeColour (QColor)
static int getObjectExportId (const void *)

Protected Types

typedef std::map< int, int > ColourRefCount
typedef std::set< MeasureRect > MeasureRectSet

Protected Member Functions

int getYForHeight (View *v, float height) const
float getHeightForY (View *v, int y) const
virtual int getDefaultColourHint (bool dark, bool &impose)
TextModel::PointList getLocalPoints (View *v, int x, int y) const
virtual QColor getBaseQColor () const
virtual QColor getBackgroundQColor (View *v) const
virtual QColor getForegroundQColor (View *v) const
std::vector< QColor > getPartialShades (View *v) const
virtual void flagBaseColourChanged ()
void connectSignals (const Model *)
virtual size_t alignToReference (View *v, size_t frame) const
virtual size_t alignFromReference (View *v, size_t frame) const
bool clipboardHasDifferentAlignment (View *v, const Clipboard &clip) const
void addMeasureRectToSet (const MeasureRect &r)
void deleteMeasureRectFromSet (const MeasureRect &r)
void updateMeasurePixrects (View *v) const
virtual void updateMeasureRectYCoords (View *v, const MeasureRect &r) const
virtual void setMeasureRectYCoord (View *v, MeasureRect &r, bool start, int y) const
virtual void setMeasureRectFromPixrect (View *v, MeasureRect &r, QRect pixrect) const
MeasureRectSet::const_iterator findFocusedMeasureRect (QPoint) const
void paintMeasurementRect (View *v, QPainter &paint, const MeasureRect &r, bool focus) const
virtual bool convertPropertyStrings (QString nameString, QString valueString, PropertyName &name, int &value)

Protected Attributes

TextModelm_model
bool m_editing
QPoint m_editOrigin
TextModel::Point m_originalPoint
TextModel::Point m_editingPoint
TextModel::EditCommand * m_editingCommand
int m_colour
bool m_colourExplicitlySet
bool m_defaultColourSet
MeasureRectSet m_measureRects
MeasureRect m_draggingRect
bool m_haveDraggingRect
bool m_haveCurrentMeasureRect
QPoint m_currentMeasureRectPoint
QString m_presentationName

Static Protected Attributes

static ColourRefCount m_colourRefCount


Member Typedef Documentation

typedef std::map<int, int> SingleColourLayer::ColourRefCount [protected, inherited]

Definition at line 68 of file SingleColourLayer.h.

typedef std::set<MeasureRect> Layer::MeasureRectSet [protected, inherited]

Definition at line 529 of file Layer.h.

typedef QString PropertyContainer::PropertyName [inherited]

Definition at line 35 of file PropertyContainer.h.

typedef std::vector<PropertyName> PropertyContainer::PropertyList [inherited]

Definition at line 36 of file PropertyContainer.h.


Member Enumeration Documentation

enum Layer::VerticalPosition [inherited]

Enumerator:
PositionTop 
PositionMiddle 
PositionBottom 

Definition at line 79 of file Layer.h.

enum Layer::SnapType [inherited]

Enumerator:
SnapLeft 
SnapRight 
SnapNearest 
SnapNeighbouring 

Definition at line 123 of file Layer.h.

enum Layer::ColourSignificance [inherited]

Enumerator:
ColourAbsent 
ColourIrrelevant 
ColourDistinguishes 
ColourAndBackgroundSignificant 
ColourHasMeaningfulValue 

Definition at line 242 of file Layer.h.

enum PropertyContainer::PropertyType [inherited]

Enumerator:
ToggleProperty 
RangeProperty 
ValueProperty 
ColourProperty 
UnitsProperty 
InvalidProperty 

Definition at line 38 of file PropertyContainer.h.


Constructor & Destructor Documentation

TextLayer::TextLayer (  ) 

Definition at line 35 of file TextLayer.cpp.


Member Function Documentation

void TextLayer::paint ( View v,
QPainter &  paint,
QRect  rect 
) const [virtual]

Implements Layer.

Definition at line 281 of file TextLayer.cpp.

References View::getBackground(), SingleColourLayer::getBaseQColor(), View::getForeground(), View::getFrameForX(), getLocalPoints(), SparseModel< PointType >::getPoints(), SparseModel< PointType >::getSampleRate(), View::getXForFrame(), getYForHeight(), SparseModel< PointType >::isOK(), m_model, and View::shouldIlluminateLocalFeatures().

QString TextLayer::getFeatureDescription ( View v,
QPoint &   
) const [virtual]

Reimplemented from Layer.

Definition at line 157 of file TextLayer.cpp.

References RealTime::frame2RealTime(), getLocalPoints(), SparseModel< PointType >::getSampleRate(), View::getXForFrame(), getYForHeight(), SparseModel< PointType >::isReady(), m_model, and RealTime::toText().

bool TextLayer::snapToFeatureFrame ( View v,
int &  frame,
size_t &  resolution,
SnapType  snap 
) const [virtual]

!! too much overlap with TimeValueLayer/TimeInstantLayer

Reimplemented from Layer.

Definition at line 195 of file TextLayer.cpp.

References getLocalPoints(), SparseModel< PointType >::getPoints(), SparseModel< PointType >::getResolution(), View::getXForFrame(), m_model, Layer::SnapLeft, Layer::SnapNeighbouring, Layer::SnapRight, and Layer::snapToFeatureFrame().

void TextLayer::drawStart ( View v,
QMouseEvent *   
) [virtual]

Reimplemented from Layer.

Definition at line 383 of file TextLayer.cpp.

References View::getFrameForX(), getHeightForY(), SparseModel< PointType >::getResolution(), m_editing, m_editingCommand, m_editingPoint, m_model, and m_originalPoint.

void TextLayer::drawDrag ( View v,
QMouseEvent *   
) [virtual]

Reimplemented from Layer.

Definition at line 409 of file TextLayer.cpp.

References View::getFrameForX(), getHeightForY(), SparseModel< PointType >::getResolution(), m_editing, m_editingCommand, m_editingPoint, and m_model.

void TextLayer::drawEnd ( View v,
QMouseEvent *   
) [virtual]

Reimplemented from Layer.

Definition at line 428 of file TextLayer.cpp.

References m_editing, m_editingCommand, m_editingPoint, and m_model.

void TextLayer::eraseStart ( View v,
QMouseEvent *   
) [virtual]

Reimplemented from Layer.

Definition at line 452 of file TextLayer.cpp.

References getLocalPoints(), m_editing, m_editingCommand, m_editingPoint, and m_model.

void TextLayer::eraseDrag ( View v,
QMouseEvent *   
) [virtual]

Reimplemented from Layer.

Definition at line 470 of file TextLayer.cpp.

void TextLayer::eraseEnd ( View v,
QMouseEvent *   
) [virtual]

Reimplemented from Layer.

Definition at line 475 of file TextLayer.cpp.

References getLocalPoints(), m_editing, m_editingCommand, m_editingPoint, and m_model.

void TextLayer::editStart ( View v,
QMouseEvent *   
) [virtual]

Reimplemented from Layer.

Definition at line 497 of file TextLayer.cpp.

References getLocalPoints(), m_editing, m_editingCommand, m_editingPoint, m_editOrigin, m_model, and m_originalPoint.

void TextLayer::editDrag ( View v,
QMouseEvent *   
) [virtual]

Reimplemented from Layer.

Definition at line 519 of file TextLayer.cpp.

References View::getFrameForX(), getHeightForY(), SparseModel< PointType >::getResolution(), m_editing, m_editingCommand, m_editingPoint, m_editOrigin, m_model, and m_originalPoint.

void TextLayer::editEnd ( View v,
QMouseEvent *   
) [virtual]

Reimplemented from Layer.

Definition at line 546 of file TextLayer.cpp.

References m_editing, m_editingCommand, m_editingPoint, m_model, and m_originalPoint.

void TextLayer::moveSelection ( Selection  s,
size_t  newStartFrame 
) [virtual]

Reimplemented from Layer.

Definition at line 597 of file TextLayer.cpp.

References Selection::contains(), TextPoint::frame, Selection::getEndFrame(), SparseModel< PointType >::getPoints(), Selection::getStartFrame(), and m_model.

void TextLayer::resizeSelection ( Selection  s,
Selection  newSize 
) [virtual]

Reimplemented from Layer.

Definition at line 622 of file TextLayer.cpp.

References Selection::contains(), Selection::getEndFrame(), SparseModel< PointType >::getPoints(), Selection::getStartFrame(), and m_model.

void TextLayer::deleteSelection ( Selection  s  )  [virtual]

Reimplemented from Layer.

Definition at line 656 of file TextLayer.cpp.

References Selection::contains(), Selection::getEndFrame(), SparseModel< PointType >::getPoints(), Selection::getStartFrame(), and m_model.

void TextLayer::copy ( View v,
Selection  s,
Clipboard to 
) [virtual]

Reimplemented from Layer.

Definition at line 675 of file TextLayer.cpp.

References Clipboard::addPoint(), Layer::alignToReference(), Selection::contains(), Selection::getEndFrame(), SparseModel< PointType >::getPoints(), Selection::getStartFrame(), and m_model.

bool TextLayer::paste ( View v,
const Clipboard from,
int  frameOffset,
bool  interactive 
) [virtual]

Paste from the given clipboard onto the layer at the given frame offset.

If interactive is true, the layer may ask the user about paste options through a dialog if desired, and may return false if the user cancelled the paste operation. This function should return true if a paste actually occurred.

Reimplemented from Layer.

Definition at line 693 of file TextLayer.cpp.

References Layer::alignFromReference(), Layer::clipboardHasDifferentAlignment(), Clipboard::getPoints(), and m_model.

bool TextLayer::editOpen ( View v,
QMouseEvent *  e 
) [virtual]

Open an editor on the item under the mouse (e.g.

on double-click). If there is no item or editing is not supported, return false.

Reimplemented from Layer.

Definition at line 574 of file TextLayer.cpp.

References CommandHistory::addCommand(), CommandHistory::getInstance(), getLocalPoints(), and m_model.

virtual const Model* TextLayer::getModel (  )  const [inline, virtual]

Implements Layer.

Definition at line 65 of file TextLayer.h.

References m_model.

void TextLayer::setModel ( TextModel model  ) 

Definition at line 47 of file TextLayer.cpp.

References Layer::connectSignals(), m_model, and Layer::modelReplaced().

Layer::PropertyList TextLayer::getProperties (  )  const [virtual]

Get a list of the names of all the supported properties on this container.

These should be fixed (i.e. not internationalized).

Reimplemented from SingleColourLayer.

Definition at line 60 of file TextLayer.cpp.

References SingleColourLayer::getProperties().

QString TextLayer::getPropertyLabel ( const PropertyName  )  const [virtual]

Reimplemented from SingleColourLayer.

Definition at line 67 of file TextLayer.cpp.

References SingleColourLayer::getPropertyLabel().

Layer::PropertyType TextLayer::getPropertyType ( const PropertyName  )  const [virtual]

Reimplemented from SingleColourLayer.

Definition at line 73 of file TextLayer.cpp.

References SingleColourLayer::getPropertyType().

int TextLayer::getPropertyRangeAndValue ( const PropertyName ,
int *  min,
int *  max,
int *  deflt 
) const [virtual]

Reimplemented from SingleColourLayer.

Definition at line 79 of file TextLayer.cpp.

References SingleColourLayer::getPropertyRangeAndValue().

QString TextLayer::getPropertyValueLabel ( const PropertyName ,
int  value 
) const [virtual]

Reimplemented from SingleColourLayer.

Definition at line 86 of file TextLayer.cpp.

References SingleColourLayer::getPropertyValueLabel().

void TextLayer::setProperty ( const PropertyName ,
int  value 
) [virtual]

Reimplemented from SingleColourLayer.

Definition at line 93 of file TextLayer.cpp.

References SingleColourLayer::setProperty().

bool TextLayer::isLayerScrollable ( const View v  )  const [virtual]

This should return true if the layer can safely be scrolled automatically by a given view (simply copying the existing data and then refreshing the exposed area) without altering its meaning.

For the view widget as a whole this is usually not possible because of invariant (non-scrolling) material displayed over the top, but the widget may be able to optimise scrolling better if it is known that individual views can be scrolled safely in this way.

Reimplemented from Layer.

Definition at line 105 of file TextLayer.cpp.

References View::shouldIlluminateLocalFeatures().

virtual bool TextLayer::isLayerEditable (  )  const [inline, virtual]

This should return true if the layer can be edited by the user.

If this is the case, the appropriate edit tools may be made available by the application and the layer's drawStart/Drag/End and editStart/Drag/End methods should be implemented.

Reimplemented from Layer.

Definition at line 79 of file TextLayer.h.

virtual int TextLayer::getCompletion ( View  )  const [inline, virtual]

Return the proportion of background work complete in drawing this view, as a percentage -- in most cases this will be the value returned by pointer from a call to the underlying model's isReady(int *) call.

The view may choose to show a progress meter if it finds that this returns < 100 at any given moment.

Reimplemented from Layer.

Definition at line 81 of file TextLayer.h.

References SparseModel< PointType >::getCompletion(), and m_model.

bool TextLayer::getValueExtents ( float &  min,
float &  max,
bool &  logarithmic,
QString &  unit 
) const [virtual]

Return the minimum and maximum values for the y axis of the model in this layer, as well as whether the layer is configured to use a logarithmic y axis display.

Also return the unit for these values if known.

This function returns the "normal" extents for the layer, not necessarily the extents actually in use in the display.

Implements Layer.

Definition at line 99 of file TextLayer.cpp.

void TextLayer::toXml ( QTextStream &  stream,
QString  indent = "",
QString  extraAttributes = "" 
) const [virtual]

Convert the layer's data (though not those of the model it refers to) into XML for file output.

This class implements the basic name/type/model-id output; subclasses will typically call this superclass implementation with extra attributes describing their particular properties.

Reimplemented from SingleColourLayer.

Definition at line 783 of file TextLayer.cpp.

References SingleColourLayer::toXml().

void TextLayer::setProperties ( const QXmlAttributes &  attributes  )  [virtual]

Set the particular properties of a layer (those specific to the subclass) from a set of XML attributes.

This is the effective inverse of the toXml method.

Reimplemented from SingleColourLayer.

Definition at line 790 of file TextLayer.cpp.

References SingleColourLayer::setProperties().

int TextLayer::getYForHeight ( View v,
float  height 
) const [protected]

Definition at line 267 of file TextLayer.cpp.

Referenced by getFeatureDescription(), getLocalPoints(), and paint().

float TextLayer::getHeightForY ( View v,
int  y 
) const [protected]

Definition at line 274 of file TextLayer.cpp.

Referenced by drawDrag(), drawStart(), and editDrag().

int TextLayer::getDefaultColourHint ( bool  dark,
bool &  impose 
) [protected, virtual]

Reimplemented from SingleColourLayer.

Definition at line 775 of file TextLayer.cpp.

References ColourDatabase::getColourIndex(), and ColourDatabase::getInstance().

TextModel::PointList TextLayer::getLocalPoints ( View v,
int  x,
int  y 
) const [protected]

Definition at line 113 of file TextLayer.cpp.

References View::getFrameForX(), SparseModel< PointType >::getPoints(), View::getXForFrame(), getYForHeight(), and m_model.

Referenced by editOpen(), editStart(), eraseEnd(), eraseStart(), getFeatureDescription(), paint(), and snapToFeatureFrame().

void SingleColourLayer::setBaseColour ( int   )  [virtual, inherited]