| 53 | static std::mutex g_poolMutex; |
| 54 | |
| 55 | ImageDisplayDriver::ImageDisplayDriver( const Box2i &displayWindow, const Box2i &dataWindow, const vector<string> &channelNames, ConstCompoundDataPtr parameters ) : |
| 56 | DisplayDriver( displayWindow, dataWindow, channelNames, parameters ), |
| 57 | m_image( new ImagePrimitive( dataWindow, displayWindow ) ) |
| 58 | { |
| 59 | for ( vector<string>::const_iterator it = channelNames.begin(); it != channelNames.end(); it++ ) |
| 60 | { |
| 61 | m_image->createChannel<float>( *it ); |
| 62 | } |
| 63 | if( parameters ) |
| 64 | { |
| 65 | // Add all entries that follow our 'header:' metadata convention to the blindData. |
| 66 | // Other entries are omitted. |
| 67 | CompoundDataMap &xData = m_image->blindData()->writable(); |
| 68 | const CompoundDataMap &yData = parameters->readable(); |
| 69 | CompoundDataMap::const_iterator iterY = yData.begin(); |
| 70 | for ( ; iterY != yData.end(); iterY++ ) |
| 71 | { |
| 72 | if( starts_with( iterY->first.string(), "header:" ) ) |
| 73 | { |
| 74 | xData[ iterY->first.string().substr( 7 ) ] = iterY->second->copy(); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | ConstStringDataPtr handle = parameters->member<StringData>( "handle" ); |
| 79 | if( handle ) |
| 80 | { |
| 81 | std::lock_guard<std::mutex> lock( g_poolMutex ); |
| 82 | g_pool[handle->readable()] = m_image; |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | ImageDisplayDriver::~ImageDisplayDriver() |
| 88 | { |