| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/drivers/qt/ui/animation.ui.h
Go to the documentation of this file.

    00001 /************************************************************************************
    00002 TerraView - visualization and exploration of geographical databases
    00003 using TerraLib.
    00004 Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
    00005 This file is part of TerraView. TerraView is free software; you can redistribute it
    00006 and/or modify it under the terms of the GNU General Public License as published by
    00007 the Free Software Foundation; either version 2 of the License, or
    00008 (at your option) any later version.
    00009
    00010 You should have received a copy of the GNU General Public License
    00011 along with TerraView.
    00012 The authors reassure the license terms regarding the warranties.
    00013 They specifically disclaim any warranties, including, but not limited to,
    00014 the implied warranties of merchantability and fitness for a particular purpose.
    00015 The software provided hereunder is on an "as is" basis, and the authors have no
    00016 obligation to provide maintenance, support, updates, enhancements, or modifications.
    00017 In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
    00018 indirect, special, incidental, or consequential damages arising out of the use of
    00019 this program and its documentation.
    00020 *************************************************************************************/
    00021 #include <qdir.h>
    00022 #include <qvaluelist.h>
    00023 #include <qapplication.h>
    00024 //#include <terraViewBase.h>
    00025 #include <TeQtCanvas.h>
    00026 #include <TeQtAnimaThread.h>
    00027 #include <TeWaitCursor.h>
    00028 #include <qfiledialog.h>
    00029 #include <qmessagebox.h>
    00030 #include <qstringlist.h>
    00031 #include <qdatetime.h>
    00032
    00033 void Animation::init()
    00034 {
    00035            help_ = 0;
    00036            canvas_ = 0;
    00037
    00038            pauseButton->setEnabled(false);
    00039            stopButton->setEnabled(false);
    00040            playButton->setEnabled(false);
    00041            playingScrollBar->setEnabled(false);
    00042            velocitySlider->setEnabled(false);
    00043            velocityTextLabel->setEnabled(false);
    00044            frameNumbertextLabel->setEnabled(false);
    00045            frameNumberLineEdit->setEnabled(false);
    00046            loopCheckBox->setEnabled(false);
    00047            velocitySlider->setMinValue(1);
    00048            velocitySlider->setMaxValue(1000);
    00049            velocitySlider->setValue(500);
    00050 }
    00051
    00052 void Animation::playButton_clicked()
    00053 {
    00054            animaThread_.pause(false);
    00055            animaThread_.pauseFrame(0);
    00056            animaThread_.start();
    00057            playButton->setEnabled(false);
    00058            pauseButton->setEnabled(true);
    00059            stopButton->setEnabled(true);
    00060            playingScrollBar->setEnabled(true);
    00061            directoryPushButton->setEnabled(false);
    00062 }
    00063
    00064
    00065 void Animation::pauseButton_clicked()
    00066 {
    00067            directoryPushButton->setEnabled(false);
    00068            bool p = !animaThread_.pause();
    00069            animaThread_.pause(p);
    00070            if(p == false)
    00071                       animaThread_.start();
    00072 }
    00073
    00074
    00075 void Animation::stopButton_clicked()
    00076 {
    00077            animaThread_.stop();
    00078            stopButton->setEnabled(false);
    00079            pauseButton->setEnabled(false);
    00080            playButton->setEnabled(true);
    00081            playingScrollBar->setEnabled(false);
    00082            directoryPushButton->setEnabled(true);
    00083 }
    00084
    00085
    00086 void Animation::velocitySlider_valueChanged( int v)
    00087 {
    00088            string t = Te2String((double)v/10., 1);
    00089            velocitylineEdit->setText(t.c_str());
    00090 }
    00091
    00092
    00093 void Animation::playingScrollBar_valueChanged( int f)
    00094 {
    00095            if(animaThread_.pause())
    00096                       animaThread_.showFrame(f);
    00097            else
    00098                       animaThread_.frame(f);
    00099 }
    00100
    00101
    00102 void Animation::closeEvent( QCloseEvent * )
    00103 {
    00104            if(animaThread_.running())
    00105                       animaThread_.stop();
    00106            hide();
    00107 }
    00108
    00109
    00110 void Animation::directoryPushButton_clicked()
    00111 {
    00112            QString animaDir = QFileDialog::getExistingDirectory(
    00113                                  QString::null,
    00114                                  this,
    00115                                  tr("Get Existing Directory"),
    00116                                  tr("Select a directory"),
    00117                                  true);
    00118            setAnimaParams(animaDir, canvas_);
    00119 }
    00120
    00121
    00122 void Animation::setAnimaParams(QString& animaDir, TeQtCanvas* canvas)
    00123 {
    00124            if (!animaDir.isEmpty())
    00125            {
    00126                       TeWaitCursor wait;
    00127                       if(animaThread_.running())
    00128                                  animaThread_.stop();
    00129
    00130                       QDir dir(animaDir);
    00131
    00132                       animaThread_.setAnimation(this, dir);
    00133                       velocityTextLabel->setEnabled(true);
    00134                       velocitySlider->setEnabled(true);
    00135                       frameNumbertextLabel->setEnabled(true);
    00136                       loopCheckBox->setEnabled(true);
    00137
    00138                       animaThread_.canvas(canvas);
    00139                       stopButton->setEnabled(false);
    00140                       pauseButton->setEnabled(false);
    00141                       playButton->setEnabled(true);
    00142                       playingScrollBar->setEnabled(false);
    00143                       directoryPushButton->setEnabled(false);
    00144
    00145                       QStringList fileList;
    00146                       fileList = dir.entryList(QDir::Files);
    00147                       if(fileList.count() == 0)
    00148                       {
    00149                                  velocitySlider->setMaxValue(1000);
    00150                                  velocitySlider->setValue(500);
    00151                                  wait.resetWaitCursor();
    00152                                  return;
    00153                       }
    00154                       QString s = *(fileList.at(0));
    00155                       QString ss = dir.absPath() + "/" + s;
    00156                       QPixmap pixmap(ss);
    00157                       QPixmap pix(pixmap.width(), pixmap.height());
    00158                       QTime time;
    00159                       time.start();
    00160                       pixmap.load(ss);
    00161                       bitBlt(&pix, 0, 0, &pixmap, 0, 0, pixmap.width(), pixmap.height(), Qt::CopyROP);
    00162                       int ms = time.elapsed();
    00163                       time.restart();
    00164                       pixmap.load(ss);
    00165                       bitBlt(&pix, 0, 0, &pixmap, 0, 0, pixmap.width(), pixmap.height(), Qt::CopyROP);
    00166                       ms += time.elapsed();
    00167                       ms /= 2;
    00168                       time.restart();
    00169                       pixmap.load(ss);
    00170                       bitBlt(&pix, 0, 0, &pixmap, 0, 0, pixmap.width(), pixmap.height(), Qt::CopyROP);
    00171                       ms += time.elapsed();
    00172                       ms /= 2;
    00173
    00174                       int vmax = 20;
    00175                       if(ms)
    00176                                  vmax = 10000/ms;
    00177                       velocitySlider->setMaxValue(vmax);
    00178                       velocitySlider->setValue(vmax/2);
    00179            }
    00180            else
    00181            {
    00182                       QMessageBox::warning(this, tr("Warning"), tr("Select a directory!"));
    00183                       pauseButton->setEnabled(false);
    00184                       stopButton->setEnabled(false);
    00185                       playButton->setEnabled(false);
    00186                       playingScrollBar->setEnabled(false);
    00187                       velocitySlider->setEnabled(false);
    00188                       velocityTextLabel->setEnabled(false);
    00189                       frameNumbertextLabel->setEnabled(false);
    00190                       loopCheckBox->setEnabled(false);
    00191            }
    00192 }
    00193
    00194 void Animation::velocitylineEdit_returnPressed()
    00195 {
    00196            QString t = velocitylineEdit->text();
    00197            double d = atof(t.latin1()) * 10.;
    00198            int v = (int)d;
    00199            velocitySlider->setValue(v);
    00200 }
    00201
    00202
    00203 void Animation::playDir( QString /* dir */)
    00204 {
    00205            pauseButton->setEnabled(true);
    00206            stopButton->setEnabled(true);
    00207            playButton->setEnabled(true);
    00208            playingScrollBar->setEnabled(true);
    00209            velocitySlider->setEnabled(true);
    00210            velocityTextLabel->setEnabled(true);
    00211            frameNumbertextLabel->setEnabled(true);
    00212            loopCheckBox->setEnabled(true);
    00213            directoryPushButton->setEnabled(false);
    00214            directoryPushButton_clicked();
    00215            loopCheckBox->setChecked(true);
    00216            playButton_clicked();
    00217 }
    00218
    00219 void Animation::setCanvas( TeQtCanvas* canvas )
    00220 {
    00221            canvas_ = canvas;
    00222 }
    00223
    00224 void Animation::helpPushButton_clicked()
    00225 {
    00226            if(help_)
    00227                       delete help_;
    00228
    00229            help_ = new Help(this, "help", false);
    00230            help_->init("animation.htm");
    00231            if(help_->erro_ == false)
    00232            {
    00233                       help_->show();
    00234                       help_->raise();
    00235            }
    00236            else
    00237            {
    00238                       delete help_;
    00239                       help_ = 0;
    00240            }
    00241 }

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines