Normalize line endings

A few files snuck in with CRLF for the line endings.  These make it hard
to look at diffs as every line appears to have changed.  This commit
makes only line ending changes, so can be ignored
This commit is contained in:
Seth Hillbrand 2019-06-19 07:18:30 -07:00
parent 6aa0ceff36
commit 77cefe0c16
8 changed files with 1623 additions and 1623 deletions

View File

@ -1,4 +1,4 @@
/*
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>

File diff suppressed because it is too large Load Diff

View File

@ -1,177 +1,177 @@
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2019 Kicad Developers, see AUTHORS.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
*/
#ifndef BITMOP2CMP_GUI_H_
#define BITMOP2CMP_GUI_H_
#include "bitmap2component.h"
#include "bitmap2cmp_gui_base.h"
#include <potracelib.h>
#include <common.h> // for EDA_UNITS_T
class IMAGE_SIZE
{
public:
IMAGE_SIZE();
// Set the unit used for m_outputSize, and convert the old m_outputSize value
// to the value in new unit
void SetUnit( EDA_UNITS_T aUnit );
// Accessors:
void SetOriginalDPI( int aDPI )
{
m_originalDPI = aDPI;
}
void SetOriginalSizePixels( int aPixels )
{
m_originalSizePixels = aPixels;
}
double GetOutputSize()
{
return m_outputSize;
}
void SetOutputSize( double aSize, EDA_UNITS_T aUnit )
{
m_unit = aUnit;
m_outputSize = aSize;
}
int GetOriginalSizePixels()
{
return m_originalSizePixels;
}
// Set the m_outputSize value from the m_originalSizePixels and the selected unit
void SetOutputSizeFromInitialImageSize();
/** @return the pixels per inch value to build the output image.
* It is used by potrace to build the polygonal image
*/
int GetOutputDPI();
private:
EDA_UNITS_T m_unit; // The units for m_outputSize (mm, inch, dpi)
double m_outputSize; // The size in m_unit of the output image, depending on
// the user settings. Set to the initial image size
int m_originalDPI; // The image DPI if specified in file, or 0 if unknown
int m_originalSizePixels; // The original image size read from file, in pixels
};
class BM2CMP_FRAME : public BM2CMP_FRAME_BASE
{
public:
BM2CMP_FRAME( KIWAY* aKiway, wxWindow* aParent );
~BM2CMP_FRAME();
// overload KIWAY_PLAYER virtual
bool OpenProjectFiles( const std::vector<wxString>& aFilenames, int aCtl = 0 ) override;
private:
// Event handlers
void OnPaintInit( wxPaintEvent& event ) override;
void OnPaintGreyscale( wxPaintEvent& event ) override;
void OnPaintBW( wxPaintEvent& event ) override;
void OnLoadFile( wxCommandEvent& event ) override;
void OnExportToFile( wxCommandEvent& event ) override;
void OnExportToClipboard( wxCommandEvent& event ) override;
///> @return the EDA_UNITS_T from the m_PixelUnit choice
EDA_UNITS_T getUnitFromSelection();
// return a string giving the output size, according to the selected unit
wxString FormatOutputSize( double aSize );
/**
* Generate a schematic library which contains one component:
* the logo
*/
void exportEeschemaFormat();
/**
* Generate a module in S expr format
*/
void exportPcbnewFormat();
/**
* Generate a postscript file
*/
void exportPostScriptFormat();
/**
* Generate a file suitable to be copied into a page layout
* description file (.kicad_wks file
*/
void OnExportLogo();
void Binarize( double aThreshold ); // aThreshold = 0.0 (black level) to 1.0 (white level)
void OnNegativeClicked( wxCommandEvent& event ) override;
void OnThresholdChange( wxScrollEvent& event ) override;
void OnSizeChangeX( wxCommandEvent& event ) override;
void OnSizeChangeY( wxCommandEvent& event ) override;
void OnSizeUnitChange( wxCommandEvent& event ) override;
void ToggleAspectRatioLock( wxCommandEvent& event ) override;
void NegateGreyscaleImage();
/**
* generate a export data of the current bitmap.
* @param aOutput is a string buffer to fill with data
* @param aFormat is the format to generate
*/
void ExportToBuffer( std::string& aOutput, OUTPUT_FMT_ID aFormat );
void updateImageInfo();
void OnFormatChange( wxCommandEvent& event ) override;
void exportBitmap( OUTPUT_FMT_ID aFormat );
void LoadSettings( wxConfigBase* aCfg ) override;
void SaveSettings( wxConfigBase* aCfg ) override;
private:
wxImage m_Pict_Image;
wxBitmap m_Pict_Bitmap;
wxImage m_Greyscale_Image;
wxBitmap m_Greyscale_Bitmap;
wxImage m_NB_Image;
wxBitmap m_BN_Bitmap;
IMAGE_SIZE m_outputSizeX;
IMAGE_SIZE m_outputSizeY;
bool m_Negative;
wxString m_BitmapFileName;
wxString m_ConvertedFileName;
wxSize m_frameSize;
wxPoint m_framePos;
std::unique_ptr<wxConfigBase> m_config;
bool m_exportToClipboard;
bool m_AspectRatioLocked;
double m_AspectRatio;
};
#endif// BITMOP2CMP_GUI_H_
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2019 Kicad Developers, see AUTHORS.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
*/
#ifndef BITMOP2CMP_GUI_H_
#define BITMOP2CMP_GUI_H_
#include "bitmap2component.h"
#include "bitmap2cmp_gui_base.h"
#include <potracelib.h>
#include <common.h> // for EDA_UNITS_T
class IMAGE_SIZE
{
public:
IMAGE_SIZE();
// Set the unit used for m_outputSize, and convert the old m_outputSize value
// to the value in new unit
void SetUnit( EDA_UNITS_T aUnit );
// Accessors:
void SetOriginalDPI( int aDPI )
{
m_originalDPI = aDPI;
}
void SetOriginalSizePixels( int aPixels )
{
m_originalSizePixels = aPixels;
}
double GetOutputSize()
{
return m_outputSize;
}
void SetOutputSize( double aSize, EDA_UNITS_T aUnit )
{
m_unit = aUnit;
m_outputSize = aSize;
}
int GetOriginalSizePixels()
{
return m_originalSizePixels;
}
// Set the m_outputSize value from the m_originalSizePixels and the selected unit
void SetOutputSizeFromInitialImageSize();
/** @return the pixels per inch value to build the output image.
* It is used by potrace to build the polygonal image
*/
int GetOutputDPI();
private:
EDA_UNITS_T m_unit; // The units for m_outputSize (mm, inch, dpi)
double m_outputSize; // The size in m_unit of the output image, depending on
// the user settings. Set to the initial image size
int m_originalDPI; // The image DPI if specified in file, or 0 if unknown
int m_originalSizePixels; // The original image size read from file, in pixels
};
class BM2CMP_FRAME : public BM2CMP_FRAME_BASE
{
public:
BM2CMP_FRAME( KIWAY* aKiway, wxWindow* aParent );
~BM2CMP_FRAME();
// overload KIWAY_PLAYER virtual
bool OpenProjectFiles( const std::vector<wxString>& aFilenames, int aCtl = 0 ) override;
private:
// Event handlers
void OnPaintInit( wxPaintEvent& event ) override;
void OnPaintGreyscale( wxPaintEvent& event ) override;
void OnPaintBW( wxPaintEvent& event ) override;
void OnLoadFile( wxCommandEvent& event ) override;
void OnExportToFile( wxCommandEvent& event ) override;
void OnExportToClipboard( wxCommandEvent& event ) override;
///> @return the EDA_UNITS_T from the m_PixelUnit choice
EDA_UNITS_T getUnitFromSelection();
// return a string giving the output size, according to the selected unit
wxString FormatOutputSize( double aSize );
/**
* Generate a schematic library which contains one component:
* the logo
*/
void exportEeschemaFormat();
/**
* Generate a module in S expr format
*/
void exportPcbnewFormat();
/**
* Generate a postscript file
*/
void exportPostScriptFormat();
/**
* Generate a file suitable to be copied into a page layout
* description file (.kicad_wks file
*/
void OnExportLogo();
void Binarize( double aThreshold ); // aThreshold = 0.0 (black level) to 1.0 (white level)
void OnNegativeClicked( wxCommandEvent& event ) override;
void OnThresholdChange( wxScrollEvent& event ) override;
void OnSizeChangeX( wxCommandEvent& event ) override;
void OnSizeChangeY( wxCommandEvent& event ) override;
void OnSizeUnitChange( wxCommandEvent& event ) override;
void ToggleAspectRatioLock( wxCommandEvent& event ) override;
void NegateGreyscaleImage();
/**
* generate a export data of the current bitmap.
* @param aOutput is a string buffer to fill with data
* @param aFormat is the format to generate
*/
void ExportToBuffer( std::string& aOutput, OUTPUT_FMT_ID aFormat );
void updateImageInfo();
void OnFormatChange( wxCommandEvent& event ) override;
void exportBitmap( OUTPUT_FMT_ID aFormat );
void LoadSettings( wxConfigBase* aCfg ) override;
void SaveSettings( wxConfigBase* aCfg ) override;
private:
wxImage m_Pict_Image;
wxBitmap m_Pict_Bitmap;
wxImage m_Greyscale_Image;
wxBitmap m_Greyscale_Bitmap;
wxImage m_NB_Image;
wxBitmap m_BN_Bitmap;
IMAGE_SIZE m_outputSizeX;
IMAGE_SIZE m_outputSizeY;
bool m_Negative;
wxString m_BitmapFileName;
wxString m_ConvertedFileName;
wxSize m_frameSize;
wxPoint m_framePos;
std::unique_ptr<wxConfigBase> m_config;
bool m_exportToClipboard;
bool m_AspectRatioLocked;
double m_AspectRatio;
};
#endif// BITMOP2CMP_GUI_H_

