コード例 #1
0
ファイル: State.hpp プロジェクト: macsux/XCSoar
  void Refresh(fixed Time) {
    available.Expire(Time, fixed(10));
    if (!available)
      traffic.clear();

    for (unsigned i = traffic.size(); i-- > 0;)
      if (!traffic[i].Refresh(Time))
        traffic.quick_remove(i);

    NewTraffic = false;
  }
コード例 #2
0
void
FlarmDetails::LoadSecondary()
{
  LogStartUp(_T("OpenFLARMDetails"));

  // if (FLARM Details already there) delete them;
  if (!FLARM_Names.empty())
    FLARM_Names.clear();

  TLineReader *reader = OpenDataTextFile(_T("xcsoar-flarm.txt"));
  if (reader != NULL) {
    LoadSecondaryFile(*reader);
    delete reader;
  }
}
コード例 #3
0
void
TerrainXSRenderer::Draw(Canvas &canvas, const ChartRenderer &chart, const short *elevations) const
{
  const fixed max_distance = chart.GetXMax();

  StaticArray<RasterPoint, CrossSectionRenderer::NUM_SLICES + 2> points;

  canvas.SelectNullPen();

  RasterBuffer::TerrainType last_type = RasterBuffer::TerrainType::UNKNOWN;
  fixed last_distance = fixed(0);

  for (unsigned j = 0; j < CrossSectionRenderer::NUM_SLICES; ++j) {
    const fixed distance_factor =
        fixed(j) / (CrossSectionRenderer::NUM_SLICES - 1);
    const fixed distance = distance_factor * max_distance;

    short h = elevations[j];
    RasterBuffer::TerrainType type = RasterBuffer::GetTerrainType(h);

    if (type == RasterBuffer::TerrainType::WATER)
      h = 0;

    // Close and paint polygon
    if (j != 0 &&
        type != last_type &&
        last_type != RasterBuffer::TerrainType::UNKNOWN) {
      const fixed center_distance = (distance + last_distance) / 2;
      points.append() = chart.ToScreen(center_distance, fixed(0));
      points.append() = chart.ToScreen(center_distance, fixed(-500));

      DrawPolygon(canvas, last_type, points.begin(), points.size());
    }

    if (type != RasterBuffer::TerrainType::UNKNOWN) {
      if (j == 0) {
        // Start first polygon
        points.append() = chart.ToScreen(distance, fixed(-500));
        points.append() = chart.ToScreen(distance, fixed(h));
      } else if (type != last_type) {
        // Start new polygon
        points.clear();

        const fixed center_distance = (distance + last_distance) / 2;
        points.append() = chart.ToScreen(center_distance, fixed(-500));
        points.append() = chart.ToScreen(center_distance, fixed(0));
      }

      if (j + 1 == CrossSectionRenderer::NUM_SLICES) {
        // Close and paint last polygon
        points.append() = chart.ToScreen(distance, fixed(h));
        points.append() = chart.ToScreen(distance, fixed(-500));

        DrawPolygon(canvas, type, points.begin(), points.size());
      } else if (type == last_type && j != 0) {
        // Add single point to polygon
        points.append() = chart.ToScreen(distance, fixed(h));
      }
    }

    last_type = type;
    last_distance = distance;
  }
}
コード例 #4
0
ファイル: AvFilter.hpp プロジェクト: DRIZO/xcsoar
 /**
  * Resets filter (zero samples)
  */
 void Reset() {
   x.clear();
 }
