mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-08 16:59:59 +01:00
Work in progress: undo & redo of mixing group creation and delete
actions.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "Log.h"
|
||||
#include "View.h"
|
||||
#include "Mixer.h"
|
||||
#include "MixingGroup.h"
|
||||
#include "tinyxml2Toolkit.h"
|
||||
#include "SessionVisitor.h"
|
||||
#include "SessionCreator.h"
|
||||
@@ -163,6 +164,10 @@ void Action::restore(uint target, uint64_t id)
|
||||
Log::Info("Restore %s '%s' ", nodename.c_str(), sessionNode->Attribute("label"));
|
||||
#endif
|
||||
|
||||
//
|
||||
// compare source lists
|
||||
//
|
||||
|
||||
// we operate on the current session
|
||||
Session *se = Mixer::manager().session();
|
||||
if (se == nullptr)
|
||||
@@ -194,6 +199,7 @@ void Action::restore(uint target, uint64_t id)
|
||||
else
|
||||
lsit++;
|
||||
}
|
||||
|
||||
// remaining ids in list sessionsources : to remove
|
||||
while ( !sessionsources.empty() ){
|
||||
Source *s = Mixer::manager().findSource( sessionsources.front() );
|
||||
@@ -208,6 +214,7 @@ void Action::restore(uint target, uint64_t id)
|
||||
}
|
||||
sessionsources.pop_front();
|
||||
}
|
||||
|
||||
// remaining ids in list loadersources : to add
|
||||
while ( !loadersources.empty() ){
|
||||
#ifdef ACTION_DEBUG
|
||||
@@ -220,6 +227,54 @@ void Action::restore(uint target, uint64_t id)
|
||||
loadersources.pop_front();
|
||||
}
|
||||
|
||||
//
|
||||
// compare mixing groups
|
||||
//
|
||||
|
||||
// Get the list of mixing groups in the xml loader
|
||||
std::list< SourceList > loadergroups = loader.getMixingGroups();
|
||||
|
||||
// apply all changes creating or modifying groups in the session
|
||||
// (after this, new groups are created and existing groups are adjusted)
|
||||
for (auto group_loader_it = loadergroups.begin(); group_loader_it != loadergroups.end(); group_loader_it++) {
|
||||
se->updateMixingGroup( *group_loader_it );
|
||||
}
|
||||
|
||||
// Get the updated list of mixing groups in the session
|
||||
std::list< SourceList > sessiongroups = se->getMixingGroups();
|
||||
// the remaining case is if session has groups that are not in the loaded xml
|
||||
// (that should therefore be deleted)
|
||||
if ( sessiongroups.size() > loadergroups.size() )
|
||||
{
|
||||
// find those groups ! : loop over every session group
|
||||
for (auto group_se_it = sessiongroups.begin(); group_se_it != sessiongroups.end(); ) {
|
||||
// asume we do not find it in the loadergroups
|
||||
bool is_in_loadergroups = false;
|
||||
// look in the loaded groups if there is one EQUAL to it
|
||||
for (auto group_loader_it = loadergroups.begin(); group_loader_it != loadergroups.end(); group_loader_it++) {
|
||||
// compare the groups
|
||||
if ( compare( *group_loader_it, *group_se_it) == SOURCELIST_EQUAL ) {
|
||||
// yeah, found an EQUAL group that was loaded
|
||||
is_in_loadergroups = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// remove the group from the list if it was loaded
|
||||
if ( is_in_loadergroups )
|
||||
group_se_it = sessiongroups.erase(group_se_it);
|
||||
// else keep it and continue
|
||||
else
|
||||
group_se_it++;
|
||||
}
|
||||
|
||||
// the remaining groups in sessiongroups do not have an EQUAL match in the loader groups
|
||||
for (auto group_se_it = sessiongroups.begin(); group_se_it != sessiongroups.end(); ) {
|
||||
// remove that group from the session
|
||||
se->removeMixingGroup( *group_se_it );
|
||||
group_se_it = sessiongroups.erase(group_se_it);
|
||||
}
|
||||
}
|
||||
|
||||
// free
|
||||
locked_ = false;
|
||||
|
||||
|
||||
40
Mixer.cpp
40
Mixer.cpp
@@ -148,6 +148,7 @@ void Mixer::update()
|
||||
if (sessionImporters_.back().wait_for(timeout_) == std::future_status::ready ) {
|
||||
// get the session loaded by this loader
|
||||
merge( sessionImporters_.back().get() );
|
||||
// FIXME: shouldn't we delete the imported session?
|
||||
// done with this session loader
|
||||
sessionImporters_.pop_back();
|
||||
}
|
||||
@@ -209,22 +210,6 @@ void Mixer::update()
|
||||
// update session and associated sources
|
||||
session_->update(dt_);
|
||||
|
||||
// update session's mixing groups
|
||||
auto group_iter = session_->beginMixingGroup();
|
||||
while ( group_iter != session_->endMixingGroup() ){
|
||||
// update all valid groups
|
||||
if ((*group_iter)->size() > 1) {
|
||||
(*group_iter)->update(dt_);
|
||||
group_iter++;
|
||||
}
|
||||
// delete invalid groups (singletons)
|
||||
else {
|
||||
mixing_.scene.fg()->detach( (*group_iter)->group() );
|
||||
delete (*group_iter);
|
||||
group_iter = session_->eraseMixingGroup(group_iter);
|
||||
}
|
||||
}
|
||||
|
||||
// grab frames to recorders & streamers
|
||||
FrameGrabbing::manager().grabFrame(session_->frame(), dt_);
|
||||
|
||||
@@ -785,7 +770,7 @@ Source * Mixer::findSource (uint64_t id)
|
||||
SourceList Mixer::findSources (float depth_from, float depth_to)
|
||||
{
|
||||
SourceList found;
|
||||
SourceList dsl = session_->depthSorted();
|
||||
SourceList dsl = session_->getDepthSortedList();
|
||||
SourceList::iterator it = dsl.begin();
|
||||
for (; it != dsl.end(); it++) {
|
||||
if ( (*it)->depth() > depth_to )
|
||||
@@ -1057,11 +1042,8 @@ void Mixer::merge(Session *session)
|
||||
// import and attach session's mixing groups
|
||||
auto group_iter = session->beginMixingGroup();
|
||||
while ( group_iter != session->endMixingGroup() ){
|
||||
if (session_->addMixingGroup( *group_iter ) )
|
||||
mixing_.scene.fg()->attach( (*group_iter)->group() );
|
||||
else
|
||||
delete (*group_iter);
|
||||
group_iter = session->eraseMixingGroup(group_iter);
|
||||
session_->updateMixingGroup((*group_iter)->getCopy(), mixing_.scene.fg());
|
||||
group_iter = session->deleteMixingGroup(group_iter);
|
||||
}
|
||||
|
||||
// needs to update !
|
||||
@@ -1091,7 +1073,7 @@ void Mixer::merge(SessionSource *source)
|
||||
float target_depth = source->depth();
|
||||
|
||||
// get how much space we need from there
|
||||
SourceList dsl = session->depthSorted();
|
||||
SourceList dsl = session->getDepthSortedList();
|
||||
float start_depth = dsl.front()->depth();
|
||||
float end_depth = dsl.back()->depth();
|
||||
float need_depth = MAX( end_depth - start_depth, LAYER_STEP);
|
||||
@@ -1142,11 +1124,8 @@ void Mixer::merge(SessionSource *source)
|
||||
// import and attach session's mixing groups
|
||||
auto group_iter = session->beginMixingGroup();
|
||||
while ( group_iter != session->endMixingGroup() ){
|
||||
if (session_->addMixingGroup( *group_iter ) )
|
||||
mixing_.scene.fg()->attach( (*group_iter)->group() );
|
||||
else
|
||||
delete (*group_iter);
|
||||
group_iter = session->eraseMixingGroup(group_iter);
|
||||
session_->updateMixingGroup((*group_iter)->getCopy(), mixing_.scene.fg());
|
||||
group_iter = session->deleteMixingGroup(group_iter);
|
||||
}
|
||||
|
||||
// needs to update !
|
||||
@@ -1170,9 +1149,6 @@ void Mixer::swap()
|
||||
// detatch current session's nodes from views
|
||||
for (auto source_iter = session_->begin(); source_iter != session_->end(); source_iter++)
|
||||
detach(*source_iter);
|
||||
// detatch current session's mixing groups
|
||||
for (auto group_iter = session_->beginMixingGroup(); group_iter != session_->endMixingGroup(); group_iter++)
|
||||
mixing_.scene.fg()->detach( (*group_iter)->group() );
|
||||
}
|
||||
|
||||
// swap back and front
|
||||
@@ -1192,7 +1168,7 @@ void Mixer::swap()
|
||||
|
||||
// attach new session's mixing group to mixingview
|
||||
for (auto group_iter = session_->beginMixingGroup(); group_iter != session_->endMixingGroup(); group_iter++)
|
||||
mixing_.scene.fg()->attach( (*group_iter)->group() );
|
||||
(*group_iter)->attachTo( mixing_.scene.fg() );
|
||||
|
||||
// set resolution
|
||||
session_->setResolution( session_->config(View::RENDERING)->scale_ );
|
||||
|
||||
125
MixingGroup.cpp
125
MixingGroup.cpp
@@ -13,24 +13,20 @@
|
||||
#include "MixingGroup.h"
|
||||
|
||||
|
||||
MixingGroup::MixingGroup (SourceList sources) : root_(nullptr), lines_(nullptr), center_(nullptr),
|
||||
MixingGroup::MixingGroup (SourceList sources) : parent_(nullptr), root_(nullptr), lines_(nullptr), center_(nullptr),
|
||||
center_pos_(glm::vec2(0.f, 0.f)), active_(true), update_action_(ACTION_NONE), updated_source_(nullptr)
|
||||
{
|
||||
// create unique id
|
||||
id_ = GlmToolkit::uniqueId();
|
||||
|
||||
// fill the vector of sources with the given list
|
||||
for (auto it = sources.begin(); it != sources.end(); it++){
|
||||
// add only if not linked already
|
||||
if ((*it)->mixinggroup_ == nullptr) {
|
||||
(*it)->mixinggroup_ = this;
|
||||
sources_.push_back(*it);
|
||||
// compute barycenter on the way (1)
|
||||
center_pos_ += glm::vec2((*it)->group(View::MIXING)->translation_);
|
||||
}
|
||||
}
|
||||
// compute barycenter (2)
|
||||
center_pos_ /= sources_.size();
|
||||
|
||||
// sort the vector of sources in clockwise order around the center pos_
|
||||
sources_ = mixing_sorted( sources_, center_pos_);
|
||||
|
||||
// scene elements
|
||||
root_ = new Group;
|
||||
@@ -38,18 +34,20 @@ MixingGroup::MixingGroup (SourceList sources) : root_(nullptr), lines_(nullptr),
|
||||
center_->visible_ = false;
|
||||
center_->color = glm::vec4(COLOR_MIXING_GROUP, 0.75f);
|
||||
center_->scale_ = glm::vec3(0.6f, 0.6f, 1.f);
|
||||
center_->translation_ = glm::vec3(center_pos_, 0.f);
|
||||
root_->attach(center_);
|
||||
|
||||
// create
|
||||
recenter();
|
||||
createLineStrip();
|
||||
}
|
||||
|
||||
MixingGroup::~MixingGroup ()
|
||||
{
|
||||
for (auto it = sources_.begin(); it != sources_.end(); it++) {
|
||||
(*it)->mixinggroup_ = nullptr;
|
||||
(*it)->overlay_mixinggroup_->visible_ = false;
|
||||
}
|
||||
for (auto it = sources_.begin(); it != sources_.end(); it++)
|
||||
(*it)->clearMixingGroup();
|
||||
|
||||
if (parent_)
|
||||
parent_->detach( root_ );
|
||||
delete root_;
|
||||
}
|
||||
|
||||
@@ -58,6 +56,32 @@ void MixingGroup::accept(Visitor& v)
|
||||
v.visit(*this);
|
||||
}
|
||||
|
||||
void MixingGroup::attachTo( Group *parent )
|
||||
{
|
||||
if (parent_ != nullptr)
|
||||
parent_->detach( root_ );
|
||||
|
||||
parent_ = parent;
|
||||
|
||||
if (parent_ != nullptr)
|
||||
parent_->attach(root_);
|
||||
}
|
||||
|
||||
void MixingGroup::recenter()
|
||||
{
|
||||
// compute barycenter (0)
|
||||
center_pos_ = glm::vec2(0.f, 0.f);
|
||||
for (auto it = sources_.begin(); it != sources_.end(); it++){
|
||||
// compute barycenter (1)
|
||||
center_pos_ += glm::vec2((*it)->group(View::MIXING)->translation_);
|
||||
}
|
||||
// compute barycenter (2)
|
||||
center_pos_ /= sources_.size();
|
||||
|
||||
// set center
|
||||
center_->translation_ = glm::vec3(center_pos_, 0.f);
|
||||
}
|
||||
|
||||
void MixingGroup::update (float dt)
|
||||
{
|
||||
// active if current source in the group
|
||||
@@ -71,16 +95,7 @@ void MixingGroup::update (float dt)
|
||||
|
||||
// update path
|
||||
move(updated_source_);
|
||||
|
||||
// compute barycenter (0)
|
||||
center_pos_ = glm::vec2(0.f, 0.f);
|
||||
for (auto it = sources_.begin(); it != sources_.end(); it++){
|
||||
// compute barycenter (1)
|
||||
center_pos_ += glm::vec2((*it)->group(View::MIXING)->translation_);
|
||||
}
|
||||
// compute barycenter (2)
|
||||
center_pos_ /= sources_.size();
|
||||
center_->translation_ = glm::vec3(center_pos_, 0.f);
|
||||
recenter();
|
||||
}
|
||||
else if (update_action_ == ACTION_GRAB_ALL ) {
|
||||
|
||||
@@ -170,20 +185,78 @@ void MixingGroup::detach (Source *s)
|
||||
// ok, its in the list !
|
||||
if (its != sources_.end()) {
|
||||
// tell the source
|
||||
(*its)->mixinggroup_ = nullptr;
|
||||
(*its)->clearMixingGroup();
|
||||
// erase the source from the list
|
||||
sources_.erase(its);
|
||||
// update barycenter
|
||||
recenter();
|
||||
// clear index, delete lines_, and recreate path and index with remaining sources
|
||||
createLineStrip();
|
||||
}
|
||||
}
|
||||
|
||||
void MixingGroup::detach (SourceList l)
|
||||
{
|
||||
for (auto sit = l.begin(); sit != l.end(); sit++) {
|
||||
// find the source
|
||||
SourceList::iterator its = std::find(sources_.begin(), sources_.end(), *sit);
|
||||
// ok, its in the list !
|
||||
if (its != sources_.end()) {
|
||||
// tell the source
|
||||
(*its)->clearMixingGroup();
|
||||
// erase the source from the list
|
||||
sources_.erase(its);
|
||||
}
|
||||
}
|
||||
// update barycenter
|
||||
recenter();
|
||||
// clear index, delete lines_, and recreate path and index with remaining sources
|
||||
createLineStrip();
|
||||
}
|
||||
|
||||
|
||||
void MixingGroup::attach (Source *s)
|
||||
{
|
||||
// if source is not already in a group (this or other)
|
||||
if (s->mixinggroup_ == nullptr) {
|
||||
// tell the source
|
||||
s->mixinggroup_ = this;
|
||||
// add the source
|
||||
sources_.push_back(s);
|
||||
// update barycenter
|
||||
recenter();
|
||||
// clear index, delete lines_, and recreate path and index with remaining sources
|
||||
createLineStrip();
|
||||
}
|
||||
}
|
||||
|
||||
void MixingGroup::attach (SourceList l)
|
||||
{
|
||||
for (auto sit = l.begin(); sit != l.end(); sit++) {
|
||||
if ( (*sit)->mixinggroup_ == nullptr) {
|
||||
// tell the source
|
||||
(*sit)->mixinggroup_ = this;
|
||||
// add the source
|
||||
sources_.push_back(*sit);
|
||||
}
|
||||
}
|
||||
// update barycenter
|
||||
recenter();
|
||||
// clear index, delete lines_, and recreate path and index with remaining sources
|
||||
createLineStrip();
|
||||
}
|
||||
|
||||
uint MixingGroup::size()
|
||||
{
|
||||
return sources_.size();
|
||||
}
|
||||
|
||||
SourceList MixingGroup::getCopy() const
|
||||
{
|
||||
SourceList sl = sources_;
|
||||
return sl;
|
||||
}
|
||||
|
||||
SourceList::iterator MixingGroup::begin ()
|
||||
{
|
||||
return sources_.begin();
|
||||
@@ -219,6 +292,10 @@ void MixingGroup::createLineStrip()
|
||||
delete lines_;
|
||||
}
|
||||
|
||||
// sort the vector of sources in clockwise order around the center pos_
|
||||
sources_ = mixing_sorted( sources_, center_pos_);
|
||||
|
||||
// start afresh list of indices
|
||||
index_points_.clear();
|
||||
|
||||
// path linking all sources
|
||||
|
||||
@@ -16,6 +16,9 @@ public:
|
||||
MixingGroup (SourceList sources);
|
||||
~MixingGroup ();
|
||||
|
||||
// Get unique id
|
||||
inline uint64_t id () const { return id_; }
|
||||
|
||||
// actions for update
|
||||
typedef enum {
|
||||
ACTION_NONE = 0,
|
||||
@@ -28,7 +31,7 @@ public:
|
||||
inline void follow (Source *s) { updated_source_ = s; }
|
||||
|
||||
// node to draw
|
||||
inline Group *group () { return root_; }
|
||||
void attachTo( Group *parent );
|
||||
|
||||
// accept all kind of visitors
|
||||
virtual void accept (Visitor& v);
|
||||
@@ -39,19 +42,25 @@ public:
|
||||
void setActive (bool on);
|
||||
|
||||
// Source list manipulation
|
||||
SourceList getCopy() const;
|
||||
SourceList::iterator begin ();
|
||||
SourceList::iterator end ();
|
||||
uint size ();
|
||||
bool contains (Source *s);
|
||||
void detach (Source *s);
|
||||
void detach (SourceList l);
|
||||
void attach (Source *s);
|
||||
void attach (SourceList l);
|
||||
|
||||
private:
|
||||
|
||||
// Drawing elements
|
||||
Group *parent_;
|
||||
Group *root_;
|
||||
LineLoop *lines_;
|
||||
Symbol *center_;
|
||||
void createLineStrip();
|
||||
void recenter();
|
||||
void move (Source *s);
|
||||
|
||||
// properties linked to sources
|
||||
@@ -60,11 +69,11 @@ private:
|
||||
std::map< Source *, uint> index_points_;
|
||||
|
||||
// status and actions
|
||||
uint64_t id_;
|
||||
bool active_;
|
||||
Action update_action_;
|
||||
Source *updated_source_;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // MIXINGGROUP_H
|
||||
|
||||
@@ -12,12 +12,13 @@
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#include "Log.h"
|
||||
#include "Mixer.h"
|
||||
#include "defines.h"
|
||||
#include "Settings.h"
|
||||
#include "Decorations.h"
|
||||
#include "UserInterfaceManager.h"
|
||||
#include "Log.h"
|
||||
#include "ActionManager.h"
|
||||
#include "MixingGroup.h"
|
||||
|
||||
#include "MixingView.h"
|
||||
@@ -128,13 +129,15 @@ void MixingView::draw()
|
||||
|
||||
// special action of Mixing view
|
||||
if (ImGui::Selectable( ICON_FA_DRAW_POLYGON " Link" )){
|
||||
// TODO create MixingGroup
|
||||
MixingGroup *mg = Mixer::manager().session()->createMixingGroup(Mixer::selection().getCopy());
|
||||
scene.fg()->attach(mg->group());
|
||||
Source *cur = Mixer::selection().front();
|
||||
Mixer::manager().unsetCurrentSource();
|
||||
Mixer::selection().clear();
|
||||
Mixer::manager().setCurrentSource( cur );
|
||||
// create MixingGroup
|
||||
if (Mixer::manager().session()->updateMixingGroup(Mixer::selection().getCopy(), scene.fg() ) ) {
|
||||
Action::manager().store(std::string("Sources linked."), Mixer::manager().session()->lastMixingGroup()->id());
|
||||
// clear selection and select one of the sources of the group
|
||||
Source *cur = Mixer::selection().front();
|
||||
Mixer::manager().unsetCurrentSource();
|
||||
Mixer::selection().clear();
|
||||
Mixer::manager().setCurrentSource( cur );
|
||||
}
|
||||
}
|
||||
ImGui::Separator();
|
||||
|
||||
|
||||
167
Session.cpp
167
Session.cpp
@@ -39,7 +39,11 @@ Session::Session() : failedSource_(nullptr), active_(true), fading_target_(0.f)
|
||||
Session::~Session()
|
||||
{
|
||||
// TODO delete all mixing groups?
|
||||
|
||||
auto group_iter = mixing_groups_.begin();
|
||||
while ( group_iter != mixing_groups_.end() ){
|
||||
delete (*group_iter);
|
||||
group_iter = mixing_groups_.erase(group_iter);
|
||||
}
|
||||
|
||||
// delete all sources
|
||||
for(auto it = sources_.begin(); it != sources_.end(); ) {
|
||||
@@ -91,17 +95,18 @@ void Session::update(float dt)
|
||||
}
|
||||
}
|
||||
|
||||
// // update the mixinggroups
|
||||
// for (auto g = mixing_groups_.begin(); g != mixing_groups_.end(); ) {
|
||||
// // update all valid groups
|
||||
// if ((*g)->size() > 1) {
|
||||
// (*g)->update(dt);
|
||||
// g++;
|
||||
// }
|
||||
// // delete invalid groups (singletons)
|
||||
// else
|
||||
// g = deleteMixingGroup(g);
|
||||
// }
|
||||
// update session's mixing groups
|
||||
auto group_iter = mixing_groups_.begin();
|
||||
while ( group_iter != mixing_groups_.end() ){
|
||||
// update all valid groups
|
||||
if ((*group_iter)->size() > 1) {
|
||||
(*group_iter)->update(dt);
|
||||
group_iter++;
|
||||
}
|
||||
else
|
||||
// delete invalid groups (singletons)
|
||||
group_iter = deleteMixingGroup(group_iter);
|
||||
}
|
||||
|
||||
// apply fading (smooth dicotomic reaching)
|
||||
float f = render_.fading();
|
||||
@@ -183,6 +188,9 @@ void Session::removeSource(Source *s)
|
||||
if (its != sources_.end()) {
|
||||
// remove Node from the rendering scene
|
||||
render_.scene.ws()->detach( s->group(View::RENDERING) );
|
||||
// inform group
|
||||
if (s->mixingGroup() != nullptr)
|
||||
s->mixingGroup()->detach(s);
|
||||
// erase the source from the update list & get next element
|
||||
sources_.erase(its);
|
||||
}
|
||||
@@ -260,7 +268,7 @@ SourceList::iterator Session::find(float depth_from, float depth_to)
|
||||
return std::find_if(sources_.begin(), sources_.end(), Source::hasDepth(depth_from, depth_to));
|
||||
}
|
||||
|
||||
SourceList Session::depthSorted() const
|
||||
SourceList Session::getDepthSortedList() const
|
||||
{
|
||||
return depth_sorted(sources_);
|
||||
}
|
||||
@@ -324,9 +332,9 @@ void Session::move(int current_index, int target_index)
|
||||
sources_.insert(to, s);
|
||||
}
|
||||
|
||||
MixingGroup *Session::createMixingGroup(SourceList sources)
|
||||
bool Session::updateMixingGroup(SourceList sources, Group *parent)
|
||||
{
|
||||
// will return the pointer to created MixingGroup
|
||||
// pointer to created MixingGroup
|
||||
MixingGroup *g = nullptr;
|
||||
|
||||
// verify that all sources given are valid in the sesion
|
||||
@@ -337,56 +345,125 @@ MixingGroup *Session::createMixingGroup(SourceList sources)
|
||||
valid_sources.push_back(*found);
|
||||
}
|
||||
|
||||
// create mixing group with valid sources (if it is a group of at least 2 sources)
|
||||
// try to create mixing group with valid sources (if it is a group of at least 2 sources)
|
||||
if (valid_sources.size() > 1) {
|
||||
g = new MixingGroup(valid_sources);
|
||||
mixing_groups_.push_back(g);
|
||||
|
||||
// does this interfere with existing groups?
|
||||
SourceListCompare c = SOURCELIST_DISTINCT;
|
||||
for (auto group_it = mixing_groups_.begin(); group_it!= mixing_groups_.end(); group_it++) {
|
||||
SourceList group_sources = (*group_it)->getCopy();
|
||||
c = compare( group_sources, sources );
|
||||
if ( c != SOURCELIST_DISTINCT ){
|
||||
// case of source list containing entirely the group
|
||||
if ( c == SOURCELIST_FIRST_IN_SECOND ) {
|
||||
// extend the group with extra sources
|
||||
g = *group_it;
|
||||
// add all sources (will ignore already linked sources)
|
||||
g->attach( sources );
|
||||
}
|
||||
// case of mixing group containing entirely the source list
|
||||
else if ( c == SOURCELIST_SECOND_IN_FIRST ) {
|
||||
// reduce the group from the extra sources
|
||||
g = *group_it;
|
||||
// keep only elements of group_sources that are not in sources
|
||||
for (auto it = sources.begin(); it != sources.end(); it++)
|
||||
group_sources.remove(*it);
|
||||
// remove all extra sources
|
||||
g->detach( group_sources );
|
||||
}
|
||||
// stop the loop
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// the sourcelist is distinct from all existing groups
|
||||
// (NB: ignore INTERSECT and EQUAL cases)
|
||||
if ( c == SOURCELIST_DISTINCT ) {
|
||||
// create and add a new mixing group
|
||||
g = new MixingGroup(valid_sources);
|
||||
mixing_groups_.push_back(g);
|
||||
}
|
||||
|
||||
// if provided, attach the group to the parent
|
||||
if (g && parent != nullptr)
|
||||
g->attachTo( parent );
|
||||
|
||||
}
|
||||
|
||||
return g;
|
||||
return ( g != nullptr );
|
||||
}
|
||||
|
||||
|
||||
bool Session::addMixingGroup (MixingGroup *mg)
|
||||
bool Session::removeMixingGroup (SourceList sources)
|
||||
{
|
||||
// verify that all sources given in MixingGroup are valid in the sesion
|
||||
bool ok = true;
|
||||
for (auto _it = mg->begin(); _it != mg->end(); _it++) {
|
||||
bool ret = false;
|
||||
|
||||
// verify that all sources given are valid in the sesion
|
||||
SourceList valid_sources;
|
||||
for (auto _it = sources.begin(); _it != sources.end(); _it++) {
|
||||
SourceList::iterator found = std::find(sources_.begin(), sources_.end(), *_it);
|
||||
if ( found == sources_.end()) {
|
||||
ok = false;
|
||||
if ( found != sources_.end())
|
||||
valid_sources.push_back(*found);
|
||||
}
|
||||
|
||||
// does this intersect with existing groups?
|
||||
SourceListCompare c = SOURCELIST_DISTINCT;
|
||||
|
||||
for (auto group_it = mixing_groups_.begin(); group_it!= mixing_groups_.end(); group_it++) {
|
||||
SourceList group_sources = (*group_it)->getCopy();
|
||||
c = compare( group_sources, sources );
|
||||
if ( c == SOURCELIST_EQUAL ) {
|
||||
delete (*group_it);
|
||||
mixing_groups_.erase(group_it);
|
||||
// stop the loop
|
||||
ret = true;
|
||||
break;
|
||||
}
|
||||
// case of mixing group containing entirely the source list
|
||||
else if ( c == SOURCELIST_INTERSECT ) {
|
||||
group_sources = intersect( group_sources, sources);
|
||||
// remove all extra sources
|
||||
(*group_it)->detach( group_sources );
|
||||
// stop the loop
|
||||
ret = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ok)
|
||||
mixing_groups_.push_back(mg);
|
||||
return ok;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Session::createMixingGroups (std::list<SourceList> groups)
|
||||
std::list<SourceList> Session::getMixingGroups () const
|
||||
{
|
||||
// create mixing groups (if any)
|
||||
for (auto group_it = groups.begin(); group_it != groups.end(); group_it++){
|
||||
createMixingGroup( *group_it );
|
||||
std::list<SourceList> lmg;
|
||||
|
||||
for (auto group_it = mixing_groups_.begin(); group_it!= mixing_groups_.end(); group_it++)
|
||||
lmg.push_back( (*group_it)->getCopy() );
|
||||
|
||||
return lmg;
|
||||
}
|
||||
|
||||
MixingGroup *Session::lastMixingGroup ()
|
||||
{
|
||||
if (mixing_groups_.empty())
|
||||
return nullptr;
|
||||
return mixing_groups_.back();
|
||||
}
|
||||
|
||||
std::list<MixingGroup *>::iterator Session::deleteMixingGroup (std::list<MixingGroup *>::iterator g)
|
||||
{
|
||||
if (g != mixing_groups_.end()) {
|
||||
delete (*g);
|
||||
return mixing_groups_.erase(g);
|
||||
}
|
||||
return mixing_groups_.end();
|
||||
}
|
||||
|
||||
std::vector<MixingGroup *>::iterator Session::eraseMixingGroup (std::vector<MixingGroup *>::iterator g)
|
||||
{
|
||||
return mixing_groups_.erase(g);
|
||||
}
|
||||
|
||||
uint Session::numMixingGroup() const
|
||||
{
|
||||
return mixing_groups_.size();
|
||||
}
|
||||
|
||||
std::vector<MixingGroup *>::iterator Session::beginMixingGroup()
|
||||
std::list<MixingGroup *>::iterator Session::beginMixingGroup()
|
||||
{
|
||||
return mixing_groups_.begin();
|
||||
}
|
||||
|
||||
std::vector<MixingGroup *>::iterator Session::endMixingGroup()
|
||||
std::list<MixingGroup *>::iterator Session::endMixingGroup()
|
||||
{
|
||||
return mixing_groups_.end();
|
||||
}
|
||||
|
||||
34
Session.h
34
Session.h
@@ -40,7 +40,7 @@ public:
|
||||
SourceList::iterator find (std::string name);
|
||||
SourceList::iterator find (Node *node);
|
||||
SourceList::iterator find (float depth_from, float depth_to);
|
||||
SourceList depthSorted() const;
|
||||
SourceList getDepthSortedList () const;
|
||||
|
||||
SourceList::iterator find (uint64_t id);
|
||||
SourceIdList getIdList() const;
|
||||
@@ -57,44 +57,44 @@ public:
|
||||
inline bool active () { return active_; }
|
||||
|
||||
// return the last source which failed
|
||||
Source *failedSource() { return failedSource_; }
|
||||
Source *failedSource () { return failedSource_; }
|
||||
|
||||
// get frame result of render
|
||||
inline FrameBuffer *frame () const { return render_.frame(); }
|
||||
|
||||
// configure rendering resolution
|
||||
void setResolution(glm::vec3 resolution, bool useAlpha = false);
|
||||
void setResolution (glm::vec3 resolution, bool useAlpha = false);
|
||||
|
||||
// manipulate fading of output
|
||||
void setFading(float f, bool forcenow = false);
|
||||
inline float fading() const { return fading_target_; }
|
||||
void setFading (float f, bool forcenow = false);
|
||||
inline float fading () const { return fading_target_; }
|
||||
|
||||
// configuration for group nodes of views
|
||||
inline Group *config (View::Mode m) const { return config_.at(m); }
|
||||
|
||||
// name of file containing this session (for transfer)
|
||||
void setFilename(const std::string &filename) { filename_ = filename; }
|
||||
std::string filename() const { return filename_; }
|
||||
void setFilename (const std::string &filename) { filename_ = filename; }
|
||||
std::string filename () const { return filename_; }
|
||||
|
||||
// mixing group
|
||||
bool addMixingGroup(MixingGroup *mg);
|
||||
MixingGroup *createMixingGroup (SourceList sources);
|
||||
std::vector<MixingGroup *>::iterator eraseMixingGroup (std::vector<MixingGroup *>::iterator g);
|
||||
void createMixingGroups (std::list<SourceList> groups);
|
||||
uint numMixingGroup() const;
|
||||
std::vector<MixingGroup *>::iterator beginMixingGroup();
|
||||
std::vector<MixingGroup *>::iterator endMixingGroup();
|
||||
bool updateMixingGroup (SourceList sources, Group *parent = nullptr);
|
||||
bool removeMixingGroup (SourceList sources);
|
||||
MixingGroup *lastMixingGroup ();
|
||||
std::list<SourceList> getMixingGroups () const;
|
||||
std::list<MixingGroup *>::iterator beginMixingGroup ();
|
||||
std::list<MixingGroup *>::iterator endMixingGroup ();
|
||||
std::list<MixingGroup *>::iterator deleteMixingGroup (std::list<MixingGroup *>::iterator g);
|
||||
|
||||
// lock and unlock access (e.g. while saving)
|
||||
void lock();
|
||||
void unlock();
|
||||
void lock ();
|
||||
void unlock ();
|
||||
|
||||
protected:
|
||||
RenderView render_;
|
||||
std::string filename_;
|
||||
Source *failedSource_;
|
||||
SourceList sources_;
|
||||
std::vector<MixingGroup *> mixing_groups_;
|
||||
std::list<MixingGroup *> mixing_groups_;
|
||||
std::map<View::Mode, Group*> config_;
|
||||
bool active_;
|
||||
std::list<FrameGrabber *> grabbers_;
|
||||
|
||||
@@ -92,35 +92,12 @@ void SessionCreator::load(const std::string& filename)
|
||||
SessionLoader::load( xmlDoc_.FirstChildElement("Session") );
|
||||
|
||||
// create groups
|
||||
session_->createMixingGroups( getMixingGroups() );
|
||||
std::list< SourceList > groups = getMixingGroups();
|
||||
for (auto group_it = groups.begin(); group_it != groups.end(); group_it++)
|
||||
session_->updateMixingGroup( *group_it );
|
||||
|
||||
// all good
|
||||
session_->setFilename(filename);
|
||||
|
||||
// for (std::map< uint64_t, Source* >::iterator qwe = sources_id_.begin(); qwe != sources_id_.end(); qwe++){
|
||||
// Log::Info("%ld - %ld ", qwe->first, qwe->second->id());
|
||||
// }
|
||||
|
||||
// int count = 0;
|
||||
// std::list< SourceIdList >::iterator git;
|
||||
// for (git = groups_sources_id_.begin(); git != groups_sources_id_.end(); git++)
|
||||
// {
|
||||
// Log::Info("XML Groups %d", count++);
|
||||
// std::list<uint64_t>::iterator sit;
|
||||
// for (sit = (*git).begin(); sit != (*git).end(); sit++ ) {
|
||||
// Log::Info("- %ld", (*sit) );
|
||||
// }
|
||||
// }
|
||||
|
||||
// std::list< SourceList > ngrou = getMixingGroupsIdList();
|
||||
// count = 0;
|
||||
// for (auto git = ngrou.begin(); git != ngrou.end(); git++)
|
||||
// {
|
||||
// Log::Info("NEW Groups %d", count++);
|
||||
// for (auto sit = (*git).begin(); sit != (*git).end(); sit++ ) {
|
||||
// Log::Info("- %ld", (*sit)->id() );
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -741,6 +741,13 @@ bool Source::hasNode::operator()(const Source* elem) const
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void Source::clearMixingGroup()
|
||||
{
|
||||
mixinggroup_ = nullptr;
|
||||
overlay_mixinggroup_->visible_ = false;
|
||||
}
|
||||
|
||||
CloneSource *Source::clone()
|
||||
{
|
||||
CloneSource *s = new CloneSource(this);
|
||||
|
||||
1
Source.h
1
Source.h
@@ -141,6 +141,7 @@ public:
|
||||
|
||||
// groups for mixing
|
||||
MixingGroup *mixingGroup() const { return mixinggroup_; }
|
||||
void clearMixingGroup();
|
||||
|
||||
struct hasNode: public std::unary_function<Source*, bool>
|
||||
{
|
||||
|
||||
@@ -114,5 +114,7 @@ SourceList join (SourceList first, SourceList second)
|
||||
SourceList l = second;
|
||||
for (auto it = first.begin(); it != first.end(); it++)
|
||||
l.push_back(*it);
|
||||
l.unique();
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user