Ejemplo n.º 1
0
void main() {
    FILE *fp = NULL;
    
    setlocale(LC_ALL, "Russian");

    for (;;) {
        showStatusBar();
        showMenu(fp);

        switch(_getche()) {
        case '1':
            fp = openFile(fp);
			break;
        case '2':
            if (fp != NULL)
                fileAnalyze(fp);                
            break;
        case '3':
            puts("Осторожно, прога закрывается без предупреждений!");
            if (fp != NULL)
				fclose(fp);
            exit(1);
        default:
            puts("Была нажата клавиша.");
            break;
        }
    }
}
Ejemplo n.º 2
0
TTMpeg2MainWnd::TTMpeg2MainWnd( QWidget* parent, const char* name, Qt::WFlags fl )
  : Q3MainWindow( parent, name, fl )
			      //      image0( (const char **) image0_data )
{
  if ( !name )
    setName( "TTMpeg2MainWnd" );

  // images
  // ---------------------------------------------------------------------------
  TTCut::imgDownArrow  = new QPixmap( (const char**)downarrow_18_xpm );
  TTCut::imgUpArrow    = new QPixmap( (const char**)uparrow_18_xpm );
  TTCut::imgDelete     = new QPixmap( (const char**)cancel_18_xpm );
  TTCut::imgFileOpen24 = new QPixmap( (const char**)fileopen_24_xpm );
  TTCut::imgFileNew    = new QPixmap( (const char**)filenew_16_xpm );
  TTCut::imgFileOpen   = new QPixmap( (const char**)fileopen_16_xpm );
  TTCut::imgFileSave   = new QPixmap( (const char**)filesave_16_xpm );;
  TTCut::imgFileSaveAs = new QPixmap( (const char**)filesaveas_16_xpm );
  TTCut::imgSaveImage  = new QPixmap( (const char**)saveimage_16_xpm );
  TTCut::imgSettings   = new QPixmap( (const char**)settings_16_xpm );
  TTCut::imgSettings18 = new QPixmap( (const char**)settings_18_xpm );
  TTCut::imgExit       = new QPixmap( (const char**)exit_16_xpm );
  TTCut::imgPlay       = new QPixmap( (const char**)play_18_xpm );
  TTCut::imgStop       = new QPixmap( (const char**)stop_18_xpm );
  TTCut::imgSearch     = new QPixmap( (const char**)search_18_xpm );
  TTCut::imgChapter    = new QPixmap( (const char**)chapter_18_xpm );
  TTCut::imgPreview    = new QPixmap( (const char**)preview_18_xpm );
  TTCut::imgCutAV      = new QPixmap( (const char**)cutav_18_xpm );
  TTCut::imgCutAudio   = new QPixmap( (const char**)cutaudio_18_xpm );
  TTCut::imgGoTo       = new QPixmap( (const char**)goto_18_xpm );
  TTCut::imgMarker     = new QPixmap( (const char**)note_18_xpm );
  TTCut::imgClock      = new QPixmap( (const char**)clock_16_xpm );
  TTCut::imgApply      = new QPixmap( (const char**)apply_18_xpm );
  TTCut::imgAddToList  = new QPixmap( (const char**)addtolist_18_xpm );
  TTCut::imgFileClose  = new QPixmap( (const char**)fileclose_18_xpm );

  slider_update = true;

  // min widgets size
  // --------------------------------------------------------------------------
  setMinimumSize( QSize( 860, 480 ) );
  setMaximumSize( QSize( 1600, 1280 ) );

  // central widget
  // --------------------------------------------------------------------------
  setCentralWidget( new QWidget( this, "qt_central_widget" ) );


  // --------------------------------------------------------------------------
  // menu-bar
  // --------------------------------------------------------------------------

  // menu actions
  // --------------------------------------------------------------------------

  // file-menu
  fileOpenAction       = new QAction( this, "fileOpenAction" );
  fileOpenAction->setIconSet( QIcon( *(TTCut::imgFileOpen) ) );
  fileSettingsAction   = new QAction( this, "fileSettingsAction" );
  fileSettingsAction->setIconSet( QIcon( *(TTCut::imgSettings) ) );
  fileAnalyzeAction    = new QAction( this, "fileAnalyzeAction" );
  fileAnalyzeAction->setIconSet( QIcon( *(TTCut::imgPreview) ) );
  fileExitAction       = new QAction( this, "fileExitAction" );
  fileExitAction->setIconSet( QIcon( *(TTCut::imgExit) ) );

  // menubar
  MenuBar = new QMenuBar( this, "MenuBar" );
  
  //file-menu
  fileMenu = new Q3PopupMenu( this );
  fileOpenAction->addTo( fileMenu );
  fileAnalyzeAction->addTo( fileMenu );
  fileMenu->insertSeparator();
  fileSettingsAction->addTo( fileMenu );
  fileMenu->insertSeparator();
  fileExitAction->addTo( fileMenu );
  MenuBar->insertItem( QString("File"), fileMenu,   1 );
  

  // ---------------------------------------------------------------------------
  // tool-bar
  // ---------------------------------------------------------------------------
  toolBar = new Q3ToolBar( this, "ToolBar" );

  tbStartAnalyzing = new QToolButton( toolBar, "StartAnalyze" );
  tbStartAnalyzing->setIconSet( QIcon( *(TTCut::imgPreview) ) );

  // ---------------------------------------------------------------------------
  // status-bar
  // ---------------------------------------------------------------------------
  (void)statusBar();


  // central layout manager (grid 4x2)
  // ---------------------------------------------------------------------------
  TTMpeg2MainWndLayout = new QGridLayout( centralWidget(), 
					  4, 1, 11, 6, 
					  "TTMpeg2MainWndLayout"); 

  // open stream section
  // ---------------------------------------------------------------------------
  gbStreamName = new Q3GroupBox( centralWidget(), "gbStreamName" );
  gbStreamName->setColumnLayout(0, Qt::Vertical );
  gbStreamName->layout()->setSpacing( 6 );
  gbStreamName->layout()->setMargin( 11 );
  gbStreamNameLayout = new QGridLayout( gbStreamName->layout() );
  gbStreamNameLayout->setAlignment( Qt::AlignTop );
  
  leStreamName = new QLineEdit( gbStreamName, "leStreamName" );
  
  gbStreamNameLayout->addWidget( leStreamName, 0, 1 );
  
  pbOpenStream = new QPushButton( gbStreamName, "pbOpenStream" );
  pbOpenStream->setMinimumSize( QSize( 24, 24 ) );
  pbOpenStream->setMaximumSize( QSize( 24, 24 ) );
  pbOpenStream->setPixmap( (QPixmap)*(TTCut::imgFileOpen) );
  
  gbStreamNameLayout->addWidget( pbOpenStream, 0, 0 );
  TTMpeg2MainWndLayout->addMultiCellWidget( gbStreamName, 0, 0, 0, 1 );


  // stream info section
  // ---------------------------------------------------------------------------
  layout10 = new QHBoxLayout( 0, 0, 6, "layout10"); 
  layout9 = new QVBoxLayout( 0, 0, 6, "layout9"); 

  // buffer statistics
  gbBufferStatistics = new Q3GroupBox( centralWidget(), "gbBufferStatistics" );
  gbBufferStatistics->setColumnLayout(0, Qt::Vertical );
  gbBufferStatistics->layout()->setSpacing( 6 );
  gbBufferStatistics->layout()->setMargin( 11 );
  gbBufferStatisticsLayout = new QGridLayout( gbBufferStatistics->layout() );
  gbBufferStatisticsLayout->setAlignment( Qt::AlignTop );
  
  layout1 = new QVBoxLayout( 0, 0, 6, "layout1"); 

  slFileLength = new QLabel( gbBufferStatistics, "slFileLength" );
  layout1->addWidget( slFileLength );
  
  slReadOps = new QLabel( gbBufferStatistics, "slReadOps" );
  layout1->addWidget( slReadOps );
  
  slFillOps = new QLabel( gbBufferStatistics, "slFillOps" );
  layout1->addWidget( slFillOps );
  
  slReadTime = new QLabel( gbBufferStatistics, "slReadTime" );
  layout1->addWidget( slReadTime );
  
  gbBufferStatisticsLayout->addLayout( layout1, 0, 0 );
  
  layout2 = new QVBoxLayout( 0, 0, 6, "layout2"); 
  
  laFileLength = new QLabel( gbBufferStatistics, "laFileLength" );
  layout2->addWidget( laFileLength );
  
  laReadOps = new QLabel( gbBufferStatistics, "laReadOps" );
  layout2->addWidget( laReadOps );
  
  laFillOps = new QLabel( gbBufferStatistics, "laFillOps" );
  layout2->addWidget( laFillOps );
  
  laReadTime = new QLabel( gbBufferStatistics, "laReadTime" );
  layout2->addWidget( laReadTime );
  
  gbBufferStatisticsLayout->addLayout( layout2, 0, 1 );
  layout9->addWidget( gbBufferStatistics );

  // stream statistics
  gbStreamStatistics = new Q3GroupBox( centralWidget(), "gbStreamStatistics" );
  gbStreamStatistics->setColumnLayout(0, Qt::Vertical );
  gbStreamStatistics->layout()->setSpacing( 6 );
  gbStreamStatistics->layout()->setMargin( 11 );
  gbStreamStatisticsLayout = new QGridLayout( gbStreamStatistics->layout() );
  gbStreamStatisticsLayout->setAlignment( Qt::AlignTop );

  line1 = new Q3Frame( gbStreamStatistics, "line1" );
  line1->setFrameShape( Q3Frame::HLine );
  line1->setFrameShadow( Q3Frame::Sunken );
  line1->setFrameShape( Q3Frame::HLine );
  
  gbStreamStatisticsLayout->addMultiCellWidget( line1, 1, 1, 0, 1 );
  
  layout5 = new QVBoxLayout( 0, 0, 6, "layout5"); 
  
  slTotalFrames = new QLabel( gbStreamStatistics, "slTotalFrames" );
  layout5->addWidget( slTotalFrames );
  
  slIFrames = new QLabel( gbStreamStatistics, "slIFrames" );
  layout5->addWidget( slIFrames );
  
  slPFrames = new QLabel( gbStreamStatistics, "slPFrames" );
  layout5->addWidget( slPFrames );
  
  slBFrames = new QLabel( gbStreamStatistics, "slBFrames" );
  layout5->addWidget( slBFrames );
  
  gbStreamStatisticsLayout->addLayout( layout5, 0, 0 );
  
  layout4 = new QVBoxLayout( 0, 0, 6, "layout4"); 
  
  slSeqHeader = new QLabel( gbStreamStatistics, "slSeqHeader" );
  layout4->addWidget( slSeqHeader );
  
  slGOPHeader = new QLabel( gbStreamStatistics, "slGOPHeader" );
  layout4->addWidget( slGOPHeader );
  
  slPicHeader = new QLabel( gbStreamStatistics, "slPicHeader" );
  layout4->addWidget( slPicHeader );
  
  slSeqEndHeader = new QLabel( gbStreamStatistics, "slSeqEndHeader" );
  layout4->addWidget( slSeqEndHeader );
  
  gbStreamStatisticsLayout->addLayout( layout4, 2, 0 );
  
  layout6 = new QVBoxLayout( 0, 0, 6, "layout6"); 
  
  laSequence = new QLabel( gbStreamStatistics, "laSequence" );
  layout6->addWidget( laSequence );
  
  laGOP = new QLabel( gbStreamStatistics, "laGOP" );
  layout6->addWidget( laGOP );
  
  laPicture = new QLabel( gbStreamStatistics, "laPicture" );
  layout6->addWidget( laPicture );
  
  laSequenceEnd = new QLabel( gbStreamStatistics, "laSequenceEnd" );
  layout6->addWidget( laSequenceEnd );
  
  gbStreamStatisticsLayout->addLayout( layout6, 2, 1 );

  layout7 = new QVBoxLayout( 0, 0, 6, "layout7"); 

  laFramesTotal = new QLabel( gbStreamStatistics, "laFramesTotal" );
  layout7->addWidget( laFramesTotal );
  
  laIFrames = new QLabel( gbStreamStatistics, "laIFrames" );
  layout7->addWidget( laIFrames );
  
  laPFrames = new QLabel( gbStreamStatistics, "laPFrames" );
  layout7->addWidget( laPFrames );
  
  laBFrames = new QLabel( gbStreamStatistics, "laBFrames" );
  layout7->addWidget( laBFrames );
  
  gbStreamStatisticsLayout->addLayout( layout7, 0, 1 );
  layout9->addWidget( gbStreamStatistics );
  layout10->addLayout( layout9 );

  // list view stream info
  gbStreamInfo = new Q3GroupBox( centralWidget(), "gbStreamInfo" );
  gbStreamInfo->setColumnLayout(0, Qt::Vertical );
  gbStreamInfo->layout()->setSpacing( 6 );
  gbStreamInfo->layout()->setMargin( 11 );
  gbStreamInfoLayout = new QGridLayout( gbStreamInfo->layout() );
  gbStreamInfoLayout->setAlignment( Qt::AlignTop );
  
  lvStreamInfo = new Q3ListView( gbStreamInfo, "lvStreamInfo" );
  lvStreamInfo->addColumn( tr( "Header" ) );
  lvStreamInfo->addColumn( tr( "Offset" ) );
  lvStreamInfo->addColumn( tr( "Type" ) );
  lvStreamInfo->addColumn( tr( "Temp Ref." ) );
  lvStreamInfo->addColumn( tr( "S-Order" ) );
  lvStreamInfo->addColumn( tr( "D-Order" ) );
  lvStreamInfo->addColumn( tr( "Time-code" ) );

  lvStreamInfo->setSorting( 5, TRUE );

  gbStreamInfoLayout->addWidget( lvStreamInfo, 0, 0 );
  layout10->addWidget( gbStreamInfo );
  
  TTMpeg2MainWndLayout->addLayout( layout10, 1, 0 );
  
  // sequence info
  gbSequenceInfo = new Q3GroupBox( centralWidget(), "gbSequenceInfo" );
  gbSequenceInfo->setColumnLayout(0, Qt::Vertical );
  gbSequenceInfo->layout()->setSpacing( 6 );
  gbSequenceInfo->layout()->setMargin( 11 );
  gbSequenceInfoLayout = new QGridLayout( gbSequenceInfo->layout() );
  gbSequenceInfoLayout->setAlignment( Qt::AlignTop );
  
  layout19 = new QVBoxLayout( 0, 0, 6, "layout19"); 
  
  slBitrate = new QLabel( gbSequenceInfo, "slBitrate" );
  layout19->addWidget( slBitrate );
  
  slFramerate = new QLabel( gbSequenceInfo, "slFramerate" );
  layout19->addWidget( slFramerate );
  
  slWidth = new QLabel( gbSequenceInfo, "slWidth" );
  layout19->addWidget( slWidth );
  
  slHeight = new QLabel( gbSequenceInfo, "slHeight" );
  layout19->addWidget( slHeight );
  
  gbSequenceInfoLayout->addLayout( layout19, 0, 0 );
  
  layout20 = new QVBoxLayout( 0, 0, 6, "layout20"); 
   
  laSeqBitrate = new QLineEdit( gbSequenceInfo, "laSeqBitrate" );
  laSeqBitrate->setEnabled( FALSE );
  laSeqBitrate->setReadOnly( TRUE );
  layout20->addWidget( laSeqBitrate );
  
  laSeqFramerate = new QLineEdit( gbSequenceInfo, "laSeqFramerate" );
  laSeqFramerate->setEnabled( FALSE );
  laSeqFramerate->setReadOnly( TRUE );
  layout20->addWidget( laSeqFramerate );
  
  laSeqPicWidth = new QLineEdit( gbSequenceInfo, "laSeqPicWidth" );
  laSeqPicWidth->setEnabled( FALSE );
  laSeqPicWidth->setReadOnly( TRUE );
  layout20->addWidget( laSeqPicWidth );
  
  laSeqPicHeight = new QLineEdit( gbSequenceInfo, "laSeqPicHeight" );
  laSeqPicHeight->setEnabled( FALSE );
  laSeqPicHeight->setReadOnly( TRUE );
  layout20->addWidget( laSeqPicHeight );
  
  gbSequenceInfoLayout->addLayout( layout20, 0, 1 );
  
  TTMpeg2MainWndLayout->addWidget( gbSequenceInfo, 1, 1 );
  
  // scroll-bar
  // ---------------------------------------------------------------------------
  sbFrames = new QScrollBar( centralWidget(), "sbFrames" );
  sbFrames->setOrientation( Qt::Horizontal );
  
  TTMpeg2MainWndLayout->addMultiCellWidget( sbFrames, 2, 2, 0, 1 );
  
  // current frame info and navigation
  // ---------------------------------------------------------------------------
  frameInfo = new TTCurrentFrameInfo( centralWidget() , "FrameInfo" );

  TTMpeg2MainWndLayout->addMultiCellWidget( frameInfo, 3, 3, 0 ,1 );

  // ready
  languageChange();
  resize( QSize(963, 725).expandedTo(minimumSizeHint()) );
  //Qt4.0: clearWState( WState_Polished );

  // initialize some attributes
  // ---------------------------------------------------------------------------
  step_frame     = 0;
  step_order     = 0;
  is_stream_open = false;

  // show the video window
  // ---------------------------------------------------------------------------
  mpeg2_window = new TTMPEG2Window( 0 );
  mpeg2_window->show();
  mpeg2_window->resize( 720, 576 );

  // show the chart window
  // ---------------------------------------------------------------------------
  //chart_window = new TTFrameChart( 0, "CHARTWND", 420, 120 );
  //chart_window->show();

  // mpeg2 info window
  // ---------------------------------------------------------------------------
  //info_window = new TTMpeg2InfoView( 0, "INFOWND" );
  //info_window->show();

  // signals and slots connections
  // ---------------------------------------------------------------------------
  // file-menu
  connect(fileOpenAction,     SIGNAL( activated() ),   this, SLOT(fileOpen()));
  connect(fileAnalyzeAction,  SIGNAL( activated() ),   this, SLOT(fileAnalyze()));
  connect(fileSettingsAction, SIGNAL( activated() ),   this, SLOT(fileSettings()));
  connect(fileExitAction,     SIGNAL( activated() ),   this, SLOT(fileExit()));

  // tool-bar
  connect(tbStartAnalyzing, SIGNAL(clicked()), this, SLOT(fileAnalyze()));

  // open file button
  connect(pbOpenStream,       SIGNAL( clicked() ),     this,   SLOT( fileOpen()));

  // video position slider
  connect( sbFrames,  SIGNAL( valueChanged(int) ), this, SLOT( videoSliderChanged(int) ) );
  
  // current frame info / navigation
  connect(frameInfo,          SIGNAL(nextFrame()),     this, SLOT(nextFrameAction()));
  connect(frameInfo,          SIGNAL(prevFrame()),     this, SLOT(prevFrameAction()));
  connect(frameInfo,          SIGNAL(orderAnyFrame()), this, SLOT(orderAnyFrame()));
  connect(frameInfo,          SIGNAL(orderIFrame()),   this, SLOT(orderIFrame()));
  connect(frameInfo,          SIGNAL(orderPFrame()),   this, SLOT(orderPFrame()));
  connect(frameInfo,          SIGNAL(orderBFrame()),   this, SLOT(orderBFrame()));
  connect(frameInfo,          SIGNAL(orderDisplay()),  this, SLOT(orderDisplay()));
  connect(frameInfo,          SIGNAL(orderStream()),   this, SLOT(orderStream()));

}