コード例 #5
0
void
dlgWaypointDetailsShowModal(SingleWindow &parent, const Waypoint &_waypoint,
                            bool allow_navigation)
{
    waypoint = &_waypoint;

    wf = LoadDialog(CallBackTable, parent,
                    Layout::landscape ? _T("IDR_XML_WAYPOINTDETAILS_L") :
                    _T("IDR_XML_WAYPOINTDETAILS"));
    assert(wf != NULL);

    LastUsedWaypoints::Add(_waypoint);

    UpdateCaption(waypoint->name.c_str(), waypoint->file_num);

    wf->SetKeyDownNotify(FormKeyDown);

    wInfo = (DockWindow *)wf->FindByName(_T("info"));
    assert(wInfo != NULL);
    wInfo->SetWidget(new WaypointInfoWidget(UIGlobals::GetDialogLook(),
                                            _waypoint));

    wCommand = (DockWindow *)wf->FindByName(_T("commands"));
    assert(wCommand != NULL);
    wCommand->SetWidget(new WaypointCommandsWidget(UIGlobals::GetDialogLook(),
                        wf, _waypoint,
                        protected_task_manager));
    wCommand->Hide();

    wDetails = wf->FindByName(_T("frmDetails"));
    assert(wDetails != NULL);

    ListControl *wFilesList = (ListControl *)wf->FindByName(_T("Files"));
    assert(wFilesList != NULL);

    EditWindow *wDetailsText = (EditWindow *)wf->FindByName(_T("Details"));
    assert(wDetailsText != NULL);
    wDetailsText->SetText(waypoint->details.c_str());

#ifdef ANDROID
    int num_files = std::distance(waypoint->files_external.begin(),
                                  waypoint->files_external.end());
    if (num_files > 0) {
        wFilesList->SetPaintItemCallback(OnFileListItemPaint);
        wFilesList->SetCursorCallback(OnFileListEnter);
        wFilesList->SetActivateCallback(OnFileListEnter);

        unsigned list_height = wFilesList->GetItemHeight() * std::min(num_files, 5);
        wFilesList->Resize(wFilesList->GetWidth(), list_height);
        wFilesList->SetLength(num_files);

        PixelRect rc = wDetailsText->GetPosition();
        rc.top += list_height;
        wDetailsText->Move(rc);
    } else
#endif
        wFilesList->Hide();

    wImage = (PaintWindow *)wf->FindByName(_T("frmImage"));
    assert(wImage != NULL);
    wMagnify = (WndButton *)wf->FindByName(_T("cmdMagnify"));
    assert(wMagnify != NULL);
    wShrink = (WndButton *)wf->FindByName(_T("cmdShrink"));
    assert(wShrink != NULL);

    if (!allow_navigation) {
        WndButton* butnav = (WndButton *)wf->FindByName(_T("cmdPrev"));
        assert(butnav != NULL);
        butnav->Hide();

        butnav = (WndButton *)wf->FindByName(_T("cmdNext"));
        assert(butnav != NULL);
        butnav->Hide();

        butnav = (WndButton *)wf->FindByName(_T("cmdGoto"));
        assert(butnav != NULL);
        butnav->Hide();
    }

    for (auto it = waypoint->files_embed.begin(),
            it_end = waypoint->files_embed.end();
            it != it_end && !images.full(); it++) {
        TCHAR path[MAX_PATH];
        LocalPath(path, it->c_str());
        if (!images.append().LoadFile(path))
            images.shrink(images.size() - 1);
    }

    page = 0;

    NextPage(0); // JMW just to turn proper pages on/off

    wf->ShowModal();

    delete wf;

    for (auto image = images.begin(); image < images.end(); image++)
        image->Reset();

    images.clear();
}
コード例 #6
0
 void Clear() {
   labels.clear();
 }
