labplot  2.8.2
About: LabPlot is an application for plotting and analysis of 2D and 3D functions and data. It is a complete rewrite of LabPlot1 and lacks in the first release a lot of features available in the predecessor. On the other hand, the GUI and the usability is more superior.
  Fossies Dox: labplot-2.8.2.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

TextLabel Class Reference

A label supporting rendering of html- and tex-formatted texts. More...

#include <TextLabel.h>

Inheritance diagram for TextLabel:
[legend]
Collaboration diagram for TextLabel:
[legend]

Classes

struct  TextWrapper
 

Public Types

enum class  Type { General , PlotTitle , AxisTitle , PlotLegendTitle }
 
enum class  BorderShape {
  NoBorder , Rect , Ellipse , RoundSideRect ,
  RoundCornerRect , InwardsRoundCornerRect , DentedBorderRect , Cuboid ,
  UpPointingRectangle , DownPointingRectangle , LeftPointingRectangle , RightPointingRectangle
}
 
typedef TextLabelPrivate Private
 
- Public Types inherited from WorksheetElement
enum class  Orientation { Horizontal , Vertical }
 
enum class  WorksheetElementName { NameCartesianPlot = 1 }
 
enum class  HorizontalPosition { Left , Center , Right , Custom }
 
enum class  VerticalPosition { Top , Center , Bottom , Custom }
 
enum class  HorizontalAlignment { Left , Center , Right }
 
enum class  VerticalAlignment { Top , Center , Bottom }
 
- Public Types inherited from AbstractAspect
enum class  ChildIndexFlag { IncludeHidden = 0x01 , Recursive = 0x02 , Compress = 0x04 }
 Flags which control numbering scheme of children. More...
 

Signals

void textWrapperChanged (const TextLabel::TextWrapper &)
 
void teXFontSizeChanged (const int)
 
void teXFontChanged (const QFont)
 
void fontColorChanged (const QColor)
 
void backgroundColorChanged (const QColor)
 
void positionChanged (const WorksheetElement::PositionWrapper &)
 
void horizontalAlignmentChanged (WorksheetElement::HorizontalAlignment)
 
void verticalAlignmentChanged (WorksheetElement::VerticalAlignment)
 
void rotationAngleChanged (qreal)
 
void visibleChanged (bool)
 
void borderShapeChanged (TextLabel::BorderShape)
 
void borderPenChanged (QPen &)
 
void borderOpacityChanged (float)
 
void teXImageUpdated (bool)
 
void changed ()
 
- Signals inherited from AbstractAspect
void aspectDescriptionAboutToChange (const AbstractAspect *)
 Emitted before the name, comment or caption spec is changed. More...
 
void aspectDescriptionChanged (const AbstractAspect *)
 Emitted after the name, comment or caption spec have changed. More...
 
void aspectAboutToBeAdded (const AbstractAspect *parent, const AbstractAspect *before, const AbstractAspect *child)
 Emitted before a new child is inserted. More...
 
void aspectAdded (const AbstractAspect *)
 Emitted after a new Aspect has been added to the tree. More...
 
void aspectAboutToBeRemoved (const AbstractAspect *)
 Emitted before an aspect is removed from its parent. More...
 
void aspectRemoved (const AbstractAspect *parent, const AbstractAspect *before, const AbstractAspect *child)
 Emitted from the parent after removing a child. More...
 
void aspectHiddenAboutToChange (const AbstractAspect *)
 Emitted before the hidden attribute is changed. More...
 
void aspectHiddenChanged (const AbstractAspect *)
 Emitted after the hidden attribute has changed. More...
 
void statusInfo (const QString &)
 Emitted whenever some aspect in the tree wants to give status information to the user. More...
 
void renameRequested ()
 
void selected (const AbstractAspect *)
 
void deselected (const AbstractAspect *)
 
void childAspectSelectedInView (const AbstractAspect *)
 
void childAspectDeselectedInView (const AbstractAspect *)
 

