-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Render Pass Menu #6177
base: 1.5_maintenance
Are you sure you want to change the base?
Render Pass Menu #6177
Changes from 1 commit
e4e5b4e
b9e8e63
27a348b
83ff385
89a4281
34f5783
d65b37a
a39941a
b40973a
9293fc3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,9 @@ | |
|
||
#include "Gaffer/Context.h" | ||
#include "Gaffer/ScriptNode.h" | ||
#include "Gaffer/NameValuePlug.h" | ||
#include "Gaffer/CompoundDataPlug.h" | ||
#include "Gaffer/MetadataAlgo.h" | ||
|
||
#include "boost/bind/bind.hpp" | ||
|
||
|
@@ -146,5 +149,51 @@ std::vector<IECore::InternedString> ScriptNodeAlgo::getLastSelectedPath( const G | |
ScriptNodeAlgo::ChangedSignal &ScriptNodeAlgo::selectedPathsChangedSignal( Gaffer::ScriptNode *script ) | ||
{ | ||
return changedSignals( script ).selectedPathsChangedSignal; | ||
} | ||
|
||
NameValuePlug *ScriptNodeAlgo::acquireRenderPassPlug( Gaffer::ScriptNode *script, bool createIfMissing ) | ||
{ | ||
for( NameValuePlug::Iterator it( script->variablesPlug() ); !it.done(); ++it ) | ||
{ | ||
if( (*it)->getName() == "renderPass" ) | ||
Comment on lines
+156
to
+158
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we just use |
||
{ | ||
if( (*it)->valuePlug<StringPlug>() ) | ||
{ | ||
return it->get(); | ||
} | ||
else | ||
{ | ||
throw IECore::Exception( fmt::format( "Plug type of {} is {}, but must be StringPlug", (*it)->valuePlug()->fullName(), (*it)->valuePlug()->typeName() ) ); | ||
} | ||
} | ||
} | ||
|
||
if( createIfMissing ) | ||
{ | ||
auto renderPassPlug = new NameValuePlug( "renderPass", new StringPlug(), "renderPass", Gaffer::Plug::Flags::Default | Gaffer::Plug::Flags::Dynamic ); | ||
MetadataAlgo::setReadOnly( renderPassPlug->namePlug(), true ); | ||
script->variablesPlug()->addChild( renderPassPlug ); | ||
|
||
return renderPassPlug; | ||
} | ||
|
||
return nullptr; | ||
} | ||
|
||
void ScriptNodeAlgo::setCurrentRenderPass( Gaffer::ScriptNode *script, std::string renderPass ) | ||
{ | ||
if( auto renderPassPlug = acquireRenderPassPlug( script ) ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this check redundant? Doesn't |
||
{ | ||
renderPassPlug->valuePlug<StringPlug>()->setValue( renderPass ); | ||
} | ||
} | ||
|
||
std::string ScriptNodeAlgo::getCurrentRenderPass( const Gaffer::ScriptNode *script ) | ||
{ | ||
if( const auto renderPassPlug = acquireRenderPassPlug( const_cast<ScriptNode *>( script ), /* createIfMissing = */ false ) ) | ||
{ | ||
return renderPassPlug->valuePlug<StringPlug>()->getValue(); | ||
} | ||
|
||
return ""; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be wrapped in an UndoScope? It wasn't before, and it does kindof feel like "UI state" that you wouldn't expect to be undoable, but it is actually editing a plug in the script, which generally speaking should be undoable.