コード例 #7
0
ファイル: dlgWaypointDetails.cpp プロジェクト: DRIZO/xcsoar
void 
dlgWaypointDetailsShowModal(const Waypoint &_waypoint,
                            bool allow_navigation)
{
  waypoint = &_waypoint;

  form = LoadDialog(CallBackTable, UIGlobals::GetMainWindow(),
                  Layout::landscape ? _T("IDR_XML_WAYPOINTDETAILS_L") :
                                      _T("IDR_XML_WAYPOINTDETAILS"));
  assert(form != nullptr);

  LastUsedWaypoints::Add(_waypoint);

  UpdateCaption();

  form->SetKeyDownFunction(FormKeyDown);

  info_widget = (DockWindow *)form->FindByName(_T("info"));
  assert(info_widget != nullptr);
  info_widget->SetWidget(new WaypointInfoWidget(UIGlobals::GetDialogLook(),
                                          _waypoint));

  commands_widget = (DockWindow *)form->FindByName(_T("commands"));
  assert(commands_widget != nullptr);
  commands_widget->SetWidget(new WaypointCommandsWidget(UIGlobals::GetDialogLook(),
                                                 form, _waypoint,
                                                 protected_task_manager));
  commands_widget->Hide();

  details_panel = form->FindByName(_T("frmDetails"));
  assert(details_panel != nullptr);

  ListControl *wFilesList = (ListControl *)form->FindByName(_T("Files"));
  assert(wFilesList != nullptr);

  LargeTextWindow *wDetailsText = (LargeTextWindow *)
    form->FindByName(_T("Details"));
  assert(wDetailsText != nullptr);
  wDetailsText->SetText(waypoint->details.c_str());

#ifdef ANDROID
  WaypointExternalFileListHandler handler;
  int num_files = std::distance(waypoint->files_external.begin(),
                                waypoint->files_external.end());
  if (num_files > 0) {
    wFilesList->SetItemRenderer(&handler);
    wFilesList->SetCursorHandler(&handler);

    unsigned list_height = wFilesList->GetItemHeight() * std::min(num_files, 5);
    wFilesList->Resize(wFilesList->GetWidth(), list_height);
    wFilesList->SetLength(num_files);

    PixelRect rc = wDetailsText->GetPosition();
    rc.top += list_height;
    wDetailsText->Move(rc);
  } else
#endif
    wFilesList->Hide();

  image_window = (PaintWindow *)form->FindByName(_T("frmImage"));
  assert(image_window != nullptr);
  magnify_button = (WndButton *)form->FindByName(_T("cmdMagnify"));
  assert(magnify_button != nullptr);
  shrink_button = (WndButton *)form->FindByName(_T("cmdShrink"));
  assert(shrink_button != nullptr);

  if (!allow_navigation) {
    for (const TCHAR *button_name :
         { _T("cmdPrev"), _T("cmdNext"), _T("cmdGoto") }) {
      Window *button = form->FindByName(button_name);
      assert(button != nullptr);
      button->Hide();
    }
  }

  for (auto it = waypoint->files_embed.begin(),
       it_end = waypoint->files_embed.end();
       it != it_end && !images.full(); it++) {
    TCHAR path[MAX_PATH];
    LocalPath(path, it->c_str());
    if (!images.append().LoadFile(path))
      images.shrink(images.size() - 1);
  }

  last_page = 2 + images.size();

  page = 0;
  UpdatePage();

  form->ShowModal();

  delete form;

  for (auto image = images.begin(); image < images.end(); image++)
    image->Reset();

  images.clear();
}
コード例 #8
0
ファイル: AvFilter.hpp プロジェクト: davidswelt/XCSoar
 /**
  * Resets filter (zero samples)
  *
  */
 void reset() {
   x.clear();
 }
