//-*****************************************************************************
void IObjectDrw::draw( const DrawContext &iCtx )
{
    if ( !m_object ) { return; }

    // Skip objects with "visible" property set to 0
    if ( iCtx.visibleOnly() ) {
        Abc::ICompoundProperty props = m_object.getProperties();
        const Abc::PropertyHeader* header = props.getPropertyHeader( "visible" );
        if ( header != NULL ) {
            Abc::IScalarProperty visible( props, "visible" );
            Abc::ISampleSelector iss( m_currentTime );
            int8_t val = 1;
            visible.get( reinterpret_cast<void*>( &val ), iss );
            if ( val == 0 ) 
                return;
        }
    }

    // GL picking, add to global selection index
    int i = 0;
    for ( DrawablePtrVec::iterator iter = m_children.begin();
          iter != m_children.end(); ++iter, i++ )
    {
        Abc::IObject iChild = m_object.getChild( i );
        int index = pushName( iChild );
        DrawablePtr dptr = (*iter);
        if ( dptr )
        {
            dptr->draw( iCtx );
        }
        if ( index >= 0 )
            popName( m_object );
    }
    
}
Ejemplo n.º 2
0
bool
ZnkDirRecursive_traverse( ZnkDirRecursive recur, const char* top_dir, ZnkStr ermsg )
{
	size_t top_dir_leng = 0;
	/***
	 * このtop_dir直下に限定した範囲でのエラー発生回数.
	 */
	size_t    local_err_num = 0;
	bool      last_result;
	char      last_ch;
	ZnkDirType dir_type;
	ZnkDirId   dir_id;

	if( recur->funcarg_isIgnoreDir_.func_ ){
		last_result = recur->funcarg_isIgnoreDir_.func_( recur,
				top_dir, recur->funcarg_isIgnoreDir_.arg_, local_err_num );
		if( last_result ){
			return true;
		}
	}
	
	if( recur->funcarg_onEnterDir_.func_ ){
		last_result = recur->funcarg_onEnterDir_.func_( recur,
				top_dir, recur->funcarg_onEnterDir_.arg_, local_err_num );
		if( !last_result ){
			if( ermsg ){
				const char* action_str = recur->is_err_ignore_ ? "Ignored" : "Interrupted";
				ZnkStr_addf( ermsg,
						"ZnkDirRecursive_traverse : Error %s. : onEnterDir failure. directory=[%s].",
						action_str, top_dir );
			}
			++local_err_num;
		}
	}

	dir_id = ZnkDir_openDir( top_dir );
	if( dir_id == NULL ){
		/* Cannot open top_dir */
		if( ermsg ){
			ZnkStr_addf( ermsg, "ZnkDirRecursive_traverse : Error : Cannot open top_dir=[%s]\n", top_dir );
		}
		return false;
	}

	top_dir_leng = Znk_strlen( top_dir );
	/***
	 * top_dir をスタックにプッシュし、以下の処理ではこの領域へのポインタとみなす.
	 * 尚、VStrの性質から各要素のC1MarshalBufが指す先の生データである文字列へのポインタ値は、
	 * スタックの拡張縮小に関わらず存在する限りにおいて無効とはならない.
	 */
	top_dir = pushName( recur, top_dir, top_dir_leng );

	while( true ){
		const char* obj = ZnkDir_readDir( dir_id );
		if( obj == NULL ){ break; }

		/***
		 * The path should be absolute path.
		 */
		ZnkStr_assign( recur->wkstr_, 0, top_dir, top_dir_leng );
		last_ch = ZnkStr_last( recur->wkstr_ );
		if( last_ch != '/' && last_ch != '\\' ){
			ZnkStr_add_c( recur->wkstr_, '/' );
		}
		ZnkStr_add( recur->wkstr_, obj );

		dir_type = ZnkDir_getType( ZnkStr_cstr(recur->wkstr_) );
		switch( dir_type ){
		case ZnkDirType_e_Directory:
			/* obj is a directory. */
			/* この呼び出し以降は、wkstr_の内容は無効となっていると考えねばならない. */
			last_result = ZnkDirRecursive_traverse( recur, ZnkStr_cstr(recur->wkstr_), ermsg );
			if( !last_result ){
				++local_err_num;
				/***
				 * ここで無視して続けるか途中で中断するのかをis_err_ignore_で切り替える.
				 */
				if( recur->is_err_ignore_ ){ continue; } else { goto FUNC_END; }
			}
			break;
		case ZnkDirType_e_File:
			/* obj is a file */
			if( recur->funcarg_processFile_.func_ ){
				last_result = recur->funcarg_processFile_.func_( recur,
						ZnkStr_cstr(recur->wkstr_), recur->funcarg_processFile_.arg_, local_err_num );
				if( !last_result ){
					if( ermsg ){
						const char* action_str = recur->is_err_ignore_ ? "Ignored" : "Interrupted";
						ZnkStr_addf( ermsg,
								"ZnkDirRecursive_traverse : Error %s. : processFile failure : file=[%s].",
								action_str, ZnkStr_cstr(recur->wkstr_) );
					}
					++local_err_num;

					/***
					 * ここで無視して続けるか途中で中断するのかをis_err_ignore_で切り替える.
					 */
					if( recur->is_err_ignore_ ){ continue; } else { goto FUNC_END; }
				}
			}
			break;
		case ZnkDirType_e_NotFound:
		{
			/* これは通常起こり得ないはずであるが、発生した場合はErrorとする */
			if( ermsg ){
				ZnkStr_addf( ermsg,
						"ZnkDirRecursive_traverse : Error : listing obj=[%s] type is NotFound.",
						ZnkStr_cstr(recur->wkstr_) );
			}
			if( recur->is_err_ignore_ ){ continue; } else { goto FUNC_END; }
			break;
		}
		case ZnkDirType_e_CannotKnow:
		default:
		{
			/* これは通常起こり得ないはずであるが、発生した場合はErrorとする */
			if( ermsg ){
				ZnkStr_addf( ermsg,
						"ZnkDirRecursive_traverse : Error : listing obj=[%s] type is CannotKnow.",
						ZnkStr_cstr(recur->wkstr_) );
			}
			if( recur->is_err_ignore_ ){ continue; } else { goto FUNC_END; }
			break;
		}
		}
	}

FUNC_END:
	ZnkDir_closeDir( dir_id );

	/***
	 * ここまでがすべて成功であった場合は、top_dir の中身はすべて空であるはずである.
	 * そこで最後に top_dir そのものを消す.
	 */
	if( recur->funcarg_onExitDir_.func_ ){
		last_result = recur->funcarg_onExitDir_.func_( recur,
				top_dir, recur->funcarg_onExitDir_.arg_, local_err_num );
		if( !last_result ){
			if( ermsg ){
				const char* action_str = recur->is_err_ignore_ ? "Ignored" : "Interrupted";
				ZnkStr_addf( ermsg,
						"ZnkDirRecursive_traverse : Error %s. : onExitDir failure. directory=[%s].",
						action_str, top_dir );
			}
			++local_err_num;
		}
	}
	/***
	 * もはやtop_dirは不要.
	 * それが指す領域を開放(スタックからポップする).
	 */
	popName( recur );
	return (bool)( local_err_num == 0 );
}