bool SCH_EDIT_FRAME::LoadCmpToFootprintLinkFile() { wxString path = wxPathOnly( Prj().GetProjectFullName() ); wxFileDialog dlg( this, _( "Load Component Footprint Link File" ), path, wxEmptyString, ComponentFileExtensionWildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST ); if( dlg.ShowModal() == wxID_CANCEL ) return false; wxString filename = dlg.GetPath(); wxString title = wxT( "Eeschema " ) + GetBuildVersion() + wxT( ' ' ) + filename; SetTitle( title ); wxArrayString choices; choices.Add( _( "Keep existing footprint field visibility" ) ); choices.Add( _( "Show all footprint fields" ) ); choices.Add( _( "Hide all footprint fields" ) ); wxSingleChoiceDialog choiceDlg( this, _( "Select the footprint field visibility setting." ), _( "Change Visibility" ), choices ); if( choiceDlg.ShowModal() == wxID_CANCEL ) return false; bool forceVisibility = (choiceDlg.GetSelection() != 0 ); bool visibilityState = (choiceDlg.GetSelection() == 1 ); if( !ProcessCmpToFootprintLinkFile( filename, forceVisibility, visibilityState ) ) { wxString msg = wxString::Format( _( "Failed to open component-footprint link file '%s'" ), filename.GetData() ); DisplayError( this, msg ); return false; } OnModify(); return true; }
void PCB_EDIT_FRAME::ListNetsAndSelect( wxCommandEvent& event ) { NETINFO_ITEM* net; wxString netFilter; wxArrayString list; netFilter = wxT( "*" ); wxTextEntryDialog dlg( this, _( "Filter Net Names" ), _( "Net Filter" ), netFilter ); if( dlg.ShowModal() != wxID_OK ) return; // cancelled by user netFilter = dlg.GetValue( ); if( netFilter.IsEmpty() ) return; wxString Line; for( unsigned ii = 0; ii < GetBoard()->GetNetCount(); ii++ ) { net = GetBoard()->m_NetInfo.GetNetItem( ii ); if( !WildCompareString( netFilter, net->GetNetname(), false ) ) continue; Line.Printf( wxT( "net %3.3d: %s" ), net->GetNet(), GetChars( net->GetNetname() ) ); list.Add( Line ); } wxSingleChoiceDialog choiceDlg( this, wxEmptyString, _( "Select Net" ), list ); if( (choiceDlg.ShowModal() == wxID_CANCEL) || (choiceDlg.GetSelection() == wxNOT_FOUND) ) return; bool found = false; unsigned netcode = (unsigned) choiceDlg.GetSelection(); // Search for the net selected. for( unsigned ii = 0; ii < GetBoard()->GetNetCount(); ii++ ) { net = GetBoard()->FindNet( ii ); if( !WildCompareString( netFilter, net->GetNetname(), false ) ) continue; if( ii == netcode ) { netcode = net->GetNet(); found = true; break; } } if( found ) { INSTALL_UNBUFFERED_DC( dc, m_canvas ); if( GetBoard()->IsHighLightNetON() ) HighLight( &dc ); GetBoard()->SetHighLightNet( netcode ); HighLight( &dc ); } }
CCamera* CViacamController::SetUpCamera() { CCamera* cam; int numDevices; int camId= -1; // Load app local data ReadAppData(wxConfigBase::Get()); numDevices= CCameraEnum::GetNumDevices (); if (numDevices== 0) { wxMessageDialog errorMsg (NULL, _("Not detected any camera. Aborting"), _T("Enable Viacam"), wxOK | wxICON_ERROR); errorMsg.ShowModal(); return NULL; } // Try to find previously used camera if (m_cameraName.Length()> 0) { for (camId= 0; camId< numDevices; camId++) if (wxString(CCameraEnum::GetDeviceName (camId), wxConvLibc)== m_cameraName) break; if (camId== numDevices) camId= -1; // Not found } // Show selection dialog when needed if (camId== -1) { if(numDevices > 1) { wxArrayString strArray; for (camId= 0; camId< numDevices; camId++) strArray.Add (wxString(CCameraEnum::GetDeviceName (camId), wxConvLibc)); wxSingleChoiceDialog choiceDlg(NULL, _("Choose the camera to use"), _T("Enable Viacam"), strArray, NULL, wxDEFAULT_DIALOG_STYLE | wxOK | wxCANCEL | wxCENTRE); if (choiceDlg.ShowModal ()!= wxID_OK) return NULL; camId= choiceDlg.GetSelection(); m_cameraName= choiceDlg.GetStringSelection (); } else { camId= 0; m_cameraName= wxString(CCameraEnum::GetDeviceName (camId), wxConvLibc); } } cam= CCameraEnum::GetCamera(camId); if (!cam) return NULL; cam->SetHorizontalFlip (true); // Try to open the camera to ensure it works if (!cam->Open ()) { wxMessageDialog errorMsg (NULL, _("Can not initialize the camera.\nPerhaps is being used by other application."), _T("Enable Viacam"), wxOK | wxICON_ERROR); errorMsg.ShowModal(); delete cam; cam= NULL; ChangeCamera(); } else cam->Close(); WriteAppData(wxConfigBase::Get()); wxConfigBase::Get()->Flush(); return cam; }