void SceneView::contextChanged( const IECore::InternedString &name ) { if( name.value() == "ui:scene:selectedPaths" ) { // if only the selection has changed then we can just update the selection // on our existing scene representation. const StringVectorData *sc = getContext()->get<StringVectorData>( "ui:scene:selectedPaths" ); RenderableGadget::Selection sr; sr.insert( sc->readable().begin(), sc->readable().end() ); BlockedConnection blockedConnection( m_selectionChangedConnection ); m_renderableGadget->setSelection( sr ); return; } if( name.value().compare( 0, 3, "ui:" ) == 0 && name.value() != "ui:scene:expandedPaths" ) { // if it's just a ui context entry that has changed, and it doesn't // affect our expansion, then early out. return; } // the context change might affect the scene itself, so we must // schedule an update. updateRequestSignal()( this ); }
void SceneView::contextChanged( const IECore::InternedString &name ) { if( name.value() == "ui:scene:selectedPaths" ) { // If only the selection has changed then we can just update the selection // on our existing scene representation. const StringVectorData *sc = getContext()->get<StringVectorData>( "ui:scene:selectedPaths" ); /// \todo Store selection as PathMatcherData within the context, so we don't need /// this conversion. GafferScene::PathMatcherDataPtr sg = new GafferScene::PathMatcherData; sg->writable().init( sc->readable().begin(), sc->readable().end() ); m_sceneGadget->setSelection( sg ); return; } else if( name.value() == "ui:scene:expandedPaths" ) { const GafferScene::PathMatcherData *expandedPaths = getContext()->get<GafferScene::PathMatcherData>( "ui:scene:expandedPaths" ); m_sceneGadget->setExpandedPaths( expandedPaths ); return; } else if( boost::starts_with( name.value(), "ui:" ) ) { // ui context entries shouldn't affect computation. return; } }
void contextChanged( const IECore::InternedString &name ) { if( !boost::starts_with( name.value(), "ui:" ) ) { m_lookThroughCameraDirty = m_viewportCameraDirty = true; } }
boost::signals::detail::unusable operator()( boost::python::object slot, ConstContextPtr context, const IECore::InternedString &name ) { try { slot( IECore::constPointerCast<Context>( context ), name.value() ); } catch( const error_already_set &e ) { PyErr_PrintEx( 0 ); // clears the error status } return boost::signals::detail::unusable(); }
const IECore::InternedString &GraphComponent::setName( const IECore::InternedString &name ) { // make sure the name is valid static boost::regex validator( "^[A-Za-z_]+[A-Za-z_0-9]*" ); if( !regex_match( name.c_str(), validator ) ) { std::string what = boost::str( boost::format( "Invalid name \"%s\"" ) % name.string() ); throw IECore::Exception( what ); } // make sure the name is unique IECore::InternedString newName = name; if( m_parent ) { bool uniqueAlready = true; for( ChildContainer::const_iterator it=m_parent->m_children.begin(), eIt=m_parent->m_children.end(); it != eIt; it++ ) { if( *it != this && (*it)->m_name == m_name ) { uniqueAlready = false; break; } } if( !uniqueAlready ) { // split name into a prefix and a numeric suffix. if no suffix // exists then it defaults to 1. std::string prefix; int suffix = numericSuffix( newName.value(), 1, &prefix ); // iterate over all the siblings to find the minimum value for the suffix which // will be greater than any existing suffix. for( ChildContainer::const_iterator it=m_parent->m_children.begin(), eIt=m_parent->m_children.end(); it != eIt; it++ ) { if( *it == this ) { continue; } if( (*it)->m_name.value().compare( 0, prefix.size(), prefix ) == 0 ) { char *endPtr = 0; long siblingSuffix = strtol( (*it)->m_name.value().c_str() + prefix.size(), &endPtr, 10 ); if( *endPtr == '\0' ) { suffix = max( suffix, (int)siblingSuffix + 1 ); } } } static boost::format formatter( "%s%d" ); newName = boost::str( formatter % prefix % suffix ); } } // set the new name if it's different to the old if( newName==m_name ) { return m_name; } Action::enact( this, // ok to bind raw pointers to this, because enact() guarantees // the lifetime of the subject. boost::bind( &GraphComponent::setNameInternal, this, newName ), boost::bind( &GraphComponent::setNameInternal, this, m_name ) ); return m_name; }