Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "QmitkSegmentationPreferencePage.h"
00019
00020 #include <QLabel>
00021 #include <QPushButton>
00022 #include <QFormLayout>
00023 #include <QCheckBox>
00024 #include <QGroupBox>
00025 #include <QRadioButton>
00026 #include <QMessageBox>
00027
00028 #include <berryIPreferencesService.h>
00029 #include <berryPlatform.h>
00030
00031 QmitkSegmentationPreferencePage::QmitkSegmentationPreferencePage()
00032 : m_MainControl(0)
00033 , m_Initializing(false)
00034 {
00035
00036 }
00037
00038 void QmitkSegmentationPreferencePage::Init(berry::IWorkbench::Pointer )
00039 {
00040
00041 }
00042
00043 void QmitkSegmentationPreferencePage::CreateQtControl(QWidget* parent)
00044 {
00045 m_Initializing = true;
00046 berry::IPreferencesService::Pointer prefService
00047 = berry::Platform::GetServiceRegistry()
00048 .GetServiceById<berry::IPreferencesService>(berry::IPreferencesService::ID);
00049
00050 m_SegmentationPreferencesNode = prefService->GetSystemPreferences()->Node("/org.mitk.views.segmentation");
00051
00052 m_MainControl = new QWidget(parent);
00053
00054 QVBoxLayout* displayOptionsLayout = new QVBoxLayout;
00055 m_RadioOutline = new QRadioButton( "Draw as outline", m_MainControl);
00056 displayOptionsLayout->addWidget( m_RadioOutline );
00057 m_RadioOverlay = new QRadioButton( "Draw as transparent overlay", m_MainControl);
00058 displayOptionsLayout->addWidget( m_RadioOverlay );
00059
00060 QFormLayout *formLayout = new QFormLayout;
00061 formLayout->addRow( "2D display", displayOptionsLayout );
00062
00063 m_VolumeRenderingCheckBox = new QCheckBox( "Show as volume rendering", m_MainControl );
00064 formLayout->addRow( "3D display", m_VolumeRenderingCheckBox );
00065 connect( m_VolumeRenderingCheckBox, SIGNAL(stateChanged(int)), this, SLOT(OnVolumeRenderingCheckboxChecked(int)) );
00066
00067 m_MainControl->setLayout(formLayout);
00068 this->Update();
00069 m_Initializing = false;
00070 }
00071
00072 QWidget* QmitkSegmentationPreferencePage::GetQtControl() const
00073 {
00074 return m_MainControl;
00075 }
00076
00077 bool QmitkSegmentationPreferencePage::PerformOk()
00078 {
00079 m_SegmentationPreferencesNode->PutBool("draw outline", m_RadioOutline->isChecked());
00080 m_SegmentationPreferencesNode->PutBool("volume rendering", m_VolumeRenderingCheckBox->isChecked());
00081 return true;
00082 }
00083
00084 void QmitkSegmentationPreferencePage::PerformCancel()
00085 {
00086
00087 }
00088
00089 void QmitkSegmentationPreferencePage::Update()
00090 {
00091
00092 if (m_SegmentationPreferencesNode->GetBool("draw outline", true) )
00093 {
00094 m_RadioOutline->setChecked( true );
00095 }
00096 else
00097 {
00098 m_RadioOverlay->setChecked( true );
00099 }
00100
00101 m_VolumeRenderingCheckBox->setChecked( m_SegmentationPreferencesNode->GetBool("volume rendering", false) );
00102 }
00103
00104 void QmitkSegmentationPreferencePage::OnVolumeRenderingCheckboxChecked(int state)
00105 {
00106 if (m_Initializing) return;
00107
00108 if ( state != Qt::Unchecked )
00109 {
00110 QMessageBox::information(NULL,
00111 "Memory warning",
00112 "Turning on volume rendering of segmentations will make the application more memory intensive (and potentially prone to crashes).\n\n"
00113 "If you encounter out-of-memory problems, try turning off volume rendering again.");
00114 }
00115 }