quint32 ViewTable::getId(int row) const { if( row < 0 ) return getCurrentId(); if( row > rowCount() ) return getCurrentId(); bool ok; quint32 result = text(row, 0).toUInt(&ok); if(!ok) return (quint32)0; return result; }
void shgPhases::addToStatusDisplay(int phaseId, const pdstring &iMsg) { // currently, we do _not_ add a \n to the message for you. if (!existsCurrent()) { cerr << "addToStatusDisplay: no current phase to display msg:" << endl; cerr << iMsg << endl; return; } if (!existsById(phaseId)) { //cerr << "addToStatusDisplay: no phase id " << phaseId << " exists to display msg:" << endl; //cerr << "\"" << iMsg << "\"" << endl; return; } const bool isCurrShg = (getCurrentId() == phaseId); shgStruct &theShgStruct = getByIDLL(phaseId); pdstring Msg; // auto-prepend "\n" for all but first message if (theShgStruct.msgText.length() > 1) Msg = pdstring("\n") + iMsg; else Msg=iMsg; theShgStruct.msgText += Msg; if (isCurrShg) { pdstring commandStr = msgTextWindowName + " insert end {" + Msg + "}"; myTclEval(interp, commandStr); commandStr = msgTextWindowName + " yview -pickplace end"; myTclEval(interp, commandStr); } }
bool shgPhases::inactivateEntireSearch(int phaseId) { // returns true iff a redraw should take place shg &theShg = getByID(phaseId); const bool isCurrShg = (getCurrentId() == phaseId); const bool anyChanges = theShg.inactivateAll(isCurrShg); return isCurrShg && anyChanges; }
bool shgPhases::configNode(int phaseId, unsigned nodeId, bool active, shgRootNode::evaluationState es, bool deferred) { // returns true iff a redraw should take place shg &theShg = getByID(phaseId); const bool isCurrShg = (getCurrentId() == phaseId); const shg::configNodeResult changes = theShg.configNode(nodeId, active, es, deferred, isCurrShg, true); // true --> rethink if needed return isCurrShg && (changes != shg::noChanges); }
bool shgPhases::addEdge(int phaseId, unsigned fromId, unsigned toId, shgRootNode::refinement theRefinement, const char *label, // used only for shadow nodes, else NULL bool rethinkFlag) { // The evaluationState param decides whether to explicitly expand // the "to" node. Rethinks the entire layout of the shg // Returns true iff a redraw should take place shg &theShg = getByID(phaseId); const bool isCurrShg = (getCurrentId() == phaseId); theShg.addEdge(fromId, toId, theRefinement, label, isCurrShg, rethinkFlag); return isCurrShg; }
bool shgPhases::addNode(int phaseId, unsigned nodeId, bool active, shgRootNode::evaluationState es, bool deferred, const pdstring &label, const pdstring &fullInfo, bool rootNodeFlag) { // returns true iff a redraw should take place shg &theShg = getByID(phaseId); const bool isCurrShg = (getCurrentId() == phaseId); theShg.addNode(nodeId, active, es, deferred, label, fullInfo, rootNodeFlag, isCurrShg); return isCurrShg; }
bool shgPhases::resumeCurrSearch() { // returns true iff successfully resumed if (!existsCurrent()) return false; int phaseId = getCurrentId(); shgStruct &theStruct = getByIDLL(phaseId); // slow... assert(theStruct.everSearched); assert(theStruct.currSearching); // make the igen call to do the actual resuming: #ifdef PARADYN perfConsult->activateSearch(phaseId); #endif theStruct.currSearching = true; return true; }
float Plan::progress(const IMC::ManeuverControlState* mcs) { if (!m_compute_progress) return -1.0; // Compute only if linear and durations exists if (!isLinear() || !m_profiles->size()) return -1.0; // If calibration has not started yet, but will later if (m_calib->notStarted()) return -1.0; float total_duration = getTotalDuration(); float exec_duration = getExecutionDuration(); // Check if its calibrating if (m_calib->inProgress()) { float time_left = m_calib->getRemaining() + exec_duration; m_progress = 100.0 * trimValue(1.0 - time_left / total_duration, 0.0, 1.0); return m_progress; } // If it's not executing, do not compute if (mcs->state != IMC::ManeuverControlState::MCS_EXECUTING || mcs->eta == 0) return m_progress; TimeProfile::const_iterator itr; itr = m_profiles->find(getCurrentId()); // If not found if (itr == m_profiles->end()) { // If beyond the last maneuver with valid duration if (m_beyond_dur) { m_progress = 100.0; return m_progress; } else { return -1.0; } } // If durations vector for this maneuver is empty if (!itr->second.durations.size()) return m_progress; IMC::Message* man = m_graph.find(getCurrentId())->second.pman->data.get(); // Get execution progress float exec_prog = Progress::compute(man, mcs, itr->second.durations, exec_duration); float prog = 100.0 - getExecutionPercentage() * (1.0 - exec_prog / 100.0); // If negative, then unable to compute // But keep last value of progress if it is not invalid if (prog < 0.0) { if (m_progress < 0.0) return -1.0; else return m_progress; } // Never output shorter than previous m_progress = prog > m_progress ? prog : m_progress; return m_progress; }
QExplicitlySharedDataPointer<Basket> BasketTree::getCurrentBasket() { QExplicitlySharedDataPointer<Basket> basket ; basket = new Basket(getCurrentId(),database); return basket; }