本文整理汇总了C++中StringVectorDataPtr::writable方法的典型用法代码示例。如果您正苦于以下问题:C++ StringVectorDataPtr::writable方法的具体用法?C++ StringVectorDataPtr::writable怎么用?C++ StringVectorDataPtr::writable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringVectorDataPtr
的用法示例。
在下文中一共展示了StringVectorDataPtr::writable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: transferSelectionToContext
void SceneView::transferSelectionToContext()
{
/// \todo If RenderableGadget used PathMatcherData, then we might not need
/// to copy data here.
const RenderableGadget::Selection &selection = m_renderableGadget->getSelection();
StringVectorDataPtr s = new StringVectorData();
s->writable().insert( s->writable().end(), selection.begin(), selection.end() );
getContext()->set( "ui:scene:selectedPaths", s.get() );
}
示例2: ImagePrimitive
ImageCompositeOp::ImageCompositeOp() : ImagePrimitiveOp( "ImageCompositeOp" )
{
IntParameter::PresetsContainer operationPresets;
operationPresets.push_back( IntParameter::Preset( "Over", Over ) );
operationPresets.push_back( IntParameter::Preset( "Max", Max ) );
operationPresets.push_back( IntParameter::Preset( "Min", Min ) );
operationPresets.push_back( IntParameter::Preset( "Multiply", Multiply ) );
m_operationParameter = new IntParameter(
"operation",
"operation description",
Over,
operationPresets
);
StringVectorDataPtr defaultChannels = new StringVectorData;
defaultChannels->writable().push_back( "R" );
defaultChannels->writable().push_back( "G" );
defaultChannels->writable().push_back( "B" );
m_channelNamesParameter = new StringVectorParameter(
"channels",
"The names of the channels to modify.",
defaultChannels
);
m_alphaChannelNameParameter = new StringParameter(
"alphaChannelName",
"The name of the channel which holds the alpha. This is used for both images.",
"A"
);
m_imageAParameter = new ImagePrimitiveParameter(
"imageA",
"imageA is the second image operand of the composite. It is named such that operation names like 'A over B' make sense. "
"Therefore parameter named 'input' represents imageB",
new ImagePrimitive()
);
IntParameter::PresetsContainer inputModePresets;
inputModePresets.push_back( IntParameter::Preset( "Premultiplied", Premultiplied ) );
inputModePresets.push_back( IntParameter::Preset( "Unpremultiplied", Unpremultiplied ) );
m_inputModeParameter = new IntParameter(
"inputMode",
"States whether the input images are premultiplied by their alpha.",
Premultiplied,
inputModePresets
);
parameters()->addParameter( m_operationParameter );
parameters()->addParameter( m_channelNamesParameter );
parameters()->addParameter( m_alphaChannelNameParameter );
parameters()->addParameter( m_imageAParameter );
parameters()->addParameter( m_inputModeParameter );
}
示例3: computeChannelNames
IECore::ConstStringVectorDataPtr Shape::computeChannelNames( const Gaffer::Context *context, const ImagePlug *parent ) const
{
assert( parent == shapePlug() );
StringVectorDataPtr result = new StringVectorData();
result->writable().push_back( "R" );
result->writable().push_back( "G" );
result->writable().push_back( "B" );
result->writable().push_back( "A" );
return result;
}
示例4: computeChannelNames
IECore::ConstStringVectorDataPtr ImageReader::computeChannelNames( const Gaffer::Context *context, const ImagePlug *parent ) const
{
std::string fileName = fileNamePlug()->getValue();
const ImageSpec *spec = imageCache()->imagespec( ustring( fileName.c_str() ) );
StringVectorDataPtr result = new StringVectorData();
result->writable() = spec->channelnames;
return result;
}
示例5: transferSelectionToContext
void SceneView::transferSelectionToContext()
{
/// \todo Use PathMatcherData for the context variable so we don't need
/// to do this copying into StringVectorData. See related comments
/// in SceneHierarchy.__transferSelectionFromContext
StringVectorDataPtr s = new StringVectorData();
m_sceneGadget->getSelection()->readable().paths( s->writable() );
getContext()->set( "ui:scene:selectedPaths", s.get() );
}
示例6: setSelectedPaths
void setSelectedPaths( Context *context, const GafferScene::PathMatcher &paths )
{
/// \todo: Switch to storing PathMatcherData after some thorough
/// testing and a major version break.
StringVectorDataPtr s = new StringVectorData;
paths.paths( s->writable() );
context->set( g_selectedPathsName, s.get() );
}
示例7: updateLookThroughCamera
void updateLookThroughCamera()
{
if( !m_lookThroughCameraDirty )
{
return;
}
m_lookThroughCameraDirty = false;
m_lookThroughCamera = NULL;
if( !enabledPlug()->getValue() )
{
m_view->viewportGadget()->setCamera( m_originalCamera.get() );
m_view->viewportGadget()->setCameraEditable( true );
m_view->hideFilter()->pathsPlug()->setToDefault();
return;
}
// We want to look through a specific camera.
// Retrieve it.
Context::Scope scopedContext( m_view->getContext() );
try
{
const string cameraPathString = cameraPlug()->getValue();
if( cameraPathString.empty() )
{
m_lookThroughCamera = GafferScene::camera( scenePlug() ); // primary render camera
}
else
{
ScenePlug::ScenePath cameraPath;
ScenePlug::stringToPath( cameraPathString, cameraPath );
m_lookThroughCamera = GafferScene::camera( scenePlug(), cameraPath );
}
}
catch( ... )
{
// If an invalid path has been entered for the camera, computation will fail.
// We just ignore that and lock to the current camera instead.
m_lookThroughCamera = NULL;
}
m_view->viewportGadget()->setCameraEditable( false );
if( m_lookThroughCamera )
{
StringVectorDataPtr invisiblePaths = new StringVectorData();
invisiblePaths->writable().push_back( m_lookThroughCamera->getName() );
m_view->hideFilter()->pathsPlug()->setValue( invisiblePaths );
}
else
{
m_view->hideFilter()->pathsPlug()->setToDefault();
}
}
示例8: childNames
IECore::StringVectorDataPtr AlembicInput::childNames() const
{
StringVectorDataPtr resultData = new StringVectorData;
std::vector<std::string> &resultVector = resultData->writable();
size_t numChildren = this->numChildren();
for( size_t i=0; i<numChildren; i++ )
{
resultVector.push_back( m_data->object.getChildHeader( i ).getName() );
}
return resultData;
}
示例9: parameterValue
IECore::DataPtr RenderManShader::parameterValue( const Gaffer::Plug *parameterPlug, NetworkBuilder &network ) const
{
if( parameterPlug->typeId() == Plug::staticTypeId() )
{
// coshader parameter
const Plug *inputPlug = parameterPlug->source<Plug>();
if( inputPlug && inputPlug != parameterPlug )
{
const RenderManShader *inputShader = inputPlug->parent<RenderManShader>();
if( inputShader )
{
const std::string &handle = network.shaderHandle( inputShader );
if( handle.size() )
{
return new StringData( handle );
}
}
}
}
else if( parameterPlug->isInstanceOf( ArrayPlug::staticTypeId() ) )
{
// coshader array parameter
StringVectorDataPtr value = new StringVectorData();
for( InputPlugIterator cIt( parameterPlug ); cIt != cIt.end(); ++cIt )
{
const Plug *inputPlug = (*cIt)->source<Plug>();
const RenderManShader *inputShader = inputPlug && inputPlug != *cIt ? inputPlug->parent<RenderManShader>() : 0;
if( inputShader )
{
value->writable().push_back( network.shaderHandle( inputShader ) );
}
else
{
value->writable().push_back( "" );
}
}
return value;
}
return Shader::parameterValue( parameterPlug, network );
}
示例10: computeChannelNames
IECore::ConstStringVectorDataPtr Shuffle::computeChannelNames( const Gaffer::Context *context, const ImagePlug *parent ) const
{
StringVectorDataPtr resultData = inPlug()->channelNamesPlug()->getValue()->copy();
vector<string> &result = resultData->writable();
for( ChannelPlugIterator it( channelsPlug() ); !it.done(); ++it )
{
string channelName = (*it)->outPlug()->getValue();
if( channelName != "" && find( result.begin(), result.end(), channelName ) == result.end() )
{
result.push_back( channelName );
}
}
return resultData;
}
示例11: StringVectorParameter
TransformOp::TransformOp()
: PrimitiveOp( "Applies a matrix transformation to primitive variables." )
{
m_multiplyOp = new MatrixMultiplyOp;
m_multiplyOp->copyParameter()->setTypedValue( false );
StringVectorDataPtr defaultPrimVars = new StringVectorData;
defaultPrimVars->writable().push_back( "P" );
defaultPrimVars->writable().push_back( "N" );
m_primVarsParameter = new StringVectorParameter(
"primVarsToModify",
"The names of primitive variables which should be transformed according to their Geometric Interpretation.",
defaultPrimVars
);
parameters()->addParameter( m_multiplyOp->matrixParameter() );
parameters()->addParameter( m_primVarsParameter );
}
示例12: computeChannelNames
IECore::ConstStringVectorDataPtr Constant::computeChannelNames( const Gaffer::Context *context, const ImagePlug *parent ) const
{
std::string channelNamePrefix = layerPlug()->getValue();
if( !channelNamePrefix.empty() )
{
channelNamePrefix += ".";
}
StringVectorDataPtr resultData = new StringVectorData();
vector<string> &result = resultData->writable();
result.push_back( channelNamePrefix + "R" );
result.push_back( channelNamePrefix + "G" );
result.push_back( channelNamePrefix + "B" );
result.push_back( channelNamePrefix + "A" );
return resultData;
}
示例13: compute
void CopyChannels::compute( Gaffer::ValuePlug *output, const Gaffer::Context *context ) const
{
if( output == mappingPlug() )
{
const string channelMatchPatterns = channelsPlug()->getValue();
CompoundObjectPtr result = new CompoundObject();
StringVectorDataPtr channelNamesData = new StringVectorData;
result->members()["__channelNames"] = channelNamesData;
vector<string> &channelNames = channelNamesData->writable();
size_t i = 0;
for( ImagePlugIterator it( inPlugs() ); !it.done(); ++i, ++it )
{
/// \todo We need this check because an unconnected input
/// has a default channelNames value of [ "R", "G", "B" ],
/// when it should have an empty default instead. Fix
/// the ImagePlug constructor and remove the check.
if( !(*it)->getInput<Plug>() )
{
continue;
}
ConstStringVectorDataPtr inputChannelNamesData = (*it)->channelNamesPlug()->getValue();
const vector<string> &inputChannelNames = inputChannelNamesData->readable();
for( vector<string>::const_iterator cIt = inputChannelNames.begin(), ceIt = inputChannelNames.end(); cIt != ceIt; ++cIt )
{
if( i > 0 && !StringAlgo::matchMultiple( *cIt, channelMatchPatterns ) )
{
continue;
}
if( find( channelNames.begin(), channelNames.end(), *cIt ) == channelNames.end() )
{
channelNames.push_back( *cIt );
}
result->members()[*cIt] = new IntData( i );
}
}
static_cast<CompoundObjectPlug *>( output )->setValue( result );
return;
}
ImageProcessor::compute( output, context );
}
示例14: Parameterised
DeepImageWriter::DeepImageWriter( const std::string &description ) : Parameterised( description )
{
m_fileNameParameter = new FileNameParameter( "fileName", "The filename to be written to.", "", "", false );
StringVectorDataPtr defaultChannels = new StringVectorData();
std::vector<std::string> &channels = defaultChannels->writable();
channels.push_back( "R" );
channels.push_back( "G" );
channels.push_back( "B" );
channels.push_back( "A" );
m_channelsParameter = new StringVectorParameter( "channelNames", "The list of channels to write.", defaultChannels );
m_resolutionParameter = new V2iParameter( "resolution", "The resolution of the image to write.", new V2iData( Imath::V2i( 2048, 1556 ) ) );
parameters()->addParameter( m_fileNameParameter );
parameters()->addParameter( m_channelsParameter );
parameters()->addParameter( m_resolutionParameter );
parameters()->addParameter( new M44fParameter( "worldToCameraMatrix", "world to camera space transformation matrix", new M44fData() ) );
parameters()->addParameter( new M44fParameter( "worldToNDCMatrix", "world to screen space projection matrix", new M44fData() ) );
}
示例15: FloatData
static IECore::DataPtr convertMetadata( const OSLQuery::Parameter &metadata )
{
if( metadata.type == TypeDesc::FLOAT )
{
return new IECore::FloatData( metadata.fdefault[0] );
}
else if( metadata.type == TypeDesc::INT )
{
return new IECore::IntData( metadata.idefault[0] );
}
else if( metadata.type == TypeDesc::STRING )
{
return new IECore::StringData( metadata.sdefault[0].c_str() );
}
else if( metadata.type.aggregate == TypeDesc::VEC3 )
{
if( metadata.type.basetype == TypeDesc::FLOAT )
{
if( metadata.type.vecsemantics == TypeDesc::COLOR )
{
return new IECore::Color3fData( Imath::Color3f(
metadata.fdefault[0],
metadata.fdefault[1],
metadata.fdefault[2]
) );
}
else
{
return new IECore::V3fData( Imath::V3f(
metadata.fdefault[0],
metadata.fdefault[1],
metadata.fdefault[2]
) );
}
}
else
{
return new IECore::V3iData( Imath::V3i(
metadata.idefault[0],
metadata.idefault[1],
metadata.idefault[2]
) );
}
}
else if( metadata.type.arraylen > 0 )
{
if( metadata.type.elementtype() == TypeDesc::FLOAT )
{
return new FloatVectorData( metadata.fdefault );
}
else if( metadata.type.elementtype() == TypeDesc::INT )
{
return new IntVectorData( metadata.idefault );
}
else if( metadata.type.elementtype() == TypeDesc::STRING )
{
StringVectorDataPtr result = new StringVectorData;
for( vector<ustring>::const_iterator it = metadata.sdefault.begin(), eIt = metadata.sdefault.end(); it != eIt; ++it )
{
result->writable().push_back( it->string() );
}
return result;
}
}
IECore::msg( IECore::Msg::Warning, "OSLShader", string( "Metadata \"" ) + metadata.name.c_str() + "\" has unsupported type" );
return NULL;
}