From e0f8b04c2042301fed5a6609305cfe7604a5eed5 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 26 Oct 2010 11:24:31 +0200 Subject: [PATCH] Eeschema: added dialog_plot_schematic_DXF_base.* --- eeschema/CMakeLists.txt | 3 +- .../dialogs/dialog_plot_schematic_DXF.cpp | 249 ++++++++ .../dialog_plot_schematic_DXF_base.cpp | 86 +++ .../dialog_plot_schematic_DXF_base.fbp | 546 ++++++++++++++++++ .../dialogs/dialog_plot_schematic_DXF_base.h | 60 ++ .../dialogs/dialog_plot_schematic_HPGL.cpp | 2 +- eeschema/dialogs/dialog_plot_schematic_PS.cpp | 2 +- eeschema/plotdxf.cpp | 427 -------------- eeschema/plotdxf.h | 123 ---- 9 files changed, 945 insertions(+), 553 deletions(-) create mode 100644 eeschema/dialogs/dialog_plot_schematic_DXF.cpp create mode 100644 eeschema/dialogs/dialog_plot_schematic_DXF_base.cpp create mode 100644 eeschema/dialogs/dialog_plot_schematic_DXF_base.fbp create mode 100644 eeschema/dialogs/dialog_plot_schematic_DXF_base.h delete mode 100644 eeschema/plotdxf.cpp delete mode 100644 eeschema/plotdxf.h diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 0f48fa8508..0879fa4b19 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -37,6 +37,8 @@ set(EESCHEMA_SRCS database.cpp delete.cpp delsheet.cpp + dialogs/dialog_plot_schematic_DXF.cpp + dialogs/dialog_plot_schematic_DXF_base.cpp dialogs/dialog_plot_schematic_HPGL.cpp dialogs/dialog_plot_schematic_HPGL_base.cpp dialogs/dialog_plot_schematic_PS.cpp @@ -120,7 +122,6 @@ set(EESCHEMA_SRCS operations_on_items_lists.cpp pinedit.cpp plot.cpp - plotdxf.cpp read_from_file_schematic_items_descriptions.cpp save_schemas.cpp schedit.cpp diff --git a/eeschema/dialogs/dialog_plot_schematic_DXF.cpp b/eeschema/dialogs/dialog_plot_schematic_DXF.cpp new file mode 100644 index 0000000000..1f74a30f66 --- /dev/null +++ b/eeschema/dialogs/dialog_plot_schematic_DXF.cpp @@ -0,0 +1,249 @@ +/** @file dialog_plot_schematic_DXF.cpp + */ + +/* + * This program source code file is part of KICAD, a free EDA CAD application. + * + * Copyright (C) 1992-2010 Lorenzo Marcantonio + * Copyright (C) 1992-2010 Kicad Developers, see change_log.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "fctsys.h" +#include "gr_basic.h" +#include "common.h" +#include "plot_common.h" +#include "confirm.h" +#include "worksheet.h" + +#include "program.h" +#include "general.h" +#include "protos.h" + +#include "dialog_plot_schematic_DXF_base.h" + +class DIALOG_PLOT_SCHEMATIC_DXF : public DIALOG_PLOT_SCHEMATIC_DXF_BASE +{ +private: + WinEDA_SchematicFrame* m_Parent; + +public: + + /// Constructors + DIALOG_PLOT_SCHEMATIC_DXF( WinEDA_SchematicFrame* parent ); + +private: + static bool m_plotColorOpt; + static int m_pageSizeSelect; + static bool m_plot_Sheet_Ref; + bool m_select_PlotAll; +private: + void OnPlotCurrent( wxCommandEvent& event ); + void OnPlotAll( wxCommandEvent& event ); + void OnCancelClick( wxCommandEvent& event ); + + void initDlg(); + void initOptVars(); + void CreateDXFFile(); + void PlotOneSheetDXF( const wxString& FileName, + SCH_SCREEN* screen, Ki_PageDescr* sheet, + wxPoint plot_offset, double scale ); +}; +/* static members (static to remember last state): */ +bool DIALOG_PLOT_SCHEMATIC_DXF::m_plotColorOpt = false; +bool DIALOG_PLOT_SCHEMATIC_DXF::m_plot_Sheet_Ref = true; + + + +void WinEDA_SchematicFrame::ToPlot_DXF( wxCommandEvent& event ) +{ + DIALOG_PLOT_SCHEMATIC_DXF DXF_frame( this ); + DXF_frame.ShowModal(); +} + + +DIALOG_PLOT_SCHEMATIC_DXF::DIALOG_PLOT_SCHEMATIC_DXF( WinEDA_SchematicFrame* parent ) + : DIALOG_PLOT_SCHEMATIC_DXF_BASE( parent ) +{ + m_Parent = parent; + m_select_PlotAll = false; + initDlg(); + + GetSizer()->SetSizeHints( this ); + Centre(); +} + +void DIALOG_PLOT_SCHEMATIC_DXF::initDlg() +{ + SetFocus(); // make the ESC work + // Set options + m_PlotColorCtrl->SetSelection( m_plotColorOpt ? 1 : 0 ); + m_Plot_Sheet_Ref_Ctrl->SetValue( m_plot_Sheet_Ref ); +} + + +/* event handler for Plot Current button + */ +void DIALOG_PLOT_SCHEMATIC_DXF::OnPlotCurrent( wxCommandEvent& event ) +{ + m_select_PlotAll = false; + + initOptVars(); + CreateDXFFile( ); + m_MsgBox->AppendText( wxT( "*****\n" ) ); +} + +/* event handler for Plot ALL button + */ +void DIALOG_PLOT_SCHEMATIC_DXF::OnPlotAll( wxCommandEvent& event ) +{ + m_select_PlotAll = true; + + initOptVars(); + CreateDXFFile( ); + m_MsgBox->AppendText( wxT( "*****\n" ) ); +} + + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + */ +void DIALOG_PLOT_SCHEMATIC_DXF::OnCancelClick( wxCommandEvent& event ) +{ + initOptVars(); + EndModal( 0 ); +} + + +void DIALOG_PLOT_SCHEMATIC_DXF::initOptVars() +{ + m_plot_Sheet_Ref = m_Plot_Sheet_Ref_Ctrl->GetValue(); + m_plotColorOpt = m_PlotColorCtrl->GetSelection() == 1 ? true : false; +} + + +void DIALOG_PLOT_SCHEMATIC_DXF::CreateDXFFile( ) +{ + WinEDA_SchematicFrame* schframe = (WinEDA_SchematicFrame*) m_Parent; + SCH_SCREEN* screen = schframe->GetScreen(); + SCH_SCREEN* oldscreen = screen; + SCH_SHEET_PATH* sheetpath, * oldsheetpath = schframe->GetSheet(); + wxString PlotFileName; + Ki_PageDescr* PlotSheet; + wxPoint plot_offset; + + /* When printing all pages, the printed page is not the current page. + * In complex hierarchies, we must setup references and others parameters + * in the printed SCH_SCREEN + * because in complex hierarchies a SCH_SCREEN (a schematic drawings) + * is shared between many sheets + */ + SCH_SHEET_LIST SheetList( NULL ); + + sheetpath = SheetList.GetFirst(); + SCH_SHEET_PATH list; + + while( true ) + { + if( m_select_PlotAll ) + { + if( sheetpath == NULL ) + break; + list.Clear(); + if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) ) + { + schframe->m_CurrentSheet = &list; + schframe->m_CurrentSheet->UpdateAllScreenReferences(); + schframe->SetSheetNumberAndCount(); + screen = schframe->m_CurrentSheet->LastScreen(); + ActiveScreen = screen; + } + else // Should not happen + return; + sheetpath = SheetList.GetNext(); + } + PlotSheet = screen->m_CurrentSheetDesc; + double scale = 10; + + plot_offset.x = 0; + plot_offset.y = 0; + + PlotFileName = schframe->GetUniqueFilenameForCurrentSheet() + wxT( + ".dxf" ); + + PlotOneSheetDXF( PlotFileName, screen, PlotSheet, plot_offset, scale ); + + if( !m_select_PlotAll ) + break; + } + + ActiveScreen = oldscreen; + schframe->m_CurrentSheet = oldsheetpath; + schframe->m_CurrentSheet->UpdateAllScreenReferences(); + schframe->SetSheetNumberAndCount(); +} + + +void DIALOG_PLOT_SCHEMATIC_DXF::PlotOneSheetDXF( const wxString& FileName, + SCH_SCREEN* screen, + Ki_PageDescr* sheet, + wxPoint plot_offset, + double scale ) +{ + wxString msg; + + FILE* output_file = wxFopen( FileName, wxT( "wt" ) ); + + if( output_file == NULL ) + { + msg = wxT( "\n** " ); + msg += _( "Unable to create " ) + FileName + wxT( " **\n" ); + m_MsgBox->AppendText( msg ); + return; + } + + msg.Printf( _( "Plot: %s " ), GetChars( FileName ) ); + m_MsgBox->AppendText( msg ); + + SetLocaleTo_C_standard(); + DXF_PLOTTER* plotter = new DXF_PLOTTER(); + plotter->set_paper_size( sheet ); + plotter->set_viewport( plot_offset, scale, 0 ); + plotter->set_color_mode( m_plotColorOpt ); + + /* Init : */ + plotter->set_creator( wxT( "EESchema-DXF" ) ); + plotter->set_filename( FileName ); + plotter->start_plot( output_file ); + + if( m_plot_Sheet_Ref ) + { + plotter->set_color( BLACK ); + m_Parent->PlotWorkSheet( plotter, screen ); + } + + PlotDrawlist( plotter, screen->EEDrawList ); + + /* fin */ + plotter->end_plot(); + delete plotter; + SetLocaleTo_Default(); + + m_MsgBox->AppendText( wxT( "Ok\n" ) ); +} diff --git a/eeschema/dialogs/dialog_plot_schematic_DXF_base.cpp b/eeschema/dialogs/dialog_plot_schematic_DXF_base.cpp new file mode 100644 index 0000000000..6709a19122 --- /dev/null +++ b/eeschema/dialogs/dialog_plot_schematic_DXF_base.cpp @@ -0,0 +1,86 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Sep 8 2010) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "dialog_plot_schematic_DXF_base.h" + +/////////////////////////////////////////////////////////////////////////// + +DIALOG_PLOT_SCHEMATIC_DXF_BASE::DIALOG_PLOT_SCHEMATIC_DXF_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* bmainSizer; + bmainSizer = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bupperSizer; + bupperSizer = new wxBoxSizer( wxHORIZONTAL ); + + + bupperSizer->Add( 10, 10, 0, wxEXPAND, 5 ); + + wxBoxSizer* sbSizerMiddle; + sbSizerMiddle = new wxBoxSizer( wxVERTICAL ); + + wxString m_PlotColorCtrlChoices[] = { _("B/W"), _("Color") }; + int m_PlotColorCtrlNChoices = sizeof( m_PlotColorCtrlChoices ) / sizeof( wxString ); + m_PlotColorCtrl = new wxRadioBox( this, wxID_ANY, _("Plot Mode:"), wxDefaultPosition, wxDefaultSize, m_PlotColorCtrlNChoices, m_PlotColorCtrlChoices, 1, wxRA_SPECIFY_COLS ); + m_PlotColorCtrl->SetSelection( 0 ); + sbSizerMiddle->Add( m_PlotColorCtrl, 0, wxALL|wxEXPAND, 5 ); + + m_Plot_Sheet_Ref_Ctrl = new wxCheckBox( this, wxID_ANY, _("Print page references"), wxDefaultPosition, wxDefaultSize, 0 ); + m_Plot_Sheet_Ref_Ctrl->SetValue(true); + sbSizerMiddle->Add( m_Plot_Sheet_Ref_Ctrl, 0, wxALL|wxEXPAND, 5 ); + + bupperSizer->Add( sbSizerMiddle, 1, wxEXPAND, 5 ); + + + bupperSizer->Add( 10, 10, 0, wxEXPAND, 5 ); + + wxBoxSizer* bbuttonsSizer; + bbuttonsSizer = new wxBoxSizer( wxVERTICAL ); + + m_buttonPlotPage = new wxButton( this, wxID_ANY, _("&Plot Page"), wxDefaultPosition, wxDefaultSize, 0 ); + bbuttonsSizer->Add( m_buttonPlotPage, 0, wxALL|wxEXPAND, 5 ); + + m_buttonPlotAll = new wxButton( this, wxID_ANY, _("Plot A&LL"), wxDefaultPosition, wxDefaultSize, 0 ); + bbuttonsSizer->Add( m_buttonPlotAll, 0, wxALL|wxEXPAND, 5 ); + + m_buttonClose = new wxButton( this, wxID_ANY, _("Close"), wxDefaultPosition, wxDefaultSize, 0 ); + bbuttonsSizer->Add( m_buttonClose, 0, wxALL|wxEXPAND, 5 ); + + bupperSizer->Add( bbuttonsSizer, 1, wxALIGN_CENTER_VERTICAL, 5 ); + + bmainSizer->Add( bupperSizer, 0, wxEXPAND, 5 ); + + m_staticText1 = new wxStaticText( this, wxID_ANY, _("Messages :"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText1->Wrap( -1 ); + bmainSizer->Add( m_staticText1, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_MsgBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY ); + m_MsgBox->SetMinSize( wxSize( -1,150 ) ); + + bmainSizer->Add( m_MsgBox, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + this->SetSizer( bmainSizer ); + this->Layout(); + + this->Centre( wxBOTH ); + + // Connect Events + m_buttonPlotPage->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_SCHEMATIC_DXF_BASE::OnPlotCurrent ), NULL, this ); + m_buttonPlotAll->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_SCHEMATIC_DXF_BASE::OnPlotAll ), NULL, this ); + m_buttonClose->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_SCHEMATIC_DXF_BASE::OnCancelClick ), NULL, this ); +} + +DIALOG_PLOT_SCHEMATIC_DXF_BASE::~DIALOG_PLOT_SCHEMATIC_DXF_BASE() +{ + // Disconnect Events + m_buttonPlotPage->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_SCHEMATIC_DXF_BASE::OnPlotCurrent ), NULL, this ); + m_buttonPlotAll->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_SCHEMATIC_DXF_BASE::OnPlotAll ), NULL, this ); + m_buttonClose->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_SCHEMATIC_DXF_BASE::OnCancelClick ), NULL, this ); + +} diff --git a/eeschema/dialogs/dialog_plot_schematic_DXF_base.fbp b/eeschema/dialogs/dialog_plot_schematic_DXF_base.fbp new file mode 100644 index 0000000000..3603102835 --- /dev/null +++ b/eeschema/dialogs/dialog_plot_schematic_DXF_base.fbp @@ -0,0 +1,546 @@ + + + + + + C++ + 1 + source_name + 0 + UTF-8 + connect + dialog_plot_schematic_DXF_base + 1000 + none + 1 + dialog_plot_schematic_DXF + + . + + 1 + 1 + 0 + 0 + + + wxBOTH + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + DIALOG_PLOT_SCHEMATIC_DXF_BASE + + 387,365 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + + EESchema Plot DXF + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bmainSizer + wxVERTICAL + none + + 5 + wxEXPAND + 0 + + + bupperSizer + wxHORIZONTAL + none + + 5 + wxEXPAND + 0 + + 10 + protected + 10 + + + + 5 + wxEXPAND + 1 + + + sbSizerMiddle + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 0 + + + "B/W" "Color" + + 1 + 1 + + + 0 + wxID_ANY + Plot Mode: + 1 + + + m_PlotColorCtrl + protected + + 0 + + wxRA_SPECIFY_COLS + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + 1 + + 1 + 1 + + + 0 + wxID_ANY + Print page references + + + m_Plot_Sheet_Ref_Ctrl + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 0 + + 10 + protected + 10 + + + + 5 + wxALIGN_CENTER_VERTICAL + 1 + + + bbuttonsSizer + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 0 + + + + 1 + 0 + 1 + + + 0 + wxID_ANY + &Plot Page + + + m_buttonPlotPage + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnPlotCurrent + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + + 1 + 0 + 1 + + + 0 + wxID_ANY + Plot A&LL + + + m_buttonPlotAll + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnPlotAll + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + + 1 + 0 + 1 + + + 0 + wxID_ANY + Close + + + m_buttonClose + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnCancelClick + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + + + 1 + 1 + + + 0 + wxID_ANY + Messages : + + + m_staticText1 + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 1 + + + + 1 + 1 + + + 0 + wxID_ANY + + 0 + -1,150 + m_MsgBox + protected + + + wxTE_MULTILINE|wxTE_READONLY + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/eeschema/dialogs/dialog_plot_schematic_DXF_base.h b/eeschema/dialogs/dialog_plot_schematic_DXF_base.h new file mode 100644 index 0000000000..9b4eab93c1 --- /dev/null +++ b/eeschema/dialogs/dialog_plot_schematic_DXF_base.h @@ -0,0 +1,60 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Sep 8 2010) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#ifndef __dialog_plot_schematic_DXF_base__ +#define __dialog_plot_schematic_DXF_base__ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////////// +/// Class DIALOG_PLOT_SCHEMATIC_DXF_BASE +/////////////////////////////////////////////////////////////////////////////// +class DIALOG_PLOT_SCHEMATIC_DXF_BASE : public wxDialog +{ + private: + + protected: + + wxRadioBox* m_PlotColorCtrl; + wxCheckBox* m_Plot_Sheet_Ref_Ctrl; + + wxButton* m_buttonPlotPage; + wxButton* m_buttonPlotAll; + wxButton* m_buttonClose; + wxStaticText* m_staticText1; + wxTextCtrl* m_MsgBox; + + // Virtual event handlers, overide them in your derived class + virtual void OnPlotCurrent( wxCommandEvent& event ) { event.Skip(); } + virtual void OnPlotAll( wxCommandEvent& event ) { event.Skip(); } + virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } + + + public: + + DIALOG_PLOT_SCHEMATIC_DXF_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("EESchema Plot DXF"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 387,365 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~DIALOG_PLOT_SCHEMATIC_DXF_BASE(); + +}; + +#endif //__dialog_plot_schematic_DXF_base__ diff --git a/eeschema/dialogs/dialog_plot_schematic_HPGL.cpp b/eeschema/dialogs/dialog_plot_schematic_HPGL.cpp index bc94d6aeb4..b13ccef79b 100644 --- a/eeschema/dialogs/dialog_plot_schematic_HPGL.cpp +++ b/eeschema/dialogs/dialog_plot_schematic_HPGL.cpp @@ -4,7 +4,7 @@ /* * This program source code file is part of KICAD, a free EDA CAD application. * - * Copyright (C) 1992-2010 Jean-Pieere Charras ShowModal(); - DXF_frame->Destroy(); -} - - -/*! - * WinEDA_PlotDXFFrame type definition - */ - -IMPLEMENT_DYNAMIC_CLASS( WinEDA_PlotDXFFrame, wxDialog ) - -/*! - * WinEDA_PlotDXFFrame event table definition - */ - -BEGIN_EVENT_TABLE( WinEDA_PlotDXFFrame, wxDialog ) - -////@begin WinEDA_PlotDXFFrame event table entries - EVT_BUTTON( ID_PLOT_DXF_CURRENT_EXECUTE, - WinEDA_PlotDXFFrame::OnPlotDXFCurrentExecuteClick ) - - EVT_BUTTON( ID_PLOT_DXF_ALL_EXECUTE, - WinEDA_PlotDXFFrame::OnPlotDXFAllExecuteClick ) - - EVT_BUTTON( wxID_CANCEL, WinEDA_PlotDXFFrame::OnCancelClick ) - -////@end WinEDA_PlotDXFFrame event table entries - -END_EVENT_TABLE() -/*! - * WinEDA_PlotDXFFrame constructors - */ - -WinEDA_PlotDXFFrame::WinEDA_PlotDXFFrame() -{ -} - - -WinEDA_PlotDXFFrame::WinEDA_PlotDXFFrame( WinEDA_DrawFrame* parent, - wxWindowID id, - const wxString& caption, - const wxPoint& pos, - const wxSize& size, - long style ) -{ - m_Parent = parent; - PlotDXFColorOpt = false; - Create( parent, id, caption, pos, size, style ); -} - - -/*! - * WinEDA_PlotDXFFrame creator - */ - -bool WinEDA_PlotDXFFrame::Create( wxWindow* parent, - wxWindowID id, - const wxString& caption, - const wxPoint& pos, - const wxSize& size, - long style ) -{ -////@begin WinEDA_PlotDXFFrame member initialisation - m_PlotDXFColorOption = NULL; - m_Plot_Sheet_Ref = NULL; - m_btClose = NULL; - m_MsgBox = NULL; - -////@end WinEDA_PlotDXFFrame member initialisation - -////@begin WinEDA_PlotDXFFrame creation - SetExtraStyle( wxWS_EX_BLOCK_EVENTS ); - wxDialog::Create( parent, id, caption, pos, size, style ); - - CreateControls(); - if( GetSizer() ) - { - GetSizer()->SetSizeHints( this ); - } - Centre(); - -////@end WinEDA_PlotDXFFrame creation - return true; -} - - -/*! - * Control creation for WinEDA_PlotDXFFrame - */ - -void WinEDA_PlotDXFFrame::CreateControls() -{ -////@begin WinEDA_PlotDXFFrame content construction - // Generated by DialogBlocks, 24/04/2009 14:25:24 (unregistered) - - WinEDA_PlotDXFFrame* itemDialog1 = this; - - wxBoxSizer* itemBoxSizer2 = new wxBoxSizer( wxVERTICAL ); - - itemDialog1->SetSizer( itemBoxSizer2 ); - - wxBoxSizer* itemBoxSizer3 = new wxBoxSizer( wxHORIZONTAL ); - itemBoxSizer2->Add( itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 ); - - wxStaticBox* itemStaticBoxSizer6Static = - new wxStaticBox( itemDialog1, wxID_ANY, _( "Plot Options:" ) ); - wxStaticBoxSizer* itemStaticBoxSizer6 = - new wxStaticBoxSizer( itemStaticBoxSizer6Static, wxVERTICAL ); - itemBoxSizer3->Add( itemStaticBoxSizer6, - 0, - wxALIGN_CENTER_VERTICAL | wxALL, - 5 ); - - wxArrayString m_PlotDXFColorOptionStrings; - m_PlotDXFColorOptionStrings.Add( _( "B/W" ) ); - m_PlotDXFColorOptionStrings.Add( _( "Color" ) ); - m_PlotDXFColorOption = - new wxRadioBox( itemDialog1, ID_RADIOBOX, _( "Plot Color:" ), - wxDefaultPosition, wxDefaultSize, - m_PlotDXFColorOptionStrings, 1, wxRA_SPECIFY_COLS ); - m_PlotDXFColorOption->SetSelection( 0 ); - itemStaticBoxSizer6->Add( m_PlotDXFColorOption, 0, wxGROW | wxALL, 5 ); - - m_Plot_Sheet_Ref = - new wxCheckBox( itemDialog1, ID_CHECKBOX, _( "Print Sheet Ref" ), - wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); - m_Plot_Sheet_Ref->SetValue( false ); - itemStaticBoxSizer6->Add( m_Plot_Sheet_Ref, 0, wxGROW | wxALL, 5 ); - - itemBoxSizer3->Add( 5, 5, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); - - wxBoxSizer* itemBoxSizer10 = new wxBoxSizer( wxVERTICAL ); - itemBoxSizer3->Add( itemBoxSizer10, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); - - wxButton* itemButton11 = new wxButton( itemDialog1, - ID_PLOT_DXF_CURRENT_EXECUTE, - _( "&Plot Page" ), - wxDefaultPosition, - wxDefaultSize, - 0 ); - itemButton11->SetDefault(); - itemBoxSizer10->Add( itemButton11, 0, wxGROW | wxALL, 5 ); - - wxButton* itemButton12 = new wxButton( itemDialog1, - ID_PLOT_DXF_ALL_EXECUTE, - _( "Plot A&LL" ), - wxDefaultPosition, - wxDefaultSize, - 0 ); - itemBoxSizer10->Add( itemButton12, 0, wxGROW | wxALL, 5 ); - - m_btClose = new wxButton( itemDialog1, wxID_CANCEL, _( "Close" ), - wxDefaultPosition, wxDefaultSize, - 0 ); - itemBoxSizer10->Add( m_btClose, 0, wxGROW | wxALL, 5 ); - - wxStaticText* itemStaticText15 = new wxStaticText( itemDialog1, - wxID_STATIC, - _( "Messages :" ), - wxDefaultPosition, - wxDefaultSize, - 0 ); - itemBoxSizer2->Add( itemStaticText15, - 0, - wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | - wxADJUST_MINSIZE, - 5 ); - - m_MsgBox = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T( "" ), - wxDefaultPosition, wxSize( -1, 200 ), - wxTE_MULTILINE ); - itemBoxSizer2->Add( m_MsgBox, 0, wxGROW | wxALL | wxFIXED_MINSIZE, 5 ); - - // Set validators - m_PlotDXFColorOption->SetValidator( wxGenericValidator( &PlotDXFColorOpt ) ); - m_Plot_Sheet_Ref->SetValidator( wxGenericValidator( &Plot_Sheet_Ref ) ); - -////@end WinEDA_PlotDXFFrame content construction - - SetFocus(); // make the ESC work -} - - -/*! - * Should we show tooltips? - */ - -bool WinEDA_PlotDXFFrame::ShowToolTips() -{ - return true; -} - - -/*! - * Get bitmap resources - */ - -wxBitmap WinEDA_PlotDXFFrame::GetBitmapResource( const wxString& name ) -{ - // Bitmap retrieval -////@begin WinEDA_PlotDXFFrame bitmap retrieval - wxUnusedVar( name ); - return wxNullBitmap; - -////@end WinEDA_PlotDXFFrame bitmap retrieval -} - - -/*! - * Get icon resources - */ - -wxIcon WinEDA_PlotDXFFrame::GetIconResource( const wxString& name ) -{ - // Icon retrieval -////@begin WinEDA_PlotDXFFrame icon retrieval - wxUnusedVar( name ); - return wxNullIcon; - -////@end WinEDA_PlotDXFFrame icon retrieval -} - - -/*! - * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON - */ - -void WinEDA_PlotDXFFrame::OnPlotDXFCurrentExecuteClick( wxCommandEvent& event ) -{ - int Select_PlotAll = FALSE; - - InitOptVars(); - CreateDXFFile( Select_PlotAll ); - m_MsgBox->AppendText( wxT( "*****\n" ) ); -} - - -/*! - * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON1 - */ - -void WinEDA_PlotDXFFrame::OnPlotDXFAllExecuteClick( wxCommandEvent& event ) -{ - int Select_PlotAll = TRUE; - - InitOptVars(); - CreateDXFFile( Select_PlotAll ); - m_MsgBox->AppendText( wxT( "*****\n" ) ); -} - - -/*! - * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL - */ - -void WinEDA_PlotDXFFrame::OnCancelClick( wxCommandEvent& event ) -{ - InitOptVars(); - EndModal( 0 ); -} - - -void WinEDA_PlotDXFFrame::InitOptVars() -{ - Plot_Sheet_Ref = m_Plot_Sheet_Ref->GetValue(); - PlotDXFColorOpt = m_PlotDXFColorOption->GetSelection(); -} - - -void WinEDA_PlotDXFFrame::CreateDXFFile( int AllPages ) -{ - WinEDA_SchematicFrame* schframe = (WinEDA_SchematicFrame*) m_Parent; - SCH_SCREEN* screen = schframe->GetScreen(); - SCH_SCREEN* oldscreen = screen; - SCH_SHEET_PATH* sheetpath, * oldsheetpath = schframe->GetSheet(); - wxString PlotFileName; - Ki_PageDescr* PlotSheet; - wxPoint plot_offset; - - /* When printing all pages, the printed page is not the current page. - * In complex hierarchies, we must setup references and others parameters - * in the printed SCH_SCREEN - * because in complex hierarchies a SCH_SCREEN (a schematic drawings) - * is shared between many sheets - */ - SCH_SHEET_LIST SheetList( NULL ); - - sheetpath = SheetList.GetFirst(); - SCH_SHEET_PATH list; - - while( true ) - { - if( AllPages ) - { - if( sheetpath == NULL ) - break; - list.Clear(); - if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) ) - { - schframe->m_CurrentSheet = &list; - schframe->m_CurrentSheet->UpdateAllScreenReferences(); - schframe->SetSheetNumberAndCount(); - screen = schframe->m_CurrentSheet->LastScreen(); - ActiveScreen = screen; - } - else // Should not happen - return; - sheetpath = SheetList.GetNext(); - } - PlotSheet = screen->m_CurrentSheetDesc; - double scale = 10; - - plot_offset.x = 0; - plot_offset.y = 0; - - PlotFileName = schframe->GetUniqueFilenameForCurrentSheet() + wxT( - ".dxf" ); - - PlotOneSheetDXF( PlotFileName, screen, PlotSheet, plot_offset, scale ); - - if( !AllPages ) - break; - } - - ActiveScreen = oldscreen; - schframe->m_CurrentSheet = oldsheetpath; - schframe->m_CurrentSheet->UpdateAllScreenReferences(); - schframe->SetSheetNumberAndCount(); -} - - -void WinEDA_PlotDXFFrame::PlotOneSheetDXF( const wxString& FileName, - SCH_SCREEN* screen, - Ki_PageDescr* sheet, - wxPoint plot_offset, - double scale ) -{ - wxString msg; - - FILE* output_file = wxFopen( FileName, wxT( "wt" ) ); - - if( output_file == NULL ) - { - msg = wxT( "\n** " ); - msg += _( "Unable to create " ) + FileName + wxT( " **\n\n" ); - m_MsgBox->AppendText( msg ); - wxBell(); - return; - } - - SetLocaleTo_C_standard(); - msg.Printf( _( "Plot: %s\n" ), FileName.GetData() ); - m_MsgBox->AppendText( msg ); - - DXF_PLOTTER* plotter = new DXF_PLOTTER(); - plotter->set_paper_size( sheet ); - plotter->set_viewport( plot_offset, scale, 0 ); - plotter->set_color_mode( PlotDXFColorOpt ); - - /* Init : */ - plotter->set_creator( wxT( "EESchema-DXF" ) ); - plotter->set_filename( FileName ); - plotter->start_plot( output_file ); - - if( Plot_Sheet_Ref ) - { - plotter->set_color( BLACK ); - m_Parent->PlotWorkSheet( plotter, screen ); - } - - PlotDrawlist( plotter, screen->EEDrawList ); - - /* fin */ - plotter->end_plot(); - delete plotter; - SetLocaleTo_Default(); - - m_MsgBox->AppendText( wxT( "Ok\n" ) ); -} diff --git a/eeschema/plotdxf.h b/eeschema/plotdxf.h deleted file mode 100644 index b4f41b80a1..0000000000 --- a/eeschema/plotdxf.h +++ /dev/null @@ -1,123 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: plotdxf.h -// Purpose: -// Author: Lorenzo Marcantonio -// Modified by: -// Created: 01/02/2006 08:37:24 -// RCS-ID: -// Copyright: GNU License -// Licence: -///////////////////////////////////////////////////////////////////////////// - -#ifndef _PLOTDXF_H_ -#define _PLOTDXF_H_ - -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma interface "plotdxf.h" -#endif - -/*! - * Includes - */ - -////@begin includes -#include "wx/valgen.h" -////@end includes - -/*! - * Forward declarations - */ - -////@begin forward declarations -class wxBoxSizer; -////@end forward declarations - -/*! - * Control identifiers - */ - -////@begin control identifiers -#define ID_DIALOG 10000 -#define ID_RADIOBOX 10001 -#define ID_CHECKBOX 10005 -#define ID_PLOT_DXF_CURRENT_EXECUTE 10003 -#define ID_PLOT_DXF_ALL_EXECUTE 10004 -#define ID_TEXTCTRL 10006 -#define SYMBOL_WINEDA_PLOTDXFFRAME_STYLE wxDEFAULT_DIALOG_STYLE|wxCAPTION|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL|MAYBE_RESIZE_BORDER -#define SYMBOL_WINEDA_PLOTDXFFRAME_TITLE _("EESchema Plot DXF") -#define SYMBOL_WINEDA_PLOTDXFFRAME_IDNAME ID_DIALOG -#define SYMBOL_WINEDA_PLOTDXFFRAME_SIZE wxSize(400, 300) -#define SYMBOL_WINEDA_PLOTDXFFRAME_POSITION wxDefaultPosition -////@end control identifiers - -/*! - * Compatibility - */ - -#ifndef wxCLOSE_BOX -#define wxCLOSE_BOX 0x1000 -#endif - -/*! - * WinEDA_PlotDXFFrame class declaration - */ - -class WinEDA_PlotDXFFrame: public wxDialog -{ - DECLARE_DYNAMIC_CLASS( WinEDA_PlotDXFFrame ) - DECLARE_EVENT_TABLE() - -public: - /// Constructors - WinEDA_PlotDXFFrame( ); - WinEDA_PlotDXFFrame( WinEDA_DrawFrame* parent, wxWindowID id = SYMBOL_WINEDA_PLOTDXFFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_PLOTDXFFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_PLOTDXFFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_PLOTDXFFRAME_SIZE, long style = SYMBOL_WINEDA_PLOTDXFFRAME_STYLE ); - - /// Creation - bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_PLOTDXFFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_PLOTDXFFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_PLOTDXFFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_PLOTDXFFRAME_SIZE, long style = SYMBOL_WINEDA_PLOTDXFFRAME_STYLE ); - - /// Creates the controls and sizers - void CreateControls(); - -////@begin WinEDA_PlotDXFFrame event handler declarations - - /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PLOT_DXF_CURRENT_EXECUTE - void OnPlotDXFCurrentExecuteClick( wxCommandEvent& event ); - - /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PLOT_DXF_ALL_EXECUTE - void OnPlotDXFAllExecuteClick( wxCommandEvent& event ); - - /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL - void OnCancelClick( wxCommandEvent& event ); - -////@end WinEDA_PlotDXFFrame event handler declarations - -////@begin WinEDA_PlotDXFFrame member function declarations - - /// Retrieves bitmap resources - wxBitmap GetBitmapResource( const wxString& name ); - - /// Retrieves icon resources - wxIcon GetIconResource( const wxString& name ); -////@end WinEDA_PlotDXFFrame member function declarations - - void InitOptVars(); - void CreateDXFFile(int AllPages); - void PlotOneSheetDXF(const wxString & FileName, - SCH_SCREEN * screen, Ki_PageDescr * sheet, - wxPoint plot_offset, double scale); - - /// Should we show tooltips? - static bool ShowToolTips(); - -////@begin WinEDA_PlotDXFFrame member variables - wxRadioBox* m_PlotDXFColorOption; - wxCheckBox* m_Plot_Sheet_Ref; - wxButton* m_btClose; - wxTextCtrl* m_MsgBox; -////@end WinEDA_PlotDXFFrame member variables - WinEDA_DrawFrame * m_Parent; - int PlotDXFColorOpt; -}; - -#endif -// _PLOTDXF_H_