当前位置: 首页>>代码示例>>C++>>正文


C++ shared_ptr::Fits方法代码示例

本文整理汇总了C++中boost::shared_ptr::Fits方法的典型用法代码示例。如果您正苦于以下问题:C++ shared_ptr::Fits方法的具体用法?C++ shared_ptr::Fits怎么用?C++ shared_ptr::Fits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boost::shared_ptr的用法示例。


在下文中一共展示了shared_ptr::Fits方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: root

void ribi::QtMusicTheoryMultiScaleDialog::any_change()
{
  std::vector<boost::shared_ptr<Music::Chord> > chords_1 = Music::Chord::CreateAllChords();
  {
    //Obtain the root
    const Music::Note root(ui->root_1->currentText().toStdString());

    //Obtain the scale
    const boost::shared_ptr<Music::Scale> scale = Music::Scale::CreateScale(
      ui->scale_1->currentText().toLower().toStdString(),root);

    //Obtain the notes in the scale
    const std::vector<Music::Note> notes = scale->GetNotes();
    std::string notes_str;
    std::for_each(notes.begin(),notes.end(),
      [&notes_str](const Music::Note& note)
      {
        notes_str+=note.ToStr();
        notes_str+="-";
      }
    );
    notes_str.resize(notes_str.size() - 1);
    ui->notes_1->setText(notes_str.c_str());

    //Obtain the fitting chords in the scale
    {
      std::vector<boost::shared_ptr<Music::Chord> > tmp;
      std::copy_if(chords_1.begin(),chords_1.end(),std::back_inserter(tmp),
        [scale](const boost::shared_ptr<Music::Chord>& chord)
        {
          return scale->Fits(chord);
        }
      );
      chords_1.swap(tmp);
    }

    //Obtain only the chords the user wants to have displayed
    {
      std::vector<boost::shared_ptr<Music::Chord> > tmp;
      std::copy_if(chords_1.begin(),chords_1.end(),std::back_inserter(tmp),
        [this](const boost::shared_ptr<Music::Chord>& chord)
        {
          return
             (ui->display_6->isChecked() && dynamic_cast<const Music::Chord6*>(chord.get()))
          || (ui->display_7->isChecked() && dynamic_cast<const Music::Chord7*>(chord.get()))
          || (ui->display_aug->isChecked() && dynamic_cast<const Music::ChordAug*>(chord.get()))
          || (ui->display_dim->isChecked() && dynamic_cast<const Music::ChordDim*>(chord.get()))
          || (ui->display_m6->isChecked() && dynamic_cast<const Music::ChordMinor6*>(chord.get()))
          || (ui->display_m7->isChecked() && dynamic_cast<const Music::ChordMinor7*>(chord.get()))
          || (ui->display_major->isChecked() && dynamic_cast<const Music::ChordMajor*>(chord.get()))
          || (ui->display_minor->isChecked() && dynamic_cast<const Music::ChordMinor*>(chord.get()))
          ;
        }
      );
      chords_1.swap(tmp);
    }
  }
  std::vector<boost::shared_ptr<Music::Chord> > chords_2 = Music::Chord::CreateAllChords();
  {
    //Obtain the root
    const Music::Note root(ui->root_2->currentText().toStdString());

    //Obtain the scale
    const boost::shared_ptr<Music::Scale> scale = Music::Scale::CreateScale(
      ui->scale_2->currentText().toLower().toStdString(),root);

    //Obtain the notes in the scale
    const std::vector<Music::Note> notes = scale->GetNotes();
    std::string notes_str;
    std::for_each(notes.begin(),notes.end(),
      [&notes_str](const Music::Note& note)
      {
        notes_str+=note.ToStr();
        notes_str+="-";
      }
    );
    notes_str.resize(notes_str.size() - 1);
    ui->notes_2->setText(notes_str.c_str());

    //Obtain the fitting chords in the scale
    {
      std::vector<boost::shared_ptr<Music::Chord> > tmp;
      std::copy_if(chords_2.begin(),chords_2.end(),std::back_inserter(tmp),
        [scale](const boost::shared_ptr<Music::Chord>& chord)
        {
          return scale->Fits(chord);
        }
      );
      chords_2.swap(tmp);
    }

    //Obtain only the chords the user wants to have displayed
    {
      std::vector<boost::shared_ptr<Music::Chord> > tmp;
      std::copy_if(chords_2.begin(),chords_2.end(),std::back_inserter(tmp),
        [this](const boost::shared_ptr<Music::Chord>& chord)
        {
          return
             (ui->display_6->isChecked() && dynamic_cast<const Music::Chord6*>(chord.get()))
          || (ui->display_7->isChecked() && dynamic_cast<const Music::Chord7*>(chord.get()))
//.........这里部分代码省略.........
开发者ID:RLED,项目名称:ProjectRichelBilderbeek,代码行数:101,代码来源:qtmusictheorymultiscaledialog.cpp


注:本文中的boost::shared_ptr::Fits方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。