View File

@ -1,53 +1,53 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Aug 4 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_text_entry_base.h"
///////////////////////////////////////////////////////////////////////////
WX_TEXT_ENTRY_DIALOG_BASE::WX_TEXT_ENTRY_DIALOG_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bSizerMain;
bSizerMain = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizerContent;
bSizerContent = new wxBoxSizer( wxVERTICAL );
m_label = new wxStaticText( this, wxID_ANY, _("MyLabel"), wxDefaultPosition, wxDefaultSize, 0 );
m_label->Wrap( -1 );
bSizerContent->Add( m_label, 0, wxALL|wxEXPAND, 5 );
m_textCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_textCtrl->SetMinSize( wxSize( 300,-1 ) );
bSizerContent->Add( m_textCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
bSizerMain->Add( bSizerContent, 1, wxALL|wxEXPAND, 5 );
m_sdbSizer1 = new wxStdDialogButtonSizer();
m_sdbSizer1OK = new wxButton( this, wxID_OK );
m_sdbSizer1->AddButton( m_sdbSizer1OK );
m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer1->AddButton( m_sdbSizer1Cancel );
m_sdbSizer1->Realize();
bSizerMain->Add( m_sdbSizer1, 0, wxALL|wxALIGN_RIGHT, 5 );
this->SetSizer( bSizerMain );
this->Layout();
bSizerMain->Fit( this );
this->Centre( wxBOTH );
}
WX_TEXT_ENTRY_DIALOG_BASE::~WX_TEXT_ENTRY_DIALOG_BASE()
{
}
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Aug 4 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_text_entry_base.h"
///////////////////////////////////////////////////////////////////////////
WX_TEXT_ENTRY_DIALOG_BASE::WX_TEXT_ENTRY_DIALOG_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bSizerMain;
bSizerMain = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizerContent;
bSizerContent = new wxBoxSizer( wxVERTICAL );
m_label = new wxStaticText( this, wxID_ANY, _("MyLabel"), wxDefaultPosition, wxDefaultSize, 0 );
m_label->Wrap( -1 );
bSizerContent->Add( m_label, 0, wxALL|wxEXPAND, 5 );
m_textCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_textCtrl->SetMinSize( wxSize( 300,-1 ) );
bSizerContent->Add( m_textCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
bSizerMain->Add( bSizerContent, 1, wxALL|wxEXPAND, 5 );
m_sdbSizer1 = new wxStdDialogButtonSizer();
m_sdbSizer1OK = new wxButton( this, wxID_OK );
m_sdbSizer1->AddButton( m_sdbSizer1OK );
m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer1->AddButton( m_sdbSizer1Cancel );
m_sdbSizer1->Realize();
bSizerMain->Add( m_sdbSizer1, 0, wxALL|wxALIGN_RIGHT, 5 );
this->SetSizer( bSizerMain );
this->Layout();
bSizerMain->Fit( this );
this->Centre( wxBOTH );
}
WX_TEXT_ENTRY_DIALOG_BASE::~WX_TEXT_ENTRY_DIALOG_BASE()
{
}

