Beispiel #1
0
bool ExportMultiple::DoExport(int channels,
                              wxFileName name,
                              bool selectedOnly,
                              double t0,
                              double t1,
                              Tags tags)
{


   // Generate a unique name if we're not allowed to overwrite
   if (!mOverwrite->GetValue()) {
      int i = 2;
      wxString base(name.GetName());
      while (name.FileExists()) {
         name.SetName(wxString::Format(wxT("%s-%d"), base.c_str(), i++));
      }
   }

   // Call the format export routine
   bool rc = mPlugins[mFormatIndex]->Export(mProject,
                                            channels,
                                            name.GetFullPath(),
                                            selectedOnly,
                                            t0,
                                            t1,
                                            NULL,
                                            &tags);
   return rc;
}
// originally an ExportMultiple method. Append suffix if newName appears in otherNames.
void FileNames::MakeNameUnique(wxArrayString &otherNames, wxFileName &newName)
{
   if (otherNames.Index(newName.GetFullName(), false) >= 0) {
      int i=2;
      wxString orig = newName.GetName();
      do {
         newName.SetName(wxString::Format(wxT("%s-%d"), orig.c_str(), i));
         i++;
      } while (otherNames.Index(newName.GetFullName(), false) >= 0);
   }
   otherNames.Add(newName.GetFullName());
}
    /**
     * Function OpenRescueLibrary
     * Creates the new rescue library. Must be called before calling any PerformAction()s.
     */
    static void OpenRescueLibrary()
    {
        wxFileName fn( g_RootSheet->GetScreen()->GetFileName() );
        fn.SetName( fn.GetName() + wxT( "-rescue" ) );
        fn.SetExt( SchematicLibraryFileExtension );
        m_library_fn.SetPath( fn.GetPath() );
        m_library_fn.SetName( fn.GetName() );
        m_library_fn.SetExt( wxT( "lib" ) );

        std::unique_ptr<PART_LIB> rescue_lib( new PART_LIB( LIBRARY_TYPE_EESCHEMA,
                        fn.GetFullPath() ) );

        m_rescue_lib = std::move( rescue_lib );
    }
Beispiel #4
0
void FbExportParentData::Append(FbModel & model, int book, wxFileName &filename, int size)
{
	int number = 0;
	wxString name = filename.GetName();
	while (true) {
		wxString fullname = Lower(filename.GetFullName());
		size_t count = Count(model);
		bool ok = true;
		for (size_t i = 0; i < count; i++) {
			FbModelData * data = Items(model, i);
			if (!data) continue;
			if (Lower(data->GetValue(model)) == fullname) { ok = false; break; }
		}
		if (ok) break;
		filename.SetName(name + wxString::Format(wxT("(%d)"), ++number));
	}
	new FbExportChildData(model, this, book, filename, size);
}
void DIALOG_BUILD_BOM::Create_BOM_Lists( int  aTypeFile,
                                         bool aIncludeSubComponents,
                                         char aExportSeparatorSymbol,
                                         bool aRunBrowser )
{
    wxString    wildcard;

    static wxFileName fn;

    wxFileName  current = g_RootSheet->GetScreen()->GetFileName();

    s_ExportSeparatorSymbol = aExportSeparatorSymbol;

    if( !fn.HasName() || fn.GetName()==NAMELESS_PROJECT )
    {
        fn.SetName( current.GetName() );
    }
    // else use a previous run's name, because fn was set before and user
    // is probably just iteratively refining the BOM.

    if( fn.GetPath().IsEmpty() )
    {
        fn.SetPath( current.GetPath() );
    }
    // else use a previous run's path, because fn was set before and user
    // is probably just iteratively refining the BOM.

    wxString bomDesc = _( "Bill of Materials" );    // translate once, use twice.

    if( aTypeFile == 0 )
    {
        fn.SetExt( wxT( "lst" ) );
        wildcard = bomDesc + wxT( " (*.lst)|*.lst" );
    }
    else
    {
        fn.SetExt( wxT( "csv" ) );
        wildcard = bomDesc + wxT( " (*.csv)|*.csv" );
    }

    wxFileDialog dlg( this, bomDesc, fn.GetPath(),
                      fn.GetFullName(), wildcard, wxFD_SAVE );

    if( dlg.ShowModal() == wxID_CANCEL )
        return;

    fn = dlg.GetPath();        // remember path+filename+ext for subsequent runs.

    m_listFileName = dlg.GetPath();

    // Close dialog, then show the list (if so requested)

    switch( aTypeFile )
    {
    case 0: // list
        CreatePartsAndLabelsFullList( aIncludeSubComponents );
        break;

    case 1: // spreadsheet, Single Part per line
        CreateSpreadSheetPartsFullList( aIncludeSubComponents, s_Add_Location, false );
        break;

    case 2: // spreadsheet, group Part with same fields per line
        CreateSpreadSheetPartsFullList( aIncludeSubComponents, s_Add_Location, true );
        break;

    case 3: // spreadsheet, one value per line and no sub-component
        CreateSpreadSheetPartsShortList();
        break;
    }

    EndModal( 1 );

    if( aRunBrowser )
    {
        wxString editorname = wxGetApp().GetEditorName();
        wxString filename   = m_listFileName;
        AddDelimiterString( filename );
        ExecuteFile( this, editorname, filename );
    }
}