Compare commits

...

6 Commits

Author SHA1 Message Date
jean-pierre charras fa85cb3a8b Do not allow spaces in component name (value field) in component library editor, in dialogs (Edit field, Create component).
In component libraries, a space in name breaks the library, and is not allowed.
2016-08-19 21:49:48 -04:00
Chris Pavlina 853984120c FUTURE_FORMAT_ERROR: don't nest errors unnecessarily. 2016-08-17 15:13:28 -04:00
Wayne Stambaugh be62a1ade6 Eeschema: fix broken component reference field in hierarchies. (fixes lp:1572812) 2016-08-10 09:44:19 -04:00
Simon Wells 3b4cdd96ab Hide OpenGL scrollbars on OS X to fix freeze. (fixes lp:1553428) 2016-08-09 15:07:17 -04:00
Jean-Pierre Charras f776b7c3fb Pcbnew: fix a minor bug where the DRC report file is always created. (fixes lp:1593389)
* Prevent DRC file from being created regardless the option selected in the check box.
* The browse file dialog now open the current project folder by default.
2016-08-09 10:49:36 -04:00
Maciej Sumiski 9d233b4cdb Pcbnew: fixed a crash when dragging a line was interrupted. (fixes lp:1606332)
* Crash was caused by removing an element from m_activeTools list, causing other
  iterators to be invalidated when dragging line in GAL mode.
