void CMyPaintDoc::saveState() { CHECKINVARIANT; if(canAddImage()) { while(canRedo()) { removeLast(); } addImage(); m_index = getHistorySize(); } CHECKINVARIANT; }
bool CMyPaintDoc::undo() { CHECKINVARIANT; bool done = false; if(canUndo()) { if(!canRedo()) { addImage(); m_index = max(getHistorySize() - 1, 1); } setImage(m_history[--m_index]->clone(true)); done = true; } CHECKINVARIANT; return done; }
bool WLivelinessPeriodicAssertion::AutomaticLivelinessAssertion() { std::lock_guard<std::recursive_mutex> guard(*this->mp_WLP->getBuiltinProtocols()->mp_PDP->getMutex()); if(this->mp_WLP->m_livAutomaticWriters.size()>0) { auto writer = this->mp_WLP->getBuiltinWriter(); auto history = this->mp_WLP->getBuiltinWriterHistory(); std::lock_guard<std::recursive_timed_mutex> wguard(writer->getMutex()); CacheChange_t* change=writer->new_change([]() -> uint32_t {return BUILTIN_PARTICIPANT_DATA_MAX_SIZE;}, ALIVE,m_iHandle); if(change!=nullptr) { //change->instanceHandle = m_iHandle; #if __BIG_ENDIAN__ change->serializedPayload.encapsulation = (uint16_t)PL_CDR_BE; #else change->serializedPayload.encapsulation = (uint16_t)PL_CDR_LE; #endif memcpy(change->serializedPayload.data,m_guidP.value,12); for(uint8_t i =12;i<24;++i) change->serializedPayload.data[i] = 0; change->serializedPayload.data[15] = m_livelinessKind+1; change->serializedPayload.length = 12+4+4+4; if(history->getHistorySize() > 0) { for(std::vector<CacheChange_t*>::iterator chit = history->changesBegin(); chit!=history->changesEnd();++chit) { if((*chit)->instanceHandle == change->instanceHandle) { history->remove_change(*chit); break; } } } history->add_change(change); } } return true; }
void SpectrumHistoryView::paintEvent(QPaintEvent *) { QColor barColor(255, 0, 0); QPainter painter(this); painter.setBrush(QColor(0, 255, 0)); for (int line=0; line < getHistorySize(); ++line) { for (unsigned int column=0; column < history[line].size(); ++column) { painter.setBrush(QColor(history[line][column])); painter.setPen(QColor(history[line][column])); painter.drawLine ( column * width() / history[line].size(),//x1 line,//y1 (column + 1) * width() / history[line].size(),//x2 line//y2 ); } } }
const PointerCoords* MotionEvent::getRawPointerCoords(size_t pointerIndex) const { return &mSamplePointerCoords[getHistorySize() * getPointerCount() + pointerIndex]; }
void CMyPaintDoc::checkInvariant(int line) const { if(m_index < 0 || m_index > getHistorySize()) { throwException(_T("Broken invariant in %s, line %d:index=%d, historySize=%d"), __TFILE__, line, m_index, m_history.size()); } }
bool CMyPaintDoc::canRedo() const { CHECKINVARIANT; return m_index < getHistorySize() - 1; }