void Transfairs::updatePartidaMaisTarde(vector<Vertex<Service>*> vec) { size_t numServices = vec.size(); Time minTime(23,59);; for (int i = 0; i < numServices; i++) { if (vec[i]->getVisited() == false) { if (vec[i]->getInfo().getHmaxChegada() < minTime) { minTime = vec[i]->getInfo().getHmaxChegada(); } } } this->partidaMaisTarde = minTime; }
void CalendarWidget::draw() { ofFill(); ofSetColor(0, 200); ofDrawRectangle(_window); std::string formatStringHourMin = "%h:%M %A"; std::string formatStringHour = "%h:%M"; std::string formatStringHourMinSec = "%h:%M:%S %A"; Poco::LocalDateTime minTime(_windowInterval.getStart()); Poco::LocalDateTime maxTime(_windowInterval.getEnd()); Poco::LocalDateTime startQuarter = Utils::ceiling(minTime, Poco::Timespan::MINUTES * 5); ofPushMatrix(); ofTranslate(_window.getPosition()); std::vector<Poco::Timestamp> hours = Utils::getInstances(startQuarter.utc().timestamp(), maxTime.utc().timestamp(), Period(Period::MINUTE, 5)); std::vector<Poco::Timestamp>::const_iterator hourIter = hours.begin(); while (hourIter != hours.end()) { Poco::DateTime time = Poco::DateTime(*hourIter); int y = _window.getHeight() * _windowInterval.map(time.timestamp()); int minute = time.minute(); float alpha = ofMap(std::abs(_windowInterval.map(time.timestamp()) - 0.5), 0, .2, .25, 1, true); if (0 == minute) { ofSetColor(255, 80 * alpha); ofDrawLine(0, y, _window.getWidth(), y); } else if (0 == minute % 15) { ofSetColor(255, 255, 0, 80 * alpha); ofDrawLine(0, y, _window.getWidth(), y); } else { ofSetColor(127, 80 * alpha); ofDrawLine(0, y, _window.getWidth(), y); } std::string label = Utils::format(Poco::LocalDateTime(time), formatStringHourMinSec); int width = _font.stringWidth(label); int height = _font.stringHeight(label); if (y - height - 4 > 0) { _font.drawString(label, _window.getWidth() - width - 4, y - 4); } ++hourIter; } int y = _window.getHeight() * _windowInterval.map(_now); ofSetColor(255); ofDrawLine(0, y, _window.getWidth(), y); std::string label = Utils::format(Poco::LocalDateTime(_now), formatStringHourMinSec); int width = _font.stringWidth(label); _font.drawString(label, _window.getWidth() - width - 4, y - 4); std::sort(_currentEvents.begin(), _currentEvents.end()); ICalendar::EventInstances::const_iterator iter = _currentEvents.begin(); int x = 0; while (iter != _currentEvents.end()) { const ICalendarEvent& event = (*iter).getEvent(); const Interval& interval = (*iter).getInterval(); if (_windowInterval.intersects(interval)) { int y0 = _window.getHeight() * _windowInterval.map(interval.getStart()); int y1 = _window.getHeight() * _windowInterval.map(interval.getEnd()); ofFill(); ofSetColor(255, 50); if (interval.contains(_now)) { ofSetColor(255, 255, 0, 50); } else { ofSetColor(255, 50); } ofDrawRectRounded(x, y0, 80, y1 - y0, 5); ofNoFill(); ofSetColor(127); ofDrawRectRounded(x, y0, 80, y1 - y0, 5); ofSetColor(255); ofDrawRectRounded(x-1, y0-1, 80+2, y1 - y0+2, 5); std::string startLabel = Utils::format(Poco::LocalDateTime(interval.getStart()), formatStringHour); std::string endLabel = Utils::format(Poco::LocalDateTime(interval.getEnd()), formatStringHour); ofFill(); ofSetColor(255); _font.drawString(event.getSummary(), x + 5, y0 + 10); _font.drawString(startLabel, x + 5, y0 + 20); _font.drawString(endLabel, x + 5, y0 + 30); x+= 84; if (x > _window.getWidth() - 160) x = 0; } ++iter; } ofPopMatrix(); }
void DefracDemo::mouseFunc(int button, int state, int x, int y) { if(button == 0)//left button { if(state == 0) //pressed { btVector3 rayTo = getRayTo(x,y); btVector3 rayFrom; if (m_ortho) { rayFrom = rayTo; rayFrom.setZ(-100.f); } else { rayFrom = m_cameraPosition; } btDefracDynamicsWorld* world = getDefracDynamicsWorld(); btScalar minTime(BT_LARGE_FLOAT); for(int b=0; b < world->getNumDefracBodies(); ++b) { btDefracBody* body = world->getDefracBody(b); for(int i=0; i < body->getTetrahedronCount(); ++i) { btTetrahedron* t = body->getTetrahedron(i); btVector3 min, max; t->getAABB(min, max); btScalar time(0); if(btDefracUtils::SegmentAABBIntersect(rayFrom, rayTo, min, max, &time) && time < minTime) { minTime = time; btVector3 pickPos = rayFrom + (rayTo-rayFrom)*time; m_oldPickingDist = (pickPos - rayFrom).length(); if(m_spring == NULL) m_spring = new btSpring(t, btVector4(0.25,0.25,0.25,0.25), 1000, 0.2); else m_spring->setTetrahedron(t); m_spring->setSourcePosition(pickPos); } } } if(m_spring != NULL) world->addSpring(m_spring); } else if(state == 1) //released { btDefracDynamicsWorld* world = getDefracDynamicsWorld(); world->removeSpring(m_spring); delete m_spring; m_spring = NULL; } } if(m_spring == NULL) { DemoApplication::mouseFunc(button,state,x,y); } }
shared_ptr<var> VCDComparator::compareVariables(shared_ptr<var> first, shared_ptr<var> second, shared_ptr<var> ret) { typename var::const_iterator itFirst = first->begin(); typename var::const_iterator itSecond = second->begin(); if(first->begin() == first->end() || second->begin() == second->end()) { //! if at least one of scalars is empty if(first->begin() != first->end() || second->begin() != second->end()) { //! if one of them is not empty //! take the smaller time and put undefined ret->addTrace(minTime(itFirst->getTime(), itSecond->getTime()), typename var::value_t('z')); return ret; } return ret; } //! here we know, that both variables are not empty if(first->back().getTime() < second->front().getTime()) { //! no common range - the first ends before the second begins for( /*itFirst*/; itFirst != first->end(); ++itFirst) { ret->addTrace(itFirst->getTime(), typename var::value_t('z')); } for( /*itSecond*/; itSecond != second->end(); ++itSecond) { typename var::value_t t = VCDComparator::compareValues(itSecond->getValue(), first->back().getValue()); ret->addTrace(itSecond->getTime(), t); } return ret; } else if (second->back().getTime() < first->front().getTime()) { //! no common range - the second ends before the first begins for( /*itSecond*/; itSecond != second->end(); ++itSecond) { ret->addTrace(itSecond->getTime(), typename var::value_t('z')); } for( /*itFirst*/; itFirst != first->end(); ++itFirst) { ret->addTrace(itFirst->getTime(), VCDComparator::compareValues(itFirst->getValue(), second->back().getValue())); } return ret; } else { //! there is common range typename var::const_iterator itFirst_prev = itFirst; typename var::const_iterator itSecond_prev = itSecond; if(itFirst->getTime() < itSecond->getTime()) { //! first begins before second do { ret->addTrace(itFirst->getTime(), 'z'); //! undefined comparison - one variable is not defined at this time itFirst_prev = itFirst++; } while(itFirst->getTime() < itSecond->getTime()); } else if(itSecond->getTime() < itFirst->getTime()) { //! second begins before first do { ret->addTrace(itSecond->getTime(),'z'); //! undefined comparison - one variable is not defined at this time itSecond_prev = itSecond++; } while(itSecond->getTime() < itFirst->getTime()); } //else {} for(;;) { if(itSecond == second->end() && itFirst == first->end()) { break; } else if(itFirst != first->end() && (itSecond == second->end() || itFirst->getTime() < itSecond->getTime())) { ret->addTrace(itFirst->getTime(),VCDComparator::compareValues(itFirst->getValue(), itSecond_prev->getValue())); itFirst_prev = itFirst++; } else if(itSecond != second->end() && (itFirst == first->end() || itSecond->getTime() < itFirst->getTime())) { ret->addTrace(itSecond->getTime(),VCDComparator::compareValues(itSecond->getValue(), itFirst_prev->getValue())); itSecond_prev = itSecond++; } else if(itSecond->getTime() == itFirst->getTime()) { typename var::value_t t = VCDComparator::compareValues(itSecond->getValue(), itFirst->getValue()); ret->addTrace(itFirst->getTime(), t); itSecond_prev = itSecond++; itFirst_prev = itFirst++; } } ret->setScopes(first->getScopes()); return ret; } }