Exemplo n.º 1
0
bool PathGenerator::CalculatePath(float destX, float destY, float destZ, bool forceDest, bool straightLine)
{
    float x, y, z;
    _sourceUnit->GetPosition(x, y, z);

    if (!Trinity::IsValidMapCoord(destX, destY, destZ) || !Trinity::IsValidMapCoord(x, y, z))
        return false;

    G3D::Vector3 dest(destX, destY, destZ);
    SetEndPosition(dest);

    G3D::Vector3 start(x, y, z);
    SetStartPosition(start);

    _forceDestination = forceDest;
    _straightLine = straightLine;

    TC_LOG_DEBUG("maps", "++ PathGenerator::CalculatePath() for %u \n", _sourceUnit->GetGUIDLow());

    // make sure navMesh works - we can run on map w/o mmap
    // check if the start and end point have a .mmtile loaded (can we pass via not loaded tile on the way?)
    if (!_navMesh || !_navMeshQuery || _sourceUnit->HasUnitState(UNIT_STATE_IGNORE_PATHFINDING) ||
        !HaveTile(start) || !HaveTile(dest))
    {
        BuildShortcut();
        _type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH);
        return true;
    }

    UpdateFilter();

    BuildPolyPath(start, dest);
    return true;
}
Exemplo n.º 2
0
void PathGenerator::CreateFilter()
{
    uint16 includeFlags = 0;
    uint16 excludeFlags = 0;

    if (_sourceUnit->GetTypeId() == TYPEID_UNIT)
    {
        Creature* creature = (Creature*)_sourceUnit;
        if (creature->CanWalk())
            includeFlags |= NAV_GROUND;          // walk

        // creatures don't take environmental damage
        if (creature->CanSwim())
            includeFlags |= (NAV_WATER | NAV_MAGMA | NAV_SLIME);           // swim
    }
    else // assume Player
    {
        // perfect support not possible, just stay 'safe'
        includeFlags |= (NAV_GROUND | NAV_WATER | NAV_MAGMA | NAV_SLIME);
    }

    _filter.setIncludeFlags(includeFlags);
    _filter.setExcludeFlags(excludeFlags);

    UpdateFilter();
}
void tpDynamicToneMappingManager::SetMethode(tpDynamicToneMappingManager::TypeMethode m)
{
	m_methode = m;

	UpdateFilter();
	ComputeLuminance();
}
void tpDynamicToneMappingManager::SetRayon(int v)
{
	m_rayon = v;

	UpdateFilter();
	ComputeLuminance();
}
Exemplo n.º 5
0
void AlbumCoverManager::ArtistChanged(QListWidgetItem* current) {
  if (!current) return;

  QString artist;
  if (current->type() == Specific_Artist) artist = current->text();

  ui_->albums->clear();
  context_menu_items_.clear();
  CancelRequests();

  // Get the list of albums.  How we do it depends on what thing we have
  // selected in the artist list.
  LibraryBackend::AlbumList albums;
  switch (current->type()) {
    case Various_Artists:
      albums = library_backend_->GetCompilationAlbums();
      break;
    case Specific_Artist:
      albums = library_backend_->GetAlbumsByArtist(current->text());
      break;
    case All_Artists:
    default:
      albums = library_backend_->GetAllAlbums();
      break;
  }

  // Sort by album name.  The list is already sorted by sqlite but it was done
  // case sensitively.
  qStableSort(albums.begin(), albums.end(), CompareAlbumNameNocase);

  for (const LibraryBackend::Album& info : albums) {
    // Don't show songs without an album, obviously
    if (info.album_name.isEmpty()) continue;

    QListWidgetItem* item =
        new QListWidgetItem(no_cover_icon_, info.album_name, ui_->albums);
    item->setData(Role_ArtistName, info.artist);
    item->setData(Role_AlbumName, info.album_name);
    item->setData(Role_FirstUrl, info.first_url);
    item->setData(Qt::TextAlignmentRole,
                  QVariant(Qt::AlignTop | Qt::AlignHCenter));
    item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled |
                   Qt::ItemIsDragEnabled);
    item->setToolTip(info.artist + " - " + info.album_name);

    if (!info.art_automatic.isEmpty() || !info.art_manual.isEmpty()) {
      quint64 id = app_->album_cover_loader()->LoadImageAsync(
          cover_loader_options_, info.art_automatic, info.art_manual,
          info.first_url.toLocalFile());
      item->setData(Role_PathAutomatic, info.art_automatic);
      item->setData(Role_PathManual, info.art_manual);
      cover_loading_tasks_[id] = item;
    }
  }

  UpdateFilter();
}
Exemplo n.º 6
0
void AlbumCoverManager::CoverImageLoaded(quint64 id, const QImage& image) {
  if (!cover_loading_tasks_.contains(id)) return;

  QListWidgetItem* item = cover_loading_tasks_.take(id);

  if (image.isNull()) return;

  item->setIcon(QPixmap::fromImage(image));
  UpdateFilter();
}
Exemplo n.º 7
0
void Feeds::SaveFilter(filters_struct * filter)
{
    if (filter->id == -1)
    {
        AddFilter(filter);
    }
    else
    {
        UpdateFilter(filter);
    }
}
Exemplo n.º 8
0
bool PathGenerator::CalculatePath(float destX, float destY, float destZ, bool forceDest)
{
    float x, y, z;
    _sourceUnit->GetPosition(x, y, z);

    if (!Trinity::IsValidMapCoord(destX, destY, destZ) || !Trinity::IsValidMapCoord(x, y, z))
        return false;

    Vector3 oldDest = GetEndPosition();
    Vector3 dest(destX, destY, destZ);
    SetEndPosition(dest);

    Vector3 start(x, y, z);
    SetStartPosition(start);

    _forceDestination = forceDest;

    sLog->outDebug(LOG_FILTER_MAPS, "++ PathGenerator::CalculatePath() for %u \n", _sourceUnit->GetGUIDLow());

    // make sure navMesh works - we can run on map w/o mmap
    // check if the start and end point have a .mmtile loaded (can we pass via not loaded tile on the way?)
    if (!_navMesh || !_navMeshQuery || _sourceUnit->HasUnitState(UNIT_STATE_IGNORE_PATHFINDING) ||
        !HaveTile(start) || !HaveTile(dest))
    {
        BuildShortcut();
        _type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH);
        return true;
    }

    UpdateFilter();

    // check if destination moved - if not we can optimize something here
    // we are following old, precalculated path?
    float dist = _sourceUnit->GetObjectSize();
    if (oldDest != Vector3::zero() && InRange(oldDest, dest, dist, dist) && _pathPoints.size() > 2)
    {
        // our target is not moving - we just coming closer
        // we are moving on precalculated path - enjoy the ride
        sLog->outDebug(LOG_FILTER_MAPS, "++ PathGenerator::CalculatePath:: precalculated path\n");

        _pathPoints.erase(_pathPoints.begin());
        return false;
    }
    else
    {
        // target moved, so we need to update the poly path
        BuildPolyPath(start, dest);
        return true;
    }
}
Exemplo n.º 9
0
bool 
AirspaceWarningManager::Update(const AircraftState& state,
                               const GlidePolar &glide_polar,
                               const TaskStats &task_stats,
                               const bool circling,
                               const unsigned dt)
{
  bool changed = false;

  // update warning states
  if (airspaces.IsEmpty()) {
    // no airspaces, no warnings possible
    assert(warnings.empty());
    return false;
  }

  // save old state
  for (auto &w : warnings)
    w.SaveState();

  // check from strongest to weakest alerts
  UpdateInside(state, glide_polar);
  UpdateGlide(state, glide_polar);
  UpdateFilter(state, circling);
  UpdateTask(state, glide_polar, task_stats);

  // action changes
  for (auto it = warnings.begin(), end = warnings.end(); it != end;) {
    if (it->WarningLive(config.acknowledgement_time, dt)) {
      if (it->ChangedState())
        changed = true;

      it++;
    } else {
      ++serial;
      it = warnings.erase(it);
    }
  }

  // sort by importance, most severe top
  warnings.sort();

  return changed;
}
Exemplo n.º 10
0
bool Shooter::PIDUpdate() {
  timer_->Reset();

  double currEncoderPos = shooterEncoder_->GetRaw() / 128.0 * 2 * 3.1415926;

  double velocity_goal = 2 * 3.1415926 * targetVelocity_;
  double instantVelocity = ((currEncoderPos - prevPos_) / (1.0 / 50.0));

  flash_matrix(y_, (double)currEncoderPos);
  const double velocity_weight_scalar = 0.35;

  double u_min = ssc_->U_min->data[0];
  double u_max = ssc_->U_max->data[0];
  double x_hat1 = ssc_->X_hat->data[1];
  double k1 = ssc_->K->data[1];
  double k0 = ssc_->K->data[0];
  double x_hat0 = ssc_->X_hat->data[0];
  const double max_reference = (u_max - velocity_weight_scalar * (velocity_goal - x_hat1) * k1) / k0 + x_hat0;
  const double min_reference = (u_min - velocity_weight_scalar * (velocity_goal - x_hat1) * k1) / k0 + x_hat0;
  double minimum = (pidGoal_ < max_reference) ? pidGoal_ : max_reference;
  pidGoal_ = (minimum > min_reference) ? minimum : min_reference;

  flash_matrix(r_, pidGoal_, velocity_goal);
  pidGoal_ += ((1.0 / 50.0) * velocity_goal);
  ssc_->update(r_, y_);

  if (velocity_goal < 1.0) {
    SetLinearPower(0.0);
    pidGoal_ = currEncoderPos;
  } else {
    SetLinearPower(ssc_->U->data[0] / 12.0);
  }

  instantVelocity =  instantVelocity / (2 * 3.1415926);
  velocity_ = UpdateFilter(instantVelocity);

  prevPos_ = currEncoderPos;
  atTarget_ = fabs(velocity_ - targetVelocity_) < VELOCITY_THRESHOLD;
  DriverStationLCD::GetInstance()->PrintfLine(DriverStationLCD::kUser_Line2, "%.1f | %.1f rps", targetVelocity_,
                     velocity_);
  DriverStationLCD::GetInstance()->UpdateLCD();
  return atTarget_;
}
Exemplo n.º 11
0
void SppTabFltr::EnableFilter(int cb)
{
	// Get check state
	HWND hCB = GetDlgItem(m_hDlg,  cb);
	int Enable = Button_GetCheck(hCB);

	// If checked then this is equivalent to selecting the current selected
	// If Un-Checked then send -1 as selected filter
	if (Enable)
	{
		UpdateFilter();
		ShowChannelArea( m_hDlg, true);
	}
	else
	{
		ShowChannelArea( m_hDlg, false);
		SendMessage(m_TopDlgWnd, WMSPP_DLG_FILTER, (WPARAM)-1, 0);
	};

	m_FilterActive = (Enable != 0);
	SentFilterInfo2Parent();

}
void AlbumCoverManager::Init() {
  // View menu
  QActionGroup* filter_group = new QActionGroup(this);
  filter_all_ = filter_group->addAction(tr("All albums"));
  filter_with_covers_ = filter_group->addAction(tr("Albums with covers"));
  filter_without_covers_ = filter_group->addAction(tr("Albums without covers"));
  filter_all_->setCheckable(true);
  filter_with_covers_->setCheckable(true);
  filter_without_covers_->setCheckable(true);
  filter_group->setExclusive(true);
  filter_all_->setChecked(true);

  QMenu* view_menu = new QMenu(this);
  view_menu->addActions(filter_group->actions());

  ui_->view->setMenu(view_menu);

  // Context menu

  QList<QAction*> actions = album_cover_choice_controller_->GetAllActions();

  connect(album_cover_choice_controller_->cover_from_file_action(),
          SIGNAL(triggered()), this, SLOT(LoadCoverFromFile()));
  connect(album_cover_choice_controller_->cover_to_file_action(),
          SIGNAL(triggered()), this, SLOT(SaveCoverToFile()));
  connect(album_cover_choice_controller_->cover_from_url_action(),
          SIGNAL(triggered()), this, SLOT(LoadCoverFromURL()));
  connect(album_cover_choice_controller_->search_for_cover_action(),
          SIGNAL(triggered()), this, SLOT(SearchForCover()));
  connect(album_cover_choice_controller_->unset_cover_action(),
          SIGNAL(triggered()), this, SLOT(UnsetCover()));
  connect(album_cover_choice_controller_->show_cover_action(),
          SIGNAL(triggered()), this, SLOT(ShowCover()));

  context_menu_->addActions(actions);
  context_menu_->addSeparator();
  context_menu_->addAction(ui_->action_load);
  context_menu_->addAction(ui_->action_add_to_playlist);

  ui_->albums->installEventFilter(this);

  // Connections
  connect(ui_->artists, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
          SLOT(ArtistChanged(QListWidgetItem*)));
  connect(ui_->filter, SIGNAL(textChanged(QString)), SLOT(UpdateFilter()));
  connect(filter_group, SIGNAL(triggered(QAction*)), SLOT(UpdateFilter()));
  connect(ui_->view, SIGNAL(clicked()), ui_->view, SLOT(showMenu()));
  connect(ui_->fetch, SIGNAL(clicked()), SLOT(FetchAlbumCovers()));
  connect(cover_fetcher_, SIGNAL(AlbumCoverFetched(quint64,QImage,CoverSearchStatistics)),
          SLOT(AlbumCoverFetched(quint64,QImage,CoverSearchStatistics)));
  connect(ui_->action_fetch, SIGNAL(triggered()), SLOT(FetchSingleCover()));
  connect(ui_->albums, SIGNAL(doubleClicked(QModelIndex)), SLOT(AlbumDoubleClicked(QModelIndex)));
  connect(ui_->action_add_to_playlist, SIGNAL(triggered()), SLOT(AddSelectedToPlaylist()));
  connect(ui_->action_load, SIGNAL(triggered()), SLOT(LoadSelectedToPlaylist()));

  #ifdef Q_OS_DARWIN
    MacLineEdit* lineedit = new MacLineEdit(ui_->filter->parentWidget());
    lineedit->set_hint(ui_->filter->hint());
    delete ui_->filter;
    ui_->horizontalLayout->insertWidget(0, lineedit);
    filter_ = lineedit;
    connect(lineedit, SIGNAL(textChanged(QString)), SLOT(UpdateFilter()));
    lineedit->show();
  #else
    filter_ = ui_->filter;
  #endif

  // Restore settings
  QSettings s;
  s.beginGroup(kSettingsGroup);

  restoreGeometry(s.value("geometry").toByteArray());
  if (!ui_->splitter->restoreState(s.value("splitter_state").toByteArray())) {
    // Sensible default size for the artists view
    ui_->splitter->setSizes(QList<int>() << 200 << width() - 200);
  }

  cover_loader_->Start(true);
  CoverLoaderInitialised();
  cover_searcher_->Init(cover_fetcher_);

  new ForceScrollPerPixel(ui_->albums, this);
}
Exemplo n.º 13
0
FeedsAndFilters::FeedsAndFilters(QWidget *parent): QWidget(parent)
{
    //this->setAttribute(Qt::WA_AcceptTouchEvents, true); // для обработки нажатия на экран


    pFeeds = static_cast<DFRSSFilter*>(parent)->pFeeds; // приводим тип, т.к. parent у нас QWidget
    settings = static_cast<DFRSSFilter*>(parent)->settings; // приводим тип, т.к. parent у нас QWidget

    feedModel = new FeedModel(parent);

    feedList = new QTreeView (this);
    feedList->setModel(feedModel);
    feedList->setColumnWidth(0, 40); // чтобы не было видно численного значения "галочки"
    feedList->hideColumn(3); // спрячем столбец с id (он нужен для работы с БД)
    feedList->setSelectionMode(QAbstractItemView::ExtendedSelection);   // чтобы можно было выделить несколько
    feedList->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(feedList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slot_feeds_menu()));
    /*
#ifdef Q_OS_ANDROID
    feedList->setAttribute(Qt::WA_AcceptTouchEvents, true); // для обработки нажатия на экран
    feedList->setAttribute(Qt::WA_StaticContents);
#endif
*/
    filterModel = new FilterModel(parent);

    filterList = new QTreeView (this);
    filterList->setModel(filterModel);
    filterList->setColumnWidth(0, 40); // чтобы не было видно численного значения "галочки"
    filterList->hideColumn(3); // спрячем столбец с id (он нужен для работы с БД)
    filterList->setSelectionMode(QAbstractItemView::ExtendedSelection); // чтобы можно было выделить несколько
    filterList->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(filterList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slot_filters_menu()));
    /*
#ifdef Q_OS_ANDROID
    filterList->setAttribute(Qt::WA_AcceptTouchEvents, true); // для обработки нажатия на экран
    filterList->setAttribute(Qt::WA_StaticContents);
#endif
*/
/*
    h1_layout = new QHBoxLayout;
    feedAdd = new QPushButton;
    feedEdit = new QPushButton;
    feedDel = new QPushButton;
    h1_layout->addWidget(feedAdd);
    h1_layout->addWidget(feedEdit);
    h1_layout->addWidget(feedDel);
    feedAdd->setText(tr("Добавить"));
    feedEdit->setText(tr("Редактировать"));
    feedDel->setText(tr("Удалить"));

    h2_layout = new QHBoxLayout;
    filterAdd = new QPushButton;
    filterEdit = new QPushButton;
    filterDel = new QPushButton;
    h2_layout->addWidget(filterAdd);
    h2_layout->addWidget(filterEdit);
    h2_layout->addWidget(filterDel);
    filterAdd->setText(tr("Добавить"));
    filterEdit->setText(tr("Редактировать"));
    filterDel->setText(tr("Удалить"));

    h3_layout = new QHBoxLayout;
    filterCheckAll = new QPushButton;
    filterUncheckAll = new QPushButton;
    filterDeleteAll = new QPushButton;
    h3_layout->addWidget(filterCheckAll);
    h3_layout->addWidget(filterUncheckAll);
    h3_layout->addWidget(filterDeleteAll);
    filterCheckAll->setText(tr("Включить все"));
    filterUncheckAll->setText(tr("Отключить все"));
    filterDeleteAll->setText(tr("Удалить все"));

    vb_layout = new QVBoxLayout;
    vb_layout->addLayout(h2_layout);
    vb_layout->addLayout(h3_layout);
*/
    hint1 = new QLabel(this);
    hint2 = new QLabel(this);
    /*
    switch (settings->current_language)
    {
    case 1:
        hint1->setText("В ленте, не имеющей фильтров, будут выведены все новости");
        hint2->setText("Добавление, редактирование и удаление фильтров доступно только после выбора ленты, которой они принадлежат");
        setWindowTitle("RSS-ленты и фильтры");
        break;
    case 2:
        hint1->setText("Feed with no filters will have all news");
        hint2->setText("Choose feed to add, edit or delete its filters");
        setWindowTitle("RSS-feeds and filters");
        break;
    default:
        break;
    }
    */
    v_layout = new QVBoxLayout;
    //v_layout->addLayout(h1_layout);
    v_layout->addWidget(feedList);
    v_layout->addWidget(hint1);
    //v_layout->addLayout(vb_layout);
    v_layout->addWidget(filterList);
    v_layout->addWidget(hint2);

