pcbnew: copy/paste code cleanup & formatting
This commit is contained in:
parent
c6a0ad895b
commit
4a5d400ec2
|
@ -1,14 +1,8 @@
|
|||
/**
|
||||
* @file kicad_clipboard.cpp
|
||||
* @brief Kicad clipboard plugin that piggybacks on the kicad_plugin
|
||||
*
|
||||
* @author Kristoffer Ödmark
|
||||
* @version 1.0
|
||||
* @date 2017-05-03
|
||||
*
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2017 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
* @author Kristoffer Ödmark
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -46,18 +40,22 @@ CLIPBOARD_IO::CLIPBOARD_IO():
|
|||
m_out = &m_formatter;
|
||||
}
|
||||
|
||||
|
||||
CLIPBOARD_IO::~CLIPBOARD_IO(){}
|
||||
|
||||
|
||||
STRING_FORMATTER* CLIPBOARD_IO::GetFormatter()
|
||||
{
|
||||
return &m_formatter;
|
||||
}
|
||||
|
||||
|
||||
void CLIPBOARD_IO::SetBoard( BOARD* aBoard )
|
||||
{
|
||||
m_board = aBoard;
|
||||
}
|
||||
|
||||
|
||||
void CLIPBOARD_IO::SaveSelection( const SELECTION& aSelected )
|
||||
{
|
||||
LOCALE_IO toggle; // toggles on, then off, the C locale.
|
||||
|
@ -147,8 +145,8 @@ void CLIPBOARD_IO::SaveSelection( const SELECTION& aSelected )
|
|||
{
|
||||
// we will fake being a .kicad_pcb to get the full parser kicking
|
||||
// This means we also need layers and nets
|
||||
m_formatter.Print( 0, "(kicad_pcb (version %d) (host pcbnew %s)\n", SEXPR_BOARD_FILE_VERSION,
|
||||
m_formatter.Quotew( GetBuildVersion() ).c_str() );
|
||||
m_formatter.Print( 0, "(kicad_pcb (version %d) (host pcbnew %s)\n",
|
||||
SEXPR_BOARD_FILE_VERSION, m_formatter.Quotew( GetBuildVersion() ).c_str() );
|
||||
|
||||
|
||||
m_formatter.Print( 0, "\n" );
|
||||
|
@ -180,11 +178,13 @@ void CLIPBOARD_IO::SaveSelection( const SELECTION& aSelected )
|
|||
}
|
||||
if( wxTheClipboard->Open() )
|
||||
{
|
||||
wxTheClipboard->SetData( new wxTextDataObject( wxString( m_formatter.GetString().c_str(), wxConvUTF8 ) ) );
|
||||
wxTheClipboard->SetData( new wxTextDataObject(
|
||||
wxString( m_formatter.GetString().c_str(), wxConvUTF8 ) ) );
|
||||
wxTheClipboard->Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BOARD_ITEM* CLIPBOARD_IO::Parse()
|
||||
{
|
||||
std::string result;
|
||||
|
@ -213,6 +213,7 @@ BOARD_ITEM* CLIPBOARD_IO::Parse()
|
|||
return item;
|
||||
}
|
||||
|
||||
|
||||
void CLIPBOARD_IO::Save( const wxString& aFileName, BOARD* aBoard,
|
||||
const PROPERTIES* aProperties )
|
||||
{
|
||||
|
@ -238,13 +239,16 @@ void CLIPBOARD_IO::Save( const wxString& aFileName, BOARD* aBoard,
|
|||
|
||||
if( wxTheClipboard->Open() )
|
||||
{
|
||||
wxTheClipboard->SetData( new wxTextDataObject( wxString( m_formatter.GetString().c_str(), wxConvUTF8 ) ) );
|
||||
wxTheClipboard->SetData( new wxTextDataObject(
|
||||
wxString( m_formatter.GetString().c_str(), wxConvUTF8 ) ) );
|
||||
wxTheClipboard->Close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BOARD* CLIPBOARD_IO::Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties )
|
||||
|
||||
BOARD* CLIPBOARD_IO::Load( const wxString& aFileName,
|
||||
BOARD* aAppendToMe, const PROPERTIES* aProperties )
|
||||
{
|
||||
std::string result;
|
||||
|
||||
|
|
|
@ -571,7 +571,8 @@ void PCB_IO::formatSetup( BOARD* aBoard, int aNestLevel ) const
|
|||
|
||||
// Save used non-copper layers in the order they are defined.
|
||||
// desired sequence for non Cu BOARD layers.
|
||||
static const PCB_LAYER_ID non_cu[] = {
|
||||
static const PCB_LAYER_ID non_cu[] =
|
||||
{
|
||||
B_Adhes, // 32
|
||||
F_Adhes,
|
||||
B_Paste,
|
||||
|
@ -720,6 +721,7 @@ void PCB_IO::formatSetup( BOARD* aBoard, int aNestLevel ) const
|
|||
m_out->Print( aNestLevel, ")\n\n" );
|
||||
}
|
||||
|
||||
|
||||
void PCB_IO::formatGeneral( BOARD* aBoard, int aNestLevel ) const
|
||||
{
|
||||
const BOARD_DESIGN_SETTINGS& dsnSettings = aBoard->GetDesignSettings();
|
||||
|
@ -741,6 +743,7 @@ void PCB_IO::formatGeneral( BOARD* aBoard, int aNestLevel ) const
|
|||
aBoard->GetTitleBlock().Format( m_out, aNestLevel, m_ctl );
|
||||
}
|
||||
|
||||
|
||||
void PCB_IO::formatBoardLayers( BOARD* aBoard, int aNestLevel ) const
|
||||
{
|
||||
m_out->Print( aNestLevel, "(layers\n" );
|
||||
|
@ -764,7 +767,8 @@ void PCB_IO::formatBoardLayers( BOARD* aBoard, int aNestLevel ) const
|
|||
|
||||
// Save used non-copper layers in the order they are defined.
|
||||
// desired sequence for non Cu BOARD layers.
|
||||
static const PCB_LAYER_ID non_cu[] = {
|
||||
static const PCB_LAYER_ID non_cu[] =
|
||||
{
|
||||
B_Adhes, // 32
|
||||
F_Adhes,
|
||||
B_Paste,
|
||||
|
@ -801,6 +805,7 @@ void PCB_IO::formatBoardLayers( BOARD* aBoard, int aNestLevel ) const
|
|||
m_out->Print( aNestLevel, ")\n\n" );
|
||||
}
|
||||
|
||||
|
||||
void PCB_IO::formatNetInformation( BOARD* aBoard, int aNestLevel ) const
|
||||
{
|
||||
const BOARD_DESIGN_SETTINGS& dsnSettings = aBoard->GetDesignSettings();
|
||||
|
@ -830,6 +835,7 @@ void PCB_IO::formatNetInformation( BOARD* aBoard, int aNestLevel ) const
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void PCB_IO::formatHeader( BOARD* aBoard, int aNestLevel ) const
|
||||
{
|
||||
formatGeneral( aBoard );
|
||||
|
|
Loading…
Reference in New Issue