LayerVector::LayerVector(Object* object) : LayerImage(object) { m_eType = Layer::VECTOR; name = QString(tr("Vector Layer")); addImageAtFrame(1); //framesVector.append(new VectorImage(imageSize, QImage::Format_ARGB32_Premultiplied, object)); }
void LayerVector::loadDomElement(QDomElement element, QString dataDirPath) { if (!element.attribute("id").isNull()) id = element.attribute("id").toInt(); name = element.attribute("name"); visible = (element.attribute("visibility") == "1"); m_eType = static_cast<LAYER_TYPE>( element.attribute( "type" ).toInt( ) ); QDomNode imageTag = element.firstChild(); while (!imageTag.isNull()) { QDomElement imageElement = imageTag.toElement(); if (!imageElement.isNull()) { if (imageElement.tagName() == "image") { if (!imageElement.attribute("src").isNull()) { QString path = dataDirPath +"/" + imageElement.attribute("src"); // the file is supposed to be in the data irectory //qDebug() << "LAY_VECTOR dataDirPath=" << dataDirPath << " ;path=" << path; //added for debugging puproses QFileInfo fi(path); if (!fi.exists()) path = imageElement.attribute("src"); int position = imageElement.attribute("frame").toInt(); loadImageAtFrame( path, position ); } else { int frame = imageElement.attribute("frame").toInt(); addImageAtFrame( frame ); getVectorImageAtFrame( frame )->loadDomElement(imageElement); } } } imageTag = imageTag.nextSibling(); } }
LayerCamera::LayerCamera(Object* object) : LayerImage(object) { type = Layer::CAMERA; name = QString("Camera Layer"); viewRect = QRect( QPoint(-320,-240), QSize(640,480) ); dialog = NULL; addImageAtFrame(1); }
void LayerCamera::loadImageAtFrame(int frameNumber, QMatrix view) { if(getIndexAtFrame(frameNumber) == -1) addImageAtFrame(frameNumber); int index = getIndexAtFrame(frameNumber); framesCamera[index] = new Camera(); framesCamera[index]->view = view; emit imageAdded(frameNumber); }
void LayerVector::loadDomElement(QDomElement element, QString filePath) { if(!element.attribute("id").isNull()) id = element.attribute("id").toInt(); name = element.attribute("name"); visible = (element.attribute("visibility") == "1"); type = element.attribute("type").toInt(); QDomNode imageTag = element.firstChild(); while(!imageTag.isNull()) { QDomElement imageElement = imageTag.toElement(); if(!imageElement.isNull()) { if(imageElement.tagName() == "image") { if(!imageElement.attribute("src").isNull()) { QString path = filePath +".data/" + imageElement.attribute("src"); // the file is supposed to be in the data irectory QFileInfo fi(path); if(!fi.exists()) path = imageElement.attribute("src"); int position = imageElement.attribute("frame").toInt(); loadImageAtFrame( path, position ); } else { int frame = imageElement.attribute("frame").toInt(); addImageAtFrame( frame ); getVectorImageAtFrame( frame )->loadDomElement(imageElement); } } } imageTag = imageTag.nextSibling(); } }
void LayerVector::loadImageAtFrame(QString path, int frameNumber) { if(getIndexAtFrame(frameNumber) == -1) addImageAtFrame(frameNumber); int index = getIndexAtFrame(frameNumber); framesVector[index]->read(path); QFileInfo fi(path); framesFilename[index] = fi.fileName(); }
void LayerBitmap::loadImageAtFrame(QString path, QPoint topLeft, int frameNumber) { //qDebug() << path; if (getIndexAtFrame(frameNumber) == -1) addImageAtFrame(frameNumber); int index = getIndexAtFrame(frameNumber); framesBitmap[index] = new BitmapImage(object, path, topLeft); QFileInfo fi(path); framesFilename[index] = fi.fileName(); }
LayerBitmap::LayerBitmap(Object* object) : LayerImage(object) { type = Layer::BITMAP; name = QString("Bitmap Layer"); addImageAtFrame(1); //imageSize = desiredSize; //frameClicked = -1; //frameOffset = 0; }
void LayerSound::loadSoundAtFrame(QString filePathString, int frameNumber) { // if (getIndexAtFrame(frameNumber) == -1) addImageAtFrame(frameNumber); int index = getIndexAtFrame(frameNumber); if (index == -1) addImageAtFrame(frameNumber); index = getIndexAtFrame(frameNumber); QFileInfo fi(filePathString); if (fi.exists()) { // sound[index] = new QSound(filePathString, NULL); Phonon::MediaObject* media = new Phonon::MediaObject(); connect(media, SIGNAL(totalTimeChanged(qint64)), this, SLOT(addTimelineKey(qint64))); media->setCurrentSource(filePathString); // quick and dirty trick to calculate soundSize // totalTime() return a value only after a call to media.play() // ( and when signal totaltimechanged is emitted totalTime() returns the correct value ) Phonon::AudioOutput* audioOutput; audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); Phonon::createPath(media, audioOutput); media->play(); media->stop(); soundSize[index] = media->totalTime(); // totalTime() returns 0 now sound[index] = media; soundFilepath[index] = filePathString; framesFilename[index] = fi.fileName(); framesModified[index] = true; } else { sound[index] = NULL; soundFilepath[index] = "Wrong file"; framesFilename[index] = "Wrong file" + filePathString; } }