#ifdef Q_OS_ANDROID
    close_fnf_button = new QPushButton(tr("Закрыть"), this);
    connect(close_fnf_button, SIGNAL(clicked()), this, SLOT(close())); // запуск по нажатию кнопки
    v_layout->addWidget(close_fnf_button);
#endif

    setLayout(v_layout); // установка главного лэйаута

#ifdef Q_OS_WIN32
    resize(640,480);
#endif
    connect(feedList, SIGNAL(clicked(QModelIndex)), this, SLOT(UpdateFilter(QModelIndex)));
    connect(feedList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(ShowEditFeed(QModelIndex)));
    connect(filterList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(ShowEditFilter(QModelIndex)));
    /*
    connect(filterAdd, SIGNAL(clicked(bool)), this, SLOT(ShowAddFilter()));
    connect(feedAdd, SIGNAL(clicked(bool)), this, SLOT(ShowAddFeed()));
    connect(filterEdit, SIGNAL(clicked(bool)), this, SLOT(ShowEditFilter()));
    connect(feedEdit, SIGNAL(clicked(bool)), this, SLOT(ShowEditFeed()));
    connect(filterDel, SIGNAL(clicked(bool)), this, SLOT(FilterDel()));
    connect(feedDel, SIGNAL(clicked(bool)), this, SLOT(FeedDel()));
    connect(filterCheckAll, SIGNAL(clicked(bool)), this, SLOT(filters_check_all()));
    connect(filterUncheckAll, SIGNAL(clicked(bool)), this, SLOT(filters_uncheck_all()));
    connect(filterDeleteAll, SIGNAL(clicked(bool)), this, SLOT(filters_delete_all()));
    */
    this->setWindowIcon(QIcon(":/img/rss.ico"));

    // устанавливаем наш обработчик событий
    installEventFilter(this);
    /*
    feedList->installEventFilter(this);
    filterList->installEventFilter(this);
    */
}
PlaylistContainer::PlaylistContainer(QWidget* parent)
    : QWidget(parent),
      ui_(new Ui_PlaylistContainer),
      manager_(nullptr),
      undo_(nullptr),
      redo_(nullptr),
      playlist_(nullptr),
      starting_up_(true),
      tab_bar_visible_(false),
      tab_bar_animation_(new QTimeLine(500, this)),
      no_matches_label_(nullptr),
      filter_timer_(new QTimer(this)) {
  ui_->setupUi(this);

  no_matches_label_ = new QLabel(ui_->playlist);
  no_matches_label_->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
  no_matches_label_->setAttribute(Qt::WA_TransparentForMouseEvents);
  no_matches_label_->setWordWrap(true);
  no_matches_label_->raise();
  no_matches_label_->hide();

  // Set the colour of the no matches label to the disabled text colour
  QPalette no_matches_palette = no_matches_label_->palette();
  const QColor no_matches_color =
      no_matches_palette.color(QPalette::Disabled, QPalette::Text);
  no_matches_palette.setColor(QPalette::Normal, QPalette::WindowText,
                              no_matches_color);
  no_matches_palette.setColor(QPalette::Inactive, QPalette::WindowText,
                              no_matches_color);
  no_matches_label_->setPalette(no_matches_palette);

  // Make it bold
  QFont no_matches_font = no_matches_label_->font();
  no_matches_font.setBold(true);
  no_matches_label_->setFont(no_matches_font);

  settings_.beginGroup(kSettingsGroup);

  // Tab bar
  ui_->tab_bar->setExpanding(false);
  ui_->tab_bar->setMovable(true);

  connect(tab_bar_animation_, SIGNAL(frameChanged(int)),
          SLOT(SetTabBarHeight(int)));
  ui_->tab_bar->setMaximumHeight(0);

  // Connections
  connect(ui_->tab_bar, SIGNAL(currentChanged(int)), SLOT(Save()));
  connect(ui_->tab_bar, SIGNAL(Save(int)), SLOT(SavePlaylist(int)));

  // set up timer for delayed filter updates
  filter_timer_->setSingleShot(true);
  filter_timer_->setInterval(kFilterDelayMs);
  connect(filter_timer_, SIGNAL(timeout()), this, SLOT(UpdateFilter()));

  // Replace playlist search filter with native search box.
  connect(ui_->filter, SIGNAL(textChanged(QString)), SLOT(MaybeUpdateFilter()));
  connect(ui_->playlist, SIGNAL(FocusOnFilterSignal(QKeyEvent*)),
          SLOT(FocusOnFilter(QKeyEvent*)));
  ui_->filter->installEventFilter(this);
}