Beispiel #1
0
/*
This method handles the inflation of surrounding tiles. When an obsticle
is detected, the surrounding tile's cost can be inflated to make the robot
avoid getting anywhere near the obsticle. By the nature of pathfinding on
grid maps, the resultant path tends to "hug the wall", however this will make
the path have some distance between itself and any obsticles
*/
void GridWorld::inflate(unsigned int x, unsigned int y, double newCost){
	updateCost(x, y, newCost);
	for (int dy = -radius; dy <= radius; dy++){
		for (int dx = -radius; dx <= radius; dx++){
			if (abs(dy) + abs(dx) != 0){
				Tile* t = getTileAt(x + dx, y + dy);
				if (t != 0 && newCost > t->cost){
					updateCost(x + dx, y + dy, INFLATION);
				}

			}
		}
	}
}
Beispiel #2
0
// for call lines
InstrItem::InstrItem(InstrView* iv, QTreeWidgetItem* parent, Addr addr,
		     TraceInstr* instr, TraceInstrCall* instrCall)
    : QTreeWidgetItem(parent)
{
  _view = iv;
  _addr = addr;
  _instr = instr;
  _instrCall = instrCall;
  _instrJump = 0;
  _inside = true;

  setTextAlignment(0, Qt::AlignRight);
  setTextAlignment(1, Qt::AlignRight);
  setTextAlignment(2, Qt::AlignRight);

  //qDebug("InstrItem: (file %d, line %d) Linecall to %s",
  //       fileno, lineno, _lineCall->call()->called()->prettyName().toAscii());

  SubCost cc = _instrCall->callCount();
  QString callStr = "  ";
  if (cc==0)
    callStr += QObject::tr("Active call to '%1'")
               .arg(_instrCall->call()->calledName());
  else
    callStr += QObject::tr("%n call(s) to '%2'", "", (uint64)cc)
               .arg(_instrCall->call()->calledName());

  TraceFunction* calledF = _instrCall->call()->called();
  calledF->addPrettyLocation(callStr);

  setText(6, callStr);

  updateGroup();
  updateCost();
}
Beispiel #3
0
// for jump lines
InstrItem::InstrItem(InstrView* iv, QTreeWidgetItem* parent, Addr addr,
		     TraceInstr* instr, TraceInstrJump* instrJump)
    : QTreeWidgetItem(parent)
{
  _view = iv;
  _addr = addr;
  _inside = true;
  _instr = instr;
  _instrCall = 0;
  _instrJump = instrJump;

  setTextAlignment(0, Qt::AlignRight);
  setTextAlignment(1, Qt::AlignRight);
  setTextAlignment(2, Qt::AlignRight);

  //qDebug("SourceItem: (file %d, line %d) Linecall to %s",
  //       fileno, lineno, _lineCall->call()->called()->prettyName().toAscii());

  QString jStr;
  if (_instrJump->isCondJump())
      jStr = QObject::tr("Jump %1 of %2 times to 0x%3")
            .arg(_instrJump->followedCount().pretty())
            .arg(_instrJump->executedCount().pretty())
            .arg(_instrJump->instrTo()->addr().toString());
  else
      jStr = QObject::tr("Jump %1 times to 0x%2")
            .arg(_instrJump->executedCount().pretty())
            .arg(_instrJump->instrTo()->addr().toString());

  setText(6, jStr);

  updateGroup();
  updateCost();
}
Beispiel #4
0
// for code lines
InstrItem::InstrItem(InstrView* iv, QTreeWidget* parent,
		     Addr addr, bool inside,
		     const QString& code, const QString& cmd,
		     const QString& args, TraceInstr* instr)
    : QTreeWidgetItem(parent)
{
  _view = iv;
  _addr = addr;
  _instr = instr;
  _instrCall = 0;
  _instrJump = 0;
  _inside = inside;

  setTextAlignment(0, Qt::AlignRight);
  setTextAlignment(1, Qt::AlignRight);
  setTextAlignment(2, Qt::AlignRight);

  if (args == "...")
      setText(0, args);
  else
      setText(0, addr.pretty());
  setText(4, code);
  setText(5, cmd);
  setText(6, args);

  TraceLine* l;
  if (instr && (l = instr->line()))
      setText(7, l->name());

  updateGroup();
  updateCost();
}
Beispiel #5
0
CallItem::CallItem(CallView* view, QTreeWidget* parent, TraceCall* c)
    : QTreeWidgetItem(parent)
{
    setTextAlignment(0, Qt::AlignRight);
    setTextAlignment(1, Qt::AlignRight);
    setTextAlignment(2, Qt::AlignRight);

  _call = c;
  _view = view;

  _active = _view->activeFunction();
  bool baseIsCycle = (_active && (_active == _active->cycle()));

  QString fName;
  if (_view->showCallers()) {
      _shown = _call->caller(true);
      fName  = c->callerName(!baseIsCycle);
  }
  else {
      _shown = _call->called(true);
      fName = c->calledName(!baseIsCycle);
  }

  _shown->addPrettyLocation(fName);

  setText(3, fName);
  updateGroup();
  updateCost();
}
Beispiel #6
0
// for source lines
SourceItem::SourceItem(SourceView* sv, QTreeWidget* parent,
		       int fileno, unsigned int lineno,
                       bool inside, const QString& src,
                       TraceLine* line)
    : QTreeWidgetItem(parent)
{
  _view = sv;
  _lineno = lineno;
  _fileno = fileno;
  _inside = inside;
  _line = line;
  _lineCall = 0;
  _lineJump = 0;

  setTextAlignment(0, Qt::AlignRight);
  setTextAlignment(1, Qt::AlignRight);
  setTextAlignment(2, Qt::AlignRight);

  if (src == "...")
      setText(0, src);
  else
      setText(0, QString::number(lineno));

  QString s = src;
  setText(4, s.replace( QRegExp("\t"), "        " ));

  updateGroup();
  updateCost();
}
Beispiel #7
0
StackItem::StackItem(StackSelection* ss,
		     QListView* parent, TraceCall* call)
  :QListViewItem(parent)
{
  _view = ss;
  _call = call;
  _function = call->called();

  updateGroup();
  updateCost();

  setText(3, _function->prettyName());
}
Beispiel #8
0
StackItem::StackItem(StackSelection* ss, 
		     QListView* parent, TraceFunction* f)
  :QListViewItem(parent)
{
  _view = ss;
  _function = f;
  _call = 0;

  updateGroup();
  updateCost();

  setText(2, QString("-- "));
  setText(3, f->prettyName());
}
Beispiel #9
0
bool QxCache::insert(const QString & sKey, const boost::any & anyObj, long lCost /* = 1 */, const QDateTime & dt /* = QDateTime() */)
{
   if (sKey.isEmpty()) { qAssert(false); return false; }
   this->remove(sKey);

   QMutexLocker locker(& m_oMutexCache);
   lCost = ((lCost < 0) ? 0 : lCost);
   QDateTime dtTemp(dt); if (! dtTemp.isValid()) { dtTemp = QDateTime::currentDateTime(); }
   QxCache::type_qx_cache item = boost::make_tuple(lCost, dtTemp, anyObj);
   bool bInsertOk = m_cache.insert(sKey, item);
   if (bInsertOk) { m_lCurrCost += lCost; updateCost(); }

   return bInsertOk;
}
Beispiel #10
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    this->setWindowTitle(tr("记账本"));


    input = new InputWindow;
    connect(input,SIGNAL(updateCost()),this,SLOT(updateStatusBar()));
    queryWnd = new QueryWnd;
    connect(queryWnd,SIGNAL(updateCost()),this,SLOT(updateStatusBar()));

    tab = new QTabWidget;
    tab->addTab(input,QIcon("images/input.png"),tr("输入"));
    tab->addTab(queryWnd,tr("查看详细"));
    this->setCentralWidget(tab);
    this->setGeometry((qApp->desktop()->width()-1150)/2,(qApp->desktop()->height()-600)/2,1150,600);

    status_bar = new StatusBar("Account");
    statusBar()->addWidget(status_bar,12);
    statusBar()->setMaximumHeight(80);
    createMenu();

}
Beispiel #11
0
StackItem::StackItem(StackSelection* ss,
                     QTreeWidget* parent, TraceCall* call)
  :QTreeWidgetItem(parent)
{
  _view = ss;
  _call = call;
  _function = call->called();

  setTextAlignment(0, Qt::AlignRight);
  setTextAlignment(1, Qt::AlignRight);
  setTextAlignment(2, Qt::AlignRight);

  updateGroup();
  updateCost();

  setText(3, _function->prettyName());
}
Beispiel #12
0
void SchedScene::swapItems(size_t i, size_t j)
{
    std::swap((*perm_)[i], (*perm_)[j]);


/*
    jobs_[i]->updateData(getItemWidth(i));
    if (i > 0)
        jobs_[i-1]->updateData(getItemWidth(i-1));
    jobs_[j]->updateData(getItemWidth(j));
    if (j > 0)
        jobs_[j-1]->updateData(getItemWidth(j-1));
*/

    updateCost();
    invalidateItems();
}
Beispiel #13
0
StackItem::StackItem(StackSelection* ss, 
                     QTreeWidget* parent, TraceFunction* f)
  :QTreeWidgetItem(parent)
{
  _view = ss;
  _function = f;
  _call = 0;

  setTextAlignment(0, Qt::AlignRight);
  setTextAlignment(1, Qt::AlignRight);
  setTextAlignment(2, Qt::AlignRight);

  updateGroup();
  updateCost();

  setText(2, QString("-- "));
  setText(3, f->prettyName());
}
Beispiel #14
0
int InputWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: updateCost(); break;
        case 1: submmit(); break;
        case 2: deleteRecords(); break;
        case 3: modify(); break;
        case 4: myClose(); break;
        default: ;
        }
        _id -= 5;
    }
    return _id;
}
Beispiel #15
0
// for messages
InstrItem::InstrItem(InstrView* iv, QTreeWidget* parent,
		     Addr addr, const QString& msg)
    : QTreeWidgetItem(parent)
{
  _view = iv;
  _addr = addr;
  _instr = 0;
  _instrCall = 0;
  _instrJump = 0;
  _inside = false;

  setTextAlignment(0, Qt::AlignRight);
  setTextAlignment(1, Qt::AlignRight);
  setTextAlignment(2, Qt::AlignRight);

  setText(0, addr.pretty());
  setText(6, msg);

  updateGroup();
  updateCost();
}
Beispiel #16
0
// for call lines
SourceItem::SourceItem(SourceView* sv, QTreeWidgetItem* parent,
		       int fileno, unsigned int lineno,
                       TraceLine* line, TraceLineCall* lineCall)
    : QTreeWidgetItem(parent)
{
  _view = sv;
  _lineno = lineno;
  _fileno = fileno;
  _inside = true;
  _line = line;
  _lineCall = lineCall;
  _lineJump = 0;

  setTextAlignment(0, Qt::AlignRight);
  setTextAlignment(1, Qt::AlignRight);
  setTextAlignment(2, Qt::AlignRight);

  //qDebug("SourceItem: (file %d, line %d) Linecall to %s",
  //       fileno, lineno, _lineCall->call()->called()->prettyName().toAscii());

  SubCost cc = _lineCall->callCount();
  QString callStr = "  ";
  if (cc==0)
      callStr += QObject::tr("Active call to '%1'")
          .arg(_lineCall->call()->calledName());
  else
      callStr += QObject::tr("%n call(s) to '%2'", "", (uint64)cc)
          .arg(_lineCall->call()->calledName());

  TraceFunction* calledF = _lineCall->call()->called();
  calledF->addPrettyLocation(callStr);

  setText(4, callStr);

  updateGroup();
  updateCost();
}
Beispiel #17
0
void MainWindow::addMonthDef()
{
    FixedWnd *FixedDlg  = new FixedWnd("Fixed");
    connect(FixedDlg,SIGNAL(updateCost()),this,SLOT(updateStatusBar()));
    FixedDlg->show();
}
Beispiel #18
0
void QxCache::setMaxCost(long l)
{
   QMutexLocker locker(& m_oMutexCache);
   m_lMaxCost = ((l < 0) ? 0 : l);
   updateCost();
}
Beispiel #19
0
SchedDemo::SchedDemo(const size_t num_planes, const moment_t timespan, const moment_t bounds, const moment_t window_span, QWidget *parent/* = 0*/, Qt::WFlags flags/* = 0*/)
	: QWidget(parent, flags)
    , jobs_removed_(0)
    , original_task_(planes_task_with_bounds(num_planes, timespan, bounds))
    //, original_perm_(num_planes)
    , window_pos_(-2)
    , window_span_(window_span)
    , next_job_(0)
    , total_cost(0)
{
    resetDemo();

    sched_ = perm2sched(task_, perm_);
    sched_src_ = perm2sched(task_src_, perm_);


	
	auto clb = boost::bind(&SchedDemo::updateCost, this);
	//scene_->setCostCallback(clb);

    //scene_->setWeightScale(100);
    //scene_->setTimeScale(20);
	
	//QGraphicsView *view = new QGraphicsView(scene_);
	//view->setMouseTracking(true);
    
    //solver_slots_.push_back(solver_slot_t("Original", order_solver));
    solver_slots_.push_back(solver_slot_t("Due dates", due_dates_solver));
    selected_solver_ = solver_slots_.size() - 1;
    solver_slots_.push_back(solver_slot_t("Random pair", boost::bind(random_solver, _1, _2, 10000)));
    solver_slots_.push_back(solver_slot_t("Best pair", all_pairs_solver));
    //solver_slots_.push_back(solver_slot_t("Best triple", boost::bind(all_triples_solver, _1, _2, 7)));
    //solver_slots_.push_back(solver_slot_t("Annealing", annealing_solver));

    sliding_window_solver sws(5, boost::bind(&SchedDemo::updateOffset, this, _1));
    solver_slots_.push_back(solver_slot_t("Window", sws));

    QGridLayout *layout = new QGridLayout;

    QWidget *sidePanel = new QWidget;
    QGridLayout *sideLayout = new QGridLayout;
    sideLayout->setAlignment(Qt::AlignTop);

    QSignalMapper *mapper = new QSignalMapper(this);

    for (size_t i = 0; i < solver_slots_.size(); ++i)
    {
        solver_slots_[i].btn = new QPushButton(solver_slots_[i].name, this);

        mapper->setMapping(solver_slots_[i].btn, i);
        connect(solver_slots_[i].btn, SIGNAL(clicked()), mapper, SLOT(map()));

        solver_slots_[i].lbl = new QLabel(this);
        sideLayout->addWidget(solver_slots_[i].btn, i, 0);
        sideLayout->addWidget(solver_slots_[i].lbl, i, 1);

    }
    connect(mapper, SIGNAL(mapped(int)), this, SLOT(setSolver(int)));
    

/*
    QPushButton *advanceBtn = new QPushButton("Advance");
    sideLayout->addWidget(advanceBtn, solver_slots_.size() + 1, 0);
    connect(advanceBtn, SIGNAL(clicked()), this, SLOT(advanceSubtask()));*/

    /*QPushButton *resetBtn = new QPushButton("Reset");
    sideLayout->addWidget(resetBtn, solver_slots_.size() + 2, 0);
    connect(resetBtn, SIGNAL(clicked()), this, SLOT(resetSubtask()));*/

    QPushButton *playBtn = new QPushButton("Play", this);
    sideLayout->addWidget(playBtn, solver_slots_.size() + 1, 0);
    connect(playBtn, SIGNAL(clicked()), this, SLOT(playDemo()));

    QPushButton *pauseBtn = new QPushButton("Pause", this);
    sideLayout->addWidget(pauseBtn, solver_slots_.size() + 1, 1);
    connect(pauseBtn, SIGNAL(clicked()), this, SLOT(pauseDemo()));

    speedBar_ = new QScrollBar(Qt::Horizontal, this);
    sideLayout->addWidget(speedBar_, solver_slots_.size() + 3, 0, 1, 2);

    play_timer_ = new QTimer(this);
    connect(play_timer_, SIGNAL(timeout()), this, SLOT(playTick()));

    QPushButton *resetBtn = new QPushButton("Reset", this);
    sideLayout->addWidget(resetBtn, solver_slots_.size() + 2, 0);
    connect(resetBtn, SIGNAL(clicked()), this, SLOT(resetDemo()));

    size_t pos_offset = solver_slots_.size() + 5;
    sideLayout->addWidget(new QLabel("Cost:"), pos_offset, 0);
    cost_display_ = new QLabel(this);
    sideLayout->addWidget(cost_display_, pos_offset, 1);
    ++pos_offset;

    sideLayout->addWidget(new QLabel("Aircrafts Processed:"), pos_offset, 0);
    processed_display_ = new QLabel(this);
    sideLayout->addWidget(processed_display_, pos_offset, 1);
    ++pos_offset;

    sideLayout->addWidget(new QLabel("Aircrafts Removed:"), pos_offset, 0);
    removed_display_ = new QLabel(this);
    sideLayout->addWidget(removed_display_, pos_offset, 1);
    ++pos_offset;

    sideLayout->addWidget(new QLabel("Aircrafts in progress:"), pos_offset, 0);
    in_progress_display_ = new QLabel(this);
    sideLayout->addWidget(in_progress_display_, pos_offset, 1);
    ++pos_offset;

    sidePanel->setLayout(sideLayout);

    //layout->addWidget(view, 0, 0);

/*
    qwt_demo_ = new QwtSchedDemo(this);
    layout->addWidget(qwt_demo_, 1, 0);
*/


    demo2_src = new qwt_demo_2(this);
    demo2_src->setAxisScale(QwtPlot::xBottom, -30, 30);
    demo2 = new qwt_demo_2(this);
    demo2->setAxisScale(QwtPlot::xBottom, -30, 30);

    layout->addWidget(demo2_src, 0, 0);
    layout->addWidget(demo2, 0, 1);
    layout->addWidget(sidePanel, 0, 3, 2, 1);

	setLayout(layout);
    //scene_->invalidateItems();
    updateCost();

}