/* * Note this is NOT thread-safe, lockSources() should be called around any calls * to this. */ void gravManager::moveToTop( std::vector<RectangleBase*>::iterator i, bool checkGrouping ) { RectangleBase* temp = (*i); RectangleBase* orig = temp; // find highest group in the chain, to move up group members from the top // of the chain while ( checkGrouping && temp->isGrouped() ) temp = temp->getGroup(); // do this to properly find iterator position, since i != temp now if ( temp != orig ) moveToTop( temp, checkGrouping ); else { drawnObjects->erase( i ); drawnObjects->push_back( temp ); if ( temp->isGroup() ) { Group* g = (Group*)temp; for ( int i = 0; i < g->numObjects(); i++ ) moveToTop( (*g)[i], false ); } } }
void SessionManager::recalculateSize() { int num = std::max( videoSessions->numObjects(), availableVideoSessions->numObjects() ); float Xscale = std::min( 0.9f, 0.4f + ( (float)num * 0.05f ) ); RectangleBase screen = objectManager->getScreenRect(); setScale( screen.getDestWidth() * Xscale, screen.getDestHeight() * 0.2f, true ); }
// Clamp the parameter to this rectangle RectangleBase Clamp(const RectangleBase& other) const { float top = Math::Max(other.Top(), Top()); float bottom = Math::Min(other.Bottom(), Bottom()); float left = Math::Max(other.Left(), Left()); float right = Math::Min(other.Right(), Right()); if(right < left) right = left; if(bottom < top) bottom = top; return RectangleBase(left, top, right, bottom); }
void VenueClientController::rearrange() { std::map<std::string, std::string> opts; std::map<std::string, std::vector<RectangleBase*> > data; data["objects"] = objects; RectangleBase smaller = *this; // uneven since most screens will be widescreen - so make vertical area // bigger so objects on top/bottom are bigger and text more readable smaller.setScale( smaller.getScaleX() * 0.6f, smaller.getScaleY() * 0.45f ); layouts.arrange( "perimeter", *this, smaller, data, opts ); }
void gravManager::addTestObject() { lockSources(); RectangleBase* obj = new RectangleBase( 0.0f, 0.0f ); drawnObjects->push_back( obj ); bool useRandName = false; if ( useRandName ) { int nameLength = 10; std::string randName; for( int i = 0; i < nameLength; i++ ) { int rand = ((float)random32() / (float)random32_max() * 95) + 32; randName += (char)rand; } obj->setName( randName ); } else if ( drawnObjects->size() % 2 == 0 ) { obj->setName( " " ); } else { obj->setName( "TEST" ); } Texture t = GLUtil::getInstance()->getTexture( "border" ); obj->setTexture( t.ID, t.width, t.height ); obj->setUserDeletable( true ); unlockSources(); }
void gravManager::scaleSelectedObjects( float scaleAmt ) { for ( unsigned int i = 0; i < selectedObjects->size(); i++ ) { RectangleBase* temp = (*selectedObjects)[i]; temp->setScale( temp->getScaleX()+temp->getScaleX()*scaleAmt, temp->getScaleY()+temp->getScaleY()*scaleAmt ); } }
void gravManager::deleteSource( std::vector<VideoSource*>::iterator si ) { lockSources(); RectangleBase* temp = (RectangleBase*)(*si); VideoSource* s = *si; removeFromLists( temp ); sources->erase( si ); // TODO need case for runway grouping? if ( temp->isGrouped() ) { Group* g = temp->getGroup(); // remove object from the group, regardless of whether it's a siteID // group or not. // this should work for runways, but should be more generic, ie for // groups of groups? maybe in removefromlists, but careful not to // degroup object before it hits that siteID check above or siteIDgroups // will have invalid references g->remove( temp ); // delete the group the object was in if this is the last object in it // and it's an automatically made siteID group // TODO probably have a better metric for determining auto-siteID groups if ( g->getSiteID().compare( "" ) != 0 && g->numObjects() == 0 ) { // note this duplicates the deleteGroup function since that does // mutex locking itself, and we already did that here removeFromLists( (RectangleBase*)g ); // remove the group from the list of siteIDgroups std::map<std::string,Group*>::iterator gi = siteIDGroups->find( g->getSiteID() ); siteIDGroups->erase( gi ); // put off the group delete, since removing it from the tree has to // happen on the main thread, and can't delete it before we remove // it from the tree objectsToDelete->push_back( g ); } } if ( gridAuto ) { std::map<std::string, std::vector<RectangleBase*> > data = std::map<std::string, std::vector<RectangleBase*> >(); data["objects"] = getMovableObjects(); layouts->arrange("grid", getScreenRect(), getEarthRect(), data); } // we need to do videosource's delete somewhere else, since this function // might be on a second thread, which would crash since the videosource // delete needs to do a GL call to delete its texture and GL calls can only // be on the main thread objectsToDelete->push_back( s ); unlockSources(); }
void VideoSource::resizeBuffer() { // get intended size so we can resize, since the width might change here RectangleBase intended; intended.setScale( intendedWidth, intendedHeight ); float posX = getDestX(); float posY = getDestY(); if ( !lastFillFull ) { posX += getCenterOffsetX(); posY += getCenterOffsetY(); } intended.setPos( posX, posY ); listener->updatePixelCount( -( vwidth * vheight ) ); vwidth = videoSink->getImageWidth(); vheight = videoSink->getImageHeight(); listener->updatePixelCount( vwidth * vheight ); if ( vheight > 0 ) destAspect = (float)vwidth / (float)vheight; else destAspect = 1.33f; if ( animated ) aspectAnimating = true; else aspect = destAspect; tex_width = GLUtil::getInstance()->pow2( vwidth ); if ( videoSink->getImageFormat() == VIDEO_FORMAT_YUV420 ) tex_height = GLUtil::getInstance()->pow2( 3*vheight/2 ); else tex_height = GLUtil::getInstance()->pow2( vheight ); gravUtil::logVerbose( "VideoSource::resizeBuffer: image size is %ix%i\n", vwidth, vheight ); gravUtil::logVerbose( "VideoSource::resizeBuffer: texture size is %ix%i\n", tex_width, tex_height ); // if it's not the first time we're allocating a texture // (ie, it's a resize) delete the previous texture if ( !init ) glDeleteTextures( 1, &texid ); glGenTextures( 1, &texid ); glBindTexture( GL_TEXTURE_2D, texid ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); unsigned char *buffer = new unsigned char[ tex_width * tex_height * 3 ]; memset( buffer, 128, tex_width * tex_height * 3 ); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, tex_width, tex_height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, buffer ); delete[] buffer; // fill to intended size fillToRect( intended, lastFillFull ); // update text bounds since the width might be different updateTextBounds(); }