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
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "cmtkQtScrollRenderView.h"
00034
00035 #include <qlabel.h>
00036 #include <QFrame>
00037 #include <QGridLayout>
00038 #include <QVBoxLayout>
00039
00040 namespace
00041 cmtk
00042 {
00043
00046
00047 QtScrollRenderView::QtScrollRenderView
00048 ( QWidget *parentWidget, const QString& title )
00049 : QGroupBox( parentWidget ),
00050 RenderImage( NULL )
00051 {
00052 if ( ! parentWidget )
00053 qFatal( "No parent widget in QtScrollRenderView constructor." );
00054
00055 if ( title != QString::null )
00056 {
00057 this->setAlignment ( Qt::AlignLeft );
00058 this->setTitle( title );
00059 }
00060
00061 ScrollView = new QScrollArea( this );
00062 RenderImage = new QtRenderImageRGB( this );
00063 ScrollView->setWidget( RenderImage );
00064 ScrollView->setFrameStyle( QFrame::NoFrame );
00065
00066
00067 QObject::connect( RenderImage,SIGNAL(signalMousePressed( Qt::MouseButton, int, int )), SIGNAL(signalMousePressed( Qt::MouseButton, int, int )) );
00068 QObject::connect( RenderImage, SIGNAL(signalMouse3D( Qt::MouseButton, const Vector3D& )), SIGNAL(signalMouse3D( Qt::MouseButton, const Vector3D& )) );
00069
00070
00071 RenderImage->setMinimumSize( 256, 256 );
00072
00073 this->m_SliderGroupBox = new QGroupBox( this );
00074 this->m_SliderGroupBox->hide();
00075
00076 QGridLayout* sliderBoxLayout = new QGridLayout( this->m_SliderGroupBox );
00077 sliderBoxLayout->setContentsMargins( 0,0,0,0 );
00078
00079 this->ImageIndexSlider = new QSlider( this->m_SliderGroupBox );
00080 this->ImageIndexSlider->setOrientation( Qt::Horizontal );
00081 this->ImageIndexSlider->setDisabled( true );
00082 sliderBoxLayout->addWidget( this->ImageIndexSlider, 0, 1 );
00083
00084 this->m_LabelL = new QLabel( this->m_SliderGroupBox );
00085 sliderBoxLayout->addWidget( this->m_LabelL, 0, 0 );
00086 this->m_LabelR = new QLabel( this->m_SliderGroupBox );
00087 sliderBoxLayout->addWidget( this->m_LabelR, 0, 2 );
00088
00089 QVBoxLayout *vbox = new QVBoxLayout;
00090 vbox->setContentsMargins( 0,0,0,0 );
00091 vbox->addWidget( this->ScrollView );
00092 vbox->addWidget( this->m_SliderGroupBox );
00093 vbox->setSpacing( 0 );
00094 this->setLayout(vbox);
00095
00096
00097 QObject::connect( ImageIndexSlider, SIGNAL( valueChanged( int ) ), SIGNAL( indexChanged( int ) ) );
00098 }
00099
00100 QtScrollRenderView::~QtScrollRenderView()
00101 {
00102 }
00103
00104 void QtScrollRenderView::slotConnectImage( ImageRGB *const image )
00105 {
00106 if ( RenderImage )
00107 {
00108 RenderImage->SetInput( image );
00109 }
00110 else
00111 {
00112 qWarning( "RenderImage is NULL in QtScrollRenderView::ConnectRenderView." );
00113 }
00114 }
00115
00116 void QtScrollRenderView::slotRender()
00117 {
00118 if ( RenderImage )
00119 {
00120 RenderImage->Render();
00121 }
00122 else
00123 {
00124 qWarning( "RenderImage is NULL in QtScrollRenderView::Render." );
00125 }
00126 }
00127
00128 void QtScrollRenderView::slotSetNumberOfSlices( unsigned int nSlices )
00129 {
00130 if ( nSlices )
00131 {
00132 ImageIndexSlider->setEnabled( true );
00133 ImageIndexSlider->setMinimum( 0 );
00134 ImageIndexSlider->setMaximum( nSlices - 1 );
00135
00136 if ( ImageIndexSlider->value() < 0 || ImageIndexSlider->value() >= (int)nSlices )
00137 {
00138 ImageIndexSlider->setValue( nSlices / 2 );
00139 }
00140 this->ImageIndexSlider->setDisabled( false );
00141 }
00142 else
00143 {
00144 ImageIndexSlider->setDisabled( true );
00145 }
00146 }
00147
00148 void QtScrollRenderView::slotSetSlice( unsigned int slice )
00149 {
00150 if ( slice <= static_cast<unsigned>(ImageIndexSlider->maximum()) )
00151 {
00152 ImageIndexSlider->setValue( slice );
00153 }
00154 }
00155
00156 }