Documentation


viewerQt.cpp

Go to the documentation of this file.
00001 
00002 //                            viewerQt.cpp                                    //
00004 
00005 #include <qspinbox.h>
00006 #include <qpushbutton.h>
00007 #include <qlabel.h>
00008 #include <qradiobutton.h>
00009 #include <qfiledialog.h>
00010 #include <qmessagebox.h>
00011 
00012 #include <animal/X3DTK/Qt/mainControllerGUI/MainController.h>
00013 #include "viewer.h"
00014 #include "viewerQt.h"
00015 
00016 namespace X3DTK{
00017 namespace Qt{
00018 
00020 ViewerQt::ViewerQt(Viewer * viewer)
00021 : ViewerDesigner()
00022 , viewer(viewer)
00023 {
00024   setTextLabelVideoName(viewer->getVideoName());
00025   switch (viewer->getVideoMode())
00026   {
00027     case Viewer::DISPLAY:
00028       radioButtonDisplay->setChecked(true);
00029       break;
00030     case Viewer::SCREEN:
00031       radioButtonScreen->setChecked(true);
00032       break;
00033     case Viewer::ANIMATION:
00034       radioButtonAnimation->setChecked(true);
00035       break;
00036     }
00037 }
00038 
00040 ViewerQt::~ViewerQt()
00041 {
00042  
00043 }
00044 
00045 void ViewerQt::widthChanged(int w)
00046 {
00047   viewer->setMinimumWidth(w);
00048   viewer->setMaximumWidth(w);
00049 }
00050 
00051 void ViewerQt::heightChanged(int h)
00052 {
00053   viewer->setMinimumHeight(h);
00054   viewer->setMaximumHeight(h);
00055 }
00056 
00057 void ViewerQt::defaultSize()
00058 {
00059   viewer->setMinimumSize(320, 240);
00060   viewer->setMaximumSize(32767, 32767);
00061 }
00062 
00063 void ViewerQt::toggleVideoAnimation(int n)
00064 {
00065   if (n==QButton::On)
00066     viewer->setVideoMode(Viewer::ANIMATION);  
00067 }
00068 
00069 void ViewerQt::toggleVideoScreen(int n)
00070 {
00071   if (n==QButton::On)
00072     viewer->setVideoMode(Viewer::SCREEN);
00073 }
00074 
00075 void ViewerQt::toggleVideoDisplay(int n)
00076 {
00077   if (n==QButton::On)
00078     viewer->setVideoMode(Viewer::DISPLAY);
00079 }
00080 
00081 void ViewerQt::chooseVideoName()
00082 {
00083   QString fileName= QFileDialog::getSaveFileName(
00084         "/tmp",
00085         "MPEG Files (*.mpg)",
00086         this,
00087         "MPEG-2 Video -- File Name dialog",
00088         "Choose a file name for the MPEG-2 Video" );
00089   if (!fileName.isEmpty())
00090   {
00091     viewer->setVideoName(fileName);
00092     setTextLabelVideoName(viewer->getVideoName());
00093   }
00094   else
00095     switch( QMessageBox::warning( this, "Video file name",
00096         "The choosen video file name is empty !\n",
00097         "Retry",
00098         "Quit", 0, 0, 1 ) )
00099     {
00100       case 0: // The user clicked the Retry again button or pressed Enter
00101         chooseVideoName();
00102         break;
00103       case 1: // The user clicked the Quit or pressed Escape
00104         // exit
00105         break;
00106     }
00107 }
00108 
00109 void ViewerQt::setTextLabelVideoName(QString videoName)
00110 {
00111   if (videoName.isEmpty())
00112     textLabelVideoName->setText("Current: <none>");
00113   else
00114     textLabelVideoName->setText("Current: "+(viewer->getVideoName()).section("/",-1,-1));
00115 }
00116 
00117 void ViewerQt::startCapture()
00118 {
00119   if (radioButtonScreen->isChecked())
00120   {
00121     if (!viewer->xvidcap())
00122       switch( QMessageBox::warning( this, "Screen capture with xvidcap",
00123         "Impossible to launch xvidcap !\n The video name can be not valid:",
00124         "New video name",
00125         "Quit", 0, 0, 1 ) )
00126       {
00127         case 0: // The user clicked the Retry again button or pressed Enter
00128           chooseVideoName();
00129           break;
00130         case 1: // The user clicked the Quit or pressed Escape
00131           //exit
00132           break;
00133       }
00134   }
00135   else
00136   {
00137     viewer->getMainController()->toggleRecord(true);
00138   }
00139 }
00140 
00141 void ViewerQt::viewCapture()
00142 {
00143   if (!viewer->viewCapture())
00144    QMessageBox::warning( this, "View video with xine",
00145         "The current video file name is not valid or a capture is running !\n",
00146         "Ok", 0);
00147 }
00148 void ViewerQt::mpeg2encode()
00149 {
00150   if (!viewer->mpeg2encode())
00151     QMessageBox::warning( this, "Encode MPEG-2 video with mpeg2encode",
00152         "Impossible to encode the video because: \n - No frames was captured or,\n - The video file name already exists or,\n - Images format is not PPM or,\n - Sizes are not multiples of 16,\n - ...\n",
00153         "Ok", 0);
00154 }
00155 
00156 }// Qtr
00157 }// X3DTK

Generated on Thu Dec 23 13:52:27 2004 by doxygen 1.3.6