Public Slots | Public Member Functions | Protected Slots | Protected Attributes

QmitkNewSegmentationDialog Class Reference
[Classes related to InteractiveSegmentationWidgets]

Dialog for QmitkInteractiveSegmentation. More...

#include <QmitkNewSegmentationDialog.h>

List of all members.

Public Slots

void setPrompt (const QString &prompt)
void setSegmentationName (const QString &name)

Public Member Functions

 QmitkNewSegmentationDialog (QWidget *parent=0)
virtual ~QmitkNewSegmentationDialog ()
const QString GetSegmentationName ()
const char * GetOrganType ()
mitk::Color GetColor ()
void SetSuggestionList (QStringList organColorList)

Protected Slots

void onAcceptClicked ()
void onNewOrganNameChanged (const QString &)
void onColorBtnClicked ()
void onColorChange (const QString &completedWord)

Protected Attributes

QLabel * lblPrompt
Q3ListBox * lstOrgans
QLineEdit * edtName
QPushButton * btnColor
QPushButton * btnOk
QLineEdit * edtNewOrgan
QString selectedOrgan
bool newOrganEntry
QColor m_Color
QCompleter * completer
QString m_SegmentationName
QStringList organList
QList< QColor > colorList

Detailed Description

Dialog for QmitkInteractiveSegmentation.

This dialog is used to ask a user about the type of a newly created segmentation and a name for it.

Warning:
Will not create a new organ type in the OrganTypeProperty. Client has to do that.

Last contribution by

Author:
maleike

.

Definition at line 47 of file QmitkNewSegmentationDialog.h.


Constructor & Destructor Documentation

QmitkNewSegmentationDialog::QmitkNewSegmentationDialog ( QWidget *  parent = 0 )

Definition at line 34 of file QmitkNewSegmentationDialog.cpp.

References btnColor, btnOk, completer, edtName, lblPrompt, mitk::OrganTypeProperty::New(), onAcceptClicked(), onColorBtnClicked(), and onColorChange().

:QDialog(parent), // true, modal
 selectedOrgan("undefined"),
 newOrganEntry(false)
{
  QDialog::setFixedSize(250, 105);

  QBoxLayout * verticalLayout = new QVBoxLayout( this );
  verticalLayout->setMargin(5);
  verticalLayout->setSpacing(5);

  mitk::OrganTypeProperty::Pointer organTypes = mitk::OrganTypeProperty::New();

  // to enter a name for the segmentation
  lblPrompt = new QLabel( "Name and color of the segmentation", this );
  verticalLayout->addWidget( lblPrompt );

  // to choose a color
  btnColor = new QPushButton( "", this );
  btnColor->setFixedWidth(25);
  btnColor->setAutoFillBackground(true);
  btnColor->setStyleSheet("background-color:rgb(255,0,0)");

  connect( btnColor, SIGNAL(clicked()), this, SLOT(onColorBtnClicked()) );

  edtName = new QLineEdit( "", this );
  QStringList completionList;
  completionList << "";
  completer = new QCompleter(completionList);
  completer->setCaseSensitivity(Qt::CaseInsensitive);
  edtName->setCompleter(completer);

  connect( completer, SIGNAL(activated(const QString&)), this, SLOT(onColorChange(const QString&)) );

  QBoxLayout * horizontalLayout2 = new QHBoxLayout();
  verticalLayout->addLayout(horizontalLayout2);
  horizontalLayout2->addWidget( btnColor );
  horizontalLayout2->addWidget( edtName );



  //buttons for closing the dialog
  btnOk = new QPushButton( tr("Ok"), this );
  btnOk->setDefault(true);
  connect( btnOk, SIGNAL(clicked()), this, SLOT(onAcceptClicked()) );

  QPushButton* btnCancel = new QPushButton( tr("Cancel"), this );
  connect( btnCancel, SIGNAL(clicked()), this, SLOT(reject()) );

  QBoxLayout * horizontalLayout = new QHBoxLayout();
  verticalLayout->addLayout(horizontalLayout);
  horizontalLayout->setSpacing(5);
  horizontalLayout->addStretch();
  horizontalLayout->addWidget( btnOk );
  horizontalLayout->addWidget( btnCancel );

  edtName->setFocus();
}
QmitkNewSegmentationDialog::~QmitkNewSegmentationDialog (  ) [virtual]

Definition at line 93 of file QmitkNewSegmentationDialog.cpp.

{
}

Member Function Documentation

mitk::Color QmitkNewSegmentationDialog::GetColor (  )

Definition at line 149 of file QmitkNewSegmentationDialog.cpp.

References m_Color.

Referenced by QmitkSegmentationView::CreateNewSegmentation(), QmitkMorphologicToolGUI::OnAcceptPreview(), QmitkBinaryThresholdULToolGUI::OnAcceptThresholdPreview(), and QmitkBinaryThresholdToolGUI::OnAcceptThresholdPreview().

{
  mitk::Color colorProperty;
  if (m_Color.spec() == 0)
  {
    colorProperty.SetRed(1);
    colorProperty.SetGreen(0);
    colorProperty.SetBlue(0);
  }
  else
  {
    colorProperty.SetRed(m_Color.redF());
    colorProperty.SetGreen(m_Color.greenF());
    colorProperty.SetBlue(m_Color.blueF());
  }
  return colorProperty;
}
const char * QmitkNewSegmentationDialog::GetOrganType (  )