Public Member Functions

 TextLabel (const QString &name, Type type=Type::General)
 
 ~TextLabel () override
 
Type type () const
 
QIcon icon () const override
 
QMenu * createContextMenu () override
 Return a new context menu. More...
 
QGraphicsItem * graphicsItem () const override
 Return the graphics item representing this element. More...
 
void setParentGraphicsItem (QGraphicsItem *)
 
void save (QXmlStreamWriter *) const override
 Save as XML. More...
 
bool load (XmlStreamReader *, bool preview) override
 Load from XML. More...
 
void loadThemeConfig (const KConfig &) override
 
void saveThemeConfig (const KConfig &) override
 
void setPosition (QPointF)
 
void setPositionInvalid (bool)
 
 BASIC_D_ACCESSOR_DECL (BorderShape, borderShape, BorderShape)
 
void setVisible (bool on) override
 Show/hide the element. More...
 
bool isVisible () const override
 Return whether the element is (at least) partially visible. More...
 
void setPrinting (bool) override
 Switches the printing mode on/off. More...
 
void retransform () override
 Tell the element to newly transform its graphics item into its coordinate system. More...
 
void handleResize (double horizontalRatio, double verticalRatio, bool pageResize) override
 
- Public Member Functions inherited from WorksheetElement
 WorksheetElement (const QString &, AspectType)
 
 ~WorksheetElement () override
 
virtual void setZValue (qreal)
 
virtual bool isFullyVisible () const
 Return whether the element is fully visible (i.e., including all child elements). More...
 
QMenu * createContextMenu () override
 Return a new context menu. More...
 
void horizontalPaddingChanged (float)
 
void verticalPaddingChanged (float)
 
void rightPaddingChanged (double)
 
void bottomPaddingChanged (double)
 
void symmetricPaddingChanged (double)
 
void hovered ()
 
void unhovered ()
 
- Public Member Functions inherited from AbstractAspect
 AbstractAspect (const QString &name, AspectType type)
 
 ~AbstractAspect () override
 
QString name () const
 
QString comment () const
 
void setCreationTime (const QDateTime &)
 
QDateTime creationTime () const
 
virtual Projectproject ()
 Return the Project this Aspect belongs to, or 0 if it is currently not part of one. More...
 
virtual QString path () const
 Return the path that leads from the top-most Aspect (usually a Project) to me. More...
 
void setHidden (bool)
 Set "hidden" property, i.e. whether to exclude this aspect from being shown in the explorer. More...
 
bool hidden () const
 
void setIsLoading (bool)
 
bool isLoading () const
 
AspectType type () const
 
bool inherits (AspectType type) const
 
AbstractAspectparentAspect () const
 Return my parent Aspect or 0 if I currently don't have one. More...
 
AbstractAspectparent (AspectType type) const
 In the parent-child hierarchy, return the first parent of type. More...
 
void setParentAspect (AbstractAspect *)
 
Folderfolder ()
 Return the folder the Aspect is contained in or 0 if there is none. More...
 
bool isDescendantOf (AbstractAspect *other)
 Return whether the there is a path upwards to the given aspect. More...
 
void addChild (AbstractAspect *)
 Add the given Aspect to my list of children. More...
 
void addChildFast (AbstractAspect *)
 Add the given Aspect to my list of children without any checks and without putting this step onto the undo-stack. More...
 
virtual void finalizeAdd ()
 
QVector< AbstractAspect * > children (AspectType type, ChildIndexFlags flags={}) const
 
void insertChildBefore (AbstractAspect *child, AbstractAspect *before)
 Insert the given Aspect at a specific position in my list of children. More...
 
void insertChildBeforeFast (AbstractAspect *child, AbstractAspect *before)
 Insert the given Aspect at a specific position in my list of children.without any checks and without putting this step onto the undo-stack. More...
 
void reparent (AbstractAspect *newParent, int newIndex=-1)
 Move a child to another parent aspect and transfer ownership. More...
 
void removeChild (AbstractAspect *)
 Remove the given Aspect from my list of children. More...
 