View File

@ -1,52 +1,52 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Aug 4 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_TEXT_ENTRY_BASE_H__
#define __DIALOG_TEXT_ENTRY_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class DIALOG_SHIM;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class WX_TEXT_ENTRY_DIALOG_BASE
///////////////////////////////////////////////////////////////////////////////
class WX_TEXT_ENTRY_DIALOG_BASE : public DIALOG_SHIM
{
private:
protected:
wxStaticText* m_label;
wxTextCtrl* m_textCtrl;
wxStdDialogButtonSizer* m_sdbSizer1;
wxButton* m_sdbSizer1OK;
wxButton* m_sdbSizer1Cancel;
public:
WX_TEXT_ENTRY_DIALOG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~WX_TEXT_ENTRY_DIALOG_BASE();
};
#endif //__DIALOG_TEXT_ENTRY_BASE_H__
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Aug 4 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_TEXT_ENTRY_BASE_H__
#define __DIALOG_TEXT_ENTRY_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class DIALOG_SHIM;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class WX_TEXT_ENTRY_DIALOG_BASE
///////////////////////////////////////////////////////////////////////////////
class WX_TEXT_ENTRY_DIALOG_BASE : public DIALOG_SHIM
{
private:
protected:
wxStaticText* m_label;
wxTextCtrl* m_textCtrl;
wxStdDialogButtonSizer* m_sdbSizer1;
wxButton* m_sdbSizer1OK;
wxButton* m_sdbSizer1Cancel;
public:
WX_TEXT_ENTRY_DIALOG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~WX_TEXT_ENTRY_DIALOG_BASE();
};
#endif //__DIALOG_TEXT_ENTRY_BASE_H__

