void WinEDA_PcbFrame::Update_config(wxWindow * displayframe) /***********************************************************/ /* enregistrement de la config */ { wxString FullFileName; wxString mask; mask = "*" + g_Prj_Config_Filename_ext; FullFileName = GetScreen()->m_FileName.AfterLast('/'); ChangeFileNameExt(FullFileName, g_Prj_Config_Filename_ext); FullFileName = EDA_FileSelector(_("Save config file"), wxPathOnly(GetScreen()->m_FileName), /* Chemin par defaut */ FullFileName, /* nom fichier par defaut */ g_Prj_Config_Filename_ext, /* extension par defaut */ mask, /* Masque d'affichage */ displayframe, wxSAVE, TRUE ); if ( FullFileName == "") return; g_PcbDefaultGrid = GetScreen()->GetGrid(); Pcbdiv_grille = GetScreen()->m_Diviseur_Grille; /* ecriture de la configuration */ EDA_Appl->WriteProjectConfig(FullFileName, "/pcbnew", ParamCfgList); }
void EDA_BASE_FRAME::ImportHotkeyConfigFromFile( EDA_HOTKEY_CONFIG* aDescList, const wxString& aDefaultShortname ) { wxString ext = DEFAULT_HOTKEY_FILENAME_EXT; wxString mask = wxT( "*." ) + ext; #if 0 // pass in the project dir as an argument wxString path = wxPathOnly( Prj().GetProjectFullName() ); #else wxString path = wxGetCwd(); #endif wxFileName fn( aDefaultShortname ); fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT ); wxString filename = EDA_FileSelector( _( "Read Hotkey Configuration File:" ), path, fn.GetFullPath(), ext, mask, this, wxFD_OPEN, true ); if( filename.IsEmpty() ) return; ReadHotkeyConfigFile( filename, aDescList ); }
void WinEDA_MainFrame::Save_Prj_Config(void) /*********************************************/ { wxString FullFileName; wxString mask( wxT("*")); g_Prj_Config_Filename_ext = wxT(".pro"); mask += g_Prj_Config_Filename_ext; FullFileName = m_PrjFileName; ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext); FullFileName = EDA_FileSelector(_("Save config file"), wxGetCwd(), /* Chemin par defaut */ FullFileName, /* nom fichier par defaut */ g_Prj_Config_Filename_ext, /* extension par defaut */ mask, /* Masque d'affichage */ this, wxSAVE, TRUE ); if ( FullFileName.IsEmpty() ) return; /* ecriture de la configuration */ EDA_Appl->WriteProjectConfig(FullFileName, wxT("/general"), CfgParamList); }
void WinEDA_GerberFrame::Update_config(void) /******************************************/ /* creation du fichier de config */ { wxString FullFileName; wxString mask("*"), g_Prj_Config_Filename_ext = ".cnf"; mask += g_Prj_Config_Filename_ext; FullFileName = "gerbview"; ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext ); FullFileName = EDA_FileSelector(_("Save config file"), "", /* Chemin par defaut */ FullFileName, /* nom fichier par defaut */ g_Prj_Config_Filename_ext, /* extension par defaut */ mask, /* Masque d'affichage */ this, wxSAVE, TRUE ); if ( FullFileName == "") return; /* ecriture de la configuration */ EDA_Appl->WriteProjectConfig(FullFileName, GROUP, ParamCfgList); }
void EDA_BASE_FRAME::ExportHotkeyConfigToFile( EDA_HOTKEY_CONFIG* aDescList, const wxString& aDefaultShortname ) { wxString ext = DEFAULT_HOTKEY_FILENAME_EXT; wxString mask = wxT( "*." ) + ext; #if 0 wxString path = wxPathOnly( Prj().GetProjectFullName() ); #else wxString path = wxGetCwd(); #endif wxFileName fn( aDefaultShortname ); fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT ); wxString filename = EDA_FileSelector( _( "Write Hotkey Configuration File:" ), path, fn.GetFullPath(), ext, mask, this, wxFD_OPEN | wxFD_SAVE, true ); if( filename.IsEmpty() ) return; WriteHotkeyConfig( aDescList, &filename ); }
void WinEDA_ModuleEditFrame::Export_Module(MODULE* ptmod, bool createlib) /************************************************************************/ /* Genere 1 fichier type Empreinte a partir de la description du module sur PCB */ { wxString FullFileName, Mask( wxT("*") ); char Line[1025]; FILE * dest; wxString msg, path; if ( ptmod == NULL ) return; ptmod->m_LibRef = ptmod->m_Reference->m_Text; FullFileName = ptmod->m_LibRef; FullFileName += createlib ? LibExtBuffer : EXT_CMP; Mask += createlib ? LibExtBuffer : EXT_CMP; if ( createlib ) path = g_RealLibDirBuffer; FullFileName = EDA_FileSelector( createlib ? _("Create lib") : _("Export Module:"), path, /* Chemin par defaut */ FullFileName, /* nom fichier par defaut */ createlib ? LibExtBuffer : EXT_CMP, /* extension par defaut */ Mask, /* Masque d'affichage */ this, wxSAVE, TRUE ); if ( FullFileName.IsEmpty() ) return; if ( createlib && wxFileExists(FullFileName) ) { msg.Printf( _("File %s exists, OK to replace ?"), FullFileName.GetData()); if( ! IsOK(this, msg) ) return; } /* Generation du fichier Empreinte */ if ( (dest = wxFopen(FullFileName, wxT("wt")) ) == NULL ) { msg.Printf( _("Unable to create <%s>"),FullFileName.GetData()) ; DisplayError(this, msg) ; return ; } fprintf(dest,"%s %s\n", ENTETE_LIBRAIRIE, DateAndTime(Line)); fputs("$INDEX\n",dest); fprintf(dest,"%s\n", CONV_TO_UTF8(ptmod->m_LibRef) ); fputs("$EndINDEX\n",dest); m_Pcb->m_Modules->WriteDescr(dest); fputs("$EndLIBRARY\n",dest); fclose(dest) ; msg.Printf( _("Module exported in file <%s>"),FullFileName.GetData()) ; DisplayInfo(this, msg) ; }
void WinEDA_CvpcbFrame::SaveQuitCvpcb(wxCommandEvent& event) /**********************************************************/ { wxString Mask, FullFileName; Mask = "*" + NetExtBuffer; if ( NetNameBuffer != "" ) { FullFileName = NetNameBuffer; ChangeFileNameExt(FullFileName, NetExtBuffer); } FullFileName = EDA_FileSelector( _("Save Net List & Cmp"), NetDirBuffer, /* Chemin par defaut */ FullFileName, /* nom fichier par defaut */ NetExtBuffer, /* extension par defaut */ Mask, /* Masque d'affichage */ this, wxSAVE, TRUE ); if ( FullFileName == "" ) return; FFileName = FullFileName; NetNameBuffer = FullFileName; if( SaveNetList() ) { modified = 0; Close(TRUE); } }
/* * Browse plugin files, add a new panel * and set m_CommandStringCtrl field */ void NETLIST_DIALOG::AddNewPluginPanel( wxCommandEvent& event ) { wxString FullFileName, Mask, Path; Mask = wxT( "*" ); Path = wxGetApp().GetExecutablePath(); FullFileName = EDA_FileSelector( _( "Plugin files:" ), Path, FullFileName, wxEmptyString, Mask, this, wxFD_OPEN, true ); if( FullFileName.IsEmpty() ) return; NETLIST_PAGE_DIALOG* CurrPage; CurrPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage(); if( CurrPage == NULL ) return; // Creates a default command line, suitable for external tool xslproc: // try to build a default command line depending on plugin extension wxString cmdLine; wxFileName fn( FullFileName ); wxString ext = fn.GetExt(); if( ext == wxT("xsl" ) ) cmdLine.Printf(wxT("xsltproc -o \"%%O\" \"%s\" \"%%I\""), GetChars(FullFileName) ); else if( ext == wxT("exe" ) || ext.IsEmpty() ) cmdLine.Printf(wxT("\"%s\" > \"%%O\" < \"%%I\""), GetChars(FullFileName) ); else cmdLine.Printf(wxT("\"%s\""), GetChars(FullFileName) ); CurrPage->m_CommandStringCtrl->SetValue( cmdLine ); /* Get a title for this page */ wxString title = CurrPage->m_TitleStringCtrl->GetValue(); if( title.IsEmpty() ) DisplayInfoMessage( this, _( "Do not forget to choose a title for this netlist control page" ) ); }
void WinEDA_ConfigFrame::AddOrInsertLibrary(wxCommandEvent& event) /****************************************************************/ /* Insert or add a library to the existing library list: New library is put in list before (insert) or after (add) the selection */ { int ii; wxString FullLibName,ShortLibName, Mask; ii = m_ListLibr->GetSelection(); if ( ii < 0 ) ii = 0; ChangeSetup(); if( event.GetId() == ADD_LIB) { if( g_LibName_List.GetCount() != 0 ) ii ++; /* Add after selection */ } Mask = wxT("*") + g_LibExtBuffer; FullLibName = EDA_FileSelector( _("Library files:"), g_RealLibDirBuffer, /* Chemin par defaut */ wxEmptyString, /* nom fichier par defaut */ g_LibExtBuffer, /* extension par defaut */ Mask, /* Masque d'affichage */ this, wxOPEN, TRUE ); if ( FullLibName.IsEmpty() ) return; ShortLibName = MakeReducedFileName(FullLibName,g_RealLibDirBuffer,g_LibExtBuffer); //Add or insert new library name if (FindLibrary(ShortLibName) == NULL) { m_LibListChanged = TRUE; g_LibName_List.Insert(ShortLibName, ii); m_ListLibr->Clear(); m_ListLibr->InsertItems(g_LibName_List, 0); } else DisplayError(this, _("Library already in use")); }
const wxString& PGM_BASE::GetEditorName() { wxString editorname = m_editor_name; if( !editorname ) { // Get the preferred editor name from environment variable first. if(!wxGetEnv( wxT( "EDITOR" ), &editorname )) { // If there is no EDITOR variable set, try the desktop default #ifdef __WXMAC__ editorname = "/usr/bin/open"; #elif __WXX11__ editorname = "/usr/bin/xdg-open"; #endif } } if( !editorname ) // We must get a preferred editor name { DisplayInfoMessage( NULL, _( "No default editor found, you must choose it" ) ); wxString mask( wxT( "*" ) ); #ifdef __WINDOWS__ mask += wxT( ".exe" ); #endif editorname = EDA_FileSelector( _( "Preferred Editor:" ), wxEmptyString, wxEmptyString, wxEmptyString, mask, NULL, wxFD_OPEN, true ); } if( !editorname.IsEmpty() ) { m_editor_name = editorname; m_common_settings->Write( wxT( "Editor" ), m_editor_name ); } return m_editor_name; }
/** * Function ExportHotkeyConfigToFile * Prompt the user for an old hotkey file to read, and read it. * @param aDescList = current hotkey list descr. to initialize. */ void EDA_BASE_FRAME::ExportHotkeyConfigToFile( struct EDA_HOTKEY_CONFIG* aDescList ) { wxString ext = DEFAULT_HOTKEY_FILENAME_EXT; wxString mask = wxT( "*." ) + ext; wxString path = wxGetCwd(); wxString filename = Kiface().Name() + wxT( "." ) + ext; filename = EDA_FileSelector( _( "Write Hotkey Configuration File:" ), path, filename, ext, mask, this, wxFD_OPEN | wxFD_SAVE, true ); if( filename.IsEmpty() ) return; WriteHotkeyConfig( aDescList, &filename ); }
/** * Function ImportHotkeyConfigFromFile * Prompt the user for an old hotkey file to read, and read it. * @param aDescList = current hotkey list descr. to initialize. */ void EDA_BASE_FRAME::ImportHotkeyConfigFromFile( struct EDA_HOTKEY_CONFIG* aDescList ) { wxString ext = DEFAULT_HOTKEY_FILENAME_EXT; wxString mask = wxT( "*." ) + ext; wxString path = wxGetCwd(); wxString filename = Kiface().Name() + wxT( '.' ) + ext; filename = EDA_FileSelector( _( "Read Hotkey Configuration File:" ), path, filename, ext, mask, this, wxFD_OPEN, true ); if( filename.IsEmpty() ) return; ReadHotkeyConfigFile( filename, aDescList ); }
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::BrowseAndSelectDocFile( wxCommandEvent& event ) { wxString FullFileName, mask; wxString docpath, filename; docpath = wxGetApp().ReturnLastVisitedLibraryPath( wxT( "doc" ) ); mask = wxT( "*" ); FullFileName = EDA_FileSelector( _( "Doc Files" ), docpath, /* Chemin par defaut */ wxEmptyString, /* nom fichier par defaut */ wxEmptyString, /* extension par defaut */ mask, /* Masque d'affichage */ this, wxFD_OPEN, true ); if( FullFileName.IsEmpty() ) return; /* If the path is already in the library search paths * list, just add the library name to the list. Otherwise, add * the library name with the full or relative path. * the relative path, when possible is preferable, * because it preserve use of default libraries paths, when the path is a sub path of * these default paths */ wxFileName fn = FullFileName; wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() ); filename = wxGetApp().ReturnFilenameWithRelativePathInLibPath( FullFileName ); // Filenames are always stored in unix like mode, ie separator "\" is stored as "/" // to ensure files are identical under unices and windows #ifdef __WINDOWS__ filename.Replace( wxT( "\\" ), wxT( "/" ) ); #endif m_DocfileCtrl->SetValue( filename ); }
bool WinEDA_CvpcbFrame::ReadInputNetList(const wxString & FullFileName) /**********************************************************************/ /* Routine de selection du nom de la netliste d'entree, et de lecure de celle-ci */ { wxString Mask, Line; if ( FullFileName.IsEmpty() ) { if( ! NetInExtBuffer.IsEmpty() ) Mask = wxT("*") + NetInExtBuffer; else Mask = wxT("*.net"); Line = EDA_FileSelector(_("Load Net List"), NetDirBuffer, /* Chemin par defaut */ NetInNameBuffer, /* nom fichier par defaut */ NetInExtBuffer, /* extension par defaut */ Mask, /* Masque d'affichage */ this, 0, FALSE ); if ( Line.IsEmpty()) return(FALSE); } else Line = FullFileName; NetInNameBuffer = Line; NetNameBuffer = Line; FFileName = NetInNameBuffer; /* Mise a jour du titre de la fenetre principale */ Line = Main_Title + wxT(" ") + NetInNameBuffer; SetTitle(Line); ReadNetListe(); return(TRUE); }
wxString GetEditorName(void) /***************************/ /* Return the prefered editor name */ { wxString editorname = g_EditorName; if ( editorname == "" ) // We get the prefered editor name from environment variable { wxGetEnv("EDITOR", &editorname); } if ( editorname == "" ) // We must get a prefered editor name { DisplayInfo(NULL, _("No default editor found, you must choose it") ); wxString mask; #ifdef __WINDOWS__ mask = "*.exe"; #endif editorname = EDA_FileSelector(_("Prefered Editor:"), "", /* Default path */ "", /* default filename */ "", /* default filename extension */ mask, /* filter for filename list */ NULL, /* parent frame */ wxOPEN, /* wxSAVE, wxOPEN ..*/ TRUE /* true = keep the current path */ ); } if ( (editorname != "") && EDA_Appl->m_EDA_CommonConfig) { g_EditorName = editorname; EDA_Appl->m_EDA_CommonConfig->Write("Editor", g_EditorName); } return g_EditorName; }
MODULE * WinEDA_ModuleEditFrame::Import_Module(wxDC * DC) /*********************************************************/ /* Importation de modules Hors librairie Lit 1 fichier type Empreinte et place le module sur PCB */ { int NbLine = 0; char Line[1024]; wxString CmpFullFileName; FILE * dest; MODULE * module = NULL; /* Lecture Fichier module */ CmpFullFileName = EDA_FileSelector( _("Import Module:"), wxEmptyString, /* Chemin par defaut */ wxEmptyString, /* nom fichier par defaut */ EXT_CMP, /* extension par defaut */ EXT_CMP_MASK, /* Masque d'affichage */ this, wxOPEN, TRUE ); if ( CmpFullFileName == wxEmptyString ) return NULL; if ( (dest = wxFopen(CmpFullFileName, wxT("rt")) ) == NULL ) { wxString msg; msg.Printf( _("File <%s> not found"), CmpFullFileName.GetData()); DisplayError(this, msg) ; return NULL; } /* Lecture Entete */ GetLine(dest, Line, &NbLine); if(strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB) != 0) { DisplayError(this, _("Not a module file")); return NULL; } /* Lecture du fichier: recherche du debut de la descr module */ while( GetLine(dest, Line, &NbLine) != NULL) { if(strnicmp( Line,"$MODULE",7) == 0) break; } module = new MODULE(m_Pcb); module->ReadDescr(dest, &NbLine); fclose(dest); /* Mise a jour du chainage */ if( m_Pcb->m_Modules ) { m_Pcb->m_Modules->Pback = module; } module->Pnext = m_Pcb->m_Modules; module->Pback = m_Pcb; m_Pcb->m_Modules = module; /* Affichage des caracteristiques : */ module->Display_Infos(this); Place_Module(module, DC) ; m_Pcb->m_Status_Pcb = 0 ; build_liste_pads(); return module; }
/***************************************************************************** * Routine to save an EESchema file. * * FileSave controls how the file is to be saved - under what name. * * Returns TRUE if the file has been saved. * *****************************************************************************/ bool WinEDA_SchematicFrame::SaveEEFile(BASE_SCREEN *Window, int FileSave) { wxString msg; wxString Name, BakName; const wxChar **LibNames; char * layer, *width; int ii, shape; bool Failed = FALSE; EDA_BaseStruct *Phead; Ki_PageDescr * PlotSheet; FILE *f; wxString dirbuf; if ( Window == NULL ) Window = ActiveScreen; /* If no name exists in the window yet - save as new. */ if( Window->m_FileName.IsEmpty() ) FileSave = FILE_SAVE_NEW; switch (FileSave) { case FILE_SAVE_AS: dirbuf = wxGetCwd() + STRING_DIR_SEP; Name = MakeFileName(dirbuf, Window->m_FileName, g_SchExtBuffer); /* Rename the old file to a '.bak' one: */ BakName = Name; if ( wxFileExists(Name) ) { ChangeFileNameExt(BakName, wxT(".bak")); wxRemoveFile(BakName); /* delete Old .bak file */ if( ! wxRenameFile(Name, BakName) ) { DisplayError(this, wxT("Warning: unable to rename old file"), 10); } } break; case FILE_SAVE_NEW: { wxString mask = wxT("*") + g_SchExtBuffer; Name = EDA_FileSelector(_("Schematic files:"), wxEmptyString, /* Chemin par defaut */ Window->m_FileName, /* nom fichier par defaut, et resultat */ g_SchExtBuffer, /* extension par defaut */ mask, /* Masque d'affichage */ this, wxSAVE, FALSE ); if ( Name.IsEmpty() ) return FALSE; Window->m_FileName = Name; dirbuf = wxGetCwd() + STRING_DIR_SEP; Name = MakeFileName(dirbuf, Name, g_SchExtBuffer); break; } default: break; } if ((f = wxFopen(Name, wxT("wt"))) == NULL) { msg = _("Failed to create file ") + Name; DisplayError(this, msg); return FALSE; } msg = _("Save file ") + Name; Affiche_Message(msg); LibNames = GetLibNames(); BakName.Empty(); // temporary buffer! for (ii = 0; LibNames[ii] != NULL; ii++) { if (ii > 0) BakName += wxT(","); BakName += LibNames[ii]; } MyFree( LibNames); if (fprintf(f, "%s %s %d\n", EESCHEMA_FILE_STAMP, SCHEMATIC_HEAD_STRING, EESCHEMA_VERSION) == EOF || fprintf(f, "LIBS:%s\n", CONV_TO_UTF8(BakName)) == EOF) { DisplayError(this, _("File write operation failed.")); fclose(f); return FALSE; } Window->ClrModify(); SaveLayers(f); /* Sauvegarde des dimensions du schema, des textes du cartouche.. */ PlotSheet = Window->m_CurrentSheet; fprintf(f,"$Descr %s %d %d\n",CONV_TO_UTF8(PlotSheet->m_Name), PlotSheet->m_Size.x, PlotSheet->m_Size.y); fprintf(f,"Sheet %d %d\n",Window->m_SheetNumber, Window->m_NumberOfSheet); fprintf(f,"Title \"%s\"\n",CONV_TO_UTF8(Window->m_Title)); fprintf(f,"Date \"%s\"\n",CONV_TO_UTF8(Window->m_Date)); fprintf(f,"Rev \"%s\"\n",CONV_TO_UTF8(Window->m_Revision)); fprintf(f,"Comp \"%s\"\n",CONV_TO_UTF8(Window->m_Company)); fprintf(f,"Comment1 \"%s\"\n", CONV_TO_UTF8(Window->m_Commentaire1)); fprintf(f,"Comment2 \"%s\"\n", CONV_TO_UTF8(Window->m_Commentaire2)); fprintf(f,"Comment3 \"%s\"\n", CONV_TO_UTF8(Window->m_Commentaire3)); fprintf(f,"Comment4 \"%s\"\n", CONV_TO_UTF8(Window->m_Commentaire4)); fprintf(f,"$EndDescr\n"); /* Sauvegarde des elements du dessin */ Phead = Window->EEDrawList; while (Phead) { switch(Phead->m_StructType) { case DRAW_LIB_ITEM_STRUCT_TYPE: /* Its a library item. */ SavePartDescr( f, (EDA_SchComponentStruct *) Phead); break; case DRAW_SHEET_STRUCT_TYPE: /* Its a Sheet item. */ SaveSheetDescr( f, (DrawSheetStruct *) Phead); break; case DRAW_SEGMENT_STRUCT_TYPE: /* Its a Segment item. */ #undef STRUCT #define STRUCT ((EDA_DrawLineStruct *) Phead) layer = "Notes"; width = "Line"; if (STRUCT->m_Layer == LAYER_WIRE) layer = "Wire"; if (STRUCT->m_Layer == LAYER_BUS) layer = "Bus"; if( STRUCT->m_Width != GR_NORM_WIDTH) layer = "Bus"; if (fprintf(f, "Wire %s %s\n", layer, width ) == EOF) { Failed = TRUE; break; } if (fprintf(f, "\t%-4d %-4d %-4d %-4d\n", STRUCT->m_Start.x,STRUCT->m_Start.y, STRUCT->m_End.x,STRUCT->m_End.y) == EOF) { Failed = TRUE; break; } break; case DRAW_BUSENTRY_STRUCT_TYPE: /* Its a Raccord item. */ #undef STRUCT #define STRUCT ((DrawBusEntryStruct *) Phead) layer = "Wire"; width = "Line"; if (STRUCT->m_Layer == LAYER_BUS) { layer = "Bus"; width = "Bus"; } if (fprintf(f, "Entry %s %s\n", layer, width) == EOF) { Failed = TRUE; break; } if( fprintf(f, "\t%-4d %-4d %-4d %-4d\n", STRUCT->m_Pos.x,STRUCT->m_Pos.y, STRUCT->m_End().x,STRUCT->m_End().y) == EOF) { Failed = TRUE; break; } break; case DRAW_POLYLINE_STRUCT_TYPE: /* Its a polyline item. */ #undef STRUCT #define STRUCT ((DrawPolylineStruct *) Phead) layer = "Notes"; width = "Line"; if (STRUCT->m_Layer == LAYER_WIRE) layer = "Wire"; if (STRUCT->m_Layer == LAYER_BUS) layer = "Bus"; if( STRUCT->m_Width != GR_NORM_WIDTH) width = "Bus"; if (fprintf(f, "Poly %s %s %d\n", width, layer, STRUCT->m_NumOfPoints) == EOF) { Failed = TRUE; break; } for (ii = 0; ii < STRUCT->m_NumOfPoints; ii++) { if (fprintf(f, "\t%-4d %-4d\n", STRUCT->m_Points[ii*2], STRUCT->m_Points[ii*2+1]) == EOF) { Failed = TRUE; break; } } break; case DRAW_JUNCTION_STRUCT_TYPE: /* Its a connection item. */ #undef STRUCT #define STRUCT ((DrawJunctionStruct *) Phead) if (fprintf(f, "Connection ~ %-4d %-4d\n", STRUCT->m_Pos.x, STRUCT->m_Pos.y) == EOF) { Failed = TRUE; } break; case DRAW_NOCONNECT_STRUCT_TYPE: /* Its a NoConnection item. */ #undef STRUCT #define STRUCT ((DrawNoConnectStruct *) Phead) if (fprintf(f, "NoConn ~ %-4d %-4d\n", STRUCT->m_Pos.x, STRUCT->m_Pos.y) == EOF) { Failed = TRUE; } break; case DRAW_TEXT_STRUCT_TYPE: /* Its a text item. */ #undef STRUCT #define STRUCT ((DrawTextStruct *) Phead) if (fprintf(f, "Text Notes %-4d %-4d %-4d %-4d ~\n%s\n", STRUCT->m_Pos.x, STRUCT->m_Pos.y, STRUCT->m_Orient, STRUCT->m_Size.x, CONV_TO_UTF8(STRUCT->m_Text)) == EOF) Failed = TRUE; break; case DRAW_LABEL_STRUCT_TYPE: /* Its a label item. */ #undef STRUCT #define STRUCT ((DrawLabelStruct *) Phead) shape = '~'; if (fprintf(f, "Text Label %-4d %-4d %-4d %-4d %c\n%s\n", STRUCT->m_Pos.x, STRUCT->m_Pos.y, STRUCT->m_Orient, STRUCT->m_Size.x, shape, CONV_TO_UTF8(STRUCT->m_Text)) == EOF) Failed = TRUE; break; case DRAW_GLOBAL_LABEL_STRUCT_TYPE: /* Its a Global label item. */ #undef STRUCT #define STRUCT ((DrawGlobalLabelStruct *) Phead) shape = STRUCT->m_Shape; if (fprintf(f, "Text GLabel %-4d %-4d %-4d %-4d %s\n%s\n", STRUCT->m_Pos.x, STRUCT->m_Pos.y, STRUCT->m_Orient, STRUCT->m_Size.x, SheetLabelType[shape], CONV_TO_UTF8(STRUCT->m_Text)) == EOF) Failed = TRUE; break; case DRAW_MARKER_STRUCT_TYPE: /* Its a marker item. */ #undef STRUCT #define STRUCT ((DrawMarkerStruct *) Phead) if( STRUCT->GetComment() ) msg = STRUCT->GetComment(); else msg.Empty(); if (fprintf(f, "Kmarq %c %-4d %-4d \"%s\" F=%X\n", (int) STRUCT->m_Type + 'A', STRUCT->m_Pos.x, STRUCT->m_Pos.y, CONV_TO_UTF8(msg), STRUCT->m_MarkFlags) == EOF) { Failed = TRUE; } break; case DRAW_SHEETLABEL_STRUCT_TYPE : case DRAW_PICK_ITEM_STRUCT_TYPE : break; default: break; } if (Failed) { DisplayError(this, _("File write operation failed.")); break; } Phead = Phead->Pnext; } if (fprintf(f, "$EndSCHEMATC\n") == EOF) Failed = TRUE; fclose(f); if (FileSave == FILE_SAVE_NEW) Window->m_FileName = Name; return !Failed; }
void WinEDA_BasePcbFrame::Archive_Modules(const wxString & LibName, bool NewModulesOnly) /***********************************************************************/ /* Sauve en Librairie: tous les nouveaux modules ( c.a.d. les modules n'existant pas deja (si NewModulesOnly == TRUE) tous les modules (si NewModulesOnly == FALSE) */ { int ii, NbModules = 0; float Pas; MODULE * Module; wxString FullFileName = LibName; if ( m_Pcb->m_Modules == NULL ) { DisplayInfo(this, _(" No modules to archive!") ); return; } if ( FullFileName.IsEmpty() ) { wxString Mask = wxT("*") + LibExtBuffer; FullFileName = EDA_FileSelector( _("Library"), g_RealLibDirBuffer, /* Chemin par defaut */ FullFileName, /* nom fichier par defaut */ LibExtBuffer, /* extension par defaut */ Mask, /* Masque d'affichage */ this, wxSAVE, TRUE ); if ( FullFileName.IsEmpty() ) return; } bool file_exists = wxFileExists(FullFileName); if ( ! NewModulesOnly && file_exists ) { wxString msg; msg.Printf( _("File %s exists, OK to replace ?"), FullFileName.GetData()); if( ! IsOK(this, msg) ) return; } DrawPanel->m_AbortRequest = FALSE; // Create a new, empty library if no old lib, or if archive all modules if ( ! NewModulesOnly || ! file_exists ) { FILE * lib_module; if ((lib_module = wxFopen(FullFileName, wxT("w+t"))) == NULL ) { wxString msg = _("Unable to create ") + FullFileName; DisplayError(this, msg); return; } char Line[256]; fprintf(lib_module,"%s %s\n", ENTETE_LIBRAIRIE, DateAndTime(Line)); fputs("$INDEX\n",lib_module); fputs("$EndINDEX\n",lib_module); fputs("$EndLIBRARY\n",lib_module); fclose(lib_module) ; } /* Calcul du nombre de modules */ Module = (MODULE *) m_Pcb->m_Modules; for( ;Module != NULL; Module = (MODULE *)Module->Pnext) NbModules++; Pas = (float) 100 / NbModules; DisplayActivity(0, wxEmptyString); Module = (MODULE *) m_Pcb->m_Modules; for( ii = 1 ;Module != NULL; ii++, Module = (MODULE *)Module->Pnext) { if( Save_1_Module(FullFileName, Module, NewModulesOnly ? FALSE : TRUE, FALSE) == 0 ) break; DisplayActivity((int)( ii * Pas) , wxEmptyString); /* Tst demande d'arret de sauvegarde ( key ESCAPE actionnee ) */ if( DrawPanel->m_AbortRequest ) break; } CreateDocLibrary(LibName); }
void DIALOG_MODULE_BOARD_EDITOR::Browse3DLib( wxCommandEvent& event ) { wxString fullfilename, shortfilename; wxString fullpath; fullpath = wxGetApp().ReturnLastVisitedLibraryPath( LIB3D_PATH ); #ifdef __WINDOWS__ fullpath.Replace( wxT( "/" ), wxT( "\\" ) ); #endif wxString fileFilters; fileFilters = wxGetTranslation( Shapes3DFileWildcard ); fileFilters += wxChar( '|' ); fileFilters += wxGetTranslation( IDF3DFileWildcard ); fullfilename = EDA_FileSelector( _( "3D Shape:" ), fullpath, wxEmptyString, wxEmptyString, wxGetTranslation( fileFilters ), this, wxFD_OPEN, true ); if( fullfilename.IsEmpty() ) return; wxFileName fn = fullfilename; wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() ); /* If the file path is already in the default search path * list, just add the name to the list. Otherwise, add * the name with the full or relative path. * the relative path, when possible is preferable, * because it preserve use of default search path, when the path is a * sub path */ wxString default_path; wxGetEnv( wxT( KISYS3DMOD ), &default_path ); fn.MakeRelativeTo( default_path ); // Here, we want a path relative only to the default_path if( fn.GetPathWithSep().StartsWith( wxT("..") ) ) fn = fullfilename; // keep the full file name shortfilename = fn.GetFullPath(); if( fn.IsAbsolute() ) { // Absolute path, ask if the user wants a relative one int diag = wxMessageBox( _( "Use a relative path?" ), _( "Path type" ), wxYES_NO | wxICON_QUESTION, this ); if( diag == wxYES ) { // Make it relative fn.MakeRelativeTo( wxT(".") ); shortfilename = fn.GetFullPath(); } } S3D_MASTER* new3DShape = new S3D_MASTER( NULL ); #ifdef __WINDOWS__ // Store filename in Unix notation shortfilename.Replace( wxT( "\\" ), wxT( "/" ) ); #endif new3DShape->SetShape3DName( shortfilename ); m_Shapes3D_list.push_back( new3DShape ); m_3D_ShapeNameListBox->Append( shortfilename ); if( m_LastSelected3DShapeIndex >= 0 ) TransfertDisplayTo3DValues( m_LastSelected3DShapeIndex ); m_LastSelected3DShapeIndex = m_3D_ShapeNameListBox->GetCount() - 1; m_3D_ShapeNameListBox->SetSelection( m_LastSelected3DShapeIndex ); Transfert3DValuesToDisplay( m_Shapes3D_list[m_LastSelected3DShapeIndex] ); }
void DIALOG_MODULE_BOARD_EDITOR::Browse3DLib( wxCommandEvent& event ) { PROJECT& prj = Prj(); SEARCH_STACK& search = Kiface().KifaceSearch(); wxString fullpath; wxString kisys3dmod = wxGetenv( wxT( KISYS3DMOD ) ); if( !kisys3dmod || !wxFileName::IsDirReadable( kisys3dmod ) ) { fullpath = search.FindValidPath( LIB3D_PATH ); } if( !fullpath ) fullpath = prj.RPath(PROJECT::VIEWER_3D).LastVisitedPath( search, LIB3D_PATH ); #ifdef __WINDOWS__ fullpath.Replace( wxT( "/" ), wxT( "\\" ) ); #endif wxString fullfilename; wxString shortfilename; wxString fileFilters = wxGetTranslation( Shapes3DFileWildcard ); fileFilters += wxChar( '|' ); fileFilters += wxGetTranslation( IDF3DFileWildcard ); fullfilename = EDA_FileSelector( _( "3D Shape:" ), fullpath, wxEmptyString, wxEmptyString, wxGetTranslation( fileFilters ), this, wxFD_OPEN, true ); if( fullfilename.IsEmpty() ) return; wxFileName fn = fullfilename; prj.RPath(PROJECT::VIEWER_3D).SaveLastVisitedPath( fn.GetPath() ); /* If the file path is already in the library search paths * list, just add the library name to the list. Otherwise, add * the library name with the full or relative path. * the relative path, when possible is preferable, * because it preserve use of default libraries paths, when the path is a * sub path of these default paths */ shortfilename = search.FilenameWithRelativePathInSearchList( fullfilename ); wxFileName aux = shortfilename; if( aux.IsAbsolute() ) { // Absolute path, ask if the user wants a relative one int diag = wxMessageBox( _( "Use a relative path?" ), _( "Path type" ), wxYES_NO | wxICON_QUESTION, this ); if( diag == wxYES ) { // Make it relative aux.MakeRelativeTo( wxT(".") ); shortfilename = aux.GetPathWithSep() + aux.GetFullName(); } } S3D_MASTER* new3DShape = new S3D_MASTER( NULL ); #ifdef __WINDOWS__ // Store filename in Unix notation shortfilename.Replace( wxT( "\\" ), wxT( "/" ) ); #endif new3DShape->SetShape3DName( shortfilename ); m_Shapes3D_list.push_back( new3DShape ); m_3D_ShapeNameListBox->Append( shortfilename ); if( m_LastSelected3DShapeIndex >= 0 ) TransfertDisplayTo3DValues( m_LastSelected3DShapeIndex ); m_LastSelected3DShapeIndex = m_3D_ShapeNameListBox->GetCount() - 1; m_3D_ShapeNameListBox->SetSelection( m_LastSelected3DShapeIndex ); Transfert3DValuesToDisplay( m_Shapes3D_list[m_LastSelected3DShapeIndex] ); }
/* Create a Screenshot of the current 3D view. * Output file format is png or jpeg, or image is copied to the clipboard */ void EDA_3D_CANVAS::TakeScreenshot( wxCommandEvent& event ) { wxFileName fn( Parent()->GetDefaultFileName() ); wxString FullFileName; wxString file_ext, mask; bool fmt_is_jpeg = false; if( event.GetId() == ID_MENU_SCREENCOPY_JPEG ) fmt_is_jpeg = true; if( event.GetId() != ID_TOOL_SCREENCOPY_TOCLIBBOARD ) { file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" ); mask = wxT( "*." ) + file_ext; FullFileName = Parent()->GetDefaultFileName(); fn.SetExt( file_ext ); FullFileName = EDA_FileSelector( _( "3D Image filename:" ), wxEmptyString, fn.GetFullName(), file_ext, mask, this, wxFD_SAVE, true ); if( FullFileName.IsEmpty() ) return; // Be sure the screen area destroyed by the file dialog is redrawn before making // a screen copy. // Without this call, under Linux the screen refresh is made to late. wxYield(); } struct vieport_params { GLint originx; GLint originy; GLint x; GLint y; } viewport; // Build image from the 3D buffer wxWindowUpdateLocker noUpdates( this ); glGetIntegerv( GL_VIEWPORT, (GLint*) &viewport ); unsigned char* pixelbuffer = (unsigned char*) malloc( viewport.x * viewport.y * 3 ); unsigned char* alphabuffer = (unsigned char*) malloc( viewport.x * viewport.y ); wxImage image( viewport.x, viewport.y ); glPixelStorei( GL_PACK_ALIGNMENT, 1 ); glReadBuffer( GL_BACK_LEFT ); glReadPixels( viewport.originx, viewport.originy, viewport.x, viewport.y, GL_RGB, GL_UNSIGNED_BYTE, pixelbuffer ); glReadPixels( viewport.originx, viewport.originy, viewport.x, viewport.y, GL_ALPHA, GL_UNSIGNED_BYTE, alphabuffer ); image.SetData( pixelbuffer ); image.SetAlpha( alphabuffer ); image = image.Mirror( false ); wxBitmap bitmap( image ); if( event.GetId() == ID_TOOL_SCREENCOPY_TOCLIBBOARD ) { wxBitmapDataObject* dobjBmp = new wxBitmapDataObject; dobjBmp->SetBitmap( bitmap ); if( wxTheClipboard->Open() ) { if( !wxTheClipboard->SetData( dobjBmp ) ) wxMessageBox( _( "Failed to copy image to clipboard" ) ); wxTheClipboard->Flush(); /* the data in clipboard will stay * available after the * application exits */ wxTheClipboard->Close(); } } else { wxImage image = bitmap.ConvertToImage(); if( !image.SaveFile( FullFileName, fmt_is_jpeg ? wxBITMAP_TYPE_JPEG : wxBITMAP_TYPE_PNG ) ) wxMessageBox( _( "Can't save file" ) ); image.Destroy(); } }
void WinEDA_ErcFrame::TestErc(wxCommandEvent& event) /**************************************************/ { ObjetNetListStruct * NetItemRef, * OldItem, * StartNet, * Lim; int NetNbItems, MinConn; if ( ! DiagErcTableInit ) { memcpy(DiagErc, DefaultDiagErc, sizeof (DefaultDiagErc)); DiagErcTableInit = TRUE; } WriteFichierERC = m_WriteResultOpt->GetValue(); if( CheckAnnotate(m_Parent, 0) ) { DisplayError(this, _("Annotation Required!") ); return; } /* Effacement des anciens marqueurs DRC */ DelERCMarkers(event); wxClientDC dc(m_Parent->DrawPanel); m_Parent->DrawPanel->PrepareGraphicContext(&dc); g_EESchemaVar.NbErrorErc = 0; g_EESchemaVar.NbWarningErc = 0; SchematicCleanUp(&dc); BuildNetList(m_Parent, ScreenSch); /* Analyse de la table des connexions : */ Lim = g_TabObjNet + g_NbrObjNet; /* Reset du flag m_FlagOfConnection, utilise par la suite */ for (NetItemRef = g_TabObjNet; NetItemRef < Lim; NetItemRef ++ ) NetItemRef->m_FlagOfConnection = (IsConnectType) 0; NetNbItems = 0; MinConn = NOC; StartNet = OldItem = NetItemRef = g_TabObjNet; for ( ; NetItemRef < Lim; NetItemRef ++ ) { /* Tst changement de net */ if( OldItem->m_NetCode != NetItemRef->m_NetCode) { MinConn = NOC; NetNbItems = 0; StartNet = NetItemRef; } switch ( NetItemRef->m_Type ) { case NET_SEGMENT: case NET_BUS: case NET_JONCTION: case NET_LABEL: case NET_BUSLABELMEMBER: case NET_PINLABEL: break; case NET_GLOBLABEL: case NET_GLOBBUSLABELMEMBER: case NET_SHEETLABEL: case NET_SHEETBUSLABELMEMBER: TestLabel(m_Parent->DrawPanel, &dc, NetItemRef, StartNet); break; case NET_NOCONNECT: MinConn = NET_NC; if( NetNbItems != 0 ) Diagnose(m_Parent->DrawPanel, &dc, NetItemRef, NULL, MinConn, UNC); break; case NET_PIN: TestOthersItems(m_Parent->DrawPanel, &dc, NetItemRef, StartNet, &NetNbItems , &MinConn); break; } OldItem = NetItemRef; } FreeTabNetList(g_TabObjNet, g_NbrObjNet ); wxString num; num.Printf(wxT("%d"), g_EESchemaVar.NbErrorErc); m_TotalErrCount->SetLabel(num); num.Printf(wxT("%d"), g_EESchemaVar.NbErrorErc-g_EESchemaVar.NbWarningErc); m_LastErrCount->SetLabel(num); num.Printf(wxT("%d"), g_EESchemaVar.NbWarningErc); m_LastWarningCount->SetLabel(num); /* Generation ouverture fichier diag */ if( WriteFichierERC == TRUE ) { wxString ErcFullFileName; ErcFullFileName = ScreenSch->m_FileName; ChangeFileNameExt(ErcFullFileName, wxT(".erc")); ErcFullFileName = EDA_FileSelector(_("ERC file:"), wxEmptyString, /* Chemin par defaut */ ErcFullFileName, /* nom fichier par defaut */ wxT(".erc"), /* extension par defaut */ wxT("*.erc"), /* Masque d'affichage */ this, wxSAVE, TRUE ); if ( ErcFullFileName.IsEmpty()) return; if ( WriteDiagnosticERC(ErcFullFileName) ) { Close(TRUE); wxString editorname = GetEditorName(); AddDelimiterString(ErcFullFileName); ExecuteFile(this, editorname, ErcFullFileName); } } }
int WinEDA_SchematicFrame::LoadOneEEProject(const wxString & FileName, bool IsNew) /********************************************************************************/ /* Routine de chargement d'un projet ( schema principal "Root" et ses sous schemas ( hierarchie ) */ { BASE_SCREEN *screen, * NextScreen; EDA_BaseStruct *EEDrawList ; wxString FullFileName, msg; bool LibCacheExist = FALSE; screen = ScreenSch ; while( screen ) { if(screen->IsModify()) break; screen = screen->Next(); } if ( screen ) { if( ! IsOK(this, _("Clear Schematic Hierarchy (modified!)?")) ) return FALSE; if ( ScreenSch->m_FileName != g_DefaultSchematicFileName ) SetLastProject(ScreenSch->m_FileName); } screen = ScreenSch ; if( ClearProjectDrawList((SCH_SCREEN*) screen) == FALSE ) return(1); FullFileName = FileName; if( (FullFileName.IsEmpty() ) && !IsNew ) { wxString mask = wxT("*") + g_SchExtBuffer; FullFileName = EDA_FileSelector( _("Schematic files:"), wxEmptyString, /* Chemin par defaut */ wxEmptyString, /* nom fichier par defaut */ g_SchExtBuffer, /* extension par defaut */ mask, /* Masque d'affichage */ this, wxOPEN, TRUE ); if ( FullFileName.IsEmpty() ) return ( FALSE ); } m_CurrentScreen = screen = ActiveScreen = ScreenSch; screen->m_CurrentItem = NULL; wxSetWorkingDirectory(wxPathOnly(FullFileName) ); m_CurrentScreen->m_FileName = FullFileName; Affiche_Message(wxEmptyString); MsgPanel->EraseMsgBox(); memset( &g_EESchemaVar,0, sizeof(g_EESchemaVar) ); m_CurrentScreen->ClrModify(); m_CurrentScreen->Pnext = NextScreen = NULL; if( IsNew ) { screen->m_CurrentSheet = &g_Sheet_A4; screen->SetZoom(32); screen->m_SheetNumber = screen->m_NumberOfSheet = 1; screen->m_Title = wxT("noname.sch"); m_CurrentScreen->m_FileName = screen->m_Title; screen->m_Company.Empty(); screen->m_Commentaire1.Empty(); screen->m_Commentaire2.Empty(); screen->m_Commentaire3.Empty(); screen->m_Commentaire4.Empty(); Read_Config(wxEmptyString, TRUE); Zoom_Automatique(TRUE); ReDrawPanel(); return (1); } // Rechargement de la configuration: msg = _("Ready\nWorking dir: \n") + wxGetCwd(); PrintMsg(msg); Read_Config(wxEmptyString, FALSE); // Delete old caches. LibraryStruct *nextlib, *lib = g_LibraryList; for (; lib != NULL; lib = nextlib ) { nextlib = lib->m_Pnext; if ( lib->m_IsLibCache ) FreeCmpLibrary(this, lib->m_Name); } if( IsNew ) { ReDrawPanel(); return (1); } // Loading the project library cache wxString FullLibName; wxString shortfilename; wxSplitPath(ScreenSch->m_FileName, NULL, &shortfilename, NULL); FullLibName << wxT(".") << STRING_DIR_SEP << shortfilename << wxT(".cache") << g_LibExtBuffer; if ( wxFileExists(FullLibName) ) { wxString libname; libname = FullLibName; ChangeFileNameExt(libname,wxEmptyString); msg = wxT("Load ") + FullLibName; LibraryStruct *LibCache = LoadLibraryName(this, FullLibName, libname); if ( LibCache ) { LibCache->m_IsLibCache = TRUE; msg += wxT(" OK"); } else msg += wxT(" ->Error"); PrintMsg( msg ); LibCacheExist = TRUE; } if ( ! wxFileExists(screen->m_FileName) && !LibCacheExist) // Nouveau projet prpbablement { msg.Printf( _("File %s not found (new project ?)"), screen->m_FileName.GetData() ); DisplayInfo(this, msg, 20); return (-1); } if( LoadOneEEFile(screen, screen->m_FileName) == FALSE) return (0); /* Chargement des sous feuilles */ while(screen) { EEDrawList = screen->EEDrawList; while(EEDrawList) { if( EEDrawList->m_StructType == DRAW_SHEET_STRUCT_TYPE) { #undef STRUCT #define STRUCT ((DrawSheetStruct*)EEDrawList) int timestamp = STRUCT->m_TimeStamp; if(timestamp == 0 ) { timestamp = GetTimeStamp(); STRUCT->m_TimeStamp = timestamp; } if( screen->Pnext == NULL) /* 1ere Sheet */ { screen->Pnext = NextScreen = CreateNewScreen(this, (SCH_SCREEN*)screen,timestamp); } else { NextScreen->Pnext = CreateNewScreen(this, (SCH_SCREEN*)NextScreen, timestamp); NextScreen = (BASE_SCREEN*)NextScreen->Pnext; } STRUCT->m_Son = NextScreen; NextScreen->m_Parent = EEDrawList; if( ! STRUCT->m_Field[SHEET_FILENAME].m_Text.IsEmpty() ) { NextScreen->m_FileName = STRUCT->m_Field[SHEET_FILENAME].m_Text; if( LoadOneEEFile(NextScreen, NextScreen->m_FileName) == TRUE ) { ActiveScreen = (SCH_SCREEN*) NextScreen; } } else DisplayError(this, _("No FileName in SubSheet")); } EEDrawList = EEDrawList->Pnext; } screen = (BASE_SCREEN*)screen->Pnext; } /* Reaffichage ecran de base (ROOT) si necessaire */ screen = ActiveScreen = ScreenSch; Zoom_Automatique(FALSE); return (1); }
/******************************************/ void WinEDA_GerberFrame::Update_config(void) /******************************************/ /* creation du fichier de config */ { wxString FullFileName; wxString mask( wxT("*") ), g_Prj_Config_Filename_ext = wxT(".cnf";) mask += g_Prj_Config_Filename_ext; FullFileName = wxT("gerbview"); ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext ); FullFileName = EDA_FileSelector(_("Save config file"), wxEmptyString, /* Chemin par defaut */ FullFileName, /* nom fichier par defaut */ g_Prj_Config_Filename_ext, /* extension par defaut */ mask, /* Masque d'affichage */ this, wxSAVE, TRUE ); if ( FullFileName.IsEmpty() ) return; /* ecriture de la configuration */ EDA_Appl->WriteProjectConfig(FullFileName, GROUP, ParamCfgList); }
void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event ) { LIB_COMPONENT* cmp = GetComponent(); wxString FullFileName; wxString file_ext; wxString mask; if( cmp == NULL ) { wxMessageBox( _( "No component" ) ); return; } switch( event.GetId() ) { case ID_LIBEDIT_GEN_PNG_FILE: { bool fmt_is_jpeg = false; // could be selectable later. so keep this option. file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" ); mask = wxT( "*." ) + file_ext; wxFileName fn( cmp->GetName() ); fn.SetExt( file_ext ); FullFileName = EDA_FileSelector( _( "Filename:" ), wxGetCwd(), fn.GetFullName(), file_ext, mask, this, wxFD_SAVE, true ); if( FullFileName.IsEmpty() ) return; // calling wxYield is mandatory under Linux, after closing the file selector dialog // to refresh the screen before creating the PNG or JPEG image from screen wxYield(); CreatePNGorJPEGFile( FullFileName, fmt_is_jpeg ); } break; case ID_LIBEDIT_GEN_SVG_FILE: { file_ext = wxT( "svg" ); mask = wxT( "*." ) + file_ext; wxFileName fn( cmp->GetName() ); fn.SetExt( file_ext ); FullFileName = EDA_FileSelector( _( "Filename:" ), wxGetCwd(), fn.GetFullName(), file_ext, mask, this, wxFD_SAVE, true ); if( FullFileName.IsEmpty() ) return; PAGE_INFO pageSave = GetScreen()->GetPageSettings(); PAGE_INFO pageTemp = pageSave; wxSize componentSize = m_component->GetBoundingBox( m_unit, m_convert ).GetSize(); // Add a small margin to the plot bounding box pageTemp.SetWidthMils( int( componentSize.x * 1.2 ) ); pageTemp.SetHeightMils( int( componentSize.y * 1.2 ) ); GetScreen()->SetPageSettings( pageTemp ); SVG_Print_Component( FullFileName ); GetScreen()->SetPageSettings( pageSave ); } break; } }
void WinEDA_PcbFrame::Process_Config(wxCommandEvent& event) /***********************************************************/ { int id = event.GetId(); wxPoint pos; wxClientDC dc(DrawPanel); DrawPanel->PrepareGraphicContext(&dc); pos = GetPosition(); pos.x += 20; pos.y += 20; switch( id ) { case ID_COLORS_SETUP : DisplayColorSetupFrame(this, pos); break; case ID_CONFIG_REQ : // Creation de la fenetre de configuration { InstallConfigFrame(pos); break; } case ID_PCB_TRACK_SIZE_SETUP: case ID_PCB_LOOK_SETUP: case ID_OPTIONS_SETUP: case ID_PCB_DRAWINGS_WIDTHS_SETUP: InstallPcbOptionsFrame(pos, &dc, id); break; case ID_PCB_PAD_SETUP: InstallPadOptionsFrame( NULL, NULL, pos); break; case ID_CONFIG_SAVE: Update_config(this); break; case ID_CONFIG_READ: { wxString FullFileName = GetScreen()->m_FileName.AfterLast('/'); ChangeFileNameExt(FullFileName, g_Prj_Config_Filename_ext); FullFileName = EDA_FileSelector(_("Read config file"), wxPathOnly(GetScreen()->m_FileName),/* Chemin par defaut */ FullFileName, /* nom fichier par defaut */ g_Prj_Config_Filename_ext, /* extension par defaut */ FullFileName, /* Masque d'affichage */ this, wxOPEN, TRUE /* ne change pas de repertoire courant */ ); if ( FullFileName == "") break; if ( ! wxFileExists(FullFileName) ) { wxString msg; msg.Printf(_("File %s not found"), FullFileName.GetData()); DisplayError(this, msg); break; } Read_Config(FullFileName ); } break; default: DisplayError(this, "WinEDA_PcbFrame::Process_Config internal error"); } }
void WinEDA_MainFrame::Process_Fct(wxCommandEvent& event) /*********************************************************/ { int id = event.GetId(); wxString FullFileName = m_PrjFileName; switch (id) { case ID_TO_PCB: ChangeFileNameExt(FullFileName, g_BoardExtBuffer); AddDelimiterString(FullFileName); ExecuteFile(this, PCBNEW_EXE, FullFileName); break; case ID_TO_CVPCB: ChangeFileNameExt(FullFileName, g_NetlistExtBuffer); AddDelimiterString(FullFileName); ExecuteFile(this, CVPCB_EXE, FullFileName); break; case ID_TO_EESCHEMA: ChangeFileNameExt(FullFileName, g_SchExtBuffer); AddDelimiterString(FullFileName); ExecuteFile(this, EESCHEMA_EXE, FullFileName); break; case ID_TO_GERBVIEW: FullFileName = wxGetCwd() + STRING_DIR_SEP; AddDelimiterString(FullFileName); ExecuteFile(this, GERBVIEW_EXE, FullFileName); break; case ID_TO_EDITOR: { wxString editorname = GetEditorName(); if ( !editorname.IsEmpty() ) ExecuteFile(this, editorname, wxEmptyString); } break; case ID_BROWSE_AN_SELECT_FILE: { wxString mask(wxT("*")), extension; #ifdef __WINDOWS__ mask += wxT(".*"); extension = wxT(".*"); #endif FullFileName = EDA_FileSelector( _("Load file:"), wxGetCwd(), /* Defualt path */ wxEmptyString, /* default filename */ extension, /* default ext. */ mask, /* mask for filename filter */ this, wxOPEN, TRUE ); if ( ! FullFileName.IsEmpty() ) { wxString fullnamewithquotes; fullnamewithquotes = wxT("\"") + FullFileName; fullnamewithquotes += wxT("\""); wxString editorname = GetEditorName(); if ( ! editorname.IsEmpty() ) ExecuteFile(this, editorname, fullnamewithquotes); } } break; break; default: DisplayError(this, wxT("WinEDA_MainFrame::Process_Fct Internal Error")); break; } }
bool GetAssociatedDocument( wxFrame* aFrame, const wxString& aDocName, const wxPathList* aPaths) { wxString docname, fullfilename, file_ext; wxString msg; wxString command; bool success = false; // Is an internet url static const wxString url_header[3] = { wxT( "http:" ), wxT( "ftp:" ), wxT( "www." ) }; for( int ii = 0; ii < 3; ii++ ) { if( aDocName.First( url_header[ii] ) == 0 ) //. seems an internet url { wxLaunchDefaultBrowser( aDocName ); return true; } } docname = aDocName; #ifdef __WINDOWS__ docname.Replace( UNIX_STRING_DIR_SEP, WIN_STRING_DIR_SEP ); #else docname.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); #endif /* Compute the full file name */ if( wxIsAbsolutePath( aDocName ) || aPaths == NULL) fullfilename = aDocName; /* If the file exists, this is a trivial case: return the filename * "as this". the name can be an absolute path, or a relative path * like ./filename or ../<filename> */ else if( wxFileName::FileExists( aDocName ) ) fullfilename = aDocName; else { fullfilename = aPaths->FindValidPath( aDocName ); } wxString mask( wxT( "*" ) ), extension; #ifdef __WINDOWS__ mask += wxT( ".*" ); extension = wxT( ".*" ); #endif if( wxIsWild( fullfilename ) ) { fullfilename = EDA_FileSelector( _( "Doc Files" ), wxPathOnly( fullfilename ), fullfilename, extension, mask, aFrame, wxFD_OPEN, true, wxPoint( -1, -1 ) ); if( fullfilename.IsEmpty() ) return false; } if( !wxFileExists( fullfilename ) ) { msg.Printf( _( "Doc File <%s> not found" ), GetChars( aDocName ) ); DisplayError( aFrame, msg ); return false; } wxFileName CurrentFileName( fullfilename ); file_ext = CurrentFileName.GetExt(); if( file_ext == wxT( "pdf" ) ) { success = OpenPDF( fullfilename ); return success; } /* Try to launch some browser (useful under linux) */ wxFileType* filetype; wxString type; filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( file_ext ); if( !filetype ) // 2nd attempt. { mimeDatabase = new wxMimeTypesManager; mimeDatabase->AddFallbacks( EDAfallbacks ); filetype = mimeDatabase->GetFileTypeFromExtension( file_ext ); delete mimeDatabase; mimeDatabase = NULL; } if( filetype ) { wxFileType::MessageParameters params( fullfilename, type ); success = filetype->GetOpenCommand( &command, params ); delete filetype; if( success ) success = ProcessExecute( command ); } if( !success ) { msg.Printf( _( "Unknown MIME type for doc file <%s>" ), GetChars( fullfilename ) ); DisplayError( aFrame, msg ); } return success; }