qwt_legend_data.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  * Qwt Widget Library
3  * Copyright (C) 1997 Josef Wilgen
4  * Copyright (C) 2002 Uwe Rathmann
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the Qwt License, Version 1.0
8  *****************************************************************************/
9 
10 #include "qwt_legend_data.h"
11 #include "qwt_text.h"
12 #include "qwt_graphic.h"
13 
16 {
17 }
18 
21 {
22 }
23 
34 {
35  m_map = map;
36 }
37 
43 {
44  return m_map;
45 }
46 
51 bool QwtLegendData::hasRole( int role ) const
52 {
53  return m_map.contains( role );
54 }
55 
64 void QwtLegendData::setValue( int role, const QVariant& data )
65 {
66  m_map[role] = data;
67 }
68 
73 QVariant QwtLegendData::value( int role ) const
74 {
75  if ( !m_map.contains( role ) )
76  return QVariant();
77 
78  return m_map[role];
79 }
80 
83 {
84  return !m_map.isEmpty();
85 }
86 
89 {
90  QwtText text;
91 
92  const QVariant titleValue = value( QwtLegendData::TitleRole );
93  if ( titleValue.canConvert< QwtText >() )
94  {
95  text = qvariant_cast< QwtText >( titleValue );
96  }
97  else if ( titleValue.canConvert< QString >() )
98  {
99  text.setText( qvariant_cast< QString >( titleValue ) );
100  }
101 
102  return text;
103 }
104 
107 {
108  const QVariant iconValue = value( QwtLegendData::IconRole );
109 
110  QwtGraphic graphic;
111  if ( iconValue.canConvert< QwtGraphic >() )
112  {
113  graphic = qvariant_cast< QwtGraphic >( iconValue );
114  }
115 
116  return graphic;
117 }
118 
121 {
122  const QVariant modeValue = value( QwtLegendData::ModeRole );
123  if ( modeValue.canConvert< int >() )
124  {
125  const int mode = qvariant_cast< int >( modeValue );
126  return static_cast< QwtLegendData::Mode >( mode );
127  }
128 
130 }
131 
qwt_graphic.h
QwtLegendData::Mode
Mode
Mode defining how a legend entry interacts.
Definition: qwt_legend_data.h:40
QwtLegendData::icon
QwtGraphic icon() const
Definition: qwt_legend_data.cpp:106
QwtLegendData::value
QVariant value(int role) const
Definition: qwt_legend_data.cpp:73
QwtLegendData::~QwtLegendData
~QwtLegendData()
Destructor.
Definition: qwt_legend_data.cpp:20
QwtGraphic
A paint device for scalable graphics.
Definition: qwt_graphic.h:75
QwtLegendData::hasRole
bool hasRole(int role) const
Definition: qwt_legend_data.cpp:51
QwtLegendData::isValid
bool isValid() const
Definition: qwt_legend_data.cpp:82
QwtLegendData::TitleRole
@ TitleRole
Definition: qwt_legend_data.h:59
QwtLegendData::setValue
void setValue(int role, const QVariant &)
Definition: qwt_legend_data.cpp:64
qwt_legend_data.h
QwtLegendData::setValues
void setValues(const QMap< int, QVariant > &)
Definition: qwt_legend_data.cpp:33
QwtLegendData::values
const QMap< int, QVariant > & values() const
Definition: qwt_legend_data.cpp:42
QMap< int, QVariant >
QwtLegendData::mode
Mode mode() const
Definition: qwt_legend_data.cpp:120
QwtText
A class representing a text.
Definition: qwt_text.h:51
range_format::map
@ map
QwtLegendData::title
QwtText title() const
Definition: qwt_legend_data.cpp:88
QwtLegendData::QwtLegendData
QwtLegendData()
Constructor.
Definition: qwt_legend_data.cpp:15
mqtt_test.data
dictionary data
Definition: mqtt_test.py:22
QwtLegendData::ModeRole
@ ModeRole
Definition: qwt_legend_data.h:56
QwtLegendData::ReadOnly
@ ReadOnly
The legend item is not interactive, like a label.
Definition: qwt_legend_data.h:43
qwt_text.h
QwtLegendData::m_map
QMap< int, QVariant > m_map
Definition: qwt_legend_data.h:85
QwtLegendData::IconRole
@ IconRole
Definition: qwt_legend_data.h:62


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:45