View File

@ -1,232 +1,232 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017 KiCad Developers, see AUTHORS.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 3 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __LIB_TABLE_GRID_H__
#define __LIB_TABLE_GRID_H__
#include <lib_table_base.h>
#include <wx/grid.h>
const wxColour COLOUR_ROW_ENABLED( 0, 0, 0 );
const wxColour COLOUR_ROW_DISABLED( 100, 100, 100 );
/// The library table grid column order is established by this sequence.
enum COL_ORDER
{
COL_ENABLED,
COL_NICKNAME,
COL_URI,
COL_TYPE,
COL_OPTIONS,
COL_DESCR,
COL_COUNT // keep as last
};
/**
* This abstract base class mixes any object derived from #LIB_TABLE into wxGridTableBase
* so the result can be used as any type of library table within wxGrid.
*/
class LIB_TABLE_GRID : public wxGridTableBase
{
public:
//-----<wxGridTableBase overloads>-------------------------------------------
int GetNumberRows() override { return (int) size(); }
int GetNumberCols() override { return COL_COUNT; }
wxString GetValue( int aRow, int aCol ) override
{
if( aRow < (int) size() )
{
const LIB_TABLE_ROW* r = at( (size_t) aRow );
switch( aCol )
{
case COL_NICKNAME: return r->GetNickName();
case COL_URI: return r->GetFullURI();
case COL_TYPE: return r->GetType();
case COL_OPTIONS: return r->GetOptions();
case COL_DESCR: return r->GetDescr();
// Render a boolean value as its text equivalent
case COL_ENABLED: return r->GetIsEnabled() ? wxT( "1" ) : wxT( "0" );
default:
; // fall thru to wxEmptyString
}
}
return wxEmptyString;
}
bool GetValueAsBool( int aRow, int aCol ) override
{
if( aRow < (int) size() && aCol == COL_ENABLED )
return at( (size_t) aRow )->GetIsEnabled();
else
return false;
}
void SetValue( int aRow, int aCol, const wxString &aValue ) override
{
if( aRow < (int) size() )
{
LIB_TABLE_ROW* r = at( (size_t) aRow );
switch( aCol )
{
case COL_NICKNAME: r->SetNickName( aValue ); break;
case COL_URI: r->SetFullURI( aValue ); break;
case COL_TYPE: r->SetType( aValue ); break;
case COL_OPTIONS: r->SetOptions( aValue ); break;
case COL_DESCR: r->SetDescr( aValue ); break;
case COL_ENABLED:
r->SetEnabled( aValue == wxT( "1" ) );
break;
}
}
}
void SetValueAsBool( int aRow, int aCol, bool aValue ) override
{
if( aRow < (int) size() && aCol == COL_ENABLED )
at( (size_t) aRow )->SetEnabled( aValue );
}
bool IsEmptyCell( int aRow, int aCol ) override
{
return !GetValue( aRow, aCol );
}
bool InsertRows( size_t aPos = 0, size_t aNumRows = 1 ) override
{
if( aPos < size() )
{
for( size_t i = 0; i < aNumRows; i++ )
{
insert( begin() + i, makeNewRow() );
}
// use the (wxGridStringTable) source Luke.
if( GetView() )
{
wxGridTableMessage msg( this,
wxGRIDTABLE_NOTIFY_ROWS_INSERTED,
aPos,
aNumRows );
GetView()->ProcessTableMessage( msg );
}
return true;
}
return false;
}
bool AppendRows( size_t aNumRows = 1 ) override
{
// do not modify aNumRows, original value needed for wxGridTableMessage below
for( int i = aNumRows; i; --i )
push_back( makeNewRow() );
if( GetView() )
{
wxGridTableMessage msg( this,
wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
aNumRows );
GetView()->ProcessTableMessage( msg );
}
return true;
}
bool DeleteRows( size_t aPos, size_t aNumRows ) override
{
// aPos may be a large positive, e.g. size_t(-1), and the sum of
// aPos+aNumRows may wrap here, so both ends of the range are tested.
if( aPos < size() && aPos + aNumRows <= size() )
{
LIB_TABLE_ROWS_ITER start = begin() + aPos;
erase( start, start + aNumRows );
if( GetView() )
{
wxGridTableMessage msg( this,
wxGRIDTABLE_NOTIFY_ROWS_DELETED,
aPos,
aNumRows );
GetView()->ProcessTableMessage( msg );
}
return true;
}
return false;
}
wxString GetColLabelValue( int aCol ) override
{
switch( aCol )
{
case COL_NICKNAME: return _( "Nickname" );
case COL_URI: return _( "Library Path" );
// keep this "Plugin Type" text fairly long so column is sized wide enough
case COL_TYPE: return _( "Plugin Type" );
case COL_OPTIONS: return _( "Options" );
case COL_DESCR: return _( "Description" );
case COL_ENABLED: return _( "Active" );
default: return wxEmptyString;
}
}
bool ContainsNickname( const wxString& aNickname )
{
for( size_t i = 0; i < size(); ++i )
{
LIB_TABLE_ROW* row = at( i );
if( row->GetNickName() == aNickname )
return true;
}
return false;
}
protected:
virtual LIB_TABLE_ROW* at( size_t aIndex ) = 0;
virtual size_t size() const = 0;
virtual LIB_TABLE_ROW* makeNewRow() = 0;
virtual LIB_TABLE_ROWS_ITER begin() = 0;
virtual LIB_TABLE_ROWS_ITER insert( LIB_TABLE_ROWS_ITER aIterator, LIB_TABLE_ROW* aRow ) = 0;
virtual void push_back( LIB_TABLE_ROW* aRow ) = 0;
virtual LIB_TABLE_ROWS_ITER erase( LIB_TABLE_ROWS_ITER aFirst, LIB_TABLE_ROWS_ITER aLast ) = 0;
};
#endif // __LIB_TABLE_GRID_H__
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017 KiCad Developers, see AUTHORS.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 3 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __LIB_TABLE_GRID_H__
#define __LIB_TABLE_GRID_H__
#include <lib_table_base.h>
#include <wx/grid.h>
const wxColour COLOUR_ROW_ENABLED( 0, 0, 0 );
const wxColour COLOUR_ROW_DISABLED( 100, 100, 100 );
/// The library table grid column order is established by this sequence.
enum COL_ORDER
{
COL_ENABLED,
COL_NICKNAME,
COL_URI,
COL_TYPE,
COL_OPTIONS,
COL_DESCR,
COL_COUNT // keep as last
};
/**
* This abstract base class mixes any object derived from #LIB_TABLE into wxGridTableBase
* so the result can be used as any type of library table within wxGrid.
*/
class LIB_TABLE_GRID : public wxGridTableBase
{
public:
//-----<wxGridTableBase overloads>-------------------------------------------
int GetNumberRows() override { return (int) size(); }
int GetNumberCols() override { return COL_COUNT; }
wxString GetValue( int aRow, int aCol ) override
{
if( aRow < (int) size() )
{
const LIB_TABLE_ROW* r = at( (size_t) aRow );
switch( aCol )
{
case COL_NICKNAME: return r->GetNickName();
case COL_URI: return r->GetFullURI();
case COL_TYPE: return r->GetType();
case COL_OPTIONS: return r->GetOptions();
case COL_DESCR: return r->GetDescr();
// Render a boolean value as its text equivalent
case COL_ENABLED: return r->GetIsEnabled() ? wxT( "1" ) : wxT( "0" );
default:
; // fall thru to wxEmptyString
}
}
return wxEmptyString;
}
bool GetValueAsBool( int aRow, int aCol ) override
{
if( aRow < (int) size() && aCol == COL_ENABLED )
return at( (size_t) aRow )->GetIsEnabled();
else
return false;
}
void SetValue( int aRow, int aCol, const wxString &aValue ) override
{
if( aRow < (int) size() )
{
LIB_TABLE_ROW* r = at( (size_t) aRow );
switch( aCol )
{
case COL_NICKNAME: r->SetNickName( aValue ); break;
case COL_URI: r->SetFullURI( aValue ); break;
case COL_TYPE: r->SetType( aValue ); break;
case COL_OPTIONS: r->SetOptions( aValue ); break;
case COL_DESCR: r->SetDescr( aValue ); break;
case COL_ENABLED:
r->SetEnabled( aValue == wxT( "1" ) );
break;
}
}
}
void SetValueAsBool( int aRow, int aCol, bool aValue ) override
{
if( aRow < (int) size() && aCol == COL_ENABLED )
at( (size_t) aRow )->SetEnabled( aValue );
}
bool IsEmptyCell( int aRow, int aCol ) override
{
return !GetValue( aRow, aCol );
}
bool InsertRows( size_t aPos = 0, size_t aNumRows = 1 ) override
{
if( aPos < size() )
{
for( size_t i = 0; i < aNumRows; i++ )
{
insert( begin() + i, makeNewRow() );
}
// use the (wxGridStringTable) source Luke.
if( GetView() )
{
wxGridTableMessage msg( this,
wxGRIDTABLE_NOTIFY_ROWS_INSERTED,
aPos,
aNumRows );
GetView()->ProcessTableMessage( msg );
}
return true;
}
return false;
}
bool AppendRows( size_t aNumRows = 1 ) override
{
// do not modify aNumRows, original value needed for wxGridTableMessage below
for( int i = aNumRows; i; --i )
push_back( makeNewRow() );
if( GetView() )
{
wxGridTableMessage msg( this,
wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
aNumRows );
GetView()->ProcessTableMessage( msg );
}
return true;
}
bool DeleteRows( size_t aPos, size_t aNumRows ) override
{
// aPos may be a large positive, e.g. size_t(-1), and the sum of
// aPos+aNumRows may wrap here, so both ends of the range are tested.
if( aPos < size() && aPos + aNumRows <= size() )
{
LIB_TABLE_ROWS_ITER start = begin() + aPos;
erase( start, start + aNumRows );
if( GetView() )
{
wxGridTableMessage msg( this,
wxGRIDTABLE_NOTIFY_ROWS_DELETED,
aPos,
aNumRows );
GetView()->ProcessTableMessage( msg );
}
return true;
}
return false;
}
wxString GetColLabelValue( int aCol ) override
{
switch( aCol )
{
case COL_NICKNAME: return _( "Nickname" );
case COL_URI: return _( "Library Path" );
// keep this "Plugin Type" text fairly long so column is sized wide enough
case COL_TYPE: return _( "Plugin Type" );
case COL_OPTIONS: return _( "Options" );
case COL_DESCR: return _( "Description" );
case COL_ENABLED: return _( "Active" );
default: return wxEmptyString;
}
}
bool ContainsNickname( const wxString& aNickname )
{
for( size_t i = 0; i < size(); ++i )
{
LIB_TABLE_ROW* row = at( i );
if( row->GetNickName() == aNickname )
return true;
}
return false;
}
protected:
virtual LIB_TABLE_ROW* at( size_t aIndex ) = 0;
virtual size_t size() const = 0;
virtual LIB_TABLE_ROW* makeNewRow() = 0;
virtual LIB_TABLE_ROWS_ITER begin() = 0;
virtual LIB_TABLE_ROWS_ITER insert( LIB_TABLE_ROWS_ITER aIterator, LIB_TABLE_ROW* aRow ) = 0;
virtual void push_back( LIB_TABLE_ROW* aRow ) = 0;
virtual LIB_TABLE_ROWS_ITER erase( LIB_TABLE_ROWS_ITER aFirst, LIB_TABLE_ROWS_ITER aLast ) = 0;
};
#endif // __LIB_TABLE_GRID_H__

