| 1081 | } // WriteNode::initializeKnobs |
| 1082 | |
| 1083 | void |
| 1084 | WriteNode::onEffectCreated(bool mayCreateFileDialog, |
| 1085 | const CreateNodeArgs& args) |
| 1086 | { |
| 1087 | |
| 1088 | RenderEnginePtr engine = getRenderEngine(); |
| 1089 | assert(engine); |
| 1090 | QObject::connect(engine.get(), SIGNAL(renderFinished(int)), this, SLOT(onSequenceRenderFinished())); |
| 1091 | |
| 1092 | if ( !_imp->renderButtonKnob.lock() ) { |
| 1093 | _imp->renderButtonKnob = std::dynamic_pointer_cast<KnobButton>( getKnobByName(kNatronWriteParamStartRender) ); |
| 1094 | assert( _imp->renderButtonKnob.lock() ); |
| 1095 | } |
| 1096 | |
| 1097 | |
| 1098 | //If we already loaded the Writer, do not do anything |
| 1099 | if ( _imp->embeddedPlugin.lock() ) { |
| 1100 | // Ensure the plug-in ID knob has the same value as the created reader: |
| 1101 | // The reader might have been created in onKnobsAboutToBeLoaded() however the knobs |
| 1102 | // get loaded afterwards and the plug-in ID could not reflect the underlying plugin |
| 1103 | KnobStringPtr pluginIDKnob = _imp->pluginIDStringKnob.lock(); |
| 1104 | if (pluginIDKnob) { |
| 1105 | pluginIDKnob->setValue(_imp->embeddedPlugin.lock()->getPluginID()); |
| 1106 | } |
| 1107 | return; |
| 1108 | } |
| 1109 | bool throwErrors = false; |
| 1110 | KnobStringPtr pluginIdParam = _imp->pluginIDStringKnob.lock(); |
| 1111 | std::string pattern; |
| 1112 | |
| 1113 | if (mayCreateFileDialog) { |
| 1114 | bool useDialogForWriters = appPTR->getCurrentSettings()->isFileDialogEnabledForNewWriters(); |
| 1115 | if (useDialogForWriters) { |
| 1116 | pattern = getApp()->saveImageFileDialog(); |
| 1117 | } |
| 1118 | |
| 1119 | //The user selected a file, if it fails to read do not create the node |
| 1120 | throwErrors = true; |
| 1121 | } else { |
| 1122 | |
| 1123 | std::vector<std::string> defaultParamValues = args.getPropertyN<std::string>(kCreateNodeArgsPropNodeInitialParamValues); |
| 1124 | std::vector<std::string>::iterator foundFileName = std::find(defaultParamValues.begin(), defaultParamValues.end(), std::string(kOfxImageEffectFileParamName)); |
| 1125 | if (foundFileName != defaultParamValues.end()) { |
| 1126 | std::string propName(kCreateNodeArgsPropParamValue); |
| 1127 | propName += "_"; |
| 1128 | propName += kOfxImageEffectFileParamName; |
| 1129 | pattern = args.getProperty<std::string>(propName); |
| 1130 | } |
| 1131 | } |
| 1132 | |
| 1133 | _imp->createWriteNode( throwErrors, pattern, NodeSerializationPtr() ); |
| 1134 | _imp->refreshPluginSelectorKnob(); |
| 1135 | } |
| 1136 | |
| 1137 | void |
| 1138 | WriteNode::onKnobsAboutToBeLoaded(const NodeSerializationPtr& serialization) |
nothing calls this directly
no test coverage detected