//==========================================================================// // Local Functions // //==========================================================================// void LegendSetCurrentLine (PLEGEND pLegend, int iIndex) { pLegend->pCurrentLine = (PLINESTRUCT) LBData (pLegend->hWndItems, iIndex) ; if (pLegend->pCurrentLine == (PLINESTRUCT) LB_ERR) { pLegend->pCurrentLine = NULL ; } } // LegendSetCurrentLine
static void lb_s2a21d(unsigned int dimen, list_type& pl) { LBData lbd = LBData(par::comm_world(), pl.size()); const par::communicator& comm = par::comm_world(); const unsigned int my_rank = comm.rank(); const unsigned int num_proc = comm.size(); const unsigned int num_point = lbd.size[my_rank]; const list_type::size_type glob_num_point = std::accumulate(lbd.size.begin(), lbd.size.end(), 0); if (glob_num_point < 2 * num_proc) comm.abort("Try more points", 1); // First: sort list sort_point2d_list(dimen, pl); std::vector<unsigned int>::const_iterator max_elem = std::max_element(lbd.size.begin(), lbd.size.end()); unsigned int my_num_cut = std::floor( static_cast<real>(num_point) / (*max_elem) * std::min(static_cast<int>(num_proc), std::max(static_cast<int>(num_point)-1, 0))); // Iterate until enough cuts are placed so the points can be (almost) // equally placed onto the processors - or give up real imbalance; for (unsigned int i=0; i<5; i++) { lb_create_cut(comm, my_num_cut, dimen, pl, lbd); lb_create_bin(comm, dimen, pl, lbd); imbalance = lb_s2a2_calculate_imbalance(lbd); my_num_cut = std::min(2 * my_num_cut, num_point - 1); int at_limit = static_cast<int>(my_num_cut == num_point - 1); int all_at_limit; comm.allreduce(&at_limit, &all_at_limit, par::min(), 1); if (imbalance < 0.05 || all_at_limit) break; } // if (my_rank == 0) std::cout << "Imbalance = " << imbalance << std::endl; // Migrate the points lb_migrate_points(comm, pl, lbd); }
void PrintLegend (HDC hDC, PGRAPHSTRUCT pGraph, HWND hWndLegend, RECT rectLegend) { PLEGEND pLegend ; int yItemHeight ; HFONT hFontItems ; PLINE pLine ; int iIndex ; int iIndexNum ; pLegend = LegendData (hWndLegend) ; yItemHeight = pLegend->yItemHeight ; hFontItems = pLegend->hFontItems ; pLegend->hFontItems = hFontPrinterScales ; SelectFont (hDC, pLegend->hFontItems) ; pLegend->yItemHeight = FontHeight (hDC, TRUE) ; iIndexNum = LBNumItems (pLegend->hWndItems) ; for (iIndex = 0 ; iIndex < iIndexNum ; iIndex++) { // for pLine = (PLINE) LBData (pLegend->hWndItems, iIndex) ; DrawLegendItem (pLegend, pLine, iIndex * pLegend->yItemHeight, hDC) ; } // for pLegend->hFontItems = hFontItems ; pLegend->yItemHeight = yItemHeight ; SelectBrush (hDC, GetStockObject (HOLLOW_BRUSH)) ; SelectPen (hDC, GetStockObject (BLACK_PEN)) ; Rectangle (hDC, 0, 0, rectLegend.right - rectLegend.left, rectLegend.bottom - rectLegend.top) ; }
void OnDrawLegendItem (HWND hWnd, LPDRAWITEMSTRUCT lpDI) { // OnDrawItem HFONT hFontPrevious ; HDC hDC ; PLEGEND pLegend ; PLINESTRUCT pLine ; int iLBIndex ; COLORREF preBkColor = 0; COLORREF preTextColor = 0; BOOL ResetColor = FALSE ; hDC = lpDI->hDC ; iLBIndex = DIIndex (lpDI) ; pLegend = LegendData (hWnd) ; if (iLBIndex == -1) pLine = NULL ; else pLine = (PLINESTRUCT) LBData (pLegend->hWndItems, iLBIndex) ; //=============================// // Set DC attributes // //=============================// if (DISelected (lpDI) || pLine == NULL) { // if preTextColor = SetTextColor (hDC, GetSysColor (COLOR_HIGHLIGHTTEXT)) ; preBkColor = SetBkColor (hDC, GetSysColor (COLOR_HIGHLIGHT)) ; ResetColor = TRUE ; } // if ExtTextOut (hDC, lpDI->rcItem.left, lpDI->rcItem.top, ETO_OPAQUE, &(lpDI->rcItem), NULL, 0, NULL ) ; //=============================// // Draw Legend Item // //=============================// hFontPrevious = SelectFont (hDC, pLegend->hFontItems) ; if (pLine) DrawLegendItem (pLegend, pLine, lpDI->rcItem.top, hDC) ; SelectFont (hDC, hFontPrevious) ; //=============================// // Draw Focus // //=============================// if (DIFocus (lpDI)) DrawFocusRect (hDC, &(lpDI->rcItem)) ; if (ResetColor == TRUE) { // if preTextColor = SetTextColor (hDC, preTextColor) ; preBkColor = SetBkColor (hDC, preBkColor) ; } // if } // OnDrawItem