View File

@ -47,14 +47,14 @@ public:
{
}
/**
* Set a new value in evaluator buffer, and display it
* in the wxTextCtrl.
* @param aValue is the new value to store and display
* if aValue is empty, the value "0" is stored and displayed
*/
void SetValue( const wxString& aValue ) override;
/**
* Set a new value in evaluator buffer, and display it
* in the wxTextCtrl.
* @param aValue is the new value to store and display
* if aValue is empty, the value "0" is stored and displayed
*/
void SetValue( const wxString& aValue ) override;
protected:
///> Numeric expression evaluator
NUMERIC_EVALUATOR m_eval;

View File

@ -1,156 +1,156 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.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 <kiface_i.h>
#include <confirm.h>
#include <pcb_edit_frame.h>
#include <class_zone.h>
#include <zones.h>
#include <zone_settings.h>
#include <dialog_keepout_area_properties_base.h>
class DIALOG_KEEPOUT_AREA_PROPERTIES : public DIALOG_KEEPOUT_AREA_PROPERTIES_BASE
{
public:
DIALOG_KEEPOUT_AREA_PROPERTIES( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aSettings );
private:
PCB_BASE_FRAME* m_parent;
wxConfigBase* m_config; ///< Current config
ZONE_SETTINGS m_zonesettings; ///< the working copy of zone settings
ZONE_SETTINGS* m_ptr; ///< the pointer to the zone settings
///< of the zone to edit
bool TransferDataToWindow() override;
bool TransferDataFromWindow() override;
void OnLayerSelection( wxDataViewEvent& event ) override;
};
int InvokeKeepoutAreaEditor( PCB_BASE_FRAME* aCaller, ZONE_SETTINGS* aSettings )
{
DIALOG_KEEPOUT_AREA_PROPERTIES dlg( aCaller, aSettings );
return dlg.ShowModal();
}
DIALOG_KEEPOUT_AREA_PROPERTIES::DIALOG_KEEPOUT_AREA_PROPERTIES( PCB_BASE_FRAME* aParent,
ZONE_SETTINGS* aSettings ) :
DIALOG_KEEPOUT_AREA_PROPERTIES_BASE( aParent )
{
m_parent = aParent;
m_config = Kiface().KifaceSettings();
m_ptr = aSettings;
m_zonesettings = *aSettings;
m_zonesettings.SetupLayersList( m_layers, m_parent, true );
m_sdbSizerButtonsOK->SetDefault();
FinishDialogSettings();
}
bool DIALOG_KEEPOUT_AREA_PROPERTIES::TransferDataToWindow()
{
// Init keepout parameters:
m_cbTracksCtrl->SetValue( m_zonesettings.GetDoNotAllowTracks() );
m_cbViasCtrl->SetValue( m_zonesettings.GetDoNotAllowVias() );
m_cbCopperPourCtrl->SetValue( m_zonesettings.GetDoNotAllowCopperPour() );
m_cbConstrainCtrl->SetValue( m_zonesettings.m_Zone_45_Only );
switch( m_zonesettings.m_Zone_HatchingStyle )
{
case ZONE_CONTAINER::NO_HATCH: m_OutlineAppearanceCtrl->SetSelection( 0 ); break;
case ZONE_CONTAINER::DIAGONAL_EDGE: m_OutlineAppearanceCtrl->SetSelection( 1 ); break;
case ZONE_CONTAINER::DIAGONAL_FULL: m_OutlineAppearanceCtrl->SetSelection( 2 ); break;
}
SetInitialFocus( m_OutlineAppearanceCtrl );
return true;
}
void DIALOG_KEEPOUT_AREA_PROPERTIES::OnLayerSelection( wxDataViewEvent& event )
{
if( event.GetColumn() != 0 )
return;
int row = m_layers->ItemToRow( event.GetItem() );
wxVariant layerID;
m_layers->GetValue( layerID, row, 2 );
bool selected = m_layers->GetToggleValue( row, 0 );
m_zonesettings.m_Layers.set( ToLAYER_ID( layerID.GetInteger() ), selected );
}
bool DIALOG_KEEPOUT_AREA_PROPERTIES::TransferDataFromWindow()
{
// Init keepout parameters:
m_zonesettings.SetIsKeepout( true );
m_zonesettings.SetDoNotAllowTracks( m_cbTracksCtrl->GetValue() );
m_zonesettings.SetDoNotAllowVias( m_cbViasCtrl->GetValue() );
m_zonesettings.SetDoNotAllowCopperPour( m_cbCopperPourCtrl->GetValue() );
// Test for not allowed items: should have at least one item not allowed:
if( ! m_zonesettings.GetDoNotAllowTracks() &&
! m_zonesettings.GetDoNotAllowVias() &&
! m_zonesettings.GetDoNotAllowCopperPour() )
{
DisplayError( NULL, _("Tracks, vias, and pads are allowed. The keepout will have no effect." ) );
return false;
}
if( m_zonesettings.m_Layers.count() == 0 )
{
DisplayError( NULL, _( "No layers selected." ) );
return false;
}
switch( m_OutlineAppearanceCtrl->GetSelection() )
{
case 0: m_zonesettings.m_Zone_HatchingStyle = ZONE_CONTAINER::NO_HATCH; break;
case 1: m_zonesettings.m_Zone_HatchingStyle = ZONE_CONTAINER::DIAGONAL_EDGE; break;
case 2: m_zonesettings.m_Zone_HatchingStyle = ZONE_CONTAINER::DIAGONAL_FULL; break;
}
if( m_config )
m_config->Write( ZONE_NET_OUTLINES_STYLE_KEY, (long) m_zonesettings.m_Zone_HatchingStyle );
m_zonesettings.m_Zone_45_Only = m_cbConstrainCtrl->GetValue();
m_zonesettings.m_ZonePriority = 0; // for a keepout, this param is not used.
*m_ptr = m_zonesettings;
return true;
}
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.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 <kiface_i.h>
#include <confirm.h>
#include <pcb_edit_frame.h>
#include <class_zone.h>
#include <zones.h>
#include <zone_settings.h>
#include <dialog_keepout_area_properties_base.h>
class DIALOG_KEEPOUT_AREA_PROPERTIES : public DIALOG_KEEPOUT_AREA_PROPERTIES_BASE
{
public:
DIALOG_KEEPOUT_AREA_PROPERTIES( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aSettings );
private:
PCB_BASE_FRAME* m_parent;
wxConfigBase* m_config; ///< Current config
ZONE_SETTINGS m_zonesettings; ///< the working copy of zone settings
ZONE_SETTINGS* m_ptr; ///< the pointer to the zone settings
///< of the zone to edit
bool TransferDataToWindow() override;
bool TransferDataFromWindow() override;
void OnLayerSelection( wxDataViewEvent& event ) override;
};
int InvokeKeepoutAreaEditor( PCB_BASE_FRAME* aCaller, ZONE_SETTINGS* aSettings )
{
DIALOG_KEEPOUT_AREA_PROPERTIES dlg( aCaller, aSettings );
return dlg.ShowModal();
}
DIALOG_KEEPOUT_AREA_PROPERTIES::DIALOG_KEEPOUT_AREA_PROPERTIES( PCB_BASE_FRAME* aParent,
ZONE_SETTINGS* aSettings ) :
DIALOG_KEEPOUT_AREA_PROPERTIES_BASE( aParent )
{
m_parent = aParent;
m_config = Kiface().KifaceSettings();
m_ptr = aSettings;
m_zonesettings = *aSettings;
m_zonesettings.SetupLayersList( m_layers, m_parent, true );
m_sdbSizerButtonsOK->SetDefault();
FinishDialogSettings();
}
bool DIALOG_KEEPOUT_AREA_PROPERTIES::TransferDataToWindow()
{
// Init keepout parameters:
m_cbTracksCtrl->SetValue( m_zonesettings.GetDoNotAllowTracks() );
m_cbViasCtrl->SetValue( m_zonesettings.GetDoNotAllowVias() );
m_cbCopperPourCtrl->SetValue( m_zonesettings.GetDoNotAllowCopperPour() );
m_cbConstrainCtrl->SetValue( m_zonesettings.m_Zone_45_Only );
switch( m_zonesettings.m_Zone_HatchingStyle )
{
case ZONE_CONTAINER::NO_HATCH: m_OutlineAppearanceCtrl->SetSelection( 0 ); break;
case ZONE_CONTAINER::DIAGONAL_EDGE: m_OutlineAppearanceCtrl->SetSelection( 1 ); break;
case ZONE_CONTAINER::DIAGONAL_FULL: m_OutlineAppearanceCtrl->SetSelection( 2 ); break;
}
SetInitialFocus( m_OutlineAppearanceCtrl );
return true;
}
void DIALOG_KEEPOUT_AREA_PROPERTIES::OnLayerSelection( wxDataViewEvent& event )
{
if( event.GetColumn() != 0 )
return;
int row = m_layers->ItemToRow( event.GetItem() );
wxVariant layerID;
m_layers->GetValue( layerID, row, 2 );
bool selected = m_layers->GetToggleValue( row, 0 );
m_zonesettings.m_Layers.set( ToLAYER_ID( layerID.GetInteger() ), selected );
}
bool DIALOG_KEEPOUT_AREA_PROPERTIES::TransferDataFromWindow()
{
// Init keepout parameters:
m_zonesettings.SetIsKeepout( true );
m_zonesettings.SetDoNotAllowTracks( m_cbTracksCtrl->GetValue() );
m_zonesettings.SetDoNotAllowVias( m_cbViasCtrl->GetValue() );
m_zonesettings.SetDoNotAllowCopperPour( m_cbCopperPourCtrl->GetValue() );
// Test for not allowed items: should have at least one item not allowed:
if( ! m_zonesettings.GetDoNotAllowTracks() &&
! m_zonesettings.GetDoNotAllowVias() &&
! m_zonesettings.GetDoNotAllowCopperPour() )
{
DisplayError( NULL, _("Tracks, vias, and pads are allowed. The keepout will have no effect." ) );
return false;
}
if( m_zonesettings.m_Layers.count() == 0 )
{
DisplayError( NULL, _( "No layers selected." ) );
return false;
}
switch( m_OutlineAppearanceCtrl->GetSelection() )
{
case 0: m_zonesettings.m_Zone_HatchingStyle = ZONE_CONTAINER::NO_HATCH; break;
case 1: m_zonesettings.m_Zone_HatchingStyle = ZONE_CONTAINER::DIAGONAL_EDGE; break;
case 2: m_zonesettings.m_Zone_HatchingStyle = ZONE_CONTAINER::DIAGONAL_FULL; break;
}
if( m_config )
m_config->Write( ZONE_NET_OUTLINES_STYLE_KEY, (long) m_zonesettings.m_Zone_HatchingStyle );
m_zonesettings.m_Zone_45_Only = m_cbConstrainCtrl->GetValue();
m_zonesettings.m_ZonePriority = 0; // for a keepout, this param is not used.
*m_ptr = m_zonesettings;
return true;
}