object representing a text that is drawn as an overlay More...
#include <QmitkScalarBarOverlay.h>
Public Member Functions | |
QmitkScalarBarOverlay (const char *id) | |
Default Constructor. | |
virtual | ~QmitkScalarBarOverlay () |
Default Destructor. | |
virtual void | GenerateData (mitk::PropertyList::Pointer) |
Setup the QLabel with overlay specific information. | |
virtual QWidget * | GetWidget () |
returns the QLabel* that internally represents the TextOverlay | |
Protected Member Functions | |
void | GetProperties (mitk::PropertyList::Pointer) |
internal helper class to determine text-properties | |
void | SetupCallback (mitk::BaseProperty::Pointer prop) |
void | SetScaleFactor () |
Protected Attributes | |
QmitkScalarBar * | m_Widget |
QWidget internally representing the TextOverlay. | |
mitk::PropertyList::Pointer | m_PropertyList |
object representing a text that is drawn as an overlay
Definition at line 38 of file QmitkScalarBarOverlay.h.
QmitkScalarBarOverlay::QmitkScalarBarOverlay | ( | const char * | id ) |
Default Constructor.
Definition at line 29 of file QmitkScalarBarOverlay.cpp.
References m_Widget.
: QmitkOverlay(id), m_Widget( NULL ) { m_Widget = new QmitkScalarBar(); m_Widget->setStyleSheet(""); }
QmitkScalarBarOverlay::~QmitkScalarBarOverlay | ( | ) | [virtual] |
Default Destructor.
Definition at line 36 of file QmitkScalarBarOverlay.cpp.
References m_Widget.
{ m_Widget = NULL; }
void QmitkScalarBarOverlay::GenerateData | ( | mitk::PropertyList::Pointer | pl ) | [virtual] |
Setup the QLabel with overlay specific information.
First, this method sets text-overlay specific properties as described in the class docu above. Secondly, the actual text of the label is set.
No error will be issued if the property containing the text is not found, the TextOverlay will show an empty string!
Reimplemented from QmitkOverlay.
Definition at line 41 of file QmitkScalarBarOverlay.cpp.
References GetProperties(), QmitkOverlay::m_Id, m_PropertyList, MITK_ERROR, SetScaleFactor(), and SetupCallback().
{ if ( pl.IsNull() ) return; m_PropertyList = pl; if ( m_PropertyList.IsNotNull() ) { this->SetupCallback( m_PropertyList->GetProperty( m_Id ) ); this->GetProperties( pl ); this->SetScaleFactor(); } else { MITK_ERROR << "invalid propList"; } }
void QmitkScalarBarOverlay::GetProperties | ( | mitk::PropertyList::Pointer | pl ) | [protected] |
internal helper class to determine text-properties
This method is only used internally to apply the text specific properties that can be set using a mitk::PropertyList. If a property cannot be found, a default value is used.
The values of these properties are then attributed to the label using QFont and QPalette.
Definition at line 73 of file QmitkScalarBarOverlay.cpp.
References m_Widget, MITK_ERROR, mitk::ColorProperty::New(), and QmitkScalarBar::SetPen().
Referenced by GenerateData().
{ if ( pl.IsNull() ) return; QPen pen = QPen(); mitk::PropertyList::Pointer propertyList = pl; QPalette palette = QPalette(); // get the desired color of the textOverlays mitk::ColorProperty::Pointer colorProp = dynamic_cast<mitk::ColorProperty*>( propertyList->GetProperty( "overlay.color" ) ); if ( colorProp.IsNull() ) { MITK_ERROR << "creating new colorProperty"; colorProp = mitk::ColorProperty::New( 127.0, 196.0, 232.0 ); } mitk::Color color = colorProp->GetColor(); pen.setColor( QColor( color[0],color[1],color[2],255 ) ); pen.setStyle( Qt::SolidLine ); pen.setCapStyle( Qt::FlatCap ); pen.setJoinStyle( Qt::MiterJoin ); m_Widget->SetPen( pen ); }
QWidget * QmitkScalarBarOverlay::GetWidget | ( | ) | [virtual] |
returns the QLabel* that internally represents the TextOverlay
Reimplemented from QmitkOverlay.
Definition at line 103 of file QmitkScalarBarOverlay.cpp.
References m_Widget.
{ return m_Widget; }
void QmitkScalarBarOverlay::SetScaleFactor | ( | ) | [protected] |
Definition at line 62 of file QmitkScalarBarOverlay.cpp.
References QmitkOverlay::m_Id, m_PropertyList, m_Widget, MITK_WARN, and QmitkScalarBar::SetScaleFactor().
Referenced by GenerateData(), and SetupCallback().
{ float scale = 2; if ( m_PropertyList.IsNull() || !m_PropertyList->GetFloatProperty( m_Id, scale ) ) { MITK_WARN << "Property " << m_Id << " could not be found"; } m_Widget->SetScaleFactor( scale ); }
void QmitkScalarBarOverlay::SetupCallback | ( | mitk::BaseProperty::Pointer | prop ) | [protected] |
Definition at line 109 of file QmitkScalarBarOverlay.cpp.
References MITK_ERROR, and SetScaleFactor().
Referenced by GenerateData().
{ if ( prop.IsNotNull() ) { typedef itk::SimpleMemberCommand< QmitkScalarBarOverlay > MemberCommandType; MemberCommandType::Pointer propModifiedCommand; propModifiedCommand = MemberCommandType::New(); propModifiedCommand->SetCallbackFunction( this, &QmitkScalarBarOverlay::SetScaleFactor ); prop->AddObserver( itk::ModifiedEvent(), propModifiedCommand ); } else { MITK_ERROR << "invalid property"; } }
Definition at line 89 of file QmitkScalarBarOverlay.h.
Referenced by GenerateData(), and SetScaleFactor().
QmitkScalarBar* QmitkScalarBarOverlay::m_Widget [protected] |
QWidget internally representing the TextOverlay.
Reimplemented from QmitkOverlay.
Definition at line 87 of file QmitkScalarBarOverlay.h.
Referenced by GetProperties(), GetWidget(), QmitkScalarBarOverlay(), SetScaleFactor(), and ~QmitkScalarBarOverlay().