From 5a4525caa063c29c5f83c81af72463072813caba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Garramu=C3=B1o?= Date: Thu, 12 Oct 2023 19:28:15 -0300 Subject: [PATCH] Fixed two crashes. Added support for IOOptions. Added USD interactive update. --- mrv2/docs/HISTORY.md | 10 +- mrv2/lib/mrvApp/CMakeLists.txt | 1 + mrv2/lib/mrvApp/mrvUSD.cpp | 42 +++++++- mrv2/lib/mrvApp/mrvUSD.h | 10 +- mrv2/lib/mrvApp/mrvUSDInline.cpp | 25 +++++ mrv2/lib/mrvEdit/mrvEditCallbacks.cpp | 11 ++- mrv2/lib/mrvFl/mrvCallbacks.cpp | 53 ++-------- mrv2/lib/mrvFl/mrvTimelinePlayer.cpp | 137 ++++++++++++++------------ mrv2/lib/mrvFl/mrvTimelinePlayer.h | 8 ++ mrv2/lib/mrvPanels/mrvPanelsAux.cpp | 3 + mrv2/lib/mrvPanels/mrvUSDPanel.cpp | 55 ++++++----- mrv2/lib/mrvPanels/mrvUSDPanel.h | 3 + tlRender | 2 +- 13 files changed, 219 insertions(+), 141 deletions(-) create mode 100644 mrv2/lib/mrvApp/mrvUSDInline.cpp diff --git a/mrv2/docs/HISTORY.md b/mrv2/docs/HISTORY.md index 416ee6a94..bfce15c27 100644 --- a/mrv2/docs/HISTORY.md +++ b/mrv2/docs/HISTORY.md @@ -39,7 +39,15 @@ v0.8.0 - Fixed reading of OCIO file name in network connections. - Color channels (layers) are now kept with the file so that switching between media will not revert to the rgba channel if there isn't an equivalent one. - +- USD Panel is now interactive. You can change the parameters and it will + show the change. The only parameter not recommended to change (except for + very simple scenes) is the complexity. +- USD Panel visibility is now saved in the Preferences. +- Refreshing of cache is now done in seconds, without re-loading and + switching an image as before. +- Creating a timeline in the Playlist Panel is also done in seconds. +- Fixed a crash when creating an empty timeline or a timeline from a clip in + the Playlist Panel. v0.7.9 ====== diff --git a/mrv2/lib/mrvApp/CMakeLists.txt b/mrv2/lib/mrvApp/CMakeLists.txt index a51f8b28b..df1e93062 100644 --- a/mrv2/lib/mrvApp/CMakeLists.txt +++ b/mrv2/lib/mrvApp/CMakeLists.txt @@ -22,6 +22,7 @@ set(HEADERS mrvPlaylistsModel.cpp mrvSettingsObject.cpp mrvUSD.cpp + mrvUSDInline.cpp ) add_library(mrvApp ${SOURCES} ${HEADERS}) diff --git a/mrv2/lib/mrvApp/mrvUSD.cpp b/mrv2/lib/mrvApp/mrvUSD.cpp index e653ae253..3317a37fd 100644 --- a/mrv2/lib/mrvApp/mrvUSD.cpp +++ b/mrv2/lib/mrvApp/mrvUSD.cpp @@ -4,13 +4,16 @@ #ifdef TLRENDER_USD -# include "mrvApp/mrvUSD.h" +# include # include "mrvPanels/mrvPanelsCallbacks.h" # include "mrvApp/mrvSettingsObject.h" +# include "mrvApp/mrvUSD.h" # include "mrvApp/App.h" +# include "mrViewer.h" + namespace mrv { namespace usd @@ -34,9 +37,40 @@ namespace mrv return o; } - bool setRenderOptions(const RenderOptions& o) + void sendIOOptions() + { + auto player = App::ui->uiView->getTimelinePlayer(); + if (!player) + return; + + auto o = renderOptions(); + + io::Options ioOptions; + ioOptions["USD/renderWidth"] = + string::Format("{0}").arg(o.renderWidth); + ioOptions["USD/complexity"] = + string::Format("{0}").arg(o.complexity); + { + std::stringstream ss; + ss << o.drawMode; + ioOptions["USD/drawMode"] = ss.str(); + } + ioOptions["USD/enableLighting"] = + string::Format("{0}").arg(o.enableLighting); + ioOptions["USD/stageCacheCount"] = + string::Format("{0}").arg(o.stageCache); + ioOptions["USD/diskCacheByteCount"] = + string::Format("{0}").arg(o.diskCache); + + player->setIOOptions(ioOptions); + } + + void setRenderOptions(const RenderOptions& o) { auto settingsObject = App::app->settingsObject(); + if (o == renderOptions()) + return; + settingsObject->setValue("USD/renderWidth", o.renderWidth); settingsObject->setValue("USD/complexity", o.complexity); settingsObject->setValue("USD/drawMode", o.drawMode); @@ -44,10 +78,12 @@ namespace mrv settingsObject->setValue("USD/stageCache", o.stageCache); settingsObject->setValue("USD/diskCache", o.diskCache); + sendIOOptions(); + if (usdPanel) usdPanel->refresh(); - return true; } + } // namespace usd } // namespace mrv diff --git a/mrv2/lib/mrvApp/mrvUSD.h b/mrv2/lib/mrvApp/mrvUSD.h index cf4095de5..69de5e8b6 100644 --- a/mrv2/lib/mrvApp/mrvUSD.h +++ b/mrv2/lib/mrvApp/mrvUSD.h @@ -2,6 +2,8 @@ // mrv2 // Copyright Contributors to the mrv2 Project. All rights reserved. +#pragma once + #ifdef TLRENDER_USD # include @@ -18,13 +20,19 @@ namespace mrv bool enableLighting = true; size_t stageCache = 10; size_t diskCache = 0; + + bool operator==(const RenderOptions& b) const; + bool operator!=(const RenderOptions& b) const; }; //! Return the current USD Render Options RenderOptions renderOptions(); //! Set the current USD Render Options - bool setRenderOptions(const RenderOptions& o); + void setRenderOptions(const RenderOptions& o); + + //! Set the current USD Render Options + void sendIOOptions(); } // namespace usd } // namespace mrv diff --git a/mrv2/lib/mrvApp/mrvUSDInline.cpp b/mrv2/lib/mrvApp/mrvUSDInline.cpp new file mode 100644 index 000000000..5e11cb311 --- /dev/null +++ b/mrv2/lib/mrvApp/mrvUSDInline.cpp @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: BSD-3-Clause +// mrv2 +// Copyright Contributors to the mrv2 Project. All rights reserved. + +#ifdef TLRENDER_USD + +# include + +namespace mrv +{ + namespace usd + { + bool RenderOptions::operator==(const RenderOptions& b) const + { + return (*this == b); + } + + bool RenderOptions::operator!=(const RenderOptions& b) const + { + return !(*this == b); + } + } // namespace usd +} // namespace mrv + +#endif diff --git a/mrv2/lib/mrvEdit/mrvEditCallbacks.cpp b/mrv2/lib/mrvEdit/mrvEditCallbacks.cpp index dbcc6c6fc..fcf621ce3 100644 --- a/mrv2/lib/mrvEdit/mrvEditCallbacks.cpp +++ b/mrv2/lib/mrvEdit/mrvEditCallbacks.cpp @@ -735,6 +735,8 @@ namespace mrv UndoRedo buffer; buffer.json = state; buffer.fileName = getEDLName(ui); + + player = ui->uiView->getTimelinePlayer(); buffer.annotations = player->getAllAnnotations(); undoBuffer.push_back(buffer); } @@ -772,6 +774,7 @@ namespace mrv UndoRedo buffer; buffer.json = state; buffer.fileName = getEDLName(ui); + player = ui->uiView->getTimelinePlayer(); buffer.annotations = player->getAllAnnotations(); redoBuffer.push_back(buffer); } @@ -1462,10 +1465,16 @@ namespace mrv auto model = ui->app->filesModel(); - const auto& sourceItems = model->observeFiles()->get(); + const auto sourceItems = model->observeFiles()->get(); + auto sourceItem = sourceItems[index]; auto destItem = model->observeA()->get(); + if (!destItem) + { + LOG_ERROR(_("Destination file is invalid.")); + return; + } if (!isTemporaryEDL(destItem->path)) { diff --git a/mrv2/lib/mrvFl/mrvCallbacks.cpp b/mrv2/lib/mrvFl/mrvCallbacks.cpp index ac3aaa8a7..a246c8815 100644 --- a/mrv2/lib/mrvFl/mrvCallbacks.cpp +++ b/mrv2/lib/mrvFl/mrvCallbacks.cpp @@ -459,6 +459,10 @@ namespace mrv #ifdef MRV2_NETWORK if (networkPanel) networkPanel->save(); +#endif +#ifdef TLRENDER_USD + if (usdPanel) + usdPanel->save(); #endif if (stereo3DPanel) stereo3DPanel->save(); @@ -1902,56 +1906,15 @@ namespace mrv model->setStereo3DOptions(o); } - // @todo: remove once tlRender supports this natively void refresh_file_cache_cb(Fl_Menu_* m, void* d) { auto ui = App::ui; - auto app = ui->app; - auto model = app->filesModel(); - if (model->observeFiles()->getSize() < 1) - return; - - auto AIndex = model->observeAIndex()->get(); - auto item = model->observeA()->get(); int layer = ui->uiColorChannel->value(); - auto player = ui->uiView->getTimelinePlayer(); - timeline::Playback playback = player->playback(); - auto currentTime = player->currentTime(); - auto inOutRange = player->inOutRange(); - - app->open(item->path.get(), item->audioPath.get()); - - auto newItem = model->observeA()->get(); - auto ANewIndex = model->observeAIndex()->get(); - newItem->inOutRange = inOutRange; - newItem->speed = item->speed; - newItem->audioOffset = item->audioOffset; - newItem->loop = item->loop; - newItem->playback = playback; - newItem->currentTime = currentTime; - newItem->annotations = item->annotations; - if (layer < ui->uiColorChannel->children()) - { - ui->uiColorChannel->value(layer); - ui->uiColorChannel->do_callback(); - } - else - { - ui->uiColorChannel->label(_("(no image)")); - } - - // Close the old item - model->setA(AIndex); - model->close(); - - // Switch to new item - model->setA(ANewIndex); - - player = ui->uiView->getTimelinePlayer(); - player->setAllAnnotations(newItem->annotations); - player->seek(currentTime); - player->setPlayback(playback); + if (!player) + return; + const io::Options& options = player->getIOOptions(); + player->setIOOptions(options); } void copy_filename_cb(Fl_Menu_* m, void* d) diff --git a/mrv2/lib/mrvFl/mrvTimelinePlayer.cpp b/mrv2/lib/mrvFl/mrvTimelinePlayer.cpp index 3c67f97d7..912151aef 100644 --- a/mrv2/lib/mrvFl/mrvTimelinePlayer.cpp +++ b/mrv2/lib/mrvFl/mrvTimelinePlayer.cpp @@ -44,7 +44,7 @@ namespace mrv struct TimelinePlayer::Private { - std::shared_ptr timelinePlayer; + std::shared_ptr player; std::shared_ptr > speedObserver; std::shared_ptr > @@ -80,72 +80,72 @@ namespace mrv }; void TimelinePlayer::_init( - const std::shared_ptr& timelinePlayer, + const std::shared_ptr& player, const std::shared_ptr& context) { TLRENDER_P(); - p.timelinePlayer = timelinePlayer; + p.player = player; p.speedObserver = observer::ValueObserver::create( - p.timelinePlayer->observeSpeed(), + p.player->observeSpeed(), [this](double value) { speedChanged(value); }); p.playbackObserver = observer::ValueObserver::create( - p.timelinePlayer->observePlayback(), + p.player->observePlayback(), [this](timeline::Playback value) { playbackChanged(value); }); p.loopObserver = observer::ValueObserver::create( - p.timelinePlayer->observeLoop(), + p.player->observeLoop(), [this](timeline::Loop value) { loopChanged(value); }); p.currentTimeObserver = observer::ValueObserver::create( - p.timelinePlayer->observeCurrentTime(), + p.player->observeCurrentTime(), [this](const otime::RationalTime& value) { currentTimeChanged(value); }); p.inOutRangeObserver = observer::ValueObserver::create( - p.timelinePlayer->observeInOutRange(), + p.player->observeInOutRange(), [this](const otime::TimeRange value) { inOutRangeChanged(value); }); p.currentVideoObserver = observer::ValueObserver::create( - p.timelinePlayer->observeCurrentVideo(), + p.player->observeCurrentVideo(), [this](const timeline::VideoData& value) { currentVideoChanged(value); }, observer::CallbackAction::Suppress); p.volumeObserver = observer::ValueObserver::create( - p.timelinePlayer->observeVolume(), + p.player->observeVolume(), [this](float value) { volumeChanged(value); }); p.muteObserver = observer::ValueObserver::create( - p.timelinePlayer->observeMute(), + p.player->observeMute(), [this](bool value) { muteChanged(value); }); p.audioOffsetObserver = observer::ValueObserver::create( - p.timelinePlayer->observeAudioOffset(), + p.player->observeAudioOffset(), [this](double value) { audioOffsetChanged(value); }); p.currentAudioObserver = observer::ListObserver::create( - p.timelinePlayer->observeCurrentAudio(), + p.player->observeCurrentAudio(), [this](const std::vector& value) { currentAudioChanged(value); }); p.cacheOptionsObserver = observer::ValueObserver::create( - p.timelinePlayer->observeCacheOptions(), + p.player->observeCacheOptions(), [this](const timeline::PlayerCacheOptions& value) { cacheOptionsChanged(value); }); p.cacheInfoObserver = observer::ValueObserver::create( - p.timelinePlayer->observeCacheInfo(), + p.player->observeCacheInfo(), [this](const timeline::PlayerCacheInfo& value) { cacheInfoChanged(value); }); @@ -157,11 +157,11 @@ namespace mrv } TimelinePlayer::TimelinePlayer( - const std::shared_ptr& timelinePlayer, + const std::shared_ptr& player, const std::shared_ptr& context) : _p(new Private) { - _init(timelinePlayer, context); + _init(player, context); } TimelinePlayer::~TimelinePlayer() @@ -171,124 +171,134 @@ namespace mrv const std::weak_ptr& TimelinePlayer::context() const { - return _p->timelinePlayer->getContext(); + return _p->player->getContext(); } const std::shared_ptr& TimelinePlayer::player() const { - return _p->timelinePlayer; + return _p->player; } const std::shared_ptr& TimelinePlayer::timeline() const { - return _p->timelinePlayer->getTimeline(); + return _p->player->getTimeline(); } const otio::SerializableObject::Retainer& TimelinePlayer::getTimeline() const { - return _p->timelinePlayer->getTimeline()->getTimeline(); + return _p->player->getTimeline()->getTimeline(); } void TimelinePlayer::setTimeline( const otio::SerializableObject::Retainer& timeline) { - _p->timelinePlayer->getTimeline()->setTimeline(timeline); + _p->player->getTimeline()->setTimeline(timeline); } const file::Path& TimelinePlayer::path() const { - return _p->timelinePlayer->getPath(); + return _p->player->getPath(); } const file::Path& TimelinePlayer::audioPath() const { - return _p->timelinePlayer->getAudioPath(); + return _p->player->getAudioPath(); } const timeline::PlayerOptions& TimelinePlayer::getPlayerOptions() const { - return _p->timelinePlayer->getPlayerOptions(); + return _p->player->getPlayerOptions(); } const timeline::Options& TimelinePlayer::getOptions() const { - return _p->timelinePlayer->getOptions(); + return _p->player->getOptions(); } const otime::TimeRange& TimelinePlayer::timeRange() const { - return _p->timelinePlayer->getTimeRange(); + return _p->player->getTimeRange(); } const tl::io::Info& TimelinePlayer::ioInfo() const { - return _p->timelinePlayer->getIOInfo(); + return _p->player->getIOInfo(); } double TimelinePlayer::defaultSpeed() const { - return _p->timelinePlayer->getDefaultSpeed(); + return _p->player->getDefaultSpeed(); } double TimelinePlayer::speed() const { - return _p->timelinePlayer->observeSpeed()->get(); + return _p->player->observeSpeed()->get(); } timeline::Playback TimelinePlayer::playback() const { - return _p->timelinePlayer->observePlayback()->get(); + return _p->player->observePlayback()->get(); } timeline::Loop TimelinePlayer::loop() const { - return _p->timelinePlayer->observeLoop()->get(); + return _p->player->observeLoop()->get(); } const otime::RationalTime& TimelinePlayer::currentTime() const { - return _p->timelinePlayer->observeCurrentTime()->get(); + return _p->player->observeCurrentTime()->get(); } const otime::TimeRange& TimelinePlayer::inOutRange() const { - return _p->timelinePlayer->observeInOutRange()->get(); + return _p->player->observeInOutRange()->get(); + } + + tl::io::Options TimelinePlayer::getIOOptions() const + { + return _p->player->getIOOptions(); + } + + void TimelinePlayer::setIOOptions(const io::Options& value) + { + _p->player->setIOOptions(value); } const timeline::VideoData& TimelinePlayer::currentVideo() const { - return _p->timelinePlayer->observeCurrentVideo()->get(); + return _p->player->observeCurrentVideo()->get(); } float TimelinePlayer::volume() const { - return _p->timelinePlayer->observeVolume()->get(); + return _p->player->observeVolume()->get(); } bool TimelinePlayer::isMuted() const { - return _p->timelinePlayer->observeMute()->get(); + return _p->player->observeMute()->get(); } double TimelinePlayer::audioOffset() const { - return _p->timelinePlayer->observeAudioOffset()->get(); + return _p->player->observeAudioOffset()->get(); } const std::vector& TimelinePlayer::currentAudio() const { - return _p->timelinePlayer->observeCurrentAudio()->get(); + return _p->player->observeCurrentAudio()->get(); } const timeline::PlayerCacheOptions& TimelinePlayer::cacheOptions() const { - return _p->timelinePlayer->observeCacheOptions()->get(); + return _p->player->observeCacheOptions()->get(); } const timeline::PlayerCacheInfo& TimelinePlayer::cacheInfo() const { - return _p->timelinePlayer->observeCacheInfo()->get(); + return _p->player->observeCacheInfo()->get(); } template < typename T > @@ -306,14 +316,14 @@ namespace mrv { pushMessage("setSpeed", value); - _p->timelinePlayer->setSpeed(value); + _p->player->setSpeed(value); } void TimelinePlayer::setPlayback(timeline::Playback value) { pushMessage("seek", currentTime()); pushMessage("setPlayback", value); - _p->timelinePlayer->setPlayback(value); + _p->player->setPlayback(value); if (value == timeline::Playback::Stop) { @@ -331,20 +341,19 @@ namespace mrv void TimelinePlayer::forward() { pushMessage("setPlayback", timeline::Playback::Forward); - _p->timelinePlayer->setPlayback(timeline::Playback::Forward); + _p->player->setPlayback(timeline::Playback::Forward); } void TimelinePlayer::reverse() { pushMessage("setPlayback", timeline::Playback::Reverse); - _p->timelinePlayer->setPlayback(timeline::Playback::Reverse); + _p->player->setPlayback(timeline::Playback::Reverse); } void TimelinePlayer::togglePlayback() { setPlayback( - timeline::Playback::Stop == - _p->timelinePlayer->observePlayback()->get() + timeline::Playback::Stop == _p->player->observePlayback()->get() ? timeline::Playback::Forward : timeline::Playback::Stop); } @@ -353,26 +362,26 @@ namespace mrv { Message m = value; pushMessage("setLoop", m); - _p->timelinePlayer->setLoop(value); + _p->player->setLoop(value); } void TimelinePlayer::seek(const otime::RationalTime& value) { pushMessage("seek", value); - _p->timelinePlayer->seek(value); + _p->player->seek(value); if (timelineViewport) timelineViewport->updateUndoRedoButtons(); } void TimelinePlayer::timeAction(timeline::TimeAction value) { - _p->timelinePlayer->timeAction(value); + _p->player->timeAction(value); } void TimelinePlayer::start() { pushMessage("start", 0); - _p->timelinePlayer->start(); + _p->player->start(); redrawPanelThumbnails(); if (timelineViewport) timelineViewport->updateUndoRedoButtons(); @@ -381,7 +390,7 @@ namespace mrv void TimelinePlayer::end() { pushMessage("end", 0); - _p->timelinePlayer->end(); + _p->player->end(); redrawPanelThumbnails(); if (timelineViewport) timelineViewport->updateUndoRedoButtons(); @@ -420,7 +429,7 @@ namespace mrv auto time = currentTime() - otime::RationalTime(1.0, timeRange().duration().rate()); - _p->timelinePlayer->setPlayback(timeline::Playback::Reverse); + _p->player->setPlayback(timeline::Playback::Reverse); StopData* data = new StopData; data->player = this; data->time = time; @@ -436,7 +445,7 @@ namespace mrv auto time = currentTime() + otime::RationalTime(1.0, timeRange().duration().rate()); - _p->timelinePlayer->setPlayback(timeline::Playback::Forward); + _p->player->setPlayback(timeline::Playback::Forward); StopData* data = new StopData; data->player = this; data->time = time; @@ -448,31 +457,31 @@ namespace mrv void TimelinePlayer::setInOutRange(const otime::TimeRange& value) { pushMessage("setInOutRange", value); - _p->timelinePlayer->setInOutRange(value); + _p->player->setInOutRange(value); } void TimelinePlayer::setInPoint() { pushMessage("setInPoint", 0); - _p->timelinePlayer->setInPoint(); + _p->player->setInPoint(); } void TimelinePlayer::resetInPoint() { pushMessage("resetInPoint", 0); - _p->timelinePlayer->resetInPoint(); + _p->player->resetInPoint(); } void TimelinePlayer::setOutPoint() { pushMessage("setOutPoint", 0); - _p->timelinePlayer->setOutPoint(); + _p->player->setOutPoint(); } void TimelinePlayer::resetOutPoint() { pushMessage("resetOutPoint", 0); - _p->timelinePlayer->resetOutPoint(); + _p->player->resetOutPoint(); } int TimelinePlayer::videoLayer() const @@ -496,12 +505,12 @@ namespace mrv void TimelinePlayer::setVolume(float value) { - _p->timelinePlayer->setVolume(value); + _p->player->setVolume(value); } void TimelinePlayer::setMute(bool value) { - _p->timelinePlayer->setMute(value); + _p->player->setMute(value); } void TimelinePlayer::setAudioOffset(double value) @@ -509,7 +518,7 @@ namespace mrv bool send = App::ui->uiPrefs->SendAudio->value(); if (send) tcp->pushMessage("setAudioOffset", value); - _p->timelinePlayer->setAudioOffset(value); + _p->player->setAudioOffset(value); } void TimelinePlayer::setTimelineViewport(TimelineViewport* view) @@ -801,7 +810,7 @@ namespace mrv void TimelinePlayer::setCacheOptions(const timeline::PlayerCacheOptions& value) { - _p->timelinePlayer->setCacheOptions(value); + _p->player->setCacheOptions(value); } bool TimelinePlayer::hasUndo() const @@ -839,7 +848,7 @@ namespace mrv std::cout << "timeout duration: " << diff.count() << std::endl; _p->start_time = std::chrono::steady_clock::now(); #endif - _p->timelinePlayer->tick(); + _p->player->tick(); Fl::repeat_timeout(kTimeout, (Fl_Timeout_Handler)timerEvent_cb, this); } diff --git a/mrv2/lib/mrvFl/mrvTimelinePlayer.h b/mrv2/lib/mrvFl/mrvTimelinePlayer.h index 0b6363705..fcd286dd8 100644 --- a/mrv2/lib/mrvFl/mrvTimelinePlayer.h +++ b/mrv2/lib/mrvFl/mrvTimelinePlayer.h @@ -99,6 +99,14 @@ namespace mrv ///@} + //! \name I/O Options + ///@{ + + tl::io::Options getIOOptions() const; + void setIOOptions(const tl::io::Options&); + + ///@} + //! \name Video ///@{ diff --git a/mrv2/lib/mrvPanels/mrvPanelsAux.cpp b/mrv2/lib/mrvPanels/mrvPanelsAux.cpp index 783d36031..467052def 100644 --- a/mrv2/lib/mrvPanels/mrvPanelsAux.cpp +++ b/mrv2/lib/mrvPanels/mrvPanelsAux.cpp @@ -10,6 +10,9 @@ namespace mrv std::string getLayerName( const std::shared_ptr& item, const uint16_t layerId) { + if (!item || layerId >= item->videoLayers.size()) + return ""; + std::string layer = item->videoLayers[layerId]; if (layer == "Default" || layer == "A,B,G,R" || layer == "B,G,R") layer = "Color"; diff --git a/mrv2/lib/mrvPanels/mrvUSDPanel.cpp b/mrv2/lib/mrvPanels/mrvUSDPanel.cpp index 3b5d837c7..7ed2dca18 100644 --- a/mrv2/lib/mrvPanels/mrvUSDPanel.cpp +++ b/mrv2/lib/mrvPanels/mrvUSDPanel.cpp @@ -3,7 +3,6 @@ // Copyright Contributors to the mrv2 Project. All rights reserved. #if defined(TLRENDER_USD) -# include # include @@ -22,6 +21,7 @@ # include "mrvFl/mrvIO.h" +# include "mrvApp/mrvUSD.h" # include "mrvApp/mrvSettingsObject.h" namespace mrv @@ -89,18 +89,10 @@ namespace mrv cg->begin(); Y += 30; - bg = new Fl_Group(g->x(), Y, g->w(), 22 * 8); + bg = new Fl_Group(g->x(), Y, g->w(), 22 * 7); bg->box(FL_NO_BOX); bg->begin(); - Fl_Box* box = new Fl_Box( - g->x(), Y, g->w(), 40, - _("Changes are applied to " - "newly opened files.")); - box->labelsize(12); - box->align(FL_ALIGN_WRAP); - - Y += 50; auto spW = new Widget< Fl_Spinner >( g->x() + 160, Y, g->w() - 160, 20, _("Render Width")); sp = spW; @@ -111,14 +103,15 @@ namespace mrv sp->step(1); sp->range(32, 4096); sp->align(FL_ALIGN_LEFT); - int v = std_any_cast(settingsObject->value("usd/renderWidth")); + int v = std_any_cast(settingsObject->value("USD/renderWidth")); sp->value(v); spW->callback( [=](auto o) { int v = static_cast(o->value()); - settingsObject->setValue("usd/renderWidth", v); + settingsObject->setValue("USD/renderWidth", v); + _update(); }); Y += 22; @@ -129,37 +122,41 @@ namespace mrv sp->labelsize(12); sp->color((Fl_Color)-1733777408); sp->textcolor(FL_BLACK); - sp->step(0.1); - sp->range(1, 12); + sp->step(0.001); + // sp->range(1, 12); + sp->range(1, 2); sp->align(FL_ALIGN_LEFT); float complexity = - std_any_cast(settingsObject->value("usd/complexity")); + std_any_cast(settingsObject->value("USD/complexity")); sp->value(complexity); spW->callback( [=](auto o) { float v = static_cast(o->value()); - settingsObject->setValue("usd/complexity", v); + settingsObject->setValue("USD/complexity", v); + _update(); }); Y += 22; + auto mW = new Widget< Fl_Choice >( g->x() + 130, Y, g->w() - 130, 20, _("Draw Mode")); Fl_Choice* m = mW; m->labelsize(12); m->align(FL_ALIGN_LEFT); - for (const auto& i : usd::getDrawModeLabels()) + for (const auto& i : tl::usd::getDrawModeLabels()) { m->add(_(i.c_str())); } - m->value(std_any_cast(settingsObject->value("usd/drawMode"))); + m->value(std_any_cast(settingsObject->value("USD/drawMode"))); mW->callback( [=](auto o) { int v = o->value(); - settingsObject->setValue("usd/drawMode", v); + settingsObject->setValue("USD/drawMode", v); + _update(); }); Y += 22; @@ -168,13 +165,14 @@ namespace mrv Fl_Check_Button* c = cV; c->labelsize(12); c->value( - std_any_cast(settingsObject->value("usd/enableLighting"))); + std_any_cast(settingsObject->value("USD/enableLighting"))); cV->callback( [=](auto w) { int v = w->value(); - settingsObject->setValue("usd/enableLighting", v); + settingsObject->setValue("USD/enableLighting", v); + _update(); }); Y += 22; @@ -188,14 +186,15 @@ namespace mrv sp->step(1); sp->range(32, 4096); sp->align(FL_ALIGN_LEFT); - v = std_any_cast(settingsObject->value("usd/stageCacheCount")); + v = std_any_cast(settingsObject->value("USD/stageCache")); sp->value(v); spW->callback( [=](auto o) { int v = static_cast(o->value()); - settingsObject->setValue("usd/stageCacheCount", v); + settingsObject->setValue("USD/stageCache", v); + _update(); }); Y += 22; @@ -209,14 +208,15 @@ namespace mrv sp->step(1); sp->range(32, 4096); sp->align(FL_ALIGN_LEFT); - v = std_any_cast(settingsObject->value("usd/diskCacheByteCount")); + v = std_any_cast(settingsObject->value("USD/diskCache")); sp->value(v); spW->callback( [=](auto o) { int v = static_cast(o->value()); - settingsObject->setValue("usd/diskCacheByteCount", v); + settingsObject->setValue("USD/diskCache", v); + _update(); }); bg->end(); @@ -230,6 +230,11 @@ namespace mrv cg->close(); } + void USDPanel::_update() + { + usd::sendIOOptions(); + } + } // namespace mrv #endif // TLRENDER_USD diff --git a/mrv2/lib/mrvPanels/mrvUSDPanel.h b/mrv2/lib/mrvPanels/mrvUSDPanel.h index 5913adf6f..2547e3c44 100644 --- a/mrv2/lib/mrvPanels/mrvUSDPanel.h +++ b/mrv2/lib/mrvPanels/mrvUSDPanel.h @@ -18,6 +18,9 @@ namespace mrv virtual ~USDPanel(){}; void add_controls() override; + + protected: + void _update(); }; #endif // TLRENDER_USD diff --git a/tlRender b/tlRender index 6eed1b517..6f160f24a 160000 --- a/tlRender +++ b/tlRender @@ -1 +1 @@ -Subproject commit 6eed1b5175c076e97c2a7e6697a67fb1e972692a +Subproject commit 6f160f24a38443d9a2325a49dcaee5abd9870f0b