コード例 #9
0
int main()
{
  // print my name and this assignment's title 
  cout << "LAB 3a: Write A Static Array Class Template\n"; 
  cout << "Programmer: Jacky Chow\n"; 
  cout << "Editor(s) used: Notepad++\n"; 
  cout << "Compiler(s) used: Visual C++\n"; 
  cout << "File: " << __FILE__ << endl; 
  cout << "Complied: " << __DATE__ << " at " << __TIME__ << endl << endl;
  
  vector<int> k;
  StaticArray<int, 10> a;

  //Test capacity() and size()
  cout << "Capacity of a should be 10\nCapacity returns " << a.capacity() << endl;
  assert(10 == a.capacity());
  cout << "Size should be 0\nSize returns " << a.size() << endl; 
  assert(0 == a.size());

  //Test kes()  
  k = a.keys();
  cout << "Keys of a in use: ";
  for(int i = 0; i < k.size(); i++)
    cout << k[i] << " ";
  cout << endl << endl;  

  //Test operator[] setter and getter
  a[3] = 7;
  cout << "a[3] was set to 7\na[3] is returns " << a[3] << endl;
  assert(7 == a[3]);
  cout << "Size should be 1\nSize returns " << a.size() << endl; 
  assert(1 == a.size());  
  k = a.keys();
  cout << "Keys of a in use: ";
  for(int i = 0; i < k.size(); i++)
    cout << k[i] << " ";
  cout << endl << endl; 

  a[5] = 20;
  cout << "a[5] was set to 20\na[5] is returns " << a[5] << endl;
  assert(20 == a[5]);
  a[7] = 15;
  cout << "a[7] was set to 15\na[7] is returns " << a[7] << endl;
  assert(15 == a[7]);
  a[9] = 3;
  cout << "a[9] was set to 3\na[9] is returns " << a[9] << endl;
  assert(3 == a[9]);  
  k = a.keys();
  cout << "Keys of a in use: ";
  for(int i = 0; i < k.size(); i++)
    cout << k[i] << " ";
  cout << endl << endl; 

  //Test containsKey()
  cout << "\nKey 1 is currently not in use.\n";
  if(a.containsKey(1)) cout << "Error, a[1] is not is use\n";
  else 
    cout << "containsKey() on a[1] returned a false\n";
  assert(!(a.containsKey(1)));

  a[1] = 8;
  cout << "a[1] was set to 8\na[1] is returns " << a[1] << endl;
  assert(8 == a[1]);
  cout << "Key 1 is now in use.\n";

  if(a.containsKey(1)) cout << "containsKey() on a[1] now returns true\n";
  else 
    cout << "Error! a[1] did not return a true\n";
  assert(a.containsKey(1));
  k = a.keys();
  cout << "Keys of a in use: ";
  for(int i = 0; i < k.size(); i++)
    cout << k[i] << " ";
  cout << endl << endl; 

  //Test deleteKey()
  a.deleteKey(1);
  cout << "a[1] was deleted\n";
  cout << "Key 1 is again not in use.\n";
  if(a.containsKey(1)) cout << "Error, a[1] is not is use\n";
  else 
    cout << "a[1] returned a false\n";
  k = a.keys();
  cout << "Keys of a in use: ";
  for(int i = 0; i < k.size(); i++)
    cout << k[i] << " ";
  cout << endl << endl; 

  //Cout values in current inUse keys    
  for(int i = 0; i < k.size(); i++)
  {
    cout << "a[" << k[i] << "] = " << a[k[i]] << endl;
  }

  // object copy testing
  {
    const StaticArray<int, 10> copy = a; // a read-only copy
    cout << endl;
    k = copy.keys();
    for(int i = 0; i < k.size(); i++)
    {
      cout << "copy1[" << k[i] << "] = " << copy[k[i]] << endl;
    }
    cout << endl;
    for (int i = 0; i < copy.capacity(); i++)
      cout << "copy1[" << i << "] = " << copy[i] << endl;
    cout << "Keys of a in use: ";
    for(int i = 0; i < k.size(); i++)
      cout << k[i] << " ";
    cout << endl << endl; 
  }

  // object assignment testing
  {
    cout << endl;
    StaticArray<int, 10> copy; copy = a;
    k = copy.keys();
    for(int i = 0; i < k.size(); i++)
    {
      cout << "copy2[" << k[i] << "] = " << copy[k[i]] << endl;
    }
    cout << endl;
    for (int i = 0; i < copy.capacity(); i++)
      cout << "copy2[" << i << "] = " << copy[i] << endl;
    cout << "Keys of a in use: ";
    for(int i = 0; i < k.size(); i++)
      cout << k[i] << " ";
    cout << endl << endl; 
  }  
  
  //Test clear()
  cout << "\nTestting clear() on a." << endl;
  a.clear();
  k = a.keys();
  cout << "Keys of a in use: ";
  for(int i = 0; i < k.size(); i++)
    cout << k[i] << " ";
  cout << endl;   
  cout << "Size should be 0\nSize returns " << a.size() << endl; 
  assert(0 == a.size());
}
コード例 #10
0
 virtual void StartFan() {
   // Clear the GeoPointVector for the next TriangleFan
   g.clear();
 }
コード例 #11
0
ファイル: Enum.hpp プロジェクト: CnZoom/XcSoarPull
 /**
  * Clear the list of choices.  This will not notify the
  * DataFieldListener.
  */
 void ClearChoices() {
   entries.clear();
   value = 0;
 }