Public Member Functions | Protected Member Functions | Protected Attributes | Properties

QmitkNumberPropertyView Class Reference
[Widgets]

#include <QmitkNumberPropertyView.h>

Inheritance diagram for QmitkNumberPropertyView:
Inheritance graph
[legend]
Collaboration diagram for QmitkNumberPropertyView:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 QmitkNumberPropertyView (const mitk::IntProperty *, QWidget *parent)
 QmitkNumberPropertyView (const mitk::FloatProperty *, QWidget *parent)
 QmitkNumberPropertyView (const mitk::DoubleProperty *, QWidget *parent)
virtual ~QmitkNumberPropertyView ()
short decimalPlaces () const
void setDecimalPlaces (short)
QString suffix () const
void setSuffix (const QString &)
bool showPercent () const
void setShowPercent (bool)

Protected Member Functions

void initialize ()
virtual void PropertyChanged ()
virtual void PropertyRemoved ()
void DisplayNumber ()

Protected Attributes

union {
   const mitk::GenericProperty
< int > *   m_IntProperty
   const mitk::GenericProperty
< float > *   m_FloatProperty
   const mitk::GenericProperty
< double > *   m_DoubleProperty
}; 
const int m_DataType
short m_DecimalPlaces
QString m_Suffix
 -1 indicates "no limit to decimal places"
double m_DisplayFactor

Properties

short decimalPlaces
QString suffix
bool showPercent

Detailed Description

Definition at line 26 of file QmitkNumberPropertyView.h.


Constructor & Destructor Documentation

QmitkNumberPropertyView::QmitkNumberPropertyView ( const mitk::IntProperty property,
QWidget *  parent 
)

Definition at line 34 of file QmitkNumberPropertyView.cpp.

References initialize().

: QLabel( parent ),
  PropertyView( property ),
  m_IntProperty(property),
  m_DataType(DT_INT)
{
  initialize();
}
QmitkNumberPropertyView::QmitkNumberPropertyView ( const mitk::FloatProperty property,
QWidget *  parent 
)

Definition at line 43 of file QmitkNumberPropertyView.cpp.

References initialize().

: QLabel( parent ),
  PropertyView( property ),
  m_FloatProperty(property),
  m_DataType(DT_FLOAT)
{
  initialize();
}
QmitkNumberPropertyView::QmitkNumberPropertyView ( const mitk::DoubleProperty property,
QWidget *  parent 
)

Definition at line 52 of file QmitkNumberPropertyView.cpp.

References initialize().

: QLabel( parent ),
  PropertyView( property ),
  m_DoubleProperty(property),
  m_DataType(DT_DOUBLE)
{
  initialize();
}
QmitkNumberPropertyView::~QmitkNumberPropertyView (  ) [virtual]

Definition at line 61 of file QmitkNumberPropertyView.cpp.

{
}

Member Function Documentation

short QmitkNumberPropertyView::decimalPlaces (  ) const
void QmitkNumberPropertyView::DisplayNumber (  ) [protected]

Definition at line 143 of file QmitkNumberPropertyView.cpp.

References DT_DOUBLE, DT_FLOAT, DT_INT, mitk::GenericProperty< T >::GetValue(), m_DataType, m_DecimalPlaces, m_DisplayFactor, m_DoubleProperty, m_FloatProperty, and m_IntProperty.

Referenced by PropertyChanged(), setDecimalPlaces(), and setSuffix().

{
  QString displayedText;
  QTextStream stream(&displayedText);

  stream.setRealNumberPrecision(m_DecimalPlaces);
  
  switch (m_DataType)
  {
        /*
    case DT_SHORT:
      {
        short s = m_ShortProperty->GetValue();
        displayedText.sprintf(m_FormatString, s * m_DisplayFactor);
        break;
      }
    */
    case DT_INT:
      {
        int i = m_IntProperty->GetValue();
        stream << (i * m_DisplayFactor);
        break;
      }
    case DT_FLOAT:
      {
        float f = m_FloatProperty->GetValue();
        stream << (f * m_DisplayFactor);
        break;
      }
    case DT_DOUBLE:
      {
        double d = m_DoubleProperty->GetValue();
        stream << (d * m_DisplayFactor);
        break;
      }
    default:
      break;
  }
    
  setText( displayedText );
}
void QmitkNumberPropertyView::initialize (  ) [protected]

