示例#1
0
bool EDA_APP::OnInit()
{
    wxFileName      fn;
    PCB_EDIT_FRAME* frame = NULL;

    InitEDA_Appl( wxT( "Pcbnew" ), APP_PCBNEW_T );

    if( m_Checker && m_Checker->IsAnotherRunning() )
    {
        if( !IsOK( NULL, _( "Pcbnew is already running, Continue?" ) ) )
            return false;
    }

    // read current setup and reopen last directory if no filename to open in command line
    bool reopenLastUsedDirectory = argc == 1;
    GetSettings( reopenLastUsedDirectory );

    if( argc > 1 )
    {
        fn = argv[1];

        if( fn.GetExt() != PcbFileExtension )
        {
            wxLogDebug( wxT( "Pcbnew file <%s> has the wrong extension.  \
Changing extension to .brd." ), GetChars( fn.GetFullPath() ) );
            fn.SetExt( PcbFileExtension );
        }
示例#2
0
bool WinEDA_App::OnInit(void)
{
wxString msg;
wxString currCWD = wxGetCwd();

	EDA_Appl = this;
	InitEDA_Appl( wxT("cvpcb") );

    if ( m_Checker && m_Checker->IsAnotherRunning() ) 
    { 
        if ( ! IsOK(NULL, _("Cvpcb is already running, Continue?") ) )
			return false; 
    }
	
	GetSettings();					// read current setup

	wxSetWorkingDirectory(currCWD); // mofifie par GetSetting
	SetRealLibraryPath( wxT("modules") );

	if(argc > 1 )
		{
		NetInNameBuffer = argv[1];
		NetNameBuffer = argv[1];
		}

	if ( ! NetInNameBuffer.IsEmpty() )
		wxSetWorkingDirectory( wxPathOnly(NetInNameBuffer) );
	g_DrawBgColor = BLACK;

	Read_Config(NetInNameBuffer);

	m_CvpcbFrame = new WinEDA_CvpcbFrame(this, Main_Title);

	msg.Printf( wxT("Modules: %d"), nblib);
	m_CvpcbFrame->SetStatusText(msg,2);

	// Show the frame
	SetTopWindow(m_CvpcbFrame);

	m_CvpcbFrame->Show(TRUE);

	listlib();
	m_CvpcbFrame->BuildModListBox();

	if( ! NetInNameBuffer.IsEmpty() ) /* nom de fichier passe a la commande */
		{
		FFileName = MakeFileName(NetDirBuffer,
							NetInNameBuffer, NetInExtBuffer);

		m_CvpcbFrame->ReadNetListe();
		}
	else		/* Mise a jour du titre de la fenetre principale */
		{
 		msg.Printf( wxT("%s {%s%c} [no file]"),
			Main_Title.GetData(), wxGetCwd().GetData(), DIR_SEP);
		m_CvpcbFrame->SetTitle(msg);
		}

  return TRUE;
}
示例#3
0
bool WinEDA_App::OnInit(void)
{
wxString FFileName;

	EDA_Appl = this;
	InitEDA_Appl( wxT("gerbview") );

	if(argc > 1) FFileName = MakeFileName(wxEmptyString, argv[1], g_PhotoFilenameExt);

	ScreenPcb = new PCB_SCREEN(NULL, m_GerberFrame, PCB_FRAME);
	ActiveScreen = ScreenPcb;
	GetSettings();
    if ( m_Checker && m_Checker->IsAnotherRunning() )
    {
        if ( ! IsOK(NULL, _("Gerbview is already running, Continue?") ) )
			return false;
    }


	g_DrawBgColor = BLACK;

	m_GerberFrame = new WinEDA_GerberFrame(NULL, this, wxT("GerbView"),
				 wxPoint(0,0), wxSize(600,400) );
	m_GerberFrame->SetTitle(Main_Title);
	ScreenPcb->SetParentFrame(m_GerberFrame);
	m_GerberFrame->m_Pcb = new BOARD(NULL, m_GerberFrame);

	SetTopWindow(m_GerberFrame);
	m_GerberFrame->Show(TRUE);

	m_GerberFrame->m_Pcb = new BOARD(NULL, m_GerberFrame);
	m_GerberFrame->Zoom_Automatique(TRUE);

	/* Load file specified in the command line. */
	if( ! FFileName.IsEmpty() )
	{
		wxString path = wxPathOnly(FFileName);
		wxSetWorkingDirectory(path);
		Read_Config();
		if ( wxFileExists(FFileName) )
		{
			wxClientDC dc(m_GerberFrame->DrawPanel);
			m_GerberFrame->DrawPanel->PrepareGraphicContext(&dc);
			m_GerberFrame->LoadOneGerberFile(FFileName, &dc, FALSE);
		}
	}
	else Read_Config();

	return TRUE;
}
示例#4
0
bool WinEDA_App::OnInit(void)
{
wxString FFileName;
	EDA_Appl = this;

	g_DebugLevel = 0;	// Debug level */

	InitEDA_Appl( wxT("eeschema") );

    if ( m_Checker && m_Checker->IsAnotherRunning() )
    {
        if ( ! IsOK(NULL, _("Eeschema is already running, Continue?") ) )
			return false;
    }

	if(argc > 1 ) FFileName = argv[1];

	CreateScreens();

	/* init EESCHEMA */
	GetSettings();			// read current setup
	SeedLayers();

	// Create main frame (schematic frame) :
	SchematicFrame = new WinEDA_SchematicFrame(NULL, this,
					 wxT("EESchema"), wxPoint(0,0), wxSize(600,400) );
	ScreenSch->SetParentFrame(SchematicFrame);
	SchematicFrame->Show(TRUE);
	SetTopWindow(SchematicFrame);

	SchematicFrame->Zoom_Automatique(TRUE);

	/* Load file specified in the command line. */
	if( ! FFileName.IsEmpty() )
	{
		ChangeFileNameExt(FFileName, g_SchExtBuffer);
		wxSetWorkingDirectory( wxPathOnly(FFileName) );
		if ( SchematicFrame->LoadOneEEProject(FFileName, FALSE) <= 0 )
			SchematicFrame->DrawPanel->Refresh(TRUE);	// File not found or error
	}

	else
	{
		Read_Config(wxEmptyString, TRUE); // Read config file ici si pas de fichier a charger
		SchematicFrame->DrawPanel->Refresh(TRUE);
	}

	return TRUE;
}
示例#5
0
bool WinEDA_App::OnInit(void)
{
	EDA_Appl = this;
	InitEDA_Appl( wxT("kicad"));
	
	/* init kicad */
	GetSettings();					// read current setup

	m_MainFrame = new WinEDA_MainFrame(this, NULL, wxT("KiCad"),
				 wxPoint(0,0), wxSize(600,400) );
	if(argc > 1 ) m_MainFrame->m_PrjFileName = argv[1];
	else if ( m_EDA_Config )
	{
		m_MainFrame->m_PrjFileName = m_EDA_Config->Read(wxT("LastProject"),
				wxT("noname.pro") );
	}
	else m_MainFrame->m_PrjFileName = wxT("noname.pro");

	wxString Title = g_Main_Title + wxT(" ") + GetBuildVersion();
	Title += wxT(" ") + m_MainFrame->m_PrjFileName;
	m_MainFrame->SetTitle(Title);
	m_MainFrame->ReCreateMenuBar();
	m_MainFrame->RecreateBaseHToolbar();

	m_MainFrame->m_LeftWin->ReCreateTreePrj();
	SetTopWindow(m_MainFrame);
	m_MainFrame->Show(TRUE);

	/* Preparation Affichage du logo */
#ifdef SPLASH_OK
wxString logoname( wxString(m_BinDir) + wxT("logokicad.png") );
wxBitmap image;
	if ( image.LoadFile( logoname, wxBITMAP_TYPE_PNG ) )
		{
		wxSplashScreen * logoscreen = new wxSplashScreen( image,
				wxSPLASH_CENTRE_ON_PARENT | wxSPLASH_TIMEOUT,
				500, m_MainFrame, -1,
				wxDefaultPosition, wxDefaultSize,
				wxSIMPLE_BORDER | wxSTAY_ON_TOP);
		}
#endif

	if ( wxFileExists(m_MainFrame->m_PrjFileName) )
	{
		m_MainFrame->Load_Prj_Config();
	}

	return TRUE;
}
示例#6
0
bool EDA_APP::OnInit()
{
    wxFileName      fn;
    PCB_EDIT_FRAME* frame = NULL;
    wxString        msg;

    InitEDA_Appl( wxT( "Pcbnew" ), APP_PCBNEW_T );

#ifdef KICAD_SCRIPTING
    msg.Empty();
#ifdef __WINDOWS__
    // force python environment under Windows:
    const wxString python_us("python27_us");

    // Build our python path inside kicad
    wxString kipython = m_BinDir + python_us;

    // If our python install is existing inside kicad, use it
    if( wxDirExists( kipython ) )
    {
        wxString ppath;
        if( !wxGetEnv( wxT( "PYTHONPATH" ), &ppath ) || !ppath.Contains( python_us ) )
        {
            ppath << kipython << wxT("/pylib;");
            ppath << kipython << wxT("/lib;");
            ppath << kipython << wxT("/dll");
            wxSetEnv( wxT( "PYTHONPATH" ), ppath );
            DBG( std::cout << "set PYTHONPATH to "  << TO_UTF8(ppath) << "\n"; )

            // Add python executable path:
            wxGetEnv( wxT( "PATH" ), &ppath );
            if( !ppath.Contains( python_us ) )
            {
                kipython << wxT(";") << ppath;
                wxSetEnv( wxT( "PATH" ), kipython );
                DBG( std::cout << "set PATH to " << TO_UTF8(kipython) << "\n"; )
            }
示例#7
0
bool WinEDA_App::OnInit(void)
/****************************/
{
wxString FFileName;

	EDA_Appl = this;
	InitEDA_Appl( wxT("pcbnew") );

    if ( m_Checker && m_Checker->IsAnotherRunning() )
    {
        if ( ! IsOK(NULL, _("Pcbnew is already running, Continue?") ) )
			return false;
    }

	/* Add image handlers for screen hardcopy */
	wxImage::AddHandler( new wxPNGHandler );
	wxImage::AddHandler( new wxJPEGHandler );

	ScreenPcb = new PCB_SCREEN(NULL, NULL, PCB_FRAME);
	GetSettings();

	if(argc > 1)
		{
		FFileName = MakeFileName(wxEmptyString, argv[1], PcbExtBuffer);
		wxSetWorkingDirectory( wxPathOnly(FFileName) );
		}

	Read_Config(FFileName);
	g_DrawBgColor = BLACK;

	/* allocation de la memoire pour le fichier et autres buffers: */
	/* On reserve BUFMEMSIZE octets de ram pour calcul */
	buf_work = adr_lowmem = (char*)MyZMalloc(BUFMEMSIZE) ;  /* adresse de la zone de calcul */
	adr_himem = adr_lowmem + BUFMEMSIZE; /* adr limite haute */
	adr_max = adr_lowmem;

	if( adr_lowmem == NULL )
	{
		printf( "No Memory, Fatal err Memory alloc\n" );
		return(FALSE) ;
	}
	m_PcbFrame = new WinEDA_PcbFrame(NULL, this, wxT("PcbNew"),
				 wxPoint(0,0), wxSize(600,400) );
	m_PcbFrame->SetTitle(Main_Title);
	ScreenPcb->SetParentFrame(m_PcbFrame);
	ActiveScreen = ScreenPcb;
	m_PcbFrame->m_Pcb = new BOARD(NULL, m_PcbFrame);

	SetTopWindow(m_PcbFrame);
	m_PcbFrame->Show(TRUE);

	if( CreateServer(m_PcbFrame, KICAD_PCB_PORT_SERVICE_NUMBER) )
	{
		SetupServerFunction(RemoteCommand);
	}

	m_PcbFrame->Zoom_Automatique(TRUE);

	/* Load file specified in the command line. */
	if ( ! FFileName.IsEmpty() )
	{
		wxClientDC dc(m_PcbFrame->DrawPanel);
		m_PcbFrame->DrawPanel->PrepareGraphicContext(&dc);
		m_PcbFrame->LoadOnePcbFile(FFileName, &dc, FALSE);
	}

	return TRUE;
}
示例#8
0
文件: gerbview.cpp 项目: jerkey/kicad
bool EDA_APP::OnInit()
{
    wxFileName          fn;
    GERBVIEW_FRAME* frame = NULL;

    InitEDA_Appl( wxT( "GerbView" ), APP_GERBVIEW_T );

    if( m_Checker && m_Checker->IsAnotherRunning() )
    {
        if( !IsOK( NULL, _( "GerbView is already running. Continue?" ) ) )
            return false;
    }

    // read current setup and reopen last directory if no filename to open in
    // command line
    bool reopenLastUsedDirectory = argc == 1;
    GetSettings( reopenLastUsedDirectory );

    g_DrawBgColor = BLACK;

   /* Must be called before creating the main frame in order to
    * display the real hotkeys in menus or tool tips */
    ReadHotkeyConfig( wxT("GerberFrame"), s_Gerbview_Hokeys_Descr );

    frame = new  GERBVIEW_FRAME( NULL, wxT( "GerbView" ), wxPoint( 0, 0 ), wxSize( 600, 400 ) );

    /* Gerbview mainframe title */
    frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() );

    SetTopWindow( frame );                  // Set GerbView mainframe on top
    frame->Show( true );                    // Show GerbView mainframe
    frame->Zoom_Automatique( true );        // Zoom fit in frame
    frame->GetScreen()->m_FirstRedraw = false;


    if( argc <= 1 )
        return true;

    fn = argv[1];

    if( fn.IsOk() )
    {
        if( fn.DirExists() )
            wxSetWorkingDirectory( fn.GetPath() );

        // Load all files specified on the command line.
        LAYER_NUM jj = FIRST_LAYER;

        for( LAYER_NUM ii = LAYER_N_2; ii < argc && ii <= NB_GERBER_LAYERS; ++ii )
        {
            fn = wxFileName( argv[ii] );

            if( fn.FileExists() )
            {
                frame->setActiveLayer( jj );
                ++jj;
                frame->LoadGerberFiles( fn.GetFullPath() );
            }
        }
    }

    return true;
}
示例#9
0
文件: eeschema.cpp 项目: jerkey/kicad
bool EDA_APP::OnInit()
{
    wxFileName      filename;
    SCH_EDIT_FRAME* frame = NULL;
    bool fileReady = false;

    InitEDA_Appl( wxT( "Eeschema" ), APP_EESCHEMA_T );

    if( argc > 1 )
        filename = argv[1];

    if( filename.IsOk() )
    {
        if( filename.GetExt() != SchematicFileExtension )
            filename.SetExt( SchematicFileExtension );

        if( !wxGetApp().LockFile( filename.GetFullPath() ) )
        {
            DisplayError( NULL, _( "This file is already open." ) );
            return false;
        }

        fileReady = true;
    }

    if( m_Checker && m_Checker->IsAnotherRunning() )
    {
        if( !IsOK( NULL, _( "Eeschema is already running, Continue?" ) ) )
            return false;
    }

    // Give a default colour for all layers
    // (actual color will be initialized by config)
    for( int ii = 0; ii < NB_SCH_LAYERS; ii++ )
        SetLayerColor( DARKGRAY, ii );

    // read current setup and reopen last directory if no filename to open in
    // command line
    bool reopenLastUsedDirectory = argc == 1;
    GetSettings( reopenLastUsedDirectory );

   /* Must be called before creating the main frame in order to
    * display the real hotkeys in menus or tool tips */
    ReadHotkeyConfig( wxT("SchematicFrame"), s_Eeschema_Hokeys_Descr );

    // Create main frame (schematic frame) :
    frame = new SCH_EDIT_FRAME( NULL, wxT( "Eeschema" ), wxPoint( 0, 0 ), wxSize( 600, 400 ) );

    SetTopWindow( frame );
    frame->Show( true );

    CreateServer( frame, KICAD_SCH_PORT_SERVICE_NUMBER );

    frame->Zoom_Automatique( true );

    // Load file specified in the command line:
    if( fileReady )
    {
        if( !filename.GetPath().IsEmpty() )
            // wxSetWorkingDirectory does not like empty paths
            wxSetWorkingDirectory( filename.GetPath() );

        if( frame->LoadOneEEProject( filename.GetFullName(), false ) )
            frame->GetCanvas()->Refresh( true );
    }
    else
    {
        // Read a default config file if no file to load.
        frame->LoadProjectFile( wxEmptyString, true );
        frame->GetCanvas()->Refresh( true );
    }

    return true;
}