/* * Creates an illumination * according to an illumination montage and the location of a segmented worm. * * To use with protocol, use GetMontageFromProtocolInterp() first * * FlipLR is a bool. When set to 1, the illumination pattern is reflected across the worm's centerline. */ void IllumWorm(SegmentedWorm* segworm, CvSeq* IllumMontage, IplImage* img,CvSize gridSize, int FlipLR){ int DEBUG=0; if (DEBUG) printf("In IllumWorm()\n"); CvPoint* polyArr=NULL; int k; int numpts=0; for (k = 0; k < IllumMontage->total; ++k) { numpts=CreatePointArrFromMontage(&polyArr,IllumMontage,k); //ReturnHere int j; //DisplayPtArr(polyArr,numpts); CvPoint* ptPtr=polyArr; for (j = 0; j < numpts; ++j) { /** make a local copy of the current pt in worm space **/ CvPoint wormPt=*(ptPtr); /** replace that point with the new pt in image space **/ *(ptPtr)=CvtPtWormSpaceToImageSpace(wormPt,segworm, gridSize,FlipLR); /** move to the next pointer **/ ptPtr++; } if (DEBUG) { int i; printf("new polygon\n"); for (i = 0; i < numpts; i++) { printf(" (%d, %d)\n",polyArr[i].x,polyArr[i].y); cvCircle(img, polyArr[i], 1, cvScalar(255, 255, 255), 1); cvShowImage("Debug",img); cvWaitKey(10); } } /** Actually draw the polygon **/ cvFillPoly(img,&polyArr,&numpts,1,cvScalar(255,255,255),8); free(polyArr); polyArr=NULL; } if (DEBUG) { IplImage* TempImage=cvCreateImage(cvGetSize(img),IPL_DEPTH_8U,1); DrawSequence(&TempImage,segworm->LeftBound); DrawSequence(&TempImage, segworm->RightBound); double weighting=0.4; cvAddWeighted(img,weighting,TempImage,1,0,TempImage); cvShowImage("Debug",TempImage); } }
/** * * Creates the Worm heads up display for monitoring or for saving to disk * You must first pass a pointer to an IplImage that has already been allocated and * has dimensions of Worm->SizeOfImage * * */ int CreateWormHUDS(IplImage* TempImage, WormAnalysisData* Worm, WormAnalysisParam* Params, Frame* IlluminationFrame){ int CircleDiameterSize=10; /** Overly a translucent image of the illumination pattern**/ double weighting=0.20; //Alpha blend weighting if (Params->DLPOn) weighting=0.45; // if DLP is on make the illumination pattern more opaque cvAddWeighted(Worm->ImgOrig,1,IlluminationFrame->iplimg,weighting,0,TempImage); //Want to also display boundary! //cvDrawContours(TempImage, Worm->Boundary, cvScalar(255,0,0),cvScalar(0,255,0),100); DrawSequence(&TempImage,Worm->Boundary); // DrawSequence(&TempImage,Worm->Segmented->LeftBound); // DrawSequence(&TempImage,Worm->Segmented->RightBound); cvCircle(TempImage,*(Worm->Tail),CircleDiameterSize,cvScalar(255,255,255),1,CV_AA,0); cvCircle(TempImage,*(Worm->Head),CircleDiameterSize/2,cvScalar(255,255,255),1,CV_AA,0); /** Prepare Text **/ CvFont font; cvInitFont(&font,CV_FONT_HERSHEY_TRIPLEX ,1.0,1.0,0,2,CV_AA); /** Display DLP On Off **/ if (Params->DLPOn) { cvPutText(TempImage,"DLP ON",cvPoint(20,70),&font,cvScalar(255,255,255)); } /** Display Recording if we are recording **/ if (Params->Record){ cvPutText(TempImage,"Recording",cvPoint(20,100),&font,cvScalar(255,255,255)); } else { if (Params->DLPOn) cvPutText(TempImage,"Did you forget to record?",cvPoint(20,100),&font,cvScalar(255,255,255)); } /*** Let the user know if the illumination flood light is on ***/ if (Params->IllumFloodEverything){ cvPutText(TempImage,"Floodlight",cvPoint(20,130),&font,cvScalar(255,255,255)); } char protoNum[20]; /** If we are using protocols, display the protocol number **/ if (Params->ProtocolUse){ sprintf(protoNum,"Step %d",Params->ProtocolStep); cvPutText(TempImage,protoNum,cvPoint(20,160),&font,cvScalar(255,255,255)); } char frame[30]; // these are freed automatically // SEE http://stackoverflow.com/questions/1335230/is-the-memory-of-a-character-array-freed-by-going-out-of-scope sprintf(frame,"%d",Worm->frameNum); cvPutText(TempImage,frame,cvPoint(Worm->SizeOfImage.width- 200,Worm->SizeOfImage.height - 10),&font,cvScalar(255,255,255) ); return 0; }
static void DrawTimeLabel(struct Control* control) { struct TimeLabel* label = (struct TimeLabel*) control->ControlData; DrawSequence(control->posx, control->posy, label->ClearLength, ' ', control->forcolor, control->backcolor); DrawText(control->posx, control->posy, label->strings[label->current], control->forcolor, control->backcolor); }
static void DrawEntry(int x, int y, char drive, int len, int forcolor, int backcolor, int BarColor) { char* buf = "[-?-]"; buf[2] = drive; DrawSequence(x, y, len, ' ', backcolor, BarColor); DrawText(x + (len / 2) - 3, y, buf, forcolor, backcolor); }
void DrawHelpLine(int line, int x, int y, int xlen) { DrawSequence(x, y, xlen, ' ', DIALOGFORCOLOR, DIALOGBACKCOLOR); if (FileReadSuccess == HELPMEMINSUFFICIENT) { if (line == 0) DrawText(x, y, "Not enough memory to load memory page", DIALOGFORCOLOR, DIALOGBACKCOLOR); } else if (FileReadSuccess == HELPREADERROR) { if (line == 0) DrawText(x, y, "Cannot read help page", DIALOGFORCOLOR, DIALOGBACKCOLOR); } else { if (line < GetHelpLineCount()) DrawHelpLineParts(line, x, y, xlen); } }
static void DrawHelpLineParts(int line, int x, int y, int xlen) { int linkcntr = 0; char* linetxt = GetHelpLine(line); while (*linetxt) { if (IsHlpReference(linetxt)) { char *start, *end, sentinel; GetHlpLinkCaption(linetxt, &start, &end); sentinel = *end; *end = 0; linkcntr++; if ((line == CurrentLink.line) && (CurrentLink.nr == linkcntr)) DrawText(x, y, start, HILINKFORCOLOR, HILINKBACKCOLOR); else DrawText(x, y, start, LOLINKFORCOLOR, LOLINKBACKCOLOR); x += strlen(start); *end = sentinel; linetxt = PassHlpReferencePart(linetxt); } else if (IsFullLine(linetxt)) { DrawSequence(x, y, xlen-1, 'Ä', DIALOGFORCOLOR, DIALOGBACKCOLOR); linetxt = PassHlpFullLinePart(linetxt); } else if (IsHlpAsciiChar(linetxt)) { DrawSequence(x, y, 1, GetHlpAsciiChar(linetxt), DIALOGFORCOLOR, DIALOGBACKCOLOR); linetxt = PassHlpAsciiChar(linetxt); x++; } else if (IsCenterOnLine(linetxt)) { int centerx; char *begin, *end, sentinel; GetHlpTextToCenter(linetxt, &begin, &end); centerx = x + ((xlen / 2) - ((int)(end - begin) / 2)); sentinel = *end; *end = 0; if (centerx > x) DrawText(centerx, y, begin, DIALOGFORCOLOR, DIALOGBACKCOLOR); else DrawText(x, y, begin, DIALOGFORCOLOR, DIALOGBACKCOLOR); *end = sentinel; linetxt = PassCenterOnLinePart(linetxt); } else { char* next = PassNextHelpPart(linetxt); char sentinel = *next; *next = 0; DrawText(x, y, linetxt, DIALOGFORCOLOR, DIALOGBACKCOLOR); x += strlen(linetxt); *next = sentinel; linetxt = next; } } }
void Plotter::Render() { if( track_front ) { const float d = int_x[1] - log->x; int_x[0] -= d; int_x[1] -= d; } ActivateScissorAndClear(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(int_x[0], int_x[1], int_y[0], int_y[1]); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glPushAttrib(GL_ENABLE_BIT); glEnable(GL_LINE_SMOOTH); glDisable(GL_LIGHTING); DrawTicks(); if( log && log->sequences.size() > 0 ) { if( plot_mode==XY ) { for( unsigned int s=0; s < log->sequences.size() / 2; ++s ) { if( (s > 9) || show[s] ) { glColor3fv(plot_colours[s%num_plot_colours]); DrawSequence(log->sequences[2*s],log->sequences[2*s+1]); } } } else if( plot_mode==TIME_SERIES) { for( unsigned int s=0; s < log->sequences.size(); ++s ) { if( (s > 9) || show[s] ) { glColor3fv(plot_colours[s%num_plot_colours]); DrawSequence(log->sequences[s]); } } } else if( plot_mode==STACKED_HISTOGRAM ) { DrawSequenceHistogram(log->sequences); } else { assert(false); } } if( mouse_state & MouseButtonLeft ) { if( plot_mode==XY ) { glColor3fv(colour_ms); glBegin(GL_LINE_STRIP); glVertex2f(mouse_xy[0],int_y[0]); glVertex2f(mouse_xy[0],int_y[1]); glEnd(); glBegin(GL_LINE_STRIP); glVertex2f(int_x[0],mouse_xy[1]); glVertex2f(int_x[1],mouse_xy[1]); glEnd(); stringstream ss; ss << "(" << mouse_xy[0] << "," << mouse_xy[1] << ")"; glColor3f(1.0,1.0,1.0); OpenGlRenderState::ApplyWindowCoords(); glRasterPos2f( v.l+5,v.b+5 ); glutBitmapString(font,(unsigned char*)ss.str().c_str()); }else{ int xu = (int)mouse_xy[0]; glColor3fv(colour_ms); glBegin(GL_LINE_STRIP); glVertex2f(xu,int_y[0]); glVertex2f(xu,int_y[1]); glEnd(); stringstream ss; glColor3f(1.0,1.0,1.0); ss << "x=" << xu << " "; OpenGlRenderState::ApplyWindowCoords(); int tx = v.l+5; glRasterPos2f( tx,v.b+5 ); glutBitmapString(font,(unsigned char*)ss.str().c_str()); tx += glutBitmapLength(font,(unsigned char*)ss.str().c_str()); for( unsigned int s=0; s<log->sequences.size(); ++s ) { if( (s > show_n || show[s]) && log->sequences[s].HasData(xu) ) { stringstream ss; ss << " " << log->sequences[s][xu]; glColor3fv(plot_colours[s%num_plot_colours]); glRasterPos2f( tx,v.b+5 ); glutBitmapString(font,(unsigned char*)ss.str().c_str()); tx += glutBitmapLength(font,(unsigned char*)ss.str().c_str()); } } } } float ty = v.h-15; for (size_t i=0; i<log->labels.size(); ++i) { glColor3fv(plot_colours[i%num_plot_colours]); OpenGlRenderState::ApplyWindowCoords(); glRasterPos2f( v.l+5,ty); glutBitmapString(font,(unsigned char*)log->labels[i].c_str()); ty -= 15; } glPopAttrib(); }
int jubeat_online::ImageSequence::DrawSequence(const float x, const float y, sf::RenderTexture * screen_buffer) { x_ = x; y_ = y; return DrawSequence(screen_buffer); }
int jubeat_online::ImageSequence::DrawSequence(const float x, const float y, const float ex, sf::RenderTexture * screen_buffer) { exrate_ = ex; return DrawSequence(x,y,screen_buffer); }