Skip to content

Commit

Permalink
issue #1 - added AnimationEditor and AnimationPlayer
Browse files Browse the repository at this point in the history
AnimationEditor:
- edit Marker ID in one or more frames
- save Animation

AnimationPlayer:
- next/previous Frame
- play/pause Animation
- seek
  • Loading branch information
kaajo committed Sep 3, 2015
1 parent 4630667 commit 00bd3b4
Show file tree
Hide file tree
Showing 21 changed files with 452 additions and 42 deletions.
9 changes: 6 additions & 3 deletions WebCamCap2/WebCamCap2.pro
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ SOURCES += main.cpp\
src/pointchecker.cpp \
src/matrix.tpp \
gui/aboutwidget.cpp \
gui/camerawidget.cpp
gui/camerawidget.cpp \
gui/animationeditor.cpp

HEADERS += gui/wccmainwindow.h \
src/localserver.h \
Expand All @@ -41,13 +42,15 @@ HEADERS += gui/wccmainwindow.h \
src/matrix.h \
src/std_2d_vector.h \
gui/aboutwidget.h \
gui/camerawidget.h
gui/camerawidget.h \
gui/animationeditor.h

FORMS += gui/wccmainwindow.ui \
gui/addcamera.ui \
gui/projectwizard.ui \
gui/aboutwidget.ui \
gui/camerawidget.ui
gui/camerawidget.ui \
animationeditor.ui

QMAKE_CXXFLAGS += -O2 -msse -msse2 -mssse3 -std=c++11 -pedantic -Wall -Wextra

Expand Down
85 changes: 85 additions & 0 deletions WebCamCap2/animationeditor.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AnimationEditor</class>
<widget class="QMainWindow" name="AnimationEditor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>528</width>
<height>331</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QListWidget" name="pointList">
<property name="geometry">
<rect>
<x>240</x>
<y>50</y>
<width>256</width>
<height>192</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="idEdit">
<property name="geometry">
<rect>
<x>50</x>
<y>70</y>
<width>113</width>
<height>27</height>
</rect>
</property>
</widget>
<widget class="QCheckBox" name="checkBox">
<property name="geometry">
<rect>
<x>60</x>
<y>120</y>
<width>121</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>All next frames</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>528</width>
<height>27</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>toolBar</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionSave_Animation"/>
</widget>
<action name="actionSave_Animation">
<property name="text">
<string>Save Animation</string>
</property>
<property name="toolTip">
<string>Save animation</string>
</property>
</action>
</widget>
<resources/>
<connections/>
</ui>
25 changes: 19 additions & 6 deletions WebCamCap2/gui/aboutwidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>347</width>
<width>320</width>
<height>240</height>
</rect>
</property>
Expand All @@ -22,8 +22,8 @@
<widget class="QPushButton" name="closeButton">
<property name="geometry">
<rect>
<x>120</x>
<y>210</y>
<x>130</x>
<y>230</y>
<width>80</width>
<height>23</height>
</rect>
Expand Down Expand Up @@ -62,8 +62,8 @@
<property name="geometry">
<rect>
<x>10</x>
<y>110</y>
<width>331</width>
<y>130</y>
<width>311</width>
<height>91</height>
</rect>
</property>
Expand Down Expand Up @@ -100,7 +100,7 @@
<x>0</x>
<y>40</y>
<width>351</width>
<height>41</height>
<height>21</height>
</rect>
</property>
<property name="text">
Expand All @@ -119,6 +119,19 @@
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>0</x>
<y>70</y>
<width>321</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt;Some icons made by &lt;/span&gt;&lt;a href=&quot;http://www.flaticon.com/authors/daniel-bruce&quot;&gt;&lt;span style=&quot; font-size:8pt; text-decoration: underline; color:#0000ff;&quot;&gt;Daniel Bruce &lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt;from &lt;/span&gt;&lt;a href=&quot;http://www.flaticon.com/&quot;&gt;&lt;span style=&quot; font-size:8pt; text-decoration: underline; color:#0000ff;&quot;&gt;www.flaticon.com&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</widget>
<resources/>
<connections>
Expand Down
95 changes: 95 additions & 0 deletions WebCamCap2/gui/animationeditor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#include "animationeditor.h"
#include "ui_animationeditor.h"

#include <QFileDialog>

#include "openglscene.h"