Definition at line 65 of file QmitkNumberPropertyView.cpp.

References m_DisplayFactor, m_Suffix, and setDecimalPlaces().

Referenced by QmitkNumberPropertyView().

{ // only to be called from constructors
  m_Suffix = "";
  m_DisplayFactor = 1.0;
  //setDecimalPlaces(-1); // unlimited
  setDecimalPlaces(2);
}
void QmitkNumberPropertyView::PropertyChanged (  ) [protected, virtual]
void QmitkNumberPropertyView::PropertyRemoved (  ) [protected, virtual]

Implements mitk::PropertyObserver.

Definition at line 137 of file QmitkNumberPropertyView.cpp.

References mitk::PropertyView::m_Property.

{
  m_Property = NULL;
  setText("n/a");
}
void QmitkNumberPropertyView::setDecimalPlaces ( short  places )

Definition at line 78 of file QmitkNumberPropertyView.cpp.

References DisplayNumber(), and m_DecimalPlaces.

Referenced by initialize().

{
  m_DecimalPlaces = places;
  
//  if (m_DecimalPlaces >= 0)
//  {
//    m_FormatString = "%%.%if";  
//    m_FormatString.sprintf(QString(m_FormatString), m_DecimalPlaces); // do copy before sprintf
//  }
//  else
//  {
//    m_FormatString = "%g";  
//  }
  
  DisplayNumber();
}
void QmitkNumberPropertyView::setShowPercent ( bool  show )

Definition at line 115 of file QmitkNumberPropertyView.cpp.

References m_DisplayFactor, and setSuffix().

{
  if (show)
  {
    m_DisplayFactor = 100.0;
    setSuffix("%");
  }
  else
  {
    m_DisplayFactor = 1.0;
    setSuffix("");
  }
  
  //DisplayNumber(); // gets called in setSuffix
}
void QmitkNumberPropertyView::setSuffix ( const QString &  suffix )

Definition at line 103 of file QmitkNumberPropertyView.cpp.

References DisplayNumber(), m_Suffix, and suffix().

Referenced by setShowPercent().

bool QmitkNumberPropertyView::showPercent (  ) const
QString QmitkNumberPropertyView::suffix (  ) const

Referenced by setSuffix().


Member Data Documentation

union { ... } [protected]
const int QmitkNumberPropertyView::m_DataType [protected]

Definition at line 67 of file QmitkNumberPropertyView.h.

Referenced by DisplayNumber().

Definition at line 69 of file QmitkNumberPropertyView.h.

Referenced by DisplayNumber(), and setDecimalPlaces().

Definition at line 71 of file QmitkNumberPropertyView.h.

Referenced by DisplayNumber(), initialize(), and setShowPercent().

Definition at line 64 of file QmitkNumberPropertyView.h.

Referenced by DisplayNumber().

Definition at line 63 of file QmitkNumberPropertyView.h.

Referenced by DisplayNumber().

Definition at line 62 of file QmitkNumberPropertyView.h.

Referenced by DisplayNumber().

QString QmitkNumberPropertyView::m_Suffix [protected]

-1 indicates "no limit to decimal places"

Definition at line 70 of file QmitkNumberPropertyView.h.

Referenced by initialize(), and setSuffix().


Property Documentation

short QmitkNumberPropertyView::decimalPlaces [read, write]

Definition at line 29 of file QmitkNumberPropertyView.h.

bool QmitkNumberPropertyView::showPercent [read, write]

Definition at line 31 of file QmitkNumberPropertyView.h.

QString QmitkNumberPropertyView::suffix [read, write]

Definition at line 30 of file QmitkNumberPropertyView.h.


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