Biomedical Image Analysis Library
The Biomedical Image Analysis Library is a poweful tool for developers, physicians, researchers, engineers, and so on.
thumbnail.cpp
Go to the documentation of this file.
1 #include "thumbnail.hpp"
2 #include <QDebug>
3 #include <QFileInfo>
4 #include <qboxlayout.h>
5 #include <qlabel.h>
6 
7 Thumbnail::Thumbnail( GuiImage *image, int number, int size, QWidget *parent ) : QFrame( parent ),
8  m_imageNumber( number ) {
9  if( !image ) {
10  throw std::invalid_argument( "Image does not exists." );
11  }
12  COMMENT( "Creating thumbnail for image " << image->fileName( ).toStdString( ), 0 );
13  setFrameStyle( QFrame::Raised );
14  setFrameShape( QFrame::StyledPanel );
15  setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
16  QPixmap pix;
17  pix = image->getSlice( 0 );
18  pix = pix.scaled( size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation );
19 
20  QLabel *imageLabel = new QLabel;
21  imageLabel->setPixmap( pix );
22 
23  QFileInfo info( image->fileName( ) );
24  /*
25  * QLabel *textLabel = new QLabel;
26  * textLabel->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
27  * textLabel->setWordWrap( true );
28  */
29  QString fname = info.fileName( );
30  setToolTip( fname );
31  setAttribute( Qt::WA_AlwaysShowToolTips );
32  /*
33  * fname.truncate( 15 );
34  * textLabel->setText( fname );
35  */
36  QVBoxLayout *layout = new QVBoxLayout;
37  layout->addWidget( imageLabel, 0, Qt::AlignHCenter );
38  /* layout->addWidget( textLabel, 0, Qt::AlignCenter ); */
39  layout->addStretch( 1 );
40  layout->setMargin( 2 );
41  setLayout( layout );
42  /* setFrameShape(QFrame::Panel); */
43 }
44 
45 void Thumbnail::mousePressEvent( QMouseEvent* ) {
46  COMMENT( "Thumbnail clicked: " << imageNumber( ), 0 )
47  emit changeImage( imageNumber( ) );
48 }
49 
50 int Thumbnail::imageNumber( ) const {
51  return( m_imageNumber );
52 }
53 
56 }
void changeImage(int index)
The GuiImage class is a bridge to the Bial::Image data structure to the QImage data structure...
Definition: guiimage.h:20
void mousePressEvent(QMouseEvent *)
Definition: thumbnail.cpp:45
static size_t size
Definition: enough.c:173
void setImageNumber(int imageNumber)
Definition: thumbnail.cpp:54
Thumbnail(GuiImage *image, int number, int size, QWidget *parent=0)
Definition: thumbnail.cpp:7
int m_imageNumber
Definition: thumbnail.hpp:23
QPixmap getSlice(size_t view)
getSlice calculates and returns a QImage with the current slice of the view.
Definition: guiimage.cpp:175
QString fileName()
fileName is the image absolute path getter.
Definition: guiimage.cpp:164
int imageNumber() const
Definition: thumbnail.cpp:50