AnimationEditor::AnimationEditor(QWidget *parent) :
QMainWindow(parent),
m_ui(new Ui::AnimationEditor)
{
m_ui->setupUi(this);

//setup animation player
m_player = new AnimationPlayer(this);
this->addDockWidget(Qt::DockWidgetArea::BottomDockWidgetArea, m_player, Qt::Orientation::Horizontal);
connect(m_player, &AnimationPlayer::frameChanged, this, &AnimationEditor::setFrame);

//actions
connect(m_ui->actionSave_Animation, &QAction::triggered, this, &AnimationEditor::saveAnimation);

//tools
connect(m_ui->idEdit, &QLineEdit::textEdited, this, &AnimationEditor::editMarkerId);
}

AnimationEditor::~AnimationEditor()
{
delete m_ui;
}
Animation *AnimationEditor::animation() const
{
return m_animation;
}

void AnimationEditor::setAnimation(Animation *animation)
{
m_animation = animation;

if(m_animation->length() > 0)
{
OpenGlScene::getInstance()->setFrame(m_animation->frames()[0]);
m_player->setActualAnimation(m_animation);
}
}

void AnimationEditor::setFrame(int i)
{
if(i >= m_animation->frames().size()) return;

const Frame &frame = m_animation->frames()[i];

m_currentFrameId = i;

m_ui->pointList->clear();

for(const Marker &marker : frame.markers())
{
m_ui->pointList->addItem(QString::number(marker.id()));
}
}

void AnimationEditor::saveAnimation()
{
QString filename = QFileDialog::getSaveFileName(this,tr("Save Animation"),m_animation->name()+".fbx" , tr(".fbx Files (*.fbx)"));

if(filename != "")
{
m_animation->save(filename);
}
}

void AnimationEditor::editMarkerId(const QString &newId)
{
if(! m_ui->pointList->currentItem()) return;

if(m_ui->checkBox->isChecked())
{
for(int i = m_currentFrameId; i < m_animation->frames().size(); ++i)
{
Frame &frame = m_animation->frames()[i];
if(! frame.changeMarkerId(m_ui->pointList->currentItem()->text().toInt(), newId.toInt()))
{
break;
}
}
}
else
{
Frame &frame = m_animation->frames()[m_currentFrameId];
frame.changeMarkerId(m_ui->pointList->currentItem()->text().toInt(), newId.toInt());
}

OpenGlScene::getInstance()->setFrame(m_animation->frames()[m_currentFrameId]);
}

39 changes: 39 additions & 0 deletions WebCamCap2/gui/animationeditor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#ifndef ANIMATIONEDITOR_H
#define ANIMATIONEDITOR_H

#include <QMainWindow>

#include "animationplayer.h"
#include "animation.h"

namespace Ui {
class AnimationEditor;
}

class AnimationEditor : public QMainWindow
{
Q_OBJECT

public:
explicit AnimationEditor(QWidget *parent = 0);
~AnimationEditor();

Animation *animation() const;
void setAnimation(Animation *animation);

public slots:
void setFrame(int i);

void saveAnimation();
void editMarkerId(const QString &newId);

private:
Ui::AnimationEditor *m_ui;

AnimationPlayer *m_player;

int m_currentFrameId = -1;
Animation *m_animation = nullptr;
};

#endif // ANIMATIONEDITOR_H
10 changes: 10 additions & 0 deletions WebCamCap2/gui/wccmainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "addcamera.h"
#include "openglscene.h"
#include "src/localserver.h"
#include "animationeditor.h"

#include <QDebug>
#include <QSettings>
Expand Down Expand Up @@ -413,9 +414,18 @@ void WccMainWindow::animationEdit()
{
if(snd == m_ui->AnimationsTable->cellWidget(row, 3))
{
m_currentProject->settings()->setRecordScene(false);

//open editor window with animation
AnimationEditor* editor = new AnimationEditor(this);

editor->setAnimation(m_animations[row]);

editor->show();
/*
qDebug() << "row clicked: " << row << m_animations[row]->name();
m_animations[row]->save(QDir::currentPath());
*/
}
}
}
Expand Down
Binary file added WebCamCapGui/Pictures/last-track.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added WebCamCapGui/Pictures/music-player15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added WebCamCapGui/Pictures/music-player7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added WebCamCapGui/Pictures/next-track.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions WebCamCapGui/WebCamCapGui.pro
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ DEPENDPATH += $$PWD/../WebCamCapPrimitives

FORMS += \
animationplayer.ui

RESOURCES += \
webcamcapgui.qrc
Loading

0 comments on commit 00bd3b4

Please sign in to comment.