Definition at line 108 of file QmitkNewSegmentationDialog.cpp.

References selectedOrgan.

{
  return selectedOrgan.toLocal8Bit().constData();
}
const QString QmitkNewSegmentationDialog::GetSegmentationName (  )
void QmitkNewSegmentationDialog::onAcceptClicked (  ) [protected, slot]

Definition at line 97 of file QmitkNewSegmentationDialog.cpp.

References edtName, and m_SegmentationName.

Referenced by QmitkNewSegmentationDialog().

{
  m_SegmentationName = edtName->text();
  this->accept();
}
void QmitkNewSegmentationDialog::onColorBtnClicked (  ) [protected, slot]

Definition at line 126 of file QmitkNewSegmentationDialog.cpp.

References btnColor, and m_Color.

Referenced by QmitkNewSegmentationDialog().

{
  m_Color = QColorDialog::getColor();
  if (m_Color.spec() == 0)
  {
    m_Color.setRed(255);
    m_Color.setGreen(0);
    m_Color.setBlue(0);
  }
  btnColor->setStyleSheet(QString("background-color:rgb(%1,%2, %3)").arg(m_Color.red()).arg(m_Color.green()).arg(m_Color.blue()));
}
void QmitkNewSegmentationDialog::onColorChange ( const QString &  completedWord ) [protected, slot]

Definition at line 185 of file QmitkNewSegmentationDialog.cpp.

References btnColor, colorList, m_Color, and organList.

Referenced by QmitkNewSegmentationDialog().

{
  if (organList.contains(completedWord))
  {
    int j = organList.indexOf(completedWord);
    m_Color = colorList.at(j);
    btnColor->setStyleSheet(QString("background-color:rgb(%1,%2, %3)").arg(m_Color.red()).arg(m_Color.green()).arg(m_Color.blue()));
  }
}
void QmitkNewSegmentationDialog::onNewOrganNameChanged ( const QString &  newText ) [protected, slot]

Definition at line 114 of file QmitkNewSegmentationDialog.cpp.

References btnOk, selectedOrgan, and setSegmentationName().

{
  if (!newText.isEmpty())
  {
    btnOk->setEnabled( true );
  }

  selectedOrgan = newText;
  this->setSegmentationName( newText );

}
void QmitkNewSegmentationDialog::setPrompt ( const QString &  prompt ) [slot]
void QmitkNewSegmentationDialog::setSegmentationName ( const QString &  name ) [slot]

Definition at line 143 of file QmitkNewSegmentationDialog.cpp.

References edtName, and m_SegmentationName.

Referenced by onNewOrganNameChanged().

{
  edtName->setText( name );
  m_SegmentationName = name;
}
void QmitkNewSegmentationDialog::SetSuggestionList ( QStringList  organColorList )

Definition at line 167 of file QmitkNewSegmentationDialog.cpp.

References colorList, completer, and organList.

Referenced by QmitkSegmentationView::CreateNewSegmentation().

{
  QStringList::iterator iter;
  for (iter = organColorList.begin(); iter != organColorList.end(); ++iter)
  {
    QString& element = *iter;
    QString colorName = element.right(7);
    QColor color(colorName);
    QString organName = element.left(element.size() - 7);

    organList.push_back(organName);
    colorList.push_back(color);
  }

  QStringListModel* completeModel = static_cast<QStringListModel*> (completer->model());
  completeModel->setStringList(organList);
}

Member Data Documentation

QPushButton* QmitkNewSegmentationDialog::btnColor [protected]
QPushButton* QmitkNewSegmentationDialog::btnOk [protected]
QList<QColor> QmitkNewSegmentationDialog::colorList [protected]

Definition at line 99 of file QmitkNewSegmentationDialog.h.

Referenced by onColorChange(), and SetSuggestionList().

QCompleter* QmitkNewSegmentationDialog::completer [protected]

Definition at line 94 of file QmitkNewSegmentationDialog.h.

Referenced by QmitkNewSegmentationDialog(), and SetSuggestionList().

QLineEdit* QmitkNewSegmentationDialog::edtName [protected]

Definition at line 86 of file QmitkNewSegmentationDialog.h.

Definition at line 79 of file QmitkNewSegmentationDialog.h.

Referenced by QmitkNewSegmentationDialog(), and setPrompt().

Q3ListBox* QmitkNewSegmentationDialog::lstOrgans [protected]

Definition at line 80 of file QmitkNewSegmentationDialog.h.

Definition at line 92 of file QmitkNewSegmentationDialog.h.

Referenced by GetColor(), onColorBtnClicked(), and onColorChange().

Definition at line 90 of file QmitkNewSegmentationDialog.h.

QStringList QmitkNewSegmentationDialog::organList [protected]

Definition at line 98 of file QmitkNewSegmentationDialog.h.

Referenced by onColorChange(), and SetSuggestionList().

Definition at line 88 of file QmitkNewSegmentationDialog.h.

Referenced by GetOrganType(), and onNewOrganNameChanged().


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