/* Given a page, calc it's tab width follow current DC */ static int tab_required_width (HDC hdc, PPROPSHEETDATA propsheet, PPROPPAGE page) { int width = 0; int iconW, iconH; SIZE ext; if (page->title) { GetTextExtent (hdc, page->title, -1, &ext); width = ext.cx + 18; } if (page->icon) { GetIconSize(page->icon, &iconW, &iconH); width += (iconW + 2*_ICON_OFFSET); } if (width < _MIN_TAB_WIDTH) { width = _MIN_TAB_WIDTH; } if (width >= propsheet->head_rc.right - get_metrics (MWM_SB_WIDTH) *2) { width = propsheet->head_rc.right - get_metrics (MWM_SB_WIDTH) *2; } return width; }
/* * draw_scroll_button: * * This function draw scroll button of propsheet control . * * Author: Peng LIU * Date: 2007-12-05 */ static void draw_scroll_button (HWND hWnd, HDC hdc, RECT *title_rc, PPROPSHEETDATA propsheet, DWORD style) { RECT btn_rect = {0, 0, 0, 0}; WINDOWINFO *info; DWORD color; info = (WINDOWINFO*)GetWindowInfo (hWnd); color = GetWindowElementAttr (hWnd, WE_FGC_WINDOW); /* draw left arrow */ btn_rect.top = ((style & 0xf0L) == PSS_BOTTOM) ? title_rc->top + 1 + 2 : title_rc->top + 1; btn_rect.right = get_metrics (MWM_SB_WIDTH); btn_rect.bottom = ((style & 0xf0L) == PSS_BOTTOM) ? title_rc->bottom + 2 - 2 : title_rc->bottom - 2 - 1; //SelectClipRect (hdc, &btn_rect); info->we_rdr->draw_arrow (hWnd, hdc, &btn_rect, color , LFRDR_ARROW_LEFT); /* draw right arrow */ btn_rect.left = propsheet->head_rc.right - get_metrics(MWM_SB_WIDTH); btn_rect.right = propsheet->head_rc.right; //SelectClipRect (hdc, &btn_rect); info->we_rdr->draw_arrow (hWnd, hdc, &btn_rect, color , LFRDR_ARROW_RIGHT); }
void registry::clear_all_metrics() { for(metric_map_iterator_t it = get_metrics().begin(); it != get_metrics().end(); it++) { it->second->clear(); } }
void camera_control_read_calibration(CameraControl* cc, char* intrinsicsFile, char* distortionFile) { CvMat *intrinsic = (CvMat*) cvLoad(intrinsicsFile, 0, 0, 0); CvMat *distortion = (CvMat*) cvLoad(distortionFile, 0, 0, 0); if (cc->mapx) { cvReleaseImage(&cc->mapx); } if (cc->mapy) { cvReleaseImage(&cc->mapy); } if (intrinsic && distortion) { if (!cc->frame3chUndistort) { cc->frame3chUndistort = cvCloneImage( camera_control_query_frame(cc)); } int width, height; get_metrics(&width, &height); cc->mapx = cvCreateImage(cvSize(width, height), IPL_DEPTH_32F, 1); cc->mapy = cvCreateImage(cvSize(width, height), IPL_DEPTH_32F, 1); cvInitUndistortMap(intrinsic, distortion, cc->mapx, cc->mapy); // TODO: Shouldn't we free intrinsic and distortion here? } else { fprintf(stderr, "Warning: No lens calibration files found.\n"); } }
void camera_control_read_calibration(CameraControl* cc, char* intrinsicsFile, char* distortionFile) { CvMat *intrinsic = (CvMat*) cvLoad(intrinsicsFile, 0, 0, 0); CvMat *distortion = (CvMat*) cvLoad(distortionFile, 0, 0, 0); if (cc->mapx) { cvReleaseImage(&cc->mapx); } if (cc->mapy) { cvReleaseImage(&cc->mapy); } if (intrinsic && distortion) { if (!cc->frame3chUndistort) { enum PSMove_Bool new_frame; cc->frame3chUndistort = cvCloneImage( camera_control_query_frame(cc, NULL, NULL, &new_frame)); } int width, height; get_metrics(&width, &height); cc->mapx = cvCreateImage(cvSize(width, height), IPL_DEPTH_32F, 1); cc->mapy = cvCreateImage(cvSize(width, height), IPL_DEPTH_32F, 1); cvInitUndistortMap(intrinsic, distortion, cc->mapx, cc->mapy); cc->focl_x = CV_MAT_ELEM(*intrinsic, float, 0, 0); cc->focl_y = CV_MAT_ELEM(*intrinsic, float, 1, 1); // TODO: Shouldn't we free intrinsic and distortion here? } else {
int main() { char buf[BUFSIZE], c; int i; int t0, t1, t2; /* plain text metrics */ int s0, s1, s2; /* cypher text metrics */ scanf("%s", buf); get_metrics(buf, &s0, &s1, &s2); scanf("%s", buf); get_metrics(buf, &t0, &t1, &t2); if (s0 == t0 && s1 == t1 && s2 == t2) puts("YES"); else puts("NO"); return 0; }
//! get parameter var* sci_bert::get(int param) { var* p_var_ivec = new var_ivec; // create var_ivec; ivec &iv = (dynamic_cast<var_ivec *>(p_var_ivec))->v; // alias to vector var* p_var_bvec = new var_bvec; // create var_vec; bvec &bv = (dynamic_cast<var_bvec *>(p_var_bvec))->v; // alias to bvect switch (param) { case SCI_SIZE: case SCI_LENGTH: iv.set_length(1); iv[0] = get_length(); return(p_var_ivec); case SCI_STATE: bv = get_state(); return(p_var_bvec); case SCI_SYMBOL_SIZE: iv.set_length(1); iv[0] = get_symbol_size(); return(p_var_ivec); case SCI_THRESHOLD: iv = get_threshold(); return(p_var_ivec); case SCI_BER_CNT: iv = get_ber_cnt(); return(p_var_ivec); case SCI_BIT_CNT: iv = get_bit_cnt(); return(p_var_ivec); case SCI_METRICS: iv.set_length(1); iv[0] = get_metrics(); return(p_var_ivec); case SCI_FSM: iv.set_length(1); iv[0] = get_fsm(); return(p_var_ivec); case SCI_OUTPUT: iv.set_length(1); iv[0] = get_output(); return(p_var_ivec); default: throw sci_exception ("sci_bert::get - unknown param", param); } };
static int test_clicked_scroll_button (int x, int y, int btn_top, int btn_bottom, PPROPSHEETDATA propsheet) { RECT btn_rect = {0, 0, 0, 0}; btn_rect.right = get_metrics(MWM_SB_WIDTH); btn_rect.top = btn_top; btn_rect.bottom = btn_bottom; if (PtInRect (&btn_rect, x, y)) { return LEFT_SCROLL_BTN_CLICKED; } else { btn_rect.left = propsheet->head_rc.right - get_metrics(MWM_SB_WIDTH); btn_rect.right = propsheet->head_rc.right; if (PtInRect (&btn_rect, x, y)) { return RIGHT_SCROLL_BTN_CLICKED; } else { return NO_SCROLL_BTN_CLICKED; } } }
CameraControl * camera_control_new(int cameraID) { CameraControl* cc = (CameraControl*) calloc(1, sizeof(CameraControl)); cc->cameraID = cameraID; #if defined(CAMERA_CONTROL_USE_CL_DRIVER) int w, h; int cams = CLEyeGetCameraCount(); if (cams <= cameraID) { free(cc); return NULL; } GUID cguid = CLEyeGetCameraUUID(cameraID); cc->camera = CLEyeCreateCamera(cguid, CLEYE_COLOR_PROCESSED, CLEYE_VGA, 60); CLEyeCameraGetFrameDimensions(cc->camera, &w, &h); // Depending on color mode chosen, create the appropriate OpenCV image cc->frame4ch = cvCreateImage(cvSize(w, h), IPL_DEPTH_8U, 4); cc->frame3ch = cvCreateImage(cvSize(w, h), IPL_DEPTH_8U, 3); CLEyeCameraStart(cc->camera); #else char *video = psmove_util_get_env_string(PSMOVE_TRACKER_FILENAME_ENV); if (video) { psmove_DEBUG("Using '%s' as video input.\n", video); cc->capture = cvCaptureFromFile(video); free(video); } else { cc->capture = cvCaptureFromCAM(cc->cameraID); int width, height; get_metrics(&width, &height); cvSetCaptureProperty(cc->capture, CV_CAP_PROP_FRAME_WIDTH, width); cvSetCaptureProperty(cc->capture, CV_CAP_PROP_FRAME_HEIGHT, height); } #endif return cc; }
size_t Font::clip_from_left(Canvas &canvas, const std::string &text, float width) { float x = 0.0f; UTF8_Reader reader(text.data(), text.length()); while (!reader.is_end()) { unsigned int glyph = reader.get_char(); GlyphMetrics char_abc = get_metrics(canvas, glyph); if (x + char_abc.advance.width > width) return reader.get_position(); x += char_abc.advance.width; reader.next(); } return text.size(); }
int cluster() { FILE* fmetric = fopen("metrics","w+"); fprintf(fmetric,"@relation topology\n"); int i=0; for(i=0; i<ip_count; i++) { fprintf(fmetric, "@attribute router%d {0,1}\n", i); } fprintf(fmetric, "@data\n"); struct dirent *pDirEntry = NULL; DIR *pDir = NULL; if( (pDir = opendir("./")) == NULL ) { printf("opendir failed!\n"); return 1; } else { while( pDirEntry = readdir(pDir) ) { if ( strstr(pDirEntry->d_name, "out") && pDirEntry->d_name[0]=='o' && pDirEntry->d_name[1]=='u' && pDirEntry->d_name[2]=='t') { get_metrics(pDirEntry->d_name , fmetric); } } closedir(pDir); } fclose(fmetric); return 0; }
size_t Font::clip_from_right(Canvas &canvas, const std::string &text, float width) { float x = 0.0f; UTF8_Reader reader(text.data(), text.length()); reader.set_position(text.length()); while (reader.get_position() != 0) { reader.prev(); unsigned int glyph = reader.get_char(); GlyphMetrics char_abc = get_metrics(canvas, glyph); if (x + char_abc.advance.width > width) { reader.next(); return reader.get_position(); } x += char_abc.advance.width; } return 0; }
/* recalculate widths of the tabs after a page added or removed. */ static void recalc_tab_widths (HWND hwnd, PPROPSHEETDATA propsheet, DWORD dwStyle) { PPROPPAGE page; if (propsheet->page_count == 0) return; if (dwStyle & PSS_COMPACTTAB) { HDC hdc; SIZE ext; int total_width = 0; hdc = GetClientDC (hwnd); page = propsheet->head; while (page) { page->width = 0; if (page->title) { GetTextExtent (hdc, page->title, -1, &ext); page->width = ext.cx + TAB_MARGIN; } if (page->icon) { page->width += get_metrics (MWM_ICONX); } if (page->width < _MIN_TAB_WIDTH) { page->width = _MIN_TAB_WIDTH; } total_width += page->width; /*added by lfzhang*/ if (total_width > propsheet->head_rc.right){ total_width -= page->width; page->width = propsheet->head_rc.right - total_width; total_width += page->width; break; } page = page->next; } ReleaseDC (hdc); /* old_code if (total_width > propsheet->head_rc.right) { int new_width = 0, step = 0; page = propsheet->head; step = (total_width - propsheet->head_rc.right)/propsheet->page_count; if (step == 0) step = 1; while (page) { page->width -= step; if (page->width < _MIN_TAB_WIDTH) { page->width = _MIN_TAB_WIDTH; } if (!(page->next) && (new_width + page->width > propsheet->head_rc.right)) { page->width = propsheet->head_rc.right - new_width; } else new_width += page->width; page = page->next; } total_width = new_width; }*/ propsheet->head_width = total_width; } else { int width; //width = propsheet->head_rc.right * 8 / (propsheet->page_count * 10); width = propsheet->head_rc.right / propsheet->page_count; //if (width < _MIN_TAB_WIDTH) //width = propsheet->head_rc.right / propsheet->page_count; page = propsheet->head; while (page) { page->width = width; page = page->next; } //propsheet->head_width = width * propsheet->page_count; propsheet->head_width = propsheet->head_rc.right; } }
static void click_tab_bar (HWND hwnd, PCONTROL ctrl, PPROPSHEETDATA propsheet, LPARAM lParam) { int x = LOSWORD(lParam), y = HISWORD(lParam); PPROPPAGE page; RECT title_rc = {0, 0, 0, 0}; int scrollbtn_left = 0; int scroll_clicked; title_rc.bottom = propsheet->head_rc.bottom; title_rc.top = propsheet->head_rc.top; if ((ctrl->dwStyle & 0x0fL)!= PSS_SCROLLABLE) { page = propsheet->head; while (page) { title_rc.left = title_rc.right; title_rc.right = title_rc.left + page->width; if (PtInRect (&title_rc, x, y) && page != propsheet->active) { show_hide_page (propsheet->active, SW_HIDE); propsheet->active = page; NotifyParent (hwnd, ctrl->id, PSN_ACTIVE_CHANGED); show_hide_page (page, SW_SHOW); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return; } page = page->next; } } else { /* Normal style !!! */ page = propsheet->first_display_page; title_rc.right = (propsheet->overload == TRUE) ? title_rc.right + get_metrics(MWM_SB_WIDTH) : title_rc.right; /* check if left-right-scroll-bar clicked if they are clicked, just change the active title */ if (propsheet->overload == TRUE) { scrollbtn_left = propsheet->head_rc.right - get_metrics (MWM_SB_WIDTH); scroll_clicked = test_clicked_scroll_button (x, y, title_rc.top, title_rc.bottom, propsheet); if (scroll_clicked == LEFT_SCROLL_BTN_CLICKED) { scroll_tab_left (hwnd, ctrl, propsheet); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return; } if (scroll_clicked == RIGHT_SCROLL_BTN_CLICKED) { scroll_tab_right (hwnd, ctrl, propsheet); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return; } } while (page) { title_rc.left = title_rc.right; title_rc.right = title_rc.left + page->width; if (propsheet->overload == TRUE) if (title_rc.right > scrollbtn_left) return; if (PtInRect (&title_rc, x, y) && page != propsheet->active) { show_hide_page (propsheet->active, SW_HIDE); propsheet->active = page; NotifyParent (hwnd, ctrl->id, PSN_ACTIVE_CHANGED); show_hide_page (page, SW_SHOW); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return; } page = page->next; } } }
/* * generic function for drawing a legend icon. (added for bug #2348) * renderer specific drawing functions shouldn't be called directly, but through * this function */ int msDrawLegendIcon(mapObj *map, layerObj *lp, classObj *theclass, int width, int height, imageObj *image, int dstX, int dstY, int scale_independant, class_hittest *hittest) { int i, type, hasmarkersymbol, ret=MS_SUCCESS; double offset; double polygon_contraction = 0.5; /* used to account for the width of a polygon's outline */ shapeObj box, zigzag; lineObj box_line,zigzag_line; pointObj box_point[5], zigzag_point[4]; pointObj marker; char szPath[MS_MAXPATHLEN]; styleObj outline_style; imageObj *image_draw = image; int originalopacity = lp->opacity; rendererVTableObj *renderer; outputFormatObj *transFormat = NULL, *altFormat=NULL; const char *alternativeFormatString = NULL; if(!MS_RENDERER_PLUGIN(image->format)) { msSetError(MS_MISCERR,"unsupported image format","msDrawLegendIcon()"); return MS_FAILURE; } alternativeFormatString = msLayerGetProcessingKey(lp, "RENDERER"); if (MS_RENDERER_PLUGIN(image_draw->format) && alternativeFormatString!=NULL && (altFormat= msSelectOutputFormat(map, alternativeFormatString))) { msInitializeRendererVTable(altFormat); image_draw = msImageCreate(image->width, image->height, altFormat, image->imagepath, image->imageurl, map->resolution, map->defresolution, &map->imagecolor); renderer = MS_IMAGE_RENDERER(image_draw); } else { renderer = MS_IMAGE_RENDERER(image_draw); if (lp->opacity > 0 && lp->opacity < 100) { if (!renderer->supports_transparent_layers) { image_draw = msImageCreate(image->width, image->height, image->format, image->imagepath, image->imageurl, map->resolution, map->defresolution, NULL); if (!image_draw) { msSetError(MS_MISCERR, "Unable to initialize temporary transparent image.", "msDrawLegendIcon()"); return (MS_FAILURE); } /* set opacity to full, as the renderer should be rendering a fully opaque image */ lp->opacity=100; } } } if(renderer->supports_clipping && MS_VALID_COLOR(map->legend.outlinecolor)) { /* keep GD specific code here for now as it supports clipping */ rectObj clip; clip.maxx = dstX + width - 1; clip.maxy = dstY + height -1; clip.minx = dstX; clip.miny = dstY; renderer->setClip(image_draw,clip); } /* if the class has a keyimage, treat it as a point layer * (the keyimage will be treated there) */ if(theclass->keyimage != NULL) { type = MS_LAYER_POINT; } else { /* some polygon layers may be better drawn using zigzag if there is no fill */ type = lp->type; if(type == MS_LAYER_POLYGON) { type = MS_LAYER_LINE; for(i=0; i<theclass->numstyles; i++) { if(MS_VALID_COLOR(theclass->styles[i]->color)) { /* there is a fill */ type = MS_LAYER_POLYGON; } if(MS_VALID_COLOR(theclass->styles[i]->outlinecolor)) { /* there is an outline */ polygon_contraction = MS_MAX(polygon_contraction, theclass->styles[i]->width / 2.0); } } } } /* initialize the box used for polygons and for outlines */ box.line = &box_line; box.numlines = 1; box.line[0].point = box_point; box.line[0].numpoints = 5; box.line[0].point[0].x = dstX + polygon_contraction; box.line[0].point[0].y = dstY + polygon_contraction; box.line[0].point[1].x = dstX + width - polygon_contraction; box.line[0].point[1].y = dstY + polygon_contraction; box.line[0].point[2].x = dstX + width - polygon_contraction; box.line[0].point[2].y = dstY + height - polygon_contraction; box.line[0].point[3].x = dstX + polygon_contraction; box.line[0].point[3].y = dstY + height - polygon_contraction; box.line[0].point[4].x = box.line[0].point[0].x; box.line[0].point[4].y = box.line[0].point[0].y; /* ** now draw the appropriate color/symbol/size combination */ switch(type) { case MS_LAYER_POINT: marker.x = dstX + MS_NINT(width / 2.0); marker.y = dstY + MS_NINT(height / 2.0); if(theclass->keyimage != NULL) { int symbolNum; styleObj imgStyle; symbolObj *symbol=NULL; for(symbolNum=0; symbolNum<theclass->numstyles; symbolNum++) symbolNum = msAddImageSymbol(&(map->symbolset), msBuildPath(szPath, map->mappath, theclass->keyimage)); if(symbolNum == -1) { msSetError(MS_IMGERR, "Failed to open legend key image", "msCreateLegendIcon()"); return(MS_FAILURE); } symbol = map->symbolset.symbol[symbolNum]; initStyle(&imgStyle); /*set size so that symbol will be scaled properly #3296*/ if (width/symbol->sizex < height/symbol->sizey) imgStyle.size = symbol->sizey*(width/symbol->sizex); else imgStyle.size = symbol->sizey*(height/symbol->sizey); if (imgStyle.size > imgStyle.maxsize) imgStyle.maxsize = imgStyle.size; imgStyle.symbol = symbolNum; ret = msDrawMarkerSymbol(map ,image_draw,&marker,&imgStyle,lp->scalefactor * image_draw->resolutionfactor); if(UNLIKELY(ret == MS_FAILURE)) goto legend_icon_cleanup; /* TO DO: we may want to handle this differently depending on the relative size of the keyimage */ } else { for(i=0; i<theclass->numstyles; i++) { if(!scale_independant && map->scaledenom > 0) { styleObj *lp = theclass->styles[i]; if((lp->maxscaledenom > 0) && (map->scaledenom > lp->maxscaledenom)) continue; if((lp->minscaledenom > 0) && (map->scaledenom <= lp->minscaledenom)) continue; } if(hittest && hittest->stylehits[i].status == 0) continue; ret = msDrawMarkerSymbol(map, image_draw, &marker, theclass->styles[i], lp->scalefactor * image->resolutionfactor); if(UNLIKELY(ret == MS_FAILURE)) goto legend_icon_cleanup; } } break; case MS_LAYER_LINE: offset = 1; /* To set the offset, we only check the size/width parameter of the first style */ if (theclass->numstyles > 0) { if (theclass->styles[0]->symbol > 0 && theclass->styles[0]->symbol < map->symbolset.numsymbols && map->symbolset.symbol[theclass->styles[0]->symbol]->type != MS_SYMBOL_SIMPLE) offset = theclass->styles[0]->size/2; else offset = theclass->styles[0]->width/2; } zigzag.line = &zigzag_line; zigzag.numlines = 1; zigzag.line[0].point = zigzag_point; zigzag.line[0].numpoints = 4; zigzag.line[0].point[0].x = dstX + offset; zigzag.line[0].point[0].y = dstY + height - offset; zigzag.line[0].point[1].x = dstX + MS_NINT(width / 3.0) - 1; zigzag.line[0].point[1].y = dstY + offset; zigzag.line[0].point[2].x = dstX + MS_NINT(2.0 * width / 3.0) - 1; zigzag.line[0].point[2].y = dstY + height - offset; zigzag.line[0].point[3].x = dstX + width - offset; zigzag.line[0].point[3].y = dstY + offset; for(i=0; i<theclass->numstyles; i++) { if(!scale_independant && map->scaledenom > 0) { styleObj *lp = theclass->styles[i]; if((lp->maxscaledenom > 0) && (map->scaledenom > lp->maxscaledenom)) continue; if((lp->minscaledenom > 0) && (map->scaledenom <= lp->minscaledenom)) continue; } if(hittest && hittest->stylehits[i].status == 0) continue; if (theclass->styles[i]->_geomtransform.type == MS_GEOMTRANSFORM_NONE || theclass->styles[i]->_geomtransform.type == MS_GEOMTRANSFORM_LABELPOINT || theclass->styles[i]->_geomtransform.type == MS_GEOMTRANSFORM_LABELPOLY) { ret = msDrawLineSymbol(map, image_draw, &zigzag, theclass->styles[i], lp->scalefactor * image_draw->resolutionfactor); if(UNLIKELY(ret == MS_FAILURE)) goto legend_icon_cleanup; } else { ret = msDrawTransformedShape(map, image_draw, &zigzag, theclass->styles[i], lp->scalefactor * image_draw->resolutionfactor); if(UNLIKELY(ret == MS_FAILURE)) goto legend_icon_cleanup; } } break; case MS_LAYER_CIRCLE: case MS_LAYER_RASTER: case MS_LAYER_CHART: case MS_LAYER_POLYGON: for(i=0; i<theclass->numstyles; i++) { if(!scale_independant && map->scaledenom > 0) { styleObj *lp = theclass->styles[i]; if((lp->maxscaledenom > 0) && (map->scaledenom > lp->maxscaledenom)) continue; if((lp->minscaledenom > 0) && (map->scaledenom <= lp->minscaledenom)) continue; } if(hittest && hittest->stylehits[i].status == 0) continue; if (theclass->styles[i]->_geomtransform.type == MS_GEOMTRANSFORM_NONE || theclass->styles[i]->_geomtransform.type == MS_GEOMTRANSFORM_LABELPOINT || theclass->styles[i]->_geomtransform.type == MS_GEOMTRANSFORM_LABELPOLY) { ret = msDrawShadeSymbol(map, image_draw, &box, theclass->styles[i], lp->scalefactor * image_draw->resolutionfactor); if(UNLIKELY(ret == MS_FAILURE)) goto legend_icon_cleanup; } else { ret = msDrawTransformedShape(map, image_draw, &box, theclass->styles[i], lp->scalefactor); if(UNLIKELY(ret == MS_FAILURE)) goto legend_icon_cleanup; } } break; default: return MS_FAILURE; break; } /* end symbol drawing */ /* handle label styles */ for(i=0; i<theclass->numlabels; i++) { labelObj *l = theclass->labels[i]; if(!scale_independant && map->scaledenom > 0) { if(msScaleInBounds(map->scaledenom, l->minscaledenom, l->maxscaledenom)) { int j; for(j=0; j<l->numstyles; j++) { styleObj *s = l->styles[j]; marker.x = dstX + MS_NINT(width / 2.0); marker.y = dstY + MS_NINT(height / 2.0); if(s->_geomtransform.type == MS_GEOMTRANSFORM_LABELPOINT) { ret = msDrawMarkerSymbol(map, image_draw, &marker, s, lp->scalefactor); if(UNLIKELY(ret == MS_FAILURE)) goto legend_icon_cleanup; } } } } } /* handle "pure" text layers, i.e. layers with no symbology */ hasmarkersymbol = 0; if(theclass->numstyles == 0) { for(i=0; i<theclass->numlabels; i++) { labelObj *l = theclass->labels[i]; if(!scale_independant && map->scaledenom > 0) { if(msScaleInBounds(map->scaledenom, l->minscaledenom, l->maxscaledenom)) { int j; for(j=0; j<l->numstyles; j++) { styleObj *s = l->styles[j]; if(s->_geomtransform.type == MS_GEOMTRANSFORM_LABELPOINT) { hasmarkersymbol = 1; } } } } } } else { hasmarkersymbol = 1; } if(!hasmarkersymbol && theclass->numlabels>0) { textSymbolObj ts; pointObj textstartpt; marker.x = dstX + MS_NINT(width / 2.0); marker.y = dstY + MS_NINT(height / 2.0); initTextSymbol(&ts); msPopulateTextSymbolForLabelAndString(&ts,theclass->labels[0],msStrdup("Az"),lp->scalefactor*image_draw->resolutionfactor,image_draw->resolutionfactor, duplicate_always); ts.label->size = height - 1; ret = msComputeTextPath(map,&ts); if(UNLIKELY(ret == MS_FAILURE)) goto legend_icon_cleanup; textstartpt = get_metrics(&marker,MS_CC,ts.textpath,0,0,0,0,NULL); ret = msDrawTextSymbol(map,image_draw, textstartpt, &ts); freeTextSymbol(&ts); if(UNLIKELY(ret == MS_FAILURE)) goto legend_icon_cleanup; } /* handle an outline if necessary */ if(MS_VALID_COLOR(map->legend.outlinecolor)) { initStyle(&outline_style); outline_style.color = map->legend.outlinecolor; ret = msDrawLineSymbol(map, image_draw, &box, &outline_style, image_draw->resolutionfactor); if(UNLIKELY(ret == MS_FAILURE)) goto legend_icon_cleanup; /* reset clipping rectangle */ if(renderer->supports_clipping) renderer->resetClip(image_draw); } if (altFormat) { rendererVTableObj *renderer = MS_IMAGE_RENDERER(image); rendererVTableObj *altrenderer = MS_IMAGE_RENDERER(image_draw); rasterBufferObj rb; memset(&rb,0,sizeof(rasterBufferObj)); ret = altrenderer->getRasterBufferHandle(image_draw,&rb); if(UNLIKELY(ret == MS_FAILURE)) goto legend_icon_cleanup; ret = renderer->mergeRasterBuffer(image,&rb,lp->opacity*0.01,0,0,0,0,rb.width,rb.height); if(UNLIKELY(ret == MS_FAILURE)) goto legend_icon_cleanup; /* * hack to work around bug #3834: if we have use an alternate renderer, the symbolset may contain * symbols that reference it. We want to remove those references before the altFormat is destroyed * to avoid a segfault and/or a leak, and so the the main renderer doesn't pick the cache up thinking * it's for him. */ for(i=0; i<map->symbolset.numsymbols; i++) { if (map->symbolset.symbol[i]!=NULL) { symbolObj *s = map->symbolset.symbol[i]; if(s->renderer == altrenderer) { altrenderer->freeSymbol(s); s->renderer = NULL; } } } } else if(image != image_draw) { rendererVTableObj *renderer = MS_IMAGE_RENDERER(image_draw); rasterBufferObj rb; memset(&rb,0,sizeof(rasterBufferObj)); lp->opacity = originalopacity; ret = renderer->getRasterBufferHandle(image_draw,&rb); if(UNLIKELY(ret == MS_FAILURE)) goto legend_icon_cleanup; ret = renderer->mergeRasterBuffer(image,&rb,lp->opacity*0.01,0,0,0,0,rb.width,rb.height); if(UNLIKELY(ret == MS_FAILURE)) goto legend_icon_cleanup; /* deref and possibly free temporary transparent output format. */ msApplyOutputFormat( &transFormat, NULL, MS_NOOVERRIDE, MS_NOOVERRIDE, MS_NOOVERRIDE ); } legend_icon_cleanup: if(image != image_draw) { msFreeImage(image_draw); } return ret; }
/* notice!!! This is the core function of propsheet normal style !! and it is run very slow, because propsheet is designed by single-link-list */ static void update_propsheet (PPROPSHEETDATA propsheet) { PPROPPAGE temp, page; int tab_width = 0; if (propsheet->first_display_page == NULL) { propsheet->first_display_page = propsheet->head; } page = propsheet->head; /*test the tabs are overload ?*/ propsheet->overload = FALSE; while (page) { tab_width += page->width; if (tab_width > (propsheet->head_rc.right - get_metrics (MWM_SB_WIDTH) * 2)) { propsheet->overload = TRUE; propsheet->head_width = propsheet->head_rc.right - get_metrics (MWM_SB_WIDTH) * 2; break; } page = page->next; } if (propsheet->overload == FALSE) { propsheet->first_display_page = propsheet->head; } /* test if active is right of first_display_page */ if (! propsheet->active) return; page = propsheet->active->next; while (page) { if (page == propsheet->first_display_page) { propsheet->first_display_page = propsheet->active; break; } page = page->next; } /* calc the first-display-page */ page = propsheet->first_display_page; while (page) { temp = page; tab_width = 0; while (temp) { tab_width += temp->width; if (temp == propsheet->active) { if (tab_width <= propsheet->head_width) { return; } } temp = temp->next; } propsheet->first_display_page = propsheet->first_display_page->next; page = page->next; } }
/* * draw_propsheet: * * This function draw nonclilent area of propsheet control . * * Author: Peng LIU * Date: 2007-12-03 */ static void draw_propsheet (HWND hwnd, HDC hdc, PCONTROL ctrl, PPROPSHEETDATA propsheet, PPROPPAGE page) { RECT title_rc = {0, 0, 1, 0}, rc; int flag = 0; DWORD main_c, old_brush_c; int scrollbtn_left = 0; title_rc.bottom = propsheet->head_rc.bottom; if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) { title_rc.top = propsheet->head_rc.top; } main_c = GetWindowElementAttr (hwnd, WE_MAINC_THREED_BODY); /* Draw the content window border*/ if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) { SetRect(&rc, 0, 0, propsheet->head_rc.right, ctrl->bottom - ctrl->top - RECTH(propsheet->head_rc) + 1); /* rc.left = 0; rc.right = propsheet->head_rc.right; rc.top = 0; rc.bottom = rc.top + ctrl->bottom - ctrl->top - RECTH(propsheet->head_rc) + 1; */ } else { SetRect(&rc, 0, propsheet->head_rc.bottom - 1, propsheet->head_rc.right, propsheet->head_rc.bottom + ctrl->bottom - ctrl->top - RECTH(propsheet->head_rc)); /* rc.left = 0; rc.top = propsheet->head_rc.bottom - 1; rc.right = propsheet->head_rc.right; rc.bottom = rc.top + ctrl->bottom - ctrl->top - RECTH(propsheet->head_rc) + 1; */ } ((WINDOWINFO*)GetWindowInfo (hwnd))->we_rdr->draw_3dbox(hdc, &rc, main_c, LFRDR_BTN_STATUS_NORMAL); /* Just for PSS_SCROLLABLE style if title is overload (too many titles for the propsheet) we should move-right the leftmot title some pixel and we should draw a small icon (left arrow) for the sheet */ if ((ctrl->dwStyle & 0x0fL) == PSS_SCROLLABLE) { title_rc.right = (propsheet->overload == TRUE) ? title_rc.right + get_metrics (MWM_SB_WIDTH) : title_rc.right; if (propsheet->overload == TRUE) scrollbtn_left = propsheet->head_rc.right - get_metrics (MWM_SB_WIDTH); } old_brush_c = SetBrushColor (hdc, DWORD2PIXEL (hdc, main_c)); while (page) { if (((ctrl->dwStyle & 0x0fL) == PSS_SCROLLABLE) && propsheet->overload == TRUE) if (((title_rc.right + page->width > scrollbtn_left) || (page->width == 0)) && !(propsheet->first_display_page == page)) break; if ((ctrl->dwStyle & 0x0fL) == PSS_COMPACTTAB) { if (((title_rc.right + page->width > propsheet->head_rc.right) || (page->width == 0)) && !(propsheet->first_display_page == page)) break; } /* draw some box for title */ if (title_rc.right == 1) title_rc.left = title_rc.right - 1; else title_rc.left = title_rc.right; title_rc.right = title_rc.left + page->width; flag = 0; if (page == propsheet->active) flag = flag | LFRDR_TAB_ACTIVE; if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) flag = flag | LFRDR_TAB_BOTTOM; if (page->icon) { flag = flag | LFRDR_TAB_ICON; ((WINDOWINFO*)GetWindowInfo (hwnd))->we_rdr->draw_tab (hwnd, hdc, &title_rc, page->title,main_c, flag, page->icon); } else ((WINDOWINFO*)GetWindowInfo (hwnd))->we_rdr->draw_tab (hwnd, hdc, &title_rc, page->title, main_c, flag, 0); page = page->next; } /* draw scroll button , just for PSS_SCROLLABLE style */ if ((ctrl->dwStyle & 0x0fL) == PSS_SCROLLABLE && propsheet->overload == TRUE) draw_scroll_button (hwnd, hdc, &title_rc, propsheet, ctrl->dwStyle); SetBrushColor (hdc, DWORD2PIXEL(hdc, old_brush_c)); }
CameraControl * camera_control_new_with_settings(int cameraID, int width, int height, int framerate, int cam_type) { CameraControl* cc = (CameraControl*) calloc(1, sizeof(CameraControl)); cc->cameraID = cameraID; if (framerate <= 0) { framerate = PSMOVE_TRACKER_DEFAULT_FPS; } if (cam_type == PSMove_Camera_PS3EYE_BLUEDOT) { cc->focl_x = (float)PS3EYE_FOCAL_LENGTH_BLUE; cc->focl_y = (float)PS3EYE_FOCAL_LENGTH_BLUE; } else if (cam_type == PSMove_Camera_PS3EYE_REDDOT) { cc->focl_x = (float)PS3EYE_FOCAL_LENGTH_RED; cc->focl_y = (float)PS3EYE_FOCAL_LENGTH_RED; } else if (cam_type == PSMove_Camera_Unknown) { cc->focl_x = (float)PS3EYE_FOCAL_LENGTH_BLUE; cc->focl_y = (float)PS3EYE_FOCAL_LENGTH_BLUE; } // Needed for cbb tracker. Will be overwritten by camera calibration files if they exist. #if defined(CAMERA_CONTROL_USE_CL_DRIVER) // Windows 32-bit. Either CL_SDK or Registry_requiring int cams = CLEyeGetCameraCount(); if (cams <= cameraID) { free(cc); return NULL; } GUID cguid = CLEyeGetCameraUUID(cameraID); cc->camera = CLEyeCreateCamera(cguid, CLEYE_COLOR_PROCESSED, CLEYE_VGA, framerate); CLEyeCameraGetFrameDimensions(cc->camera, &width, &height); // Depending on color mode chosen, create the appropriate OpenCV image cc->frame4ch = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 4); cc->frame3ch = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3); CLEyeCameraStart(cc->camera); #elif defined(CAMERA_CONTROL_USE_PS3EYE_DRIVER) // Mac or Windows // Initialize PS3EYEDriver ps3eye_init(); int cams = ps3eye_count_connected(); psmove_DEBUG("Found %i ps3eye(s) with CAMERA_CONTROL_USE_PS3EYE_DRIVER.\n", cams); if (cams <= cameraID) { free(cc); return NULL; } if (width <= 0 || height <= 0) { get_metrics(&width, &height); } psmove_DEBUG("Attempting to open ps3eye with cameraId, width, height, framerate: %d, %d, %d, %d.\n", cameraID, width, height, framerate); cc->eye = ps3eye_open(cameraID, width, height, framerate); if (cc->eye == NULL) { psmove_WARNING("Failed to open camera ID %d", cameraID); free(cc); return NULL; } cc->framebgr = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3); #else // Assume webcam accessible from OpenCV. char *video = psmove_util_get_env_string(PSMOVE_TRACKER_FILENAME_ENV); if (video) { psmove_DEBUG("Using '%s' as video input.\n", video); cc->capture = cvCaptureFromFile(video); free(video); } else { cc->capture = cvCaptureFromCAM(cc->cameraID); if (width <= 0 || height <= 0) { get_metrics(&width, &height); } cvSetCaptureProperty(cc->capture, CV_CAP_PROP_FRAME_WIDTH, width); cvSetCaptureProperty(cc->capture, CV_CAP_PROP_FRAME_HEIGHT, height); } #endif cc->width = width; cc->height = height; cc->deinterlace = PSMove_False; return cc; }
/* window procedure of the property sheet. */ static int PropSheetCtrlProc (HWND hwnd, int message, WPARAM wParam, LPARAM lParam) { PCONTROL ctrl; PPROPSHEETDATA propsheet; ctrl = gui_Control (hwnd); propsheet = (PROPSHEETDATA *) ctrl->dwAddData2; switch (message) { case MSG_CREATE: { #ifdef __TARGET_MSTUDIO__ SetWindowBkColor(hwnd, GetWindowElementPixel (hwnd, WE_MAINC_THREED_BODY)); #endif if (!(propsheet = calloc (1, sizeof (PROPSHEETDATA)))) { return -1; } ctrl->dwAddData2 = (DWORD)propsheet; break; } /* make the client size same as window size */ case MSG_SIZECHANGED: { const RECT* rcWin = (RECT *)wParam; RECT* rcClient = (RECT *)lParam; /* cale the width of content page */ *rcClient = *rcWin; propsheet->head_rc.right = RECTWP (rcClient); if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) { propsheet->head_rc.top = RECTHP (rcClient) - get_metrics (MWM_ICONY) - 2 - _ICON_OFFSET * 2; propsheet->head_rc.bottom = RECTHP (rcClient); } else { propsheet->head_rc.bottom = get_metrics (MWM_ICONY) + 2 + _ICON_OFFSET * 2; } if ((ctrl->dwStyle & 0x0fL)!= PSS_SCROLLABLE) { recalc_tab_widths (hwnd, propsheet, ctrl->dwStyle); } else { HDC hdc; propsheet->head_width = propsheet->head_rc.right; if (propsheet->head) { PPROPPAGE page; hdc = GetClientDC(hwnd); page = propsheet->head; while(page) { page->width = tab_required_width (hdc, propsheet, page); page = page->next; } ReleaseDC (hdc); update_propsheet (propsheet); } } resize_children (propsheet, rcClient, ctrl->dwStyle); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return 1; } case MSG_DESTROY: { PPROPPAGE page, temp; page = propsheet->head; while (page) { temp = page->next; destroy_page (page); free (page); page = temp; } free (propsheet); break; } case MSG_GETDLGCODE: { return DLGC_WANTTAB | DLGC_WANTARROWS; } case PSM_SHEETCMD: { int index = 0; PPROPPAGE page = propsheet->head; while (page) { if (SendMessage (page->hwnd, MSG_SHEETCMD, wParam, lParam)) /* when encounter an error, return page index plus 1. */ return index + 1; index++; page = page->next; } return 0; /* success */ } case PSM_SETACTIVEINDEX: { PPROPPAGE page; if ((page = get_page (propsheet, wParam)) && page != propsheet->active) { show_hide_page (propsheet->active, SW_HIDE); propsheet->active = page; update_propsheet (propsheet); NotifyParent (hwnd, ctrl->id, PSN_ACTIVE_CHANGED); show_hide_page (page, SW_SHOW); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return PS_OKAY; } return PS_ERR; } case PSM_GETACTIVEINDEX: { int index = 0; PPROPPAGE page = propsheet->head; while (page) { if (page == propsheet->active) { return index; } index ++; page = page->next; } return PS_ERR; } case PSM_GETACTIVEPAGE: { return (propsheet->active) ? propsheet->active->hwnd : HWND_INVALID; } case PSM_GETPAGE: { int index = 0; PPROPPAGE page = propsheet->head; while (page) { if (index == wParam) { return page->hwnd; } index ++; page = page->next; } return HWND_INVALID; } case PSM_GETPAGEINDEX: { int index = 0; PPROPPAGE page = propsheet->head; while (page) { if (page->hwnd == wParam) { return index; } index ++; page = page->next; } return PS_ERR; } case PSM_GETPAGECOUNT: { return propsheet->page_count; } case PSM_GETTITLELENGTH: { int len = PS_ERR; PPROPPAGE page; if ((page = get_page (propsheet, wParam))) { len = strlen (page->title); } return len; } case PSM_GETTITLE: { char* buffer = (char*)lParam; PPROPPAGE page; if ((page = get_page (propsheet, wParam))) { strcpy (buffer, page->title); return PS_OKAY; } return PS_ERR; } case PSM_SETTITLE: { BOOL rc = PS_ERR; char* buffer = (char*)lParam; PPROPPAGE page; HDC hdc; if ((ctrl->dwStyle & 0x0fL) != PSS_SCROLLABLE) { if ((page = get_page (propsheet, wParam))) { rc = set_page_title (page, buffer); recalc_tab_widths (hwnd, propsheet, ctrl->dwStyle); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); } } else { if ((page = get_page (propsheet, wParam))) { hdc = GetClientDC (hwnd); rc = set_page_title_normal_style (hdc, propsheet, page, buffer); ReleaseDC (hdc); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); } } return rc; } case PSM_ADDPAGE: { if ((ctrl->dwStyle & 0x0fL) != PSS_SCROLLABLE) { int index; PPROPPAGE page; if ((propsheet->head_rc.right / (propsheet->page_count + 1)) < _MIN_TAB_WIDTH) { return PS_ERR; } if (!(page = calloc (1, sizeof (PROPPAGE)))) { return PS_ERR; } if (!create_page (hwnd, ctrl->dwStyle, propsheet, page, (DLGTEMPLATE *)wParam, (WNDPROC)lParam)) { free (page); return PS_ERR; } index = append_page (propsheet, page); if (propsheet->active) { show_hide_page (propsheet->active, SW_HIDE); } propsheet->active = page; NotifyParent (hwnd, ctrl->id, PSN_ACTIVE_CHANGED); show_hide_page (page, SW_SHOW); recalc_tab_widths (hwnd, propsheet, ctrl->dwStyle); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return index; } else { return add_new_page_normal_style (hwnd, ctrl, propsheet, (DLGTEMPLATE *)wParam, (WNDPROC)lParam); } } case PSM_REMOVEPAGE: { if ((ctrl->dwStyle & 0x0fL) != PSS_SCROLLABLE) { PPROPPAGE page; if ((page = get_page (propsheet, wParam))) { remove_page (propsheet, page); destroy_page (page); free (page); recalc_tab_widths (hwnd, propsheet, ctrl->dwStyle); } else { return PS_ERR; } if (propsheet->active == page) { propsheet->active = propsheet->head; NotifyParent (hwnd, ctrl->id, PSN_ACTIVE_CHANGED); if (propsheet->active) { show_hide_page (propsheet->active, SW_SHOW); } } InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return PS_OKAY; } else { return delete_page (hwnd, ctrl, propsheet, wParam); } } case MSG_LBUTTONDOWN: { click_tab_bar (hwnd, ctrl, propsheet, lParam); /* dump_propsheetdata (propsheet); */ break; } case MSG_KEYDOWN: { PPROPPAGE page, new_active = NULL; if (!(lParam & KS_CTRL) || (propsheet->head == NULL)) { break; } /* Key borad message for PSS_COMPACTTAB and PSS_SIMPLE */ switch (LOWORD (wParam)) { case SCANCODE_CURSORBLOCKDOWN: case SCANCODE_CURSORBLOCKRIGHT: if ((ctrl->dwStyle & 0x0fL)!= PSS_SCROLLABLE) { new_active = propsheet->active->next; if (new_active == NULL) new_active = propsheet->head; break; } else { scroll_tab_right (hwnd, ctrl, propsheet); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return 0; } case SCANCODE_CURSORBLOCKUP: case SCANCODE_CURSORBLOCKLEFT: if ((ctrl->dwStyle & 0x0fL)!= PSS_SCROLLABLE) { page = propsheet->head; if (propsheet->head == propsheet->active) { while (page && page->next) { page = page->next; } } else { while (page) { if (page->next == propsheet->active) break; page = page->next; } } new_active = page; break; } else { scroll_tab_left (hwnd, ctrl, propsheet); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return 0; } } /* switch */ if (new_active == NULL) { break; } show_hide_page (propsheet->active, SW_HIDE); propsheet->active = new_active; NotifyParent (hwnd, ctrl->id, PSN_ACTIVE_CHANGED); show_hide_page (new_active, SW_SHOW); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return 0; } case MSG_NCPAINT: case MSG_PAINT: { HDC hdc = BeginPaint (hwnd); PPROPPAGE page = ((ctrl->dwStyle & 0x0fL) == PSS_SCROLLABLE) ? propsheet->first_display_page : propsheet->head; draw_propsheet (hwnd, hdc, ctrl, propsheet, page); EndPaint (hwnd, hdc); return 0; } default: break; } return DefaultControlProc (hwnd, message, wParam, lParam); }