2016-08-09 09:54:57 -04:00
13 changed files with 96 additions and 44 deletions
+10
View File
@@ -66,7 +66,13 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
SwitchBackend( aGalType );
SetBackgroundStyle( wxBG_STYLE_CUSTOM );
// Scrollbars broken in GAL on OSX
#ifdef __WXMAC__
ShowScrollbars( wxSHOW_SB_NEVER, wxSHOW_SB_NEVER );
#else
ShowScrollbars( wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS );
#endif
EnableScrolling( false, false ); // otherwise Zoom Auto disables GAL canvas
m_painter = new KIGFX::PCB_PAINTER( m_gal );
@@ -144,7 +150,11 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
m_drawing = true;
// Scrollbars broken in GAL on OSX
#ifndef __WXMAC__
m_viewControls->UpdateScrollbars();
#endif
m_view->UpdateItems();
m_gal->BeginDrawing();
m_gal->ClearScreen( m_painter->GetSettings()->GetBackgroundColor() );
+6 -6
View File
@@ -24,7 +24,7 @@
*/
#include <map>
#include <deque>
#include <list>
#include <stack>
#include <algorithm>
@@ -450,7 +450,7 @@ int TOOL_MANAGER::GetPriority( int aToolId ) const
{
int priority = 0;
for( std::deque<int>::const_iterator it = m_activeTools.begin(),
for( std::list<TOOL_ID>::const_iterator it = m_activeTools.begin(),
itEnd = m_activeTools.end(); it != itEnd; ++it )
{
if( *it == aToolId )
@@ -494,12 +494,12 @@ optional<TOOL_EVENT> TOOL_MANAGER::ScheduleWait( TOOL_BASE* aTool,
void TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent )
{
// iterate over all registered tools
for( std::deque<TOOL_ID>::iterator it = m_activeTools.begin();
for( std::list<TOOL_ID>::iterator it = m_activeTools.begin();
it != m_activeTools.end(); /* iteration is done inside */)
{
std::deque<TOOL_ID>::iterator curIt = it;
std::list<TOOL_ID>::iterator curIt = it;
TOOL_STATE* st = m_toolIdIndex[*it];
++it; // it might be overwritten, if the tool is removed the m_activeTools deque
++it; // it might be overwritten, if the tool is removed the m_activeTools list
// the tool state handler is waiting for events (i.e. called Wait() method)
if( st->pendingWait )
@@ -657,7 +657,7 @@ bool TOOL_MANAGER::finishTool( TOOL_STATE* aState, bool aDeactivate )
if( !aState->Pop() ) // if there are no other contexts saved on the stack
{
// find the tool and deactivate it
std::deque<TOOL_ID>::iterator tool = std::find( m_activeTools.begin(), m_activeTools.end(),
std::list<TOOL_ID>::iterator tool = std::find( m_activeTools.begin(), m_activeTools.end(),
aState->theTool->GetId() );
if( tool != m_activeTools.end() )
@@ -853,7 +853,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
// may only delete user defined fields
deleteFieldButton->Enable( fieldNdx >= MANDATORY_FIELDS );
fieldValueTextCtrl->SetValidator( SCH_FIELD_VALIDATOR( field.GetId() ) );
fieldValueTextCtrl->SetValidator( SCH_FIELD_VALIDATOR( false, field.GetId() ) );
fieldValueTextCtrl->SetValue( field.GetText() );
m_show_datasheet_button->Enable( fieldNdx == DATASHEET || fieldNdx == FOOTPRINT );
@@ -674,7 +674,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel()
// if fieldNdx == REFERENCE, VALUE, then disable delete button
deleteFieldButton->Enable( fieldNdx >= MANDATORY_FIELDS );
fieldValueTextCtrl->SetValidator( SCH_FIELD_VALIDATOR( field.GetId() ) );
fieldValueTextCtrl->SetValidator( SCH_FIELD_VALIDATOR( true, field.GetId() ) );
fieldValueTextCtrl->SetValue( field.GetText() );
textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.GetSize().x ) );
+25 -1
View File
@@ -102,7 +102,10 @@ void DIALOG_EDIT_ONE_FIELD::init()
wxString msg;
m_TextValue->SetFocus();
m_TextValue->SetValidator( SCH_FIELD_VALIDATOR( m_fieldId, &m_text ) );
SCH_BASE_FRAME* parent = static_cast<SCH_BASE_FRAME*>( GetParent() );
m_TextValue->SetValidator( SCH_FIELD_VALIDATOR(
parent->IsType( FRAME_SCH_LIB_EDITOR ),
m_fieldId, &m_text ) );
// Disable options for graphic text editing which are not needed for fields.
m_CommonConvert->Show( false );
@@ -252,3 +255,24 @@ DIALOG_SCH_EDIT_ONE_FIELD::DIALOG_SCH_EDIT_ONE_FIELD( SCH_BASE_FRAME* aParent,
init();
}
void DIALOG_SCH_EDIT_ONE_FIELD::UpdateField( SCH_FIELD* aField, SCH_SHEET_PATH* aSheetPath )
{
wxASSERT( aField != NULL || aField->Type() != SCH_FIELD_T );
if( aField->GetId() == REFERENCE )
{
wxASSERT( aSheetPath != NULL );
SCH_COMPONENT* component = dynamic_cast< SCH_COMPONENT* >( aField->GetParent() );
wxASSERT( component != NULL );
if( component != NULL )
component->SetRef( aSheetPath, m_text );
}
aField->SetText( m_text );
updateText( aField );
}
+1 -5
View File
@@ -153,11 +153,7 @@ public:
~DIALOG_SCH_EDIT_ONE_FIELD() {}
void UpdateField( SCH_FIELD* aField )
{
aField->SetText( m_text );
updateText( aField );
}
void UpdateField( SCH_FIELD* aField, SCH_SHEET_PATH* aSheetPath );
};
#endif // DIALOG_EDIT_ONE_FIELD_H_
@@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2014 KiCad Developers, see CHANGELOG.TXT for contributors.
* Copyright (C) 2016 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
@@ -23,10 +23,15 @@
*/
#include <dialog_lib_new_component.h>
#include <sch_validators.h>
#include <template_fieldnames.h>
DIALOG_LIB_NEW_COMPONENT::DIALOG_LIB_NEW_COMPONENT( wxWindow* parent ) :
DIALOG_LIB_NEW_COMPONENT_BASE( parent )
{
m_textName->SetValidator( SCH_FIELD_VALIDATOR( true, VALUE ) );
m_textReference->SetValidator( SCH_FIELD_VALIDATOR( true, REFERENCE ) );
// initial focus should be on first editable field.
m_textName->SetFocus();
+1 -1
View File
@@ -79,7 +79,7 @@ void SCH_EDIT_FRAME::EditComponentFieldText( SCH_FIELD* aField )
return;
}
dlg.UpdateField( aField );
dlg.UpdateField( aField, m_CurrentSheet );
m_canvas->MoveCursorToCrossHair();
m_canvas->SetIgnoreMouseEvents( false );
OnModify();
+9 -2
View File
@@ -30,10 +30,12 @@
#include <sch_validators.h>
#include <template_fieldnames.h>
SCH_FIELD_VALIDATOR::SCH_FIELD_VALIDATOR( int aFieldId, wxString* aValue ) :
SCH_FIELD_VALIDATOR::SCH_FIELD_VALIDATOR( bool aIsCmplibEditor,
int aFieldId, wxString* aValue ) :
wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, aValue )
{
m_fieldId = aFieldId;
m_isLibEditor = aIsCmplibEditor;
// Fields cannot contain carriage returns, line feeds, or tabs.
wxString excludes( "\r\n\t" );
@@ -41,6 +43,8 @@ SCH_FIELD_VALIDATOR::SCH_FIELD_VALIDATOR( int aFieldId, wxString* aValue ) :
// The reference field cannot contain spaces.
if( aFieldId == REFERENCE )
excludes += " ";
else if( aFieldId == VALUE && m_isLibEditor )
excludes += " ";
long style = GetStyle();
@@ -57,6 +61,7 @@ SCH_FIELD_VALIDATOR::SCH_FIELD_VALIDATOR( const SCH_FIELD_VALIDATOR& aValidator
wxTextValidator( aValidator )
{
m_fieldId = aValidator.m_fieldId;
m_isLibEditor = aValidator.m_isLibEditor;
}
@@ -93,6 +98,8 @@ bool SCH_FIELD_VALIDATOR::Validate( wxWindow *aParent )
else if( HasFlag( wxFILTER_EXCLUDE_CHAR_LIST ) && ContainsExcludedCharacters( val ) )
{
wxArrayString whiteSpace;
bool spaceIllegal = ( m_fieldId == REFERENCE ) ||
( m_fieldId == VALUE && m_isLibEditor );
if( val.Find( '\r' ) != wxNOT_FOUND )
whiteSpace.Add( _( "carriage return" ) );
@@ -100,7 +107,7 @@ bool SCH_FIELD_VALIDATOR::Validate( wxWindow *aParent )
whiteSpace.Add( _( "line feed" ) );
if( val.Find( '\t' ) != wxNOT_FOUND )
whiteSpace.Add( _( "tab" ) );
if( (m_fieldId == REFERENCE) && (val.Find( ' ' ) != wxNOT_FOUND) )
if( spaceIllegal && (val.Find( ' ' ) != wxNOT_FOUND) )
whiteSpace.Add( _( "space" ) );
wxString badChars;
+8 -2
View File
@@ -38,13 +38,19 @@
*
* is the text control validator used for validating the text allowed in library and
* schematic component fields.
* Note
* Reference field does not accept spaces
* Value field does not accept spaces in Component Library Editor, because in .lib component
* libraries, the value field is the component name in lib, and spaces are not allowed
* in component names in lib
*/
class SCH_FIELD_VALIDATOR : public wxTextValidator
{
int m_fieldId;
int m_fieldId;
bool m_isLibEditor;
public:
SCH_FIELD_VALIDATOR( int aFieldId, wxString* aValue = NULL );
SCH_FIELD_VALIDATOR( bool aIsCmplibEditor, int aFieldId, wxString* aValue = NULL );
SCH_FIELD_VALIDATOR( const SCH_FIELD_VALIDATOR& aValidator );
+1 -1
View File
@@ -435,7 +435,7 @@ private:
std::map<TOOL_ID, TOOL_STATE*> m_toolIdIndex;
/// Stack of the active tools
std::deque<TOOL_ID> m_activeTools;
std::list<TOOL_ID> m_activeTools;
/// Instance of ACTION_MANAGER that handles TOOL_ACTIONs
ACTION_MANAGER* m_actionMgr;
+22 -23
View File
@@ -151,7 +151,9 @@ void DIALOG_DRC_CONTROL::OnStartdrcClick( wxCommandEvent& event )
{
wxString reportName;
if( m_CreateRptCtrl->IsChecked() ) // Create a file rpt
bool make_report = m_CreateRptCtrl->IsChecked();
if( make_report ) // Create a rpt file
{
reportName = m_RptFilenameCtrl->GetValue();
@@ -160,16 +162,17 @@ void DIALOG_DRC_CONTROL::OnStartdrcClick( wxCommandEvent& event )
wxCommandEvent dummy;
OnButtonBrowseRptFileClick( dummy );
}
}
reportName = makeValidFileNameReport();
if( !reportName.IsEmpty() )
reportName = makeValidFileNameReport();
}
SetDrcParmeters();
m_tester->SetSettings( true, // Pad to pad DRC test enabled
true, // unconnected pdas DRC test enabled
true, // unconnected pads DRC test enabled
true, // DRC test for zones enabled
true, // DRC test for keepout areas enabled
reportName, m_CreateRptCtrl->IsChecked() );
reportName, make_report );
DelDRCMarkers();
@@ -217,7 +220,9 @@ void DIALOG_DRC_CONTROL::OnListUnconnectedClick( wxCommandEvent& event )
{
wxString reportName;
if( m_CreateRptCtrl->IsChecked() ) // Create a file rpt
bool make_report = m_CreateRptCtrl->IsChecked();
if( make_report ) // Create a file rpt
{
reportName = m_RptFilenameCtrl->GetValue();
@@ -226,17 +231,18 @@ void DIALOG_DRC_CONTROL::OnListUnconnectedClick( wxCommandEvent& event )
wxCommandEvent junk;
OnButtonBrowseRptFileClick( junk );
}
}
reportName = makeValidFileNameReport();
if( !reportName.IsEmpty() )
reportName = makeValidFileNameReport();
}
SetDrcParmeters();
m_tester->SetSettings( true, // Pad to pad DRC test enabled
true, // unconnected pdas DRC test enabled
true, // unconnected pads DRC test enabled
true, // DRC test for zones enabled
true, // DRC test for keepout areas enabled
reportName, m_CreateRptCtrl->IsChecked() );
reportName, make_report );
DelDRCMarkers();
@@ -271,22 +277,15 @@ void DIALOG_DRC_CONTROL::OnListUnconnectedClick( wxCommandEvent& event )
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_BROWSE_RPT_FILE
*/
void DIALOG_DRC_CONTROL::OnButtonBrowseRptFileClick( wxCommandEvent& event )
{
wxFileName fn;
wxString wildcard( _( "DRC report files (.rpt)|*.rpt" ) );
wxString Ext( wxT( "rpt" ) );
wxFileName fn = m_Parent->GetBoard()->GetFileName();
fn.SetExt( ReportFileExtension );
wxString prj_path = Prj().GetProjectPath();
fn = m_Parent->GetBoard()->GetFileName() + wxT( "-drc" );
fn.SetExt( Ext );
wxFileDialog dlg( this, _( "Save DRC Report File" ), wxEmptyString,
fn.GetFullName(), wildcard,
wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxFD_CHANGE_DIR );
wxFileDialog dlg( this, _( "Save DRC Report File" ), prj_path,
fn.GetFullName(), ReportFileWildcard,
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() == wxID_CANCEL )
return;
+5
View File
@@ -1729,6 +1729,11 @@ BOARD* PCB_IO::Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPER
{
board = dynamic_cast<BOARD*>( m_parser->Parse() );
}
catch( const FUTURE_FORMAT_ERROR& parse_error )
{
// Don't wrap a FUTURE_FORMAT_ERROR in another
throw;
}
catch( const PARSE_ERROR& parse_error )
{
if( m_parser->IsTooRecent() )