Commit bf2fbd11 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Plugging timeline with main workflow

parent f8194924
/*****************************************************************************
* MainWorkflow.cpp : Will query all of the track workflows to render the final
* image
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <QtDebug>
#include "MainWorkflow.h"
MainWorkflow::MainWorkflow()
{
m_tracks = new TrackWorkflow*[NB_TRACKS];
for (unsigned int i = 0; i < NB_TRACKS; ++i)
m_tracks[i] = new TrackWorkflow;
}
void MainWorkflow::addClip( Clip* clip, unsigned int trackId )
{
Q_ASSERT_X( trackId < NB_TRACKS, "MainWorkflow::addClip",
"The specified trackId isn't valid, for it's higher than the number of tracks");
qDebug() << "MainWorkflow: Adding clip" << clip->getUuid() << "to track" << trackId;
m_tracks[trackId]->addClip( clip );
}
/*****************************************************************************
* MainWorkflow.h : Will query all of the track workflows to render the final
* image
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef MAINWORKFLOW_H
#define MAINWORKFLOW_H
#include <QObject>
#include "TrackWorkflow.h"
//TODO: THIS HAS TO GO ASAP !!!!!
#define NB_TRACKS 1
class MainWorkflow : public QObject
{
Q_OBJECT
public:
MainWorkflow();
void addClip( Clip* clip, unsigned int trackId );
private:
TrackWorkflow** m_tracks;
};
#endif // MAINWORKFLOW_H
......@@ -34,6 +34,10 @@ TrackWorkflow::TrackWorkflow()
void TrackWorkflow::addClip( Clip* clip )
{
m_currentClipWorkflow = new ClipWorkflow( clip, m_condMutex, m_waitCondition );
}
void TrackWorkflow::startRender()
{
m_currentClipWorkflow->startRender( m_mediaPlayer );
}
......
......@@ -39,6 +39,7 @@ class TrackWorkflow : public QObject
public:
TrackWorkflow();
void startRender();
const unsigned char* getOutput() const;
private:
ClipWorkflow* m_currentClipWorkflow;
......
......@@ -72,7 +72,7 @@ void GraphicsMovieItem::paintAudioSpectrum( QPainter* painter )
for (int i = 0; i < m_media->getAudioFrameList().size(); i++)
{
//qDebug() << "Frame: " << i << "/" << m_media->getAudioFrameList().size();
for (int u = 0; u < m_media->getAudioNbSample(); u += 400)
for (unsigned int u = 0; u < m_media->getAudioNbSample(); u += 400)
{
......
......@@ -32,8 +32,10 @@ Timeline::Timeline( QWidget *parent ) :
{
m_ui.setupUi( this );
m_mainWorkflow = new MainWorkflow();
m_tracksScene = new TracksScene( this );
m_tracksView = new TracksView( m_tracksScene, m_ui.tracksFrame );
m_tracksView = new TracksView( m_tracksScene, m_mainWorkflow, m_ui.tracksFrame );
m_tracksView->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
m_tracksView->scale(1, 1);
m_tracksView->setAlignment( Qt::AlignLeft | Qt::AlignTop );
......
......@@ -27,6 +27,7 @@
#include "TracksView.h"
#include "TracksScene.h"
#include "TracksRuler.h"
#include "Workflow/MainWorkflow.h"
class Timeline : public QWidget
{
......@@ -45,11 +46,12 @@ protected:
virtual void changeEvent( QEvent *e );
private:
Ui::Timeline m_ui;
TracksView* m_tracksView;
TracksScene* m_tracksScene;
TracksRuler* m_tracksRuler;
double m_scale;
Ui::Timeline m_ui;
TracksView* m_tracksView;
TracksScene* m_tracksScene;
TracksRuler* m_tracksRuler;
double m_scale;
MainWorkflow* m_mainWorkflow;
};
#endif // TIMELINE_H
......@@ -31,8 +31,8 @@
#include "GraphicsMovieItem.h"
#include "GraphicsCursorItem.h"
TracksView::TracksView( QGraphicsScene* scene, QWidget* parent )
: QGraphicsView( scene, parent ), m_scene( scene )
TracksView::TracksView( QGraphicsScene* scene, MainWorkflow* mainWorkflow, QWidget* parent )
: QGraphicsView( scene, parent ), m_scene( scene ), m_mainWorkflow( mainWorkflow )
{
//TODO should be defined by the settings
m_tracksHeight = 50;
......@@ -183,7 +183,7 @@ int TracksView::cursorPos()
void TracksView::addClip( Media* clip, const QPoint& point )
{
int track = (int)( mapToScene( point ).y() / m_tracksHeight );
unsigned int track = (unsigned int)( mapToScene( point ).y() / m_tracksHeight );
if ( track + 1 > m_tracksCount ) return;
//mappedXPos: 1 pixel = 1 frame
......@@ -202,6 +202,10 @@ void TracksView::addClip( Media* clip, const QPoint& point )
emit durationChanged( duration );
}
item->show();
qDebug() << "TracksView::addClip: Adding a new clip to track" << track;
//FIXME: this leaks, but it will be corrected once we really use Clip instead
// of Media
m_mainWorkflow->addClip( new Clip( clip ), track );
}
void TracksView::setScale( double scaleFactor )
......
......@@ -32,13 +32,14 @@
#include <QDragMoveEvent>
#include "Media.h"
#include "GraphicsCursorItem.h"
#include "Workflow/MainWorkflow.h"
class TracksView : public QGraphicsView
{
Q_OBJECT
public:
TracksView( QGraphicsScene* scene, QWidget* parent = 0 );
TracksView( QGraphicsScene* scene, MainWorkflow* mainWorkflow, QWidget* parent = 0 );
void setDuration( int duration );
int duration() const { return m_projectDuration; }
int tracksHeight() const { return m_tracksHeight; }
......@@ -65,12 +66,13 @@ private slots:
void ensureCursorVisible();
private:
QGraphicsScene* m_scene;
int m_tracksHeight;
int m_tracksCount;
int m_projectDuration;
int m_fps;
GraphicsCursorItem* m_cursorLine;
QGraphicsScene* m_scene;
int m_tracksHeight;
unsigned int m_tracksCount;
int m_projectDuration;
int m_fps;
GraphicsCursorItem* m_cursorLine;
MainWorkflow* m_mainWorkflow;
signals:
void zoomIn();
......
......@@ -41,7 +41,8 @@ SOURCES += src/main.cpp \
src/TimelineBackend.cpp \
src/Track.cpp \
src/Workflow/ClipWorkflow.cpp \
src/Workflow/TrackWorkflow.cpp
src/Workflow/TrackWorkflow.cpp \
src/Workflow/MainWorkflow.cpp
HEADERS += src/gui/MainWindow.h \
src/gui/DockWidgetManager.h \
src/gui/LibraryWidget.h \
......@@ -75,7 +76,8 @@ HEADERS += src/gui/MainWindow.h \
src/TimelineBackend.h \
src/Track.h \
src/Workflow/ClipWorkflow.h \
src/Workflow/TrackWorkflow.h
src/Workflow/TrackWorkflow.h \
src/Workflow/MainWorkflow.h
FORMS += src/gui/ui/MainWindow.ui \
src/gui/ui/PreviewWidget.ui \
src/gui/ui/Preferences.ui \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment