multicam: finished UI implementation
This commit is contained in:
@@ -58,10 +58,18 @@ MulticamWidget::MulticamWidget(QWidget *parent) :
|
||||
|
||||
void MulticamWidget::SetMulticamNodeInternal(ViewerOutput *viewer, MultiCamNode *n, ClipBlock *clip)
|
||||
{
|
||||
ConnectViewerNode(viewer);
|
||||
node_ = n;
|
||||
display_->SetMulticamNode(n);
|
||||
clip_ = clip;
|
||||
if (GetConnectedNode() != viewer) {
|
||||
ConnectViewerNode(viewer);
|
||||
}
|
||||
|
||||
if (node_ != n) {
|
||||
node_ = n;
|
||||
display_->SetMulticamNode(n);
|
||||
}
|
||||
|
||||
if (clip_ != clip) {
|
||||
clip_ = clip;
|
||||
}
|
||||
}
|
||||
|
||||
void MulticamWidget::SetMulticamNode(ViewerOutput *viewer, MultiCamNode *n, ClipBlock *clip, const rational &time)
|
||||
@@ -145,6 +153,8 @@ void MulticamWidget::Switch(int source, bool split_clip)
|
||||
Core::instance()->undo_stack()->push(command);
|
||||
|
||||
display_->update();
|
||||
|
||||
emit Switched();
|
||||
}
|
||||
|
||||
void MulticamWidget::DisplayClicked(const QPoint &p)
|
||||
|
||||
@@ -42,6 +42,9 @@ protected:
|
||||
virtual void DisconnectNodeEvent(ViewerOutput *n) override;
|
||||
virtual void TimeChangedEvent(const rational &t) override;
|
||||
|
||||
signals:
|
||||
void Switched();
|
||||
|
||||
private:
|
||||
void SetMulticamNodeInternal(ViewerOutput *viewer, MultiCamNode *n, ClipBlock *clip);
|
||||
|
||||
|
||||
@@ -1235,30 +1235,23 @@ void TimelineWidget::ShowContextMenu()
|
||||
reveal_in_project->setData(reinterpret_cast<quintptr>(clip->connected_viewer()));
|
||||
connect(reveal_in_project, &QAction::triggered, this, &TimelineWidget::RevealInProject);
|
||||
|
||||
/*if (Sequence *sequence = dynamic_cast<Sequence*>(clip->connected_viewer())) {
|
||||
Menu *multicam_menu = new Menu(tr("Multi-Cam"), &menu);
|
||||
menu.addMenu(multicam_menu);
|
||||
|
||||
QAction *multicam_enabled = multicam_menu->addAction(tr("Enabled"));
|
||||
if (Sequence *sequence = dynamic_cast<Sequence*>(clip->connected_viewer())) {
|
||||
QAction *multicam_enabled = menu.addAction(tr("Multi-Cam"));
|
||||
multicam_enabled->setCheckable(true);
|
||||
|
||||
auto mcn = sequence->FindOutputNode<MultiCamNode>();
|
||||
multicam_enabled->setChecked(!mcn.empty());
|
||||
MultiCamNode *mcn = nullptr;
|
||||
auto paths = clip->FindWaysNodeArrivesHere(sequence);
|
||||
|
||||
multicam_menu->addSeparator();
|
||||
|
||||
QAction *multicam_update = multicam_menu->addAction(tr("Update"));
|
||||
multicam_update->setEnabled(!mcn.empty());
|
||||
|
||||
if (!mcn.empty()) {
|
||||
auto n = mcn.first();
|
||||
multicam_enabled->setProperty("multicam", Node::PtrToValue(n));
|
||||
multicam_update->setProperty("multicam", Node::PtrToValue(n));
|
||||
for (const NodeInput &i : paths) {
|
||||
if ((mcn = dynamic_cast<MultiCamNode*>(i.node()))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
multicam_enabled->setChecked(mcn);
|
||||
|
||||
connect(multicam_enabled, &QAction::triggered, this, &TimelineWidget::MulticamEnabledTriggered);
|
||||
connect(multicam_update, &QAction::triggered, this, &TimelineWidget::MulticamUpdateTriggered);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1492,16 +1485,57 @@ void TimelineWidget::CacheDiscard()
|
||||
|
||||
void TimelineWidget::MulticamEnabledTriggered(bool e)
|
||||
{
|
||||
if (e) {
|
||||
// Add multicam node
|
||||
} else if (MultiCamNode *m = Node::ValueToPtr<MultiCamNode>(sender()->property("multicam"))) {
|
||||
// Remove multicam node
|
||||
}
|
||||
}
|
||||
MultiUndoCommand *command = new MultiUndoCommand();
|
||||
|
||||
void TimelineWidget::MulticamUpdateTriggered()
|
||||
{
|
||||
// Update multicam node
|
||||
for (Block *b : qAsConst(selected_blocks_)) {
|
||||
if (ClipBlock *c = dynamic_cast<ClipBlock*>(b)) {
|
||||
if (Sequence *s = dynamic_cast<Sequence*>(c->connected_viewer())) {
|
||||
if (e) {
|
||||
|
||||
// Adding multicams
|
||||
// Create multicam node and add it to the graph
|
||||
MultiCamNode *n = new MultiCamNode();
|
||||
n->SetSequenceType(c->GetTrackType());
|
||||
command->add_child(new NodeAddCommand(s->parent(), n));
|
||||
|
||||
|
||||
// For each output the sequence has to this clip, disconnect it and
|
||||
// connect to the multicam instead
|
||||
QVector<NodeInput> inputs = c->FindWaysNodeArrivesHere(s);
|
||||
for (const NodeInput &i : inputs) {
|
||||
command->add_child(new NodeEdgeRemoveCommand(s, i));
|
||||
command->add_child(new NodeEdgeAddCommand(n, i));
|
||||
}
|
||||
|
||||
command->add_child(new NodeEdgeAddCommand(s, NodeInput(n, n->kSequenceInput)));
|
||||
|
||||
// Move sequence node one unit back, and place multicam in sequence's spot
|
||||
QPointF sequence_pos = c->GetNodePositionInContext(s);
|
||||
command->add_child(new NodeSetPositionCommand(s, c, sequence_pos - QPointF(1, 0)));
|
||||
command->add_child(new NodeSetPositionCommand(n, c, sequence_pos));
|
||||
|
||||
} else {
|
||||
|
||||
// Removing multicams
|
||||
// Locate first multicam that specifically ends up at this clip
|
||||
QVector<NodeInput> inputs = c->FindWaysNodeArrivesHere(s);
|
||||
for (const NodeInput &i : inputs) {
|
||||
if (MultiCamNode *mcn = dynamic_cast<MultiCamNode*>(i.node())) {
|
||||
for (auto it=mcn->output_connections().cbegin(); it!=mcn->output_connections().cend(); it++) {
|
||||
command->add_child(new NodeEdgeRemoveCommand(it->first, it->second));
|
||||
command->add_child(new NodeEdgeAddCommand(s, it->second));
|
||||
}
|
||||
|
||||
command->add_child(new NodeRemoveAndDisconnectCommand(mcn));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Core::instance()->undo_stack()->pushIfHasChildren(command);
|
||||
}
|
||||
|
||||
void TimelineWidget::AddGhost(TimelineViewGhostItem *ghost)
|
||||
|
||||
@@ -447,7 +447,6 @@ private slots:
|
||||
void CacheDiscard();
|
||||
|
||||
void MulticamEnabledTriggered(bool e);
|
||||
void MulticamUpdateTriggered();
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -427,7 +427,15 @@ void ViewerWidget::StartCapture(TimelineWidget *source, const TimeRange &time, c
|
||||
|
||||
void ViewerWidget::ConnectMulticamWidget(MulticamWidget *p)
|
||||
{
|
||||
if (multicam_panel_) {
|
||||
disconnect(multicam_panel_, &MulticamWidget::Switched, this, &ViewerWidget::DetectMulticamNodeNow);
|
||||
}
|
||||
|
||||
multicam_panel_ = p;
|
||||
|
||||
if (multicam_panel_) {
|
||||
connect(multicam_panel_, &MulticamWidget::Switched, this, &ViewerWidget::DetectMulticamNodeNow);
|
||||
}
|
||||
}
|
||||
|
||||
FramePtr ViewerWidget::DecodeCachedImage(const QString &cache_path, const QUuid &cache_id, const int64_t& time)
|
||||
@@ -607,6 +615,11 @@ void ViewerWidget::SaveFrameAsImage()
|
||||
Core::instance()->OpenExportDialogForViewer(GetConnectedNode(), GetTime(), true);
|
||||
}
|
||||
|
||||
void ViewerWidget::DetectMulticamNodeNow()
|
||||
{
|
||||
DetectMulticamNode(GetTime());
|
||||
}
|
||||
|
||||
void ViewerWidget::CloseAudioProcessor()
|
||||
{
|
||||
audio_processor_.Close();
|
||||
@@ -903,7 +916,7 @@ void ViewerWidget::PlayInternal(int speed, bool in_to_out_only)
|
||||
if (viewer != this) {
|
||||
viewer->PauseInternal();
|
||||
}
|
||||
viewer->auto_cacher_->SetRendersPaused(true);
|
||||
viewer->auto_cacher_->SetThumbnailsPaused(true);
|
||||
}
|
||||
|
||||
RenderManager::instance()->SetAggressiveGarbageCollection(true);
|
||||
@@ -1005,7 +1018,7 @@ void ViewerWidget::PauseInternal()
|
||||
UpdateAudioProcessor();
|
||||
|
||||
foreach (ViewerWidget* viewer, instances_) {
|
||||
viewer->auto_cacher_->SetRendersPaused(false);
|
||||
viewer->auto_cacher_->SetThumbnailsPaused(false);
|
||||
}
|
||||
|
||||
UpdateTextureFromNode();
|
||||
@@ -1796,7 +1809,7 @@ void ViewerWidget::SetZoomFromMenu(QAction *action)
|
||||
void ViewerWidget::ViewerInvalidatedVideoRange(const TimeRange &range)
|
||||
{
|
||||
// If our current frame is within this range, we need to update
|
||||
if (GetTime() >= range.in() && (GetTime() < range.out() || range.in() == range.out())) {
|
||||
if (!IsPlaying() && GetTime() >= range.in() && (GetTime() < range.out() || range.in() == range.out())) {
|
||||
QMetaObject::invokeMethod(this, &ViewerWidget::UpdateTextureFromNode, Qt::QueuedConnection);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ public:
|
||||
|
||||
if (!IsPlaying()) {
|
||||
// If is playing, this will happen by the next frame automatically
|
||||
DetectMulticamNode(GetTime());
|
||||
DetectMulticamNodeNow();
|
||||
UpdateTextureFromNode();
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@ public:
|
||||
|
||||
if (!IsPlaying()) {
|
||||
// If is playing, this will happen by the next frame automatically
|
||||
DetectMulticamNode(GetTime());
|
||||
DetectMulticamNodeNow();
|
||||
UpdateTextureFromNode();
|
||||
}
|
||||
}
|
||||
@@ -421,6 +421,8 @@ private slots:
|
||||
|
||||
void SaveFrameAsImage();
|
||||
|
||||
void DetectMulticamNodeNow();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user