void removeAllChildren ()
 Remove all child Aspects. More...
 
virtual QVector< AbstractAspect * > dependsOn () const
 
virtual bool isDraggable () const
 
virtual QVector< AspectTypedropableOn () const
 
virtual void processDropEvent (const QVector< quintptr > &)
 
template<class T >
T * ancestor () const
 Return the closest ancestor of class T (or NULL if none found). More...
 
template<class T >
QVector< T * > children (ChildIndexFlags flags={}) const
 
template<class T >
T * child (int index, ChildIndexFlags flags={}) const
 
template<class T >
T * child (const QString &name) const
 Get child by name and class. More...
 
template<class T >
int childCount (ChildIndexFlags flags={}) const
 Return the number of child Aspects inheriting from given class. More...
 
template<class T >
int indexOfChild (const AbstractAspect *child, ChildIndexFlags flags={}) const
 Return (0 based) index of child in the list of children inheriting from class T. More...
 
void setSelected (bool)
 
void setUndoAware (bool)
 
virtual QUndoStack * undoStack () const
 Return the undo stack of the Project, or 0 if this Aspect is not part of a Project. More...
 
void exec (QUndoCommand *)
 Execute the given command, pushing it on the undoStack() if available. More...
 
void exec (QUndoCommand *command, const char *preChangeSignal, const char *postChangeSignal, QGenericArgument val0=QGenericArgument(), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument())
 Execute command and arrange for signals to be sent before/after it is redone or undone. More...
 
void beginMacro (const QString &text)
 Begin an undo stack macro (series of commands) More...
 
void endMacro ()
 End the current undo stack macro. More...
 

Protected Member Functions

 TextLabel (const QString &name, TextLabelPrivate *dd, Type type=Type::General)
 
- Protected Member Functions inherited from AbstractAspect
void info (const QString &text)
 Implementations should call this whenever status information should be given to the user. More...
 
bool readBasicAttributes (XmlStreamReader *)
 Load name and creation time from XML. More...
 
void writeBasicAttributes (QXmlStreamWriter *) const
 Save name and creation time to XML. More...
 
void writeCommentElement (QXmlStreamWriter *) const
 Save the comment to XML. More...
 
bool readCommentElement (XmlStreamReader *)
 Load comment from an XML element. More...
 

Protected Attributes

TextLabelPrivate *const d_ptr
 
- Protected Attributes inherited from AbstractAspect
const AspectType m_type
 

Private Slots

void updateTeXImage ()
 
void visibilityChanged ()
 

Private Member Functions

void init ()
 

Private Attributes

Type m_type
 
QAction * visibilityAction {nullptr}
 

Additional Inherited Members

- Public Slots inherited from WorksheetElement
- Public Slots inherited from AbstractAspect
bool setName (const QString &, bool autoUnique=true)
 AbstractAspect::setName sets the name of the abstract aspect. More...
 
void setComment (const QString &)
 
void remove ()
 Remove me from my parent's list of children. More...
 
- Static Public Member Functions inherited from WorksheetElement
static QPainterPath shapeFromPath (const QPainterPath &, const QPen &)
 
- Protected Slots inherited from AbstractAspect
virtual void childSelected (const AbstractAspect *)
 
virtual void childDeselected (const AbstractAspect *)
 

Detailed Description

A label supporting rendering of html- and tex-formatted texts.

File : TextLabel.cpp Project : LabPlot

Description : Text label supporting reach text and latex formatting

Copyright : (C) 2009 Tilman Benkert (thzs@.nosp@m.gmx..nosp@m.net) Copyright : (C) 2012-2018 Alexander Semke (alexa.nosp@m.nder.nosp@m..semk.nosp@m.e@we.nosp@m.b.de) Copyright : (C) 2019 by Stefan Gerlach (stefa.nosp@m.n.ge.nosp@m.rlach.nosp@m.@uni.nosp@m..kn)

  • This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. *
  • This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. *
  • You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA *

The label is aligned relative to the specified position. The position can be either specified by providing the x- and y- coordinates in parent's coordinate system, or by specifying one of the predefined position flags (HorizontalPosition, VerticalPosition).

Definition at line 44 of file TextLabel.h.

Member Typedef Documentation

◆ Private

Definition at line 113 of file TextLabel.h.

Member Enumeration Documentation

◆ BorderShape

Enumerator
NoBorder 
Rect 
Ellipse 
RoundSideRect 
RoundCornerRect 
InwardsRoundCornerRect 
DentedBorderRect 
Cuboid 
UpPointingRectangle 
DownPointingRectangle 
LeftPointingRectangle 
RightPointingRectangle 

Definition at line 49 of file TextLabel.h.

◆ Type

enum TextLabel::Type
strong
Enumerator
General 
PlotTitle 
AxisTitle 
PlotLegendTitle 

Definition at line 48 of file TextLabel.h.

Constructor & Destructor Documentation

◆ TextLabel() [1/2]

TextLabel::TextLabel ( const QString &  name,
Type  type = Type::General 
)
explicit

Definition at line 64 of file TextLabel.cpp.

References init().

◆ ~TextLabel()

TextLabel::~TextLabel ( )
overridedefault

◆ TextLabel() [2/2]

TextLabel::TextLabel ( const QString &  name,
TextLabelPrivate dd,
Type  type = Type::General 
)
protected

Definition at line 70 of file TextLabel.cpp.

References init().

Member Function Documentation

◆ backgroundColorChanged

void TextLabel::backgroundColorChanged ( const  QColor)
signal

◆ BASIC_D_ACCESSOR_DECL()

TextLabel::BASIC_D_ACCESSOR_DECL ( BorderShape  ,
borderShape  ,
BorderShape   
)

◆ borderOpacityChanged

void TextLabel::borderOpacityChanged ( float  )
signal

◆ borderPenChanged

void TextLabel::borderPenChanged ( QPen &  )
signal

◆ borderShapeChanged

void TextLabel::borderShapeChanged ( TextLabel::BorderShape  )
signal

◆ changed

◆ createContextMenu()

QMenu * TextLabel::createContextMenu ( )
overridevirtual

Return a new context menu.

The caller takes ownership of the menu.

Reimplemented from AbstractAspect.

Definition at line 204 of file TextLabel.cpp.

References WorksheetElement::createContextMenu(), i18n, isVisible(), visibilityAction, and visibilityChanged().

Referenced by TextLabelPrivate::contextMenuEvent().

◆ fontColorChanged

void TextLabel::fontColorChanged ( const  QColor)
signal

◆ graphicsItem()

QGraphicsItem * TextLabel::graphicsItem ( ) const
overridevirtual

Return the graphics item representing this element.

Implements WorksheetElement.

Definition at line 156 of file TextLabel.cpp.

References d_ptr.

Referenced by CartesianPlotLegendPrivate::paint(), AxisPrivate::recalcShapeAndBoundingRect(), and CartesianPlotLegendPrivate::retransform().

◆ handleResize()

void TextLabel::handleResize ( double  horizontalRatio,
double  verticalRatio,
bool  pageResize 
)
overridevirtual

Implements WorksheetElement.

Definition at line 171 of file TextLabel.cpp.

References AbstractAspect::d, and DEBUG.

◆ horizontalAlignmentChanged

void TextLabel::horizontalAlignmentChanged ( WorksheetElement::HorizontalAlignment  )
signal

◆ icon()

QIcon TextLabel::icon ( ) const
overridevirtual

Returns an icon to be used in the project explorer.

Reimplemented from AbstractAspect.

Definition at line 200 of file TextLabel.cpp.

◆ init()

◆ isVisible()

bool TextLabel::isVisible ( ) const
overridevirtual

Return whether the element is (at least) partially visible.

Implements WorksheetElement.

Definition at line 343 of file TextLabel.cpp.

References AbstractAspect::d.

