E:/dev/ssip2006/snake/MainWindow.cpp

Go to the documentation of this file.
00001 #include "MainWindow.h"
00002 #include "ImageLabel.h"
00003 
00004 #include <QtGui/QFileDialog>
00005 #include <QtGui/QMessageBox>
00006 #include <QtGui/QRadioButton>
00007 
00009 MainWindow::MainWindow(QWidget* parent /* = 0 */, Qt::WindowFlags flags /* = 0 */)
00010 : QMainWindow(parent, flags),
00011 m_scaleFactor(1),
00012 m_ulPt(QPoint(150,150)),
00013 m_lrPt(QPoint(300,300))
00014 {
00015         // create gui elements defined in the Ui_MainWindow class
00016         setupUi(this);
00017         // create and set a QLabel for image loading
00018         m_imageLabel = new ImageLabel(this, m_imageFrame);
00019         m_imageLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);
00020     m_imageLabel->setAlignment(Qt::AlignBottom | Qt::AlignRight);
00021         m_imageLabel->resize(m_imageFrame->width(), m_imageFrame->height());
00022 
00023         // create a null image
00024         m_image = new QImage();
00025 
00026         m_iterationOn->setChecked(true);
00027 
00028         // signal - slot connections
00029         QObject::connect(m_actionOpen, SIGNAL(triggered()), this, SLOT(slotOpen()));
00030         QObject::connect(m_actionZoomNormal, SIGNAL(triggered()), this, SLOT(slotZoomNormal()));
00031         QObject::connect(m_snakeButton, SIGNAL(clicked()), this, SLOT(slotSnakeButtonPressed()));
00032         QObject::connect(m_demoButton, SIGNAL(clicked()), this, SLOT(slotDemoButtonPressed()));
00033         QObject::connect(m_initEllipseButton, SIGNAL(clicked()), this, SLOT(slotInitCurveButtonPressed()));
00034 
00035         QObject::connect(m_iterationOn, SIGNAL(toggled(bool)), this, SLOT(slotIterationOn()));
00036         QObject::connect(m_iterationOff, SIGNAL(toggled(bool)), this, SLOT(slotIterationOff()));
00037         QObject::connect(m_iterationStep, SIGNAL(toggled(bool)), this, SLOT(slotIterationStep()));
00038 }
00039 
00041 MainWindow::~MainWindow()
00042 {
00043         // no need to delete child widgets, QT does it all for us
00044         if (!m_image->isNull())
00045         {
00046                 delete m_image;
00047                 m_image = NULL;
00048         }
00049 }
00050 
00051 void MainWindow::showImage(QImage *img)
00052 {
00053         if(m_imageLabel)
00054                 m_imageLabel->setPixmap(QPixmap::fromImage(*img));
00055 }
00056 
00058 void MainWindow::slotOpen()
00059 {
00060         m_fileName = new QString(QFileDialog::getOpenFileName(this, tr("Open File"), QDir::currentPath()));
00061 
00062         if (!m_fileName->isEmpty())
00063         {
00064                 m_image->load(*m_fileName);
00065                 if (m_image->isNull())
00066                 {
00067                         QMessageBox::information(this, tr("Snake Ballooning"),
00068                                 tr("Cannot load %1.").arg(*m_fileName));
00069                         return;
00070                 }
00071                 m_imageLabel->setPixmap(QPixmap::fromImage(*m_image));
00072                 emit signalImageOpened();
00073                 
00074                 //scaleFactor = 1.0;
00075 
00076         //printAct->setEnabled(true);
00077         //fitToWindowAct->setEnabled(true);
00078         //updateActions();
00079 
00080         //if (!fitToWindowAct->isChecked())
00081         //    imageLabel->adjustSize();
00082     }
00083 }
00084 
00086 //void MainWindow::slotSaveAs()
00087 //{
00088 //      QString filename = QFileDialog::getOpenFileName(this, tr("Open File"), QDir::currentPath());
00089 //      QImage img = m_imageLabel->pixmap()->toImage();
00090 //      img->
00091 //}
00092 
00094 void MainWindow::slotSnakeButtonPressed()
00095 {
00096         emit signalSnakeButtonPressed();
00097 }
00098 
00100 void MainWindow::slotDemoButtonPressed()
00101 {
00102         emit signalDemoButtonPressed();
00103 }
00104 
00106 void MainWindow::slotZoomNormal()
00107 {
00108         qDebug("zoom to original");
00109 }
00110 
00112 void MainWindow::slotInitCurveButtonPressed()
00113 {
00114         emit signalInitCurve();
00115 }
00116 
00118 void MainWindow::slotIterationOn()
00119 {
00120         if (m_iterationOn->isChecked())
00121                 emit signalIterationOn();
00122 }
00123 
00125 void MainWindow::slotIterationOff()
00126 {
00127         if (m_iterationOff->isChecked())
00128                 emit signalIterationOff();
00129 }
00130 
00132 void MainWindow::slotIterationStep()
00133 {
00134         if (m_iterationStep->isChecked())
00135                 emit signalIterationStep();
00136 }
00137 

Generated on Thu Jul 6 23:16:43 2006 for Snake Ballooning by  doxygen 1.4.7