void NMGChartSeries::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { if(!vertexList.isEmpty()) { if(spaceAvailableIntoSceneChanged || rebuildScaleFactors) { calculateScaleFactors(); if(spaceAvailableIntoSceneChanged) spaceAvailableIntoSceneChanged = FALSE; if(rebuildScaleFactors) rebuildScaleFactors = FALSE; } QPen pen; pen.setColor(baseColor); pen.setWidth(1); painter->setPen(pen); if(isClipped) { painter->setClipRect(0, 0, currentWidthIntoScene + pen.width(), currentHeightIntoScene); } painter->save(); painter->translate(0,currentHeightIntoScene); if(representation == LINE_TYPE) paintLine(painter, option, widget); else if(representation == AREA_TYPE) paintArea(painter, option, widget); else if(representation == POINTS_TYPE) paintPoints(painter, option, widget); else if(representation == BARS_TYPE) paintBars(painter, option, widget); painter->restore(); } }
void ApplicationController::stepSimulation() { ground->lock(); //simulate ants for (auto & ant : ants) //pinter to Ant { if (ant->isDead()) { nests[ant->getId()]->removeAnt(); delete ant; //TODO: leave food on ground ant = nullptr; } else if (!ant->move(*ground)) //ant moves, if false it go to nest { Nest *tmp = nests[ant->getId()]; if (ant->isDead()) //after fighting { tmp->removeAnt(); delete ant; } else { tmp->addAnt(ant); tmp->addFood(ant->getFood()); } ant = nullptr; //remove ant from list } } //remove ant which come into nest ants.remove_if([](Ant * ant) { return !ant; }); //simulate nests std::list<Ant*> tmp; for (auto & pair : nests) //std::pair<int, Nest*> { tmp = pair.second->nextStep(); ants.insert(ants.begin(), tmp.begin(), tmp.end()); } //make smell to flow away ground->proceedNextStep(); //check food ground->checkFood(); //generate new food ground->generateFood(); ground->unlock(); paintArea(); showMessage(); }
void ewk_paint_context_paint(Ewk_Paint_Context* context, WebCore::FrameView* view, const Eina_Rectangle* area) { EINA_SAFETY_ON_NULL_RETURN(context); EINA_SAFETY_ON_NULL_RETURN(view); EINA_SAFETY_ON_NULL_RETURN(area); WebCore::IntRect paintArea(*area); if (view->isTransparent()) context->graphicContext->clearRect(paintArea); view->paint(context->graphicContext.get(), paintArea); }
void ApplicationController::initSimulation() { deleteAll(); std::list<int>::iterator xs = nests_x.begin(); std::list<int>::iterator ys = nests_y.begin(); for (int i=0; i < nests_number; ++i) { nests[i] = new Nest(i); nests[i]->setPosition(*(xs++), *(ys++)); nests[i]->setStartingAnts(starting_ants_number); } ground->createMap(length, height, start_food_proability, place_food_proability); paintArea(); }
void ewk_paint_context_paint_contents(Ewk_Paint_Context* context, WebCore::FrameView* view, const Eina_Rectangle* area) { EINA_SAFETY_ON_NULL_RETURN(context); EINA_SAFETY_ON_NULL_RETURN(view); EINA_SAFETY_ON_NULL_RETURN(area); WebCore::IntRect paintArea(*area); if (view->isTransparent()) context->graphicContext->clearRect(paintArea); view->paintContents(context->graphicContext.get(), paintArea); #if ENABLE(INSPECTOR) WebCore::Page* page = view->frame()->page(); if (page) { WebCore::InspectorController* controller = page->inspectorController(); if (controller->highlightedNode()) controller->drawHighlight(*context->graphicContext); } #endif }
static LRESULT CALLBACK areaWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { void *data; DWORD which; uintptr_t heldButtons = (uintptr_t) wParam; LRESULT lResult; data = getWindowData(hwnd, uMsg, wParam, lParam, &lResult); if (data == NULL) return lResult; switch (uMsg) { case WM_PAINT: paintArea(hwnd, data); return 0; case WM_ERASEBKGND: // don't draw a background; we'll do so when painting // this is to make things flicker-free; see http://msdn.microsoft.com/en-us/library/ms969905.aspx return 1; case WM_HSCROLL: scrollArea(hwnd, data, wParam, SB_HORZ); return 0; case WM_VSCROLL: scrollArea(hwnd, data, wParam, SB_VERT); return 0; case WM_SIZE: adjustAreaScrollbars(hwnd, data); return 0; case WM_ACTIVATE: // don't keep the double-click timer running if the user switched programs in between clicks areaResetClickCounter(data); return 0; case WM_MOUSEMOVE: areaMouseEvent(hwnd, data, 0, FALSE, heldButtons, lParam); return 0; case WM_LBUTTONDOWN: SetFocus(hwnd); areaMouseEvent(hwnd, data, 1, FALSE, heldButtons, lParam); return 0; case WM_LBUTTONUP: areaMouseEvent(hwnd, data, 1, TRUE, heldButtons, lParam); return 0; case WM_MBUTTONDOWN: SetFocus(hwnd); areaMouseEvent(hwnd, data, 2, FALSE, heldButtons, lParam); return 0; case WM_MBUTTONUP: areaMouseEvent(hwnd, data, 2, TRUE, heldButtons, lParam); return 0; case WM_RBUTTONDOWN: SetFocus(hwnd); areaMouseEvent(hwnd, data, 3, FALSE, heldButtons, lParam); return 0; case WM_RBUTTONUP: areaMouseEvent(hwnd, data, 3, TRUE, heldButtons, lParam); return 0; case WM_XBUTTONDOWN: SetFocus(hwnd); // values start at 1; we want them to start at 4 which = (DWORD) GET_XBUTTON_WPARAM(wParam) + 3; heldButtons = (uintptr_t) GET_KEYSTATE_WPARAM(wParam); areaMouseEvent(hwnd, data, which, FALSE, heldButtons, lParam); return TRUE; // XBUTTON messages are different! case WM_XBUTTONUP: which = (DWORD) GET_XBUTTON_WPARAM(wParam) + 3; heldButtons = (uintptr_t) GET_KEYSTATE_WPARAM(wParam); areaMouseEvent(hwnd, data, which, TRUE, heldButtons, lParam); return TRUE; case msgAreaKeyDown: return (LRESULT) areaKeyEvent(data, FALSE, wParam, lParam); case msgAreaKeyUp: return (LRESULT) areaKeyEvent(data, TRUE, wParam, lParam); case msgAreaSizeChanged: adjustAreaScrollbars(hwnd, data); repaintArea(hwnd, NULL); // this calls for an update return 0; case msgAreaGetScroll: getScrollPos(hwnd, (int *) wParam, (int *) lParam); return 0; case msgAreaRepaint: repaintArea(hwnd, (RECT *) lParam); return 0; case msgAreaRepaintAll: repaintArea(hwnd, NULL); return 0; default: return DefWindowProcW(hwnd, uMsg, wParam, lParam); } xmissedmsg("Area", "areaWndProc()", uMsg); return 0; // unreached }
void KoColorPanel::paintEvent( QPaintEvent* e ) { int lns = lines(); int startRow, endRow, startCol, endCol; paintArea( e->rect(), startRow, endRow, startCol, endCol ); QPainter p( this ); // First clear all the areas we won't paint on later (only if the widget isn't erased) if ( !e->erased() ) { // vertical rects int tmp = TILESIZE * lns; if ( startCol == 0 ) erase( 0, 0, 2, tmp ); if ( endCol == COLS ) erase( width() - 2, 0, 2, tmp ); else erase( ( endCol << 4 ) - 2, 0, 2, tmp ); int i = startCol == 0 ? 1 : startCol; for ( ; i < endCol; ++i ) erase( ( i << 4 ) - 2, 0, 4, tmp ); // horizontal rects tmp = TILESIZE * COLS; if ( startRow == 0 ) erase( 0, 0, tmp, 2 ); if ( endRow == lns ) erase( 0, height() - 2, tmp, 2 ); else erase( 0, ( endRow << 4 ) - 2, tmp, 2 ); i = startRow == 0 ? 1 : startRow; for ( ; i < endRow; ++i ) erase( 0, ( i << 4 ) - 2, tmp, 4 ); } // The "active" element (if there is one) if ( hasFocus() && m_focusPosition.x != -1 && m_focusPosition.y != -1 && mapFromPosition( m_focusPosition ).intersects( e->rect() ) ) style().drawPrimitive( QStyle::PE_Panel, &p, QRect( m_focusPosition.x << 4, m_focusPosition.y << 4, TILESIZE, TILESIZE ), colorGroup(), QStyle::Style_Sunken | QStyle::Style_Enabled ); --lns; // Attention: We just avoid some lns - 1 statements // ...all color tiles if ( !m_colorMap.isEmpty() ) { int currentRow = startRow, currentCol = startCol; while ( currentRow < endRow && currentCol < endCol ) { QMap<Position, QColor>::ConstIterator it = m_colorMap.find( Position( currentCol, currentRow ) ); if( it != m_colorMap.end() ) p.fillRect( ( currentCol << 4 ) + 2, ( currentRow << 4 ) + 2, 12, 12, it.data() ); // position of the next cell ++currentCol; if ( currentCol == endCol ) { ++currentRow; currentCol = startCol; } } } // clean up the last line (it's most likely that it's not totally filled) if ( !e->erased() && endRow > lns ) { int fields = m_colorMap.count() % COLS; erase( fields << 4, lns * TILESIZE, ( COLS - fields ) << 4, 16 ); } }