Referenced by createContextMenu(), LabelWidget::load(), CartesianPlotLegendPrivate::paint(), AxisPrivate::recalcShapeAndBoundingRect(), and CartesianPlotLegendPrivate::retransform().

◆ load()

◆ loadThemeConfig()

void TextLabel::loadThemeConfig ( const KConfig &  config)
overridevirtual

◆ positionChanged

◆ retransform()

void TextLabel::retransform ( )
overridevirtual

Tell the element to newly transform its graphics item into its coordinate system.

This method must not change the undo-aware data of the element, only the graphics item which represents the item is to be updated.

Implements WorksheetElement.

Definition at line 166 of file TextLabel.cpp.

References AbstractAspect::d.

Referenced by load(), CartesianPlotPrivate::retransform(), and CartesianPlotLegendPrivate::updatePosition().

◆ rotationAngleChanged

void TextLabel::rotationAngleChanged ( qreal  )
signal

◆ save()

void TextLabel::save ( QXmlStreamWriter *  writer) const
overridevirtual

◆ saveThemeConfig()

void TextLabel::saveThemeConfig ( const KConfig &  config)
overridevirtual

Reimplemented from WorksheetElement.

Definition at line 1117 of file TextLabel.cpp.

◆ setParentGraphicsItem()

void TextLabel::setParentGraphicsItem ( QGraphicsItem *  item)

◆ setPosition()

◆ setPositionInvalid()

void TextLabel::setPositionInvalid ( bool  invalid)

position is set to invalid if the parent item is not drawn on the scene (e.g. axis is not drawn because it's outside plot ranges -> don't draw axis' title label)

Definition at line 287 of file TextLabel.cpp.

References AbstractAspect::d.

Referenced by AxisPrivate::recalcShapeAndBoundingRect().

◆ setPrinting()

void TextLabel::setPrinting ( bool  on)
overridevirtual

Switches the printing mode on/off.

Implements WorksheetElement.

Definition at line 348 of file TextLabel.cpp.

References AbstractAspect::d.

◆ setVisible()

void TextLabel::setVisible ( bool  on)
overridevirtual

Show/hide the element.

Implements WorksheetElement.

Definition at line 338 of file TextLabel.cpp.

References AbstractAspect::d, and AbstractAspect::exec().

Referenced by visibilityChanged().

◆ teXFontChanged

void TextLabel::teXFontChanged ( const  QFont)
signal

◆ teXFontSizeChanged

void TextLabel::teXFontSizeChanged ( const int  )
signal

◆ teXImageUpdated

void TextLabel::teXImageUpdated ( bool  )
signal

◆ textWrapperChanged

void TextLabel::textWrapperChanged ( const TextLabel::TextWrapper )
signal

◆ type()

TextLabel::Type TextLabel::type ( ) const

Definition at line 76 of file TextLabel.cpp.

References m_type.

◆ updateTeXImage

void TextLabel::updateTeXImage ( )
privateslot

Definition at line 353 of file TextLabel.cpp.

References AbstractAspect::d.

Referenced by init().

◆ verticalAlignmentChanged

void TextLabel::verticalAlignmentChanged ( WorksheetElement::VerticalAlignment  )
signal

◆ visibilityChanged

void TextLabel::visibilityChanged ( )
privateslot

Definition at line 361 of file TextLabel.cpp.

References AbstractAspect::d, and setVisible().

Referenced by createContextMenu().

◆ visibleChanged

void TextLabel::visibleChanged ( bool  )
signal

Member Data Documentation

◆ d_ptr

TextLabelPrivate* const TextLabel::d_ptr
protected

Definition at line 122 of file TextLabel.h.

Referenced by graphicsItem().

◆ m_type

Type TextLabel::m_type
private

Definition at line 129 of file TextLabel.h.

Referenced by init(), and type().

◆ visibilityAction

QAction* TextLabel::visibilityAction {nullptr}
private

Definition at line 130 of file TextLabel.h.

Referenced by createContextMenu().


The documentation for this class was generated from the following files: