Skip to content

Commit

Permalink
New functionality: added Cameras. (had to change a bit the matrix vie…
Browse files Browse the repository at this point in the history
…w system)
  • Loading branch information
volute committed Jul 21, 2007
1 parent c051fe6 commit 0e4af8a
Show file tree
Hide file tree
Showing 22 changed files with 279 additions and 157 deletions.
Binary file added icons/layer-camera.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions linkmac
Expand Up @@ -36,4 +36,5 @@ install_name_tool -change $qtlib"QtGui.framework/Versions/4/QtGui" @executable_p
install_name_tool -change $qtlib"QtCore.framework/Versions/4/QtCore" @executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore $pencil/Contents/plugins/imageformats/libqjpeg.dylib
install_name_tool -change $qtlib"QtGui.framework/Versions/4/QtGui" @executable_path/../Frameworks/QtGui.framework/Versions/4/QtGui $pencil/Contents/plugins/imageformats/libqjpeg.dylib

cp Info.plist ./build/Release/Pencil.app/Contents/Info.plist
echo ok
2 changes: 2 additions & 0 deletions pencil.pro
Expand Up @@ -28,6 +28,7 @@ HEADERS += src/external/flash/flash.h \
src/graphics/vector/vertexref.h \
src/structure/layer.h \
src/structure/layerbitmap.h \
src/structure/layercamera.h \
src/structure/layerimage.h \
src/structure/layersound.h \
src/structure/layervector.h \
Expand All @@ -50,6 +51,7 @@ SOURCES += src/external/flash/flash.cpp \
src/graphics/vector/vertexref.cpp \
src/structure/layer.cpp \
src/structure/layerbitmap.cpp \
src/structure/layercamera.cpp \
src/structure/layerimage.cpp \
src/structure/layersound.cpp \
src/structure/layervector.cpp \
Expand Down
1 change: 1 addition & 0 deletions pencil.qrc
Expand Up @@ -30,6 +30,7 @@
<file>icons/layer-vector.png</file>
<file>icons/layer-bitmap.png</file>
<file>icons/layer-sound.png</file>
<file>icons/layer-camera.png</file>

<file>icons/controls/play.png</file>
<file>icons/controls/loop.png</file>
Expand Down
2 changes: 1 addition & 1 deletion src/external/linux/linux.cpp
Expand Up @@ -19,7 +19,7 @@ void initialise() {
// nothing, for now
}

void Object::exportMovie(int startFrame, int endFrame, QMatrix view, QSize exportSize, QString filePath, int fps) {
void Object::exportMovie(int startFrame, int endFrame, QMatrix view, Layer* currentLayer, QSize exportSize, QString filePath, int fps) {
QMessageBox assembling("Export",tr("Not supported yet on this platform..."),QMessageBox::Information,0,0,0);
assembling.show();
// nothing
Expand Down
4 changes: 2 additions & 2 deletions src/external/macosx/macosx.cpp
Expand Up @@ -29,7 +29,7 @@ void initialise() {
qApp->setStyle(new AquaStyle());
}

void Object::exportMovie(int startFrame, int endFrame, QMatrix view, QSize exportSize, QString filePath, int fps) {
void Object::exportMovie(int startFrame, int endFrame, QMatrix view, Layer* currentLayer, QSize exportSize, QString filePath, int fps) {
if(!filePath.endsWith(".mov", Qt::CaseInsensitive)) {
filePath = filePath + ".mov";
}
Expand All @@ -40,7 +40,7 @@ void Object::exportMovie(int startFrame, int endFrame, QMatrix view, QSize expor
QString tempPath = QDir::tempPath()+"pencil/";
QMessageBox assembling("Export",tr("Exporting movie..."),QMessageBox::Information,0,0,0);
assembling.show();
exportFrames(startFrame, endFrame, view, exportSize, tempPath+"tmp", "jpg", 100, true, true, 2);
exportFrames(startFrame, endFrame, view, currentLayer, exportSize, tempPath+"tmp", "jpg", 100, true, true, 2);

// --------- Quicktime assemble call ----------

Expand Down
2 changes: 1 addition & 1 deletion src/external/macosx/style.cpp
Expand Up @@ -246,7 +246,7 @@ void AquaStyle::drawControl(ControlElement element,
painter->drawLine( QPoint(0,16), QPoint(width,16) );*/

painter->setPen( QColor(0,78,193,128) );
painter->drawLine( QPoint(0,0), QPoint(0,16) );
painter->drawLine( QPoint(0,0), QPoint(0,height) );
painter->drawLine( QPoint(width-1,0), QPoint(width-1, height) );

painter->setPen( QColor(0,0,0,160) );
Expand Down
2 changes: 1 addition & 1 deletion src/external/win32/win32.cpp
Expand Up @@ -19,7 +19,7 @@ void initialise() {
// nothing, for now
}

void Object::exportMovie(int startFrame, int endFrame, QMatrix view, QSize exportSize, QString filePath, int fps) {
void Object::exportMovie(int startFrame, int endFrame, QMatrix view, Layer* currentLayer, QSize exportSize, QString filePath, int fps) {
QMessageBox assembling("Export",tr("Not supported yet on this platform..."),QMessageBox::Information,0,0,0);
assembling.show();
// nothing
Expand Down
122 changes: 82 additions & 40 deletions src/interface/editor.cpp
Expand Up @@ -26,7 +26,7 @@ GNU General Public License for more details.
#include "layerbitmap.h"
#include "layervector.h"
#include "layersound.h"

#include "layercamera.h"


Editor::Editor(QMainWindow* parent)
Expand Down Expand Up @@ -72,6 +72,10 @@ Editor::Editor(QMainWindow* parent)
exportFramesDialog_hBox = NULL;
exportFramesDialog_vBox = NULL;
exportFramesDialog_format = NULL;
exportMovieDialog_hBox = NULL;
exportMovieDialog_vBox = NULL;
exportMovieDialog_format = NULL;

exportFlashDialog_compression = NULL;

// FOCUS POLICY
Expand Down Expand Up @@ -128,6 +132,7 @@ Editor::Editor(QMainWindow* parent)
connect(timeLine, SIGNAL(newBitmapLayer()), this, SLOT(newBitmapLayer()));
connect(timeLine, SIGNAL(newVectorLayer()), this, SLOT(newVectorLayer()));
connect(timeLine, SIGNAL(newSoundLayer()), this, SLOT(newSoundLayer()));
connect(timeLine, SIGNAL(newCameraLayer()), this, SLOT(newCameraLayer()));
connect(timeLine, SIGNAL(deleteCurrentLayer()), this, SLOT(deleteCurrentLayer()));

connect(timeLine, SIGNAL(playClick()), this, SLOT(play()));
Expand Down Expand Up @@ -610,26 +615,32 @@ void Editor::clipboardChanged() {
void Editor::newBitmapLayer() {
if(object != NULL) {
object->addNewBitmapLayer();
currentLayer = object->getLayerCount()-1;
timeLine->updateLayerNumber( object->getLayerCount() );
scribbleArea->updateAllFrames();
setCurrentLayer( object->getLayerCount()-1 );
}
}

void Editor::newVectorLayer() {
if(object != NULL) {
object->addNewVectorLayer();
currentLayer = object->getLayerCount()-1;
timeLine->updateLayerNumber( object->getLayerCount() );
scribbleArea->updateAllFrames();
setCurrentLayer( object->getLayerCount()-1 );
}
}

void Editor::newSoundLayer() {
if(object != NULL) {
object->addNewSoundLayer();
currentLayer = object->getLayerCount()-1;
timeLine->updateLayerNumber( object->getLayerCount() );
setCurrentLayer( object->getLayerCount()-1 );
}
}

void Editor::newCameraLayer() {
if(object != NULL) {
object->addNewCameraLayer();
timeLine->updateLayerNumber( object->getLayerCount() );
setCurrentLayer( object->getLayerCount()-1 );
}
}

Expand All @@ -640,7 +651,7 @@ void Editor::deleteCurrentLayer() {
QMessageBox::Ok);
if(ret == QMessageBox::Ok) {
object->deleteLayer(currentLayer);
if(currentLayer == object->getLayerCount()) currentLayer = currentLayer-1;
if(currentLayer == object->getLayerCount()) setCurrentLayer( currentLayer-1 );
timeLine->updateLayerNumber( object->getLayerCount() );
//timeLine->update();
scribbleArea->updateAllFrames();
Expand Down Expand Up @@ -685,7 +696,7 @@ void Editor::about()
"<img src=':icons/logo.png' width='100%'><br>"
"<table style='background-color: #DDDDDD'><tr><td width='160px'>"
"Developed by: <i>Pascal Naidon</i> & <i>Patrick Corrieri</i><br>"
"Version: <b>0.4.3b</b> (15th July, 2007)<br><br>"
"Version: <b>0.4.3b</b> (21st July, 2007)<br><br>"
"<b>Thanks to:</b><br>"
"Trolltech for the Qt libraries<br>"
"Roland for the Movie export functions<br>"
Expand Down Expand Up @@ -774,6 +785,7 @@ void Editor::setObject(Object *object) {
this->object = object;
if(object) {
connect( object, SIGNAL(imageAdded(int)), this, SLOT(addFrame(int)) );
connect( object, SIGNAL(imageAdded(int,int)), this, SLOT(addFrame(int,int)) );
connect( object, SIGNAL(imageRemoved(int)), this, SLOT(removeFrame(int)) );

//currentLayer = object->getLayerCount()-1; // the default selected layer is the last one
Expand Down Expand Up @@ -852,14 +864,11 @@ void Editor::createNewDocumentDialog() {
newDocumentDialog->setModal(true);*/
}

void Editor::createExportSizeBox() {
void Editor::createExportFramesSizeBox() {
int defaultWidth = 720; int defaultHeight = 540;
exportFramesDialog_hBox = new QSpinBox(this);
exportFramesDialog_hBox->setMinimum(1);
exportFramesDialog_hBox->setMaximum(10000);
int defaultWidth = 720; int defaultHeight = 540;
//if(object != NULL) {
//defaultWidth = object->size.width(); defaultHeight = object->size.height();
//}
exportFramesDialog_hBox->setValue(defaultWidth);
exportFramesDialog_hBox->setFixedWidth(80);
exportFramesDialog_vBox = new QSpinBox(this);
Expand All @@ -869,13 +878,28 @@ void Editor::createExportSizeBox() {
exportFramesDialog_vBox->setFixedWidth(80);
}

void Editor::createExportMovieSizeBox() {
int defaultWidth = 720; int defaultHeight = 540;
exportMovieDialog_hBox = new QSpinBox(this);
exportMovieDialog_hBox->setMinimum(1);
exportMovieDialog_hBox->setMaximum(10000);
exportMovieDialog_hBox->setValue(defaultWidth);
exportMovieDialog_hBox->setFixedWidth(80);
exportMovieDialog_vBox = new QSpinBox(this);
exportMovieDialog_vBox->setMinimum(1);
exportMovieDialog_vBox->setMaximum(10000);
exportMovieDialog_vBox->setValue(defaultHeight);
exportMovieDialog_vBox->setFixedWidth(80);

}

void Editor::createExportFramesDialog() {
exportFramesDialog = new QDialog(this, Qt::Dialog);
QGridLayout *mainLayout = new QGridLayout;

QGroupBox *resolutionBox = new QGroupBox(tr("Resolution"));
if(exportFramesDialog_hBox == NULL || exportFramesDialog_vBox == NULL) {
createExportSizeBox();
createExportFramesSizeBox();
}
QGridLayout *resolutionLayout = new QGridLayout;
resolutionLayout->addWidget(exportFramesDialog_hBox,0,0);
Expand Down Expand Up @@ -907,20 +931,20 @@ void Editor::createExportMovieDialog() {
QGridLayout *mainLayout = new QGridLayout;

QGroupBox *resolutionBox = new QGroupBox(tr("Resolution"));
if(!exportFramesDialog_hBox || !exportFramesDialog_vBox) {
createExportSizeBox();
if(!exportMovieDialog_hBox || !exportMovieDialog_vBox) {
createExportMovieSizeBox();
}
QGridLayout *resolutionLayout = new QGridLayout;
resolutionLayout->addWidget(exportFramesDialog_hBox,0,0);
resolutionLayout->addWidget(exportFramesDialog_vBox,0,1);
resolutionLayout->addWidget(exportMovieDialog_hBox,0,0);
resolutionLayout->addWidget(exportMovieDialog_vBox,0,1);
resolutionBox->setLayout(resolutionLayout);

QGroupBox *formatBox = new QGroupBox(tr("Format"));
exportFramesDialog_format = new QComboBox();
exportFramesDialog_format->addItem("MOV");
exportMovieDialog_format = new QComboBox();
exportMovieDialog_format->addItem("MOV");
//exportFramesDialog_format->addItem("JPEG");
QGridLayout *formatLayout = new QGridLayout;
formatLayout->addWidget(exportFramesDialog_format,0,0);
formatLayout->addWidget(exportMovieDialog_format,0,0);
formatBox->setLayout(formatLayout);

QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
Expand Down Expand Up @@ -997,18 +1021,19 @@ bool Editor::exportSeq() {
settings.setValue("lastExportPath", QVariant(filePath));

if (!exportFramesDialog) createExportFramesDialog();
exportFramesDialog_hBox->setValue( scribbleArea->size().width() );
exportFramesDialog_vBox->setValue( scribbleArea->size().height() );
exportFramesDialog_hBox->setValue( scribbleArea->getViewRect().toRect().width() );
exportFramesDialog_vBox->setValue( scribbleArea->getViewRect().toRect().height() );
exportFramesDialog->exec();
if(exportFramesDialog->result() == QDialog::Rejected) return false;

QSize exportSize = QSize(exportFramesDialog_hBox->value(), exportFramesDialog_vBox->value());
QMatrix view = map( QRectF(QPointF(0,0), scribbleArea->size() ), QRectF(QPointF(0,0), exportSize) );
//QMatrix view = map( QRectF(QPointF(0,0), scribbleArea->size() ), QRectF(QPointF(0,0), exportSize) );
QMatrix view = map( scribbleArea->getViewRect(), QRectF(QPointF(0,0), exportSize) );
view = scribbleArea->getView() * view;

QByteArray exportFormat(exportFramesDialog_format->currentText().toLatin1());
updateMaxFrame();
object->exportFrames(1, maxFrame, view, exportSize, filePath, exportFormat, -1, false, true, 2);
object->exportFrames(1, maxFrame, view, getCurrentLayer(), exportSize, filePath, exportFormat, -1, false, true, 2);
return true;
}
}
Expand All @@ -1023,9 +1048,13 @@ bool Editor::exportX() {
return false;
} else {
settings.setValue("lastExportPath", QVariant(filePath));

QSize exportSize = scribbleArea->getViewRect().toRect().size();
QMatrix view = map( scribbleArea->getViewRect(), QRectF(QPointF(0,0), exportSize) );
view = scribbleArea->getView() * view;

updateMaxFrame();
QMatrix view = scribbleArea->getView();
object->exportX(1, maxFrame, view, scribbleArea->size(), filePath, true, 2);
object->exportX(1, maxFrame, view, exportSize, filePath, true, 2);
return true;
}
}
Expand All @@ -1041,20 +1070,17 @@ bool Editor::exportMov() {
} else {
settings.setValue("lastExportPath", QVariant(filePath));
if (!exportMovieDialog) createExportMovieDialog();
if(!exportFramesDialog_hBox || !exportFramesDialog_vBox) {
createExportSizeBox();
}
exportFramesDialog_hBox->setValue( scribbleArea->size().width() );
exportFramesDialog_vBox->setValue( scribbleArea->size().height() );
exportMovieDialog_hBox->setValue( scribbleArea->getViewRect().toRect().width() );
exportMovieDialog_vBox->setValue( scribbleArea->getViewRect().toRect().height() );
exportMovieDialog->exec();
if(exportMovieDialog->result() == QDialog::Rejected) return false;

QSize exportSize = QSize(exportFramesDialog_hBox->value(), exportFramesDialog_vBox->value());
QMatrix view = map( QRectF(QPointF(0,0), scribbleArea->size() ), QRectF(QPointF(0,0), exportSize) );
QSize exportSize = QSize(exportMovieDialog_hBox->value(), exportMovieDialog_vBox->value());
QMatrix view = map( scribbleArea->getViewRect(), QRectF(QPointF(0,0), exportSize) );
view = scribbleArea->getView() * view;

updateMaxFrame();
object->exportMovie(1, maxFrame, view, exportSize, filePath, fps);
object->exportMovie(1, maxFrame, view, getCurrentLayer(), exportSize, filePath, fps);
return true;
}
}
Expand All @@ -1074,9 +1100,12 @@ bool Editor::exportFlash() {

settings.setValue("flashCompressionLevel", 10-exportFlashDialog_compression->value() );

QSize exportSize = scribbleArea->size();
QSize exportSize = scribbleArea->getViewRect().toRect().size();
QMatrix view = map( scribbleArea->getViewRect(), QRectF(QPointF(0,0), exportSize) );
view = scribbleArea->getView() * view;

updateMaxFrame();
object->exportFlash(1, maxFrame, scribbleArea->getView(), exportSize, filePath, fps, exportFlashDialog_compression->value());
object->exportFlash(1, maxFrame, view, exportSize, filePath, fps, exportFlashDialog_compression->value());
return true;
}
}
Expand Down Expand Up @@ -1242,10 +1271,11 @@ void Editor::addKey() {
void Editor::addKey(int layerNumber, int &frameNumber) {
Layer* layer = object->getLayer(layerNumber);
if(layer != NULL) {
if(layer->type == Layer::BITMAP || layer->type == Layer::VECTOR) {
if(layer->type == Layer::BITMAP || layer->type == Layer::VECTOR || layer->type == Layer::CAMERA) {
bool success = false;
if(layer->type == Layer::BITMAP) success = ((LayerBitmap*)layer)->addImageAtFrame(frameNumber);
if(layer->type == Layer::VECTOR) success = ((LayerVector*)layer)->addImageAtFrame(frameNumber);
if(layer->type == Layer::CAMERA) success = ((LayerCamera*)layer)->addImageAtFrame(frameNumber);
if(success) {
timeLine->updateContent();
//scribbleArea->addFrame(frameNumber);
Expand All @@ -1262,20 +1292,32 @@ void Editor::removeKey() {
if(layer != NULL) {
if(layer->type == Layer::BITMAP) ((LayerBitmap*)layer)->removeImageAtFrame(currentFrame);
if(layer->type == Layer::VECTOR) ((LayerVector*)layer)->removeImageAtFrame(currentFrame);
if(layer->type == Layer::CAMERA) ((LayerCamera*)layer)->removeImageAtFrame(currentFrame);
timeLine->updateContent();
scribbleArea->updateFrame();
}
}

void Editor::addFrame(int frameNumber) {
void Editor::addFrame(int frameNumber) { // adding a frame to the cache
frameList << frameNumber;
qSort(frameList);
scribbleArea->updateFrame();
timeLine->update();
}

void Editor::addFrame(int frameNumber1, int frameNumber2) { // adding a range of frames to the cache
for(int i=frameNumber1; i<=frameNumber2; i++) {
frameList << i;
}
qSort(frameList);
scribbleArea->updateFrame();
timeLine->update();
}

void Editor::removeFrame(int frameNumber) {
frameList.removeAt( getLastIndexAtFrame(frameNumber) );
scribbleArea->updateFrame();
timeLine->update();
}

int Editor::getLastIndexAtFrame(int frameNumber) {
Expand All @@ -1296,7 +1338,7 @@ int Editor::getLastFrameAtFrame(int frameNumber) {



void Editor::config() {
void Editor::showPreferences() {
preferences->show();
}

Expand Down

0 comments on commit 0e4af8a

Please sign in to comment.