Пример #1
0
void ofApp::draw()
{
    ofBackground(255);
    
    
    float w = ofGetWidth();
    float h = ofGetHeight();
    

    float orig_width = background.getWidth();
    float orig_height = background.getHeight();
    float factor = (w/2.1) / orig_width;
    
    ofApp::img_x = w/2 - (orig_width * factor)/2;
    ofApp::img_y = h/3 - (orig_height * factor)/2;
    ofApp::img_w = orig_width * factor;
    ofApp::img_h = orig_height * factor;
    
    if(!hideMovement && !hideBackgroundWhileDrawing){
        the_stream->draw(img_x, img_y, img_w, img_h);
    }else if(!hideBackgroundWhileDrawing){
        background.draw(img_x, img_y, img_w, img_h);
    }
    
    if(drawing){
        movement.draw(img_x, img_y, img_w, img_h);
        
    }
    
    
    ofPushStyle();
    
        ofSetColor(0, 0, 0);
        string str = "STREAMING LIVE FROM: " + stream_name;
        ofDrawBitmapString(str, img_x, img_y + img_h + 20);
        ofDrawBitmapString(threshold, img_x, img_y + img_h + 35);
        
        if (!hideMovement && drawing){
            ofSetColor(250);
            ofDrawRectangle(img_x, img_y + img_h + 75, img_w, 80);
            ofSetColor(240);
            drawMinus(img_x + (img_w/2), img_y + img_h + 75 + 40);
        }else if (!hideMovement){
            ofSetColor(240);
            ofDrawRectangle(img_x, img_y + img_h + 75, img_w, 80);
            ofSetColor(180);
            drawMinus(img_x + (img_w/2), img_y + img_h + 75 + 40);
        }else{
            ofSetColor(230);
            ofDrawRectangle(img_x, img_y + img_h + 75, img_w, 80);
            ofSetColor(200);
            drawMinus(img_x + (img_w/2), img_y + img_h + 75 + 40);
        }
        
        if (!drawing){
            ofSetColor(240);
            ofDrawRectangle(img_x, img_y + img_h + 185, img_w, 80);
            ofSetColor(180);
            drawPlus(img_x + (img_w/2),img_y + img_h + 185 + 40);
        }else{
            ofSetColor(210);
            ofDrawRectangle(img_x, img_y + img_h + 185, img_w, 80);
            ofSetColor(180);
            drawPlus(img_x + (img_w/2),img_y + img_h + 185 + 40);
        }
    
//        --------
    
        //hidebackgroundWhile Drawing
        ofSetColor(252);
        if (drawing){
            ofDrawRectangle(img_x, img_y + img_h + 295, img_w, 80);
        }
    
        //next stream
    
        ofDrawRectangle(img_x + img_w + 30, img_y, 80, img_h);
        //reset current stream:
        ofDrawRectangle(img_x - 30 - 80, img_y, 80, img_h);
    
    
        //treshold -
        ofDrawRectangle(20, 20, 80, 80);
        //treshold +
        ofDrawRectangle(120, 20, 80, 80);
    
    
    ofPopStyle();

    
}
Пример #2
0
void agpVsMap(char *agpName, char *infoName, char *gifName)
/* agpVsMap - Plot clones in agp vs. map coordinates. */
{
struct mapPos *mapList, *mp;
struct agpFrag *agpList, *bp;
struct hash *cloneHash = newHash(14);
struct hashEl *hel;
struct cloneInfo *cloneList = NULL, *clone;
struct memGfx *mg = NULL;
int pixWidth = 600;
int pixHeight = 600;
int rulerHeight = 20;
int maxMapPos = 0, maxAgpPos = 0;
double scaleMap, scaleAgp;
Color orange, green;

mapList = readInfoFile(infoName);
agpList = readAgpFile(agpName);

for (mp = mapList; mp != NULL; mp = mp->next)
    {
    if (mp->phase > 0)
        {
	AllocVar(clone);
	hel = hashAddUnique(cloneHash, mp->cloneName, clone);
	clone->name = hel->name;
	clone->mp = mp;
	slAddHead(&cloneList, clone);
	if (mp->pos > maxMapPos) maxMapPos = mp->pos;
	}
    }
slReverse(&cloneList);

for (bp = agpList; bp != NULL; bp = bp->next)
    {
    if (bp->chromStart > maxAgpPos) maxAgpPos = bp->chromStart;
    }

/* Draw scatterplot on bitmap. */
mg = mgNew(pixWidth, pixHeight);
mgClearPixels(mg);
orange = mgFindColor(mg, 210, 150, 0);
green = mgFindColor(mg, 0, 200, 0);
mgDrawRuler(mg, 0, pixHeight-rulerHeight, rulerHeight, pixWidth, MG_BLACK,
       mgSmallFont(), 0, maxMapPos+1);
scaleMap = (double)pixWidth/(double)(maxMapPos+1.0);
scaleAgp = (double)(pixHeight)/(double)(maxAgpPos+1.0);
for (bp = agpList; bp != NULL; bp = bp->next)
    {
    char cloneName[128];
    fragToCloneName(bp->frag, cloneName);
    clone = hashFindVal(cloneHash, cloneName);
    if (clone == NULL)
        warn("%s is in %s but not %s", cloneName, 
	    agpName, infoName);
    else
	{
	int x = round(scaleMap*clone->mp->pos);
	int y = pixHeight - round(scaleAgp*bp->chromStart);
	int phase = clone->mp->phase;
	int back;
	if (phase <= 1) back = green;
	else if (phase == 2) back = orange;
	else back = MG_RED;
	drawPlus(mg, x, y, back);
	}
    }

mgSaveGif(mg, gifName);
}