This commit is contained in:
Jeff Young 2019-07-02 21:09:23 +01:00
parent ef03afe289
commit d03041b565
24 changed files with 101 additions and 342 deletions

View File

@ -240,36 +240,6 @@ bool SCH_EDIT_FRAME::SchematicCleanUp( SCH_SCREEN* aScreen )
}
bool SCH_EDIT_FRAME::AddMissingJunctions( SCH_SCREEN* aScreen )
{
bool added = false;
auto add_junction = [ & ]( const wxPoint& aPosition ) -> void
{
auto junction = new SCH_JUNCTION( aPosition );
AddToScreen( junction, aScreen );
BreakSegments( aPosition );
added = true;
};
for( auto item = aScreen->GetDrawItems(); item; item = item->Next() )
{
if( item->Type() == SCH_LINE_T )
{
auto line = static_cast<SCH_LINE*>( item );
if( aScreen->IsJunctionNeeded( line->GetStartPoint(), true ) )
add_junction( line->GetStartPoint() );
if( aScreen->IsJunctionNeeded( line->GetEndPoint(), true ) )
add_junction( line->GetEndPoint() );
}
}
return added;
}
void SCH_EDIT_FRAME::NormalizeSchematicOnFirstLoad( bool recalculateConnections )
{
SCH_SHEET_LIST list( g_RootSheet );

View File

@ -123,7 +123,7 @@ bool DIALOG_LIB_EDIT_PIN::TransferDataFromWindow()
return false;
}
if( !m_pin->InEditMode() )
if( m_pin->GetEditFlags() == 0 )
m_frame->SaveCopyInUndoList( m_pin->GetParent() );
m_pin->SetName( m_textPinName->GetValue() );

View File

@ -269,7 +269,7 @@ BITMAP_DEF LIB_CIRCLE::GetMenuImage() const
void LIB_CIRCLE::BeginEdit( const wxPoint aPosition )
{
m_Pos = m_initialPos = aPosition;
m_Pos = aPosition;
}

View File

@ -23,11 +23,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file class_libentry.h
* @brief Class LIB_ITEM definition.
*/
#ifndef _LIB_ITEM_H_
#define _LIB_ITEM_H_
@ -81,37 +76,28 @@ class LIB_ITEM : public EDA_ITEM
protected:
/**
* Unit identification for multiple parts per package. Set to 0 if the
* item is common to all units.
* Unit identification for multiple parts per package. Set to 0 if the item is common
* to all units.
*/
int m_Unit;
/**
* Shape identification for alternate body styles. Set 0 if the item
* is common to all body styles. This is commonly referred to as
* DeMorgan style and this is typically how it is used in KiCad.
* Shape identification for alternate body styles. Set 0 if the item is common to all
* body styles. This is typially used for representing DeMorgan variants in KiCad.
*/
int m_Convert;
/**
* The body fill type. This has meaning only for some items. For a list of
* fill types see #FILL_T.
* The body fill type. This has meaning only for some items. For a list of fill types
* see #FILL_T.
*/
FILL_T m_Fill;
wxPoint m_initialPos; ///< Temporary position when moving an existing item.
wxPoint m_initialCursorPos; ///< Initial cursor position at the beginning of a move.
/** Flag to indicate if draw item is fillable. Default is false. */
bool m_isFillable;
bool m_isFillable;
public:
LIB_ITEM( KICAD_T aType,
LIB_PART* aComponent = NULL,
int aUnit = 0,
int aConvert = 0,
FILL_T aFillType = NO_FILL );
LIB_ITEM( KICAD_T aType, LIB_PART* aComponent = NULL, int aUnit = 0, int aConvert = 0,
FILL_T aFillType = NO_FILL );
// Do not create a copy constructor. The one generated by the compiler is adequate.
@ -262,13 +248,7 @@ public:
*/
virtual void MoveTo( const wxPoint& aPosition ) = 0;
/**
* Return the current draw object position.
*
* @return A wxPoint object containing the position of the object.
*/
virtual wxPoint GetPosition() const = 0;
void SetPosition( const wxPoint& aPosition ) { MoveTo( aPosition ); }
/**
@ -293,11 +273,6 @@ public:
*/
virtual void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) = 0;
/**
* Rotate the draw item.
*/
virtual void Rotate() {}
/**
* Plot the draw item using the plot object.
*
@ -309,47 +284,26 @@ public:
virtual void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform ) = 0;
/**
* Return the width of the draw item.
*
* @return Width of draw object.
*/
virtual int GetWidth() const = 0;
/**
* Set the width of the draw item to \a aWidth.
*/
virtual void SetWidth( int aWidth ) = 0;
/**
* Check if draw object can be filled.
*
* The default setting is false. If the derived object support filling,
* set the m_isFillable member to true.
*
* @return True if draw object can be filled. Default is false.
* The default setting is false. If the derived object support filling, set the
* m_isFillable member to true.
*/
bool IsFillable() const { return m_isFillable; }
/**
* Return the draw item editing mode status.
*
* @return True if the item is being edited.
*/
bool InEditMode() const { return ( m_Flags & ( IS_NEW | IS_DRAGGED | IS_MOVED | IS_RESIZED ) ) != 0; }
virtual COLOR4D GetDefaultColor();
void SetUnit( int aUnit ) { m_Unit = aUnit; }
int GetUnit() const { return m_Unit; }
void SetConvert( int aConvert ) { m_Convert = aConvert; }
int GetConvert() const { return m_Convert; }
void SetFillMode( FILL_T aFillMode ) { m_Fill = aFillMode; }
FILL_T GetFillMode() const { return m_Fill; }
#if defined(DEBUG)

View File

@ -25,7 +25,6 @@
#include <fctsys.h>
#include <pgm_base.h>
#include <gr_basic.h>
#include <macros.h>
#include <base_struct.h>
#include <gr_text.h>
#include <kicad_string.h>
@ -35,7 +34,6 @@
#include <base_units.h>
#include <msgpanel.h>
#include <bitmaps.h>
#include <general.h>
#include <class_libentry.h>
#include <transform.h>
@ -92,21 +90,15 @@ void LIB_FIELD::Init( int id )
SetTextAngle( TEXT_ANGLE_HORIZ ); // constructor already did this.
// fields in RAM must always have names, because we are trying to get
// less dependent on field ids and more dependent on names.
// Plus assumptions are made in the field editors.
// Fields in RAM must always have names, because we are trying to get less dependent on
// field ids and more dependent on names. Plus assumptions are made in the field editors.
m_name = TEMPLATE_FIELDNAME::GetDefaultFieldName( id );
switch( id )
{
case DATASHEET:
case FOOTPRINT:
// by contrast, VALUE and REFERENCE are are always constructed as
// initially visible, and template fieldsnames' initial visibility
// is controlled by the template fieldname configuration record.
// By contrast, VALUE and REFERENCE are are always constructed as initially visible, and
// template fieldsnames' initial visibility is controlled by the template fieldname config.
if( id == DATASHEET || id == FOOTPRINT )
SetVisible( false );
break;
}
}
@ -131,18 +123,10 @@ int LIB_FIELD::GetPenSize() const
void LIB_FIELD::print( wxDC* aDC, const wxPoint& aOffset, void* aData,
const TRANSFORM& aTransform )
{
wxPoint text_pos;
COLOR4D color = IsVisible() ? GetDefaultColor() : GetInvisibleItemColor();
int linewidth = GetPenSize();
text_pos = aTransform.TransformCoordinate( GetTextPos() ) + aOffset;
wxString text;
if( aData )
text = *(wxString*)aData;
else
text = m_Text;
wxPoint text_pos = aTransform.TransformCoordinate( GetTextPos() ) + aOffset;
wxString text = aData ? *static_cast<wxString*>( aData ) : m_Text;
GRText( aDC, text_pos, color, text, GetTextAngle(), GetTextSize(), GetHorizJustify(),
GetVertJustify(), linewidth, IsItalic(), IsBold() );
@ -158,8 +142,7 @@ bool LIB_FIELD::HitTest( const wxPoint& aPosition, int aAccuracy ) const
// Build a temporary copy of the text for hit testing
EDA_TEXT tmp_text( *this );
// Reference designator text has one or 2 additional character (displays
// U? or U?A)
// Reference designator text has one or 2 additional character (displays U? or U?A)
if( m_id == REFERENCE )
{
wxString extended_text = tmp_text.GetText();
@ -173,10 +156,8 @@ bool LIB_FIELD::HitTest( const wxPoint& aPosition, int aAccuracy ) const
tmp_text.SetTextPos( DefaultTransform.TransformCoordinate( GetTextPos() ) );
/* The text orientation may need to be flipped if the
* transformation matrix causes xy axes to be flipped.
* this simple algo works only for schematic matrix (rot 90 or/and mirror)
*/
// The text orientation may need to be flipped if the transformation matrix causes xy axes
// to be flipped. This simple algo works only for schematic matrix (rot 90 or/and mirror)
bool t1 = ( DefaultTransform.x1 != 0 ) ^ ( GetTextAngle() != 0 );
tmp_text.SetTextAngle( t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT );
@ -294,8 +275,7 @@ void LIB_FIELD::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
if( IsVoid() )
return;
/* Calculate the text orientation, according to the component
* orientation/mirror */
// Calculate the text orientation, according to the component orientation/mirror
int orient = (int) GetTextAngle();
if( aTransform.y1 ) // Rotate component 90 deg.
@ -311,13 +291,10 @@ void LIB_FIELD::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_CENTER;
EDA_TEXT_VJUSTIFY_T vjustify = GR_TEXT_VJUSTIFY_CENTER;
wxPoint textpos = aTransform.TransformCoordinate( BoundaryBox.Centre() )
+ aOffset;
wxPoint textpos = aTransform.TransformCoordinate( BoundaryBox.Centre() ) + aOffset;
aPlotter->Text( textpos, GetDefaultColor(), GetShownText(),
orient, GetTextSize(),
hjustify, vjustify,
GetPenSize(), IsItalic(), IsBold() );
aPlotter->Text( textpos, GetDefaultColor(), GetShownText(), orient, GetTextSize(),
hjustify, vjustify, GetPenSize(), IsItalic(), IsBold() );
}
@ -385,12 +362,6 @@ COLOR4D LIB_FIELD::GetDefaultColor()
}
void LIB_FIELD::Rotate()
{
SetTextAngle( GetTextAngle() == TEXT_ANGLE_VERT ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT );
}
wxString LIB_FIELD::GetName( bool aTranslate ) const
{
wxString name;

View File

@ -178,8 +178,6 @@ public:
void BeginEdit( const wxPoint aStartPoint ) override;
void Rotate() override;
/**
* Sets the field text to \a aText.
*

View File

@ -1608,23 +1608,6 @@ int LIB_PIN::GetOrientationIndex( int code )
}
void LIB_PIN::Rotate()
{
int orient = PIN_RIGHT;
switch( GetOrientation() )
{
case PIN_UP: orient = PIN_LEFT; break;
case PIN_DOWN: orient = PIN_RIGHT; break;
case PIN_LEFT: orient = PIN_DOWN; break;
case PIN_RIGHT: orient = PIN_UP; break;
}
// Set the new orientation
SetOrientation( orient );
}
const BITMAP_DEF* LIB_PIN::GetOrientationSymbols()
{
return iconsPinsOrientations;

View File

@ -213,8 +213,6 @@ public:
*/
void SetOrientation( int aOrientation, bool aTestOtherPins = true );
void Rotate() override;
GRAPHIC_PINSHAPE GetShape() const { return m_shape; }
/**

View File

@ -292,12 +292,6 @@ const EDA_RECT LIB_TEXT::GetBoundingBox() const
}
void LIB_TEXT::Rotate()
{
SetTextAngle( GetTextAngle() == TEXT_ANGLE_VERT ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT );
}
void LIB_TEXT::SetText( const wxString& aText )
{
m_Text = aText;

View File

@ -80,15 +80,12 @@ public:
return TextHitTest( aRect, aContained, aAccuracy );
}
int GetPenSize( ) const override;
void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override;
const EDA_RECT GetBoundingBox() const override;
void Rotate() override;
void BeginEdit( const wxPoint aStartPoint ) override;
void CalcEdit( const wxPoint& aPosition ) override;

View File

@ -30,10 +30,6 @@
#include <sch_draw_panel.h>
#include <base_screen.h>
#include <confirm.h>
#include <eda_doc.h>
#include <sch_edit_frame.h>
#include <msgpanel.h>
#include <confirm.h>
#include <eda_dockart.h>
#include <general.h>
#include <eeschema_id.h>
@ -43,7 +39,6 @@
#include <widgets/symbol_tree_pane.h>
#include <widgets/lib_tree.h>
#include <symbol_lib_table.h>
#include <eeschema_config.h>
#include <wildcards_and_files_ext.h>
#include <wx/progdlg.h>
#include <tool/tool_manager.h>
@ -281,7 +276,7 @@ void LIB_EDIT_FRAME::RebuildSymbolUnitsList()
if( m_unitSelectBox->GetCount() != 0 )
m_unitSelectBox->Clear();
LIB_PART* part = GetCurPart();
LIB_PART* part = GetCurPart();
if( !part || part->GetUnitCount() <= 1 )
{
@ -298,8 +293,7 @@ void LIB_EDIT_FRAME::RebuildSymbolUnitsList()
}
}
// Ensure the current selected unit is compatible with
// the number of units of the current part:
// Ensure the selected unit is compatible with the number of units of the current part:
if( part && part->GetUnitCount() < m_unit )
m_unit = 1;

View File

@ -401,8 +401,6 @@ public:
/**
* Creates the SVG print file for the current edited component.
*
* @param aFullFileName = the full filename
*/
void SVG_PlotComponent( const wxString& aFullFileName );

View File

@ -75,8 +75,8 @@ std::string toUTFTildaText( const wxString& txt )
/**
* Used when a LIB_PART is not found in library
* to draw a dummy shape
* Used to draw a dummy shape when a LIB_PART is not found in library
*
* This component is a 400 mils square with the text ??
* DEF DUMMY U 0 40 Y Y 1 0 N
* F0 "U" 0 -350 60 H V
@ -372,8 +372,7 @@ bool SCH_COMPONENT::Resolve( SYMBOL_LIB_TABLE& aLibTable, PART_LIB* aCacheLib )
}
// Helper sort function, used in SCH_COMPONENT::ResolveAll, to sort
// sch component by lib_id
// Helper sort function, used in SCH_COMPONENT::ResolveAll, to sort sch component by lib_id
static bool sort_by_libid( const SCH_COMPONENT* ref, SCH_COMPONENT* cmp )
{
if( ref->GetLibId() == cmp->GetLibId() )
@ -615,20 +614,19 @@ const wxString SCH_COMPONENT::GetRef( const SCH_SHEET_PATH* sheet )
wxStringTokenizer tokenizer;
wxString separators( wxT( " " ) );
for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
for( const wxString& entry : m_PathsAndReferences )
{
tokenizer.SetString( m_PathsAndReferences[ii], separators );
tokenizer.SetString( entry, separators );
h_path = tokenizer.GetNextToken();
if( h_path.Cmp( path ) == 0 )
return tokenizer.GetNextToken();
}
// if it was not found in m_Paths array, then see if it is in
// m_Field[REFERENCE] -- if so, use this as a default for this path.
// this will happen if we load a version 1 schematic file.
// it will also mean that multiple instances of the same sheet by default
// all have the same component references, but perhaps this is best.
// If it was not found in m_Paths array, then see if it is in m_Field[REFERENCE] -- if so,
// use this as a default for this path. This will happen if we load a version 1 schematic
// file. It will also mean that multiple instances of the same sheet by default all have
// the same component references, but perhaps this is best.
if( !GetField( REFERENCE )->GetText().IsEmpty() )
{
SetRef( sheet, GetField( REFERENCE )->GetText() );
@ -651,9 +649,6 @@ bool SCH_COMPONENT::IsReferenceStringValid( const wxString& aReferenceString )
if( text.IsEmpty() )
ok = false;
// Add here other constraints
// Currently:no other constraint
return ok;
}
@ -730,9 +725,9 @@ bool SCH_COMPONENT::IsAnnotated( const SCH_SHEET_PATH* aSheet )
wxStringTokenizer tokenizer;
wxString separators( wxT( " " ) );
for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
for( const wxString& entry : m_PathsAndReferences )
{
tokenizer.SetString( m_PathsAndReferences[ii], separators );
tokenizer.SetString( entry, separators );
h_path = tokenizer.GetNextToken();
if( h_path.Cmp( path ) == 0 )
@ -754,11 +749,8 @@ void SCH_COMPONENT::SetTimeStamp( timestamp_t aNewTimeStamp )
string_oldtimestamp.Printf( wxT( "%08lX" ), (long unsigned) m_TimeStamp );
EDA_ITEM::SetTimeStamp( aNewTimeStamp );
for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
{
m_PathsAndReferences[ii].Replace( string_oldtimestamp.GetData(),
string_timestamp.GetData() );
}
for( wxString& entry : m_PathsAndReferences )
entry.Replace( string_oldtimestamp.GetData(), string_timestamp.GetData() );
}
@ -769,9 +761,9 @@ int SCH_COMPONENT::GetUnitSelection( SCH_SHEET_PATH* aSheet )
wxStringTokenizer tokenizer;
wxString separators( wxT( " " ) );
for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
for( const wxString& entry : m_PathsAndReferences )
{
tokenizer.SetString( m_PathsAndReferences[ii], separators );
tokenizer.SetString( entry, separators );
h_path = tokenizer.GetNextToken();
if( h_path.Cmp( path ) == 0 )
@ -784,8 +776,8 @@ int SCH_COMPONENT::GetUnitSelection( SCH_SHEET_PATH* aSheet )
}
}
// if it was not found in m_Paths array, then use m_unit.
// this will happen if we load a version 1 schematic file.
// If it was not found in m_Paths array, then use m_unit. This will happen if we load a
// version 1 schematic file.
return m_unit;
}
@ -801,9 +793,9 @@ void SCH_COMPONENT::SetUnitSelection( SCH_SHEET_PATH* aSheet, int aUnitSelection
wxString separators( wxT( " " ) );
//check to see if it is already there before inserting it
for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
for( wxString& entry : m_PathsAndReferences )
{
tokenizer.SetString( m_PathsAndReferences[ii], separators );
tokenizer.SetString( entry, separators );
h_path = tokenizer.GetNextToken();
if( h_path.Cmp( path ) == 0 )
@ -815,7 +807,7 @@ void SCH_COMPONENT::SetUnitSelection( SCH_SHEET_PATH* aSheet, int aUnitSelection
h_ref << aUnitSelection; // Add part selection
// Ann the part selection
m_PathsAndReferences[ii] = h_ref;
entry = h_ref;
notInArray = false;
}
}
@ -836,17 +828,16 @@ SCH_FIELD* SCH_COMPONENT::GetField( int aFieldNdx ) const
wxASSERT( field );
// use cast to remove const-ness
return (SCH_FIELD*) field;
return const_cast<SCH_FIELD*>( field );
}
wxString SCH_COMPONENT::GetFieldText( const wxString& aFieldName, SCH_EDIT_FRAME* aFrame ) const
{
for( unsigned int ii = 0; ii < m_Fields.size(); ii++ )
for( const SCH_FIELD& field : m_Fields )
{
if( aFieldName == m_Fields[ii].GetName() )
return m_Fields[ii].GetText();
if( aFieldName == field.GetName() )
return field.GetText();
}
return wxEmptyString;
@ -855,10 +846,10 @@ wxString SCH_COMPONENT::GetFieldText( const wxString& aFieldName, SCH_EDIT_FRAME
void SCH_COMPONENT::GetFields( std::vector<SCH_FIELD*>& aVector, bool aVisibleOnly )
{
for( SCH_FIELD& each_field : m_Fields )
for( SCH_FIELD& field : m_Fields )
{
if( !aVisibleOnly || ( each_field.IsVisible() && !each_field.IsVoid() ) )
aVector.push_back( &each_field );
if( !aVisibleOnly || ( field.IsVisible() && !field.IsVoid() ) )
aVector.push_back( &field );
}
}
@ -889,12 +880,10 @@ SCH_FIELD* SCH_COMPONENT::FindField( const wxString& aFieldName, bool aIncludeDe
{
unsigned start = aIncludeDefaultFields ? 0 : MANDATORY_FIELDS;
for( unsigned i = start; i<m_Fields.size(); ++i )
for( unsigned i = start; i < m_Fields.size(); ++i )
{
if( aFieldName == m_Fields[i].GetName( false ) )
{
return &m_Fields[i];
}
}
return NULL;
@ -1066,18 +1055,18 @@ void SCH_COMPONENT::ClearAnnotation( SCH_SHEET_PATH* aSheetPath )
if( aSheetPath )
path = GetPath( aSheetPath );
for( unsigned int ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
for( wxString& entry : m_PathsAndReferences )
{
// Break hierarchical reference in path, ref and multi selection:
reference_fields = wxStringTokenize( m_PathsAndReferences[ii], separators );
reference_fields = wxStringTokenize( entry, separators );
// For all components: if aSheetPath is not NULL,
// remove annotation only for the given path
if( aSheetPath == NULL || reference_fields[0].Cmp( path ) == 0 )
{
wxString NewHref = reference_fields[0];
NewHref << wxT( " " ) << defRef << wxT( " " ) << reference_fields[2];
m_PathsAndReferences[ii] = NewHref;
wxString newHref = reference_fields[0];
newHref << wxT( " " ) << defRef << wxT( " " ) << reference_fields[2];
entry = newHref;
}
}

View File

@ -25,8 +25,6 @@
#include <view/wx_view_controls.h>
#include <ws_proxy_view_item.h>
#include <gal/graphics_abstraction_layer.h>
#include <sch_draw_panel.h>
#include <sch_view.h>
@ -38,11 +36,8 @@
#include <functional>
#include <sch_sheet.h>
#include <pgm_base.h>
#include <tools/ee_actions.h>
#include <tools/ee_selection_tool.h>
using namespace std::placeholders;
SCH_DRAW_PANEL::SCH_DRAW_PANEL( wxWindow* aParentWindow, wxWindowID aWindowId,
const wxPoint& aPosition, const wxSize& aSize,

View File

@ -31,12 +31,8 @@
#include <sch_view.h>
class SCH_SHEET;
class LIB_PART;
class BASE_SCREEN;
class SCH_SCREEN;
class COLORS_DESIGN_SETTINGS;
class SCH_EDIT_FRAME;
class SCH_DRAW_PANEL : public EDA_DRAW_PANEL_GAL

View File

@ -32,15 +32,11 @@
#include <html_messagebox.h>
#include <kiface_i.h>
#include <kiway.h>
#include <msgpanel.h>
#include <pgm_base.h>
#include <profile.h>
#include <sch_draw_panel.h>
#include <advanced_config.h>
#include <general.h>
#include <eeschema_id.h>
#include <netlist.h>
#include <class_library.h>
#include <sch_edit_frame.h>
#include <symbol_lib_table.h>
@ -53,7 +49,6 @@
#include <invoke_sch_dialog.h>
#include <dialogs/dialog_schematic_find.h>
#include <dialog_symbol_remap.h>
#include <view/view.h>
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
#include <tool/action_toolbar.h>
@ -70,10 +65,8 @@
#include <tools/sch_edit_tool.h>
#include <tools/ee_inspection_tool.h>
#include <tools/sch_editor_control.h>
#include <build_version.h>
#include <wildcards_and_files_ext.h>
#include <connection_graph.h>
#include <sch_view.h>
#include <sch_painter.h>
#include <gal/graphics_abstraction_layer.h>
@ -235,7 +228,7 @@ END_EVENT_TABLE()
SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH, wxT( "Eeschema" ),
wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, SCH_EDIT_FRAME_NAME ),
m_item_to_repeat( 0 )
m_item_to_repeat( nullptr )
{
g_CurrentSheet = new SCH_SHEET_PATH();
g_ConnectionGraph = new CONNECTION_GRAPH( this );
@ -363,7 +356,7 @@ void SCH_EDIT_FRAME::setupTools()
void SCH_EDIT_FRAME::SaveCopyForRepeatItem( SCH_ITEM* aItem )
{
// we cannot store a pointer to an item in the display list here since
// that item may be deleted, such as part of a line concatonation or other.
// that item may be deleted, such as part of a line concatenation or other.
// So simply always keep a copy of the object which is to be repeated.
delete m_item_to_repeat;
@ -388,9 +381,9 @@ void SCH_EDIT_FRAME::SetSheetNumberAndCount()
// Examine all sheets path to find the current sheets path,
// and count them from root to the current sheet path:
for( unsigned i = 0; i < sheetList.size(); i++ )
for( const SCH_SHEET_PATH& sheet : sheetList )
{
wxString sheetpath = sheetList[i].Path();
wxString sheetpath = sheet.Path();
if( sheetpath == current_sheetpath ) // Current sheet path found
break;
@ -656,10 +649,9 @@ void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event )
if( Kiface().IsSingle() )
{
DisplayError( this, _( "Cannot update the PCB, because the Schematic Editor is"
" opened in stand-alone mode. In order to create/update"
" PCBs from schematics, you need to launch Kicad shell"
" and create a PCB project." ) );
DisplayError( this, _( "Cannot update the PCB, because the Schematic Editor is opened"
" in stand-alone mode. In order to create/update PCBs from"
" schematics, launch the Kicad shell and create a project." ) );
return;
}
@ -702,7 +694,7 @@ void SCH_EDIT_FRAME::ShowFindReplaceDialog( bool aReplace )
if( m_findReplaceStatusPopup )
m_findReplaceStatusPopup->Destroy();
// Must destroy statup popup first as it holds a pointer to the dialog
// Must destroy statusPopup first as it holds a pointer to the dialog
if( m_findReplaceDialog )
m_findReplaceDialog->Destroy();
@ -866,7 +858,6 @@ void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
{
player = Kiway().Player( FRAME_CVPCB, true );
player->Show( true );
// player->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
}
sendNetlistToCvpcb();
@ -956,7 +947,7 @@ void SCH_EDIT_FRAME::AddItemToScreenAndUndoList( SCH_ITEM* aItem, bool aUndoAppe
{
SCH_SCREEN* screen = GetScreen();
wxCHECK_RET( aItem != NULL, wxT( "Cannot add current aItem to list." ) );
wxCHECK_RET( aItem != NULL, wxT( "Cannot add null item to list." ) );
SCH_SHEET* parentSheet = nullptr;
SCH_COMPONENT* parentComponent = nullptr;
@ -1047,7 +1038,8 @@ void SCH_EDIT_FRAME::UpdateTitle()
if( GetScreen()->GetFileName() == m_DefaultSchematicFileName )
{
title.Printf( _( "Eeschema" ) + wxT( " \u2014 %s" ), GetScreen()->GetFileName() );
title.Printf( _( "Eeschema" ) + wxT( " \u2014 %s" ),
GetScreen()->GetFileName() );
}
else
{
@ -1055,7 +1047,8 @@ void SCH_EDIT_FRAME::UpdateTitle()
wxFileName fn = fileName;
title.Printf( _( "Eeschema" ) + wxT( " \u2014 %s [%s] \u2014 %s" ),
fn.GetFullName(), g_CurrentSheet->PathHumanReadable(),
fn.GetFullName(),
g_CurrentSheet->PathHumanReadable(),
fn.GetPath() );
if( fn.FileExists() )
@ -1156,11 +1149,11 @@ void SCH_EDIT_FRAME::FixupJunctions()
SCH_SHEET_LIST sheetList;
sheetList.BuildSheetList( g_RootSheet );
for( unsigned i = 0; i < sheetList.size(); i++ )
for( const SCH_SHEET_PATH& sheet : sheetList )
{
std::vector<wxPoint> anchors;
SetCurrentSheet( sheetList[i] );
SetCurrentSheet( sheet );
GetCurrentSheet().UpdateAllScreenReferences();
auto screen = GetCurrentSheet().LastScreen();
@ -1172,15 +1165,13 @@ void SCH_EDIT_FRAME::FixupJunctions()
auto cmp = static_cast<SCH_COMPONENT*>( item );
auto xform = cmp->GetTransform();
for( auto pin : cmp->GetPins() )
for( const SCH_PIN& pin : cmp->GetPins() )
{
auto pos = cmp->GetPosition() + xform.TransformCoordinate( pin.GetPosition() );
// Test if a _new_ junction is needed, and add it if missing
if ( screen->IsJunctionNeeded( pos, true ) )
{
AddJunction( pos );
}
}
}
}

View File

@ -34,9 +34,7 @@
#include <tool/selection.h>
#include <erc_settings.h>
#include <sch_draw_panel.h>
// enum PINSHEETLABEL_SHAPE
#include <sch_text.h>
#include <sch_text.h> // enum PINSHEETLABEL_SHAPE
#include <tool/selection.h>
#include <status_popup.h>
@ -171,12 +169,12 @@ protected:
*
* @return true if the auto save was successful otherwise false.
*/
virtual bool doAutoSave() override;
bool doAutoSave() override;
/**
* Returns true if the schematic has been modified.
*/
virtual bool isAutoSaveRequired() const override;
bool isAutoSaveRequired() const override;
/**
* Verify that annotation is complete so that a proper netlist is even
@ -193,7 +191,7 @@ protected:
public:
SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent );
~SCH_EDIT_FRAME();
~SCH_EDIT_FRAME() override;
SCH_SCREEN* GetScreen() const override;
@ -217,7 +215,7 @@ public:
bool GetAutoplaceJustify() const { return m_autoplaceJustify; }
void SetAutoplaceJustify( bool aEnable ) { m_autoplaceJustify = aEnable; }
const wxString GetNetListFormatName() const { return m_netListFormat; }
const wxString& GetNetListFormatName() const { return m_netListFormat; }
void SetNetListFormatName( const wxString& aFormat ) { m_netListFormat = aFormat; }
bool GetSpiceAjustPassiveValues() const { return m_spiceAjustPassiveValues; }
@ -230,10 +228,8 @@ public:
/**
* Return the project file parameter list for Eeschema.
*
*<p>
* Populate the project file parameter array specific to Eeschema if it hasn't
* already been populated and return a reference to the array to the caller.
* </p>
*/
PARAM_CFG_ARRAY& GetProjectFileParameters();
@ -307,6 +303,9 @@ public:
*/
void OnModify() override;
/**
* Return a human-readable description of the current screen.
*/
wxString GetScreenDesc() const override;
/**
@ -607,7 +606,6 @@ public:
void NewProject();
void LoadProject();
// read and save files
void Save_File( bool doSaveAs = false );
bool SaveProject();
@ -667,8 +665,8 @@ public:
* Checks if any of the screens has unsaved changes and asks the user whether to save or
* drop them.
*
* @return True if user decided to save or drop changes, false if the
* operation should be canceled.
* @return True if user decided to save or drop changes, false if the operation should be
* canceled.
*/
bool AskToSaveChanges();
@ -684,8 +682,8 @@ public:
SCH_TEXT* CreateNewText( int aType );
/**
* Performs routine schematic cleaning including breaking wire and buses and
* deleting identical objects superimposed on top of each other.
* Performs routine schematic cleaning including breaking wire and buses and deleting
* identical objects superimposed on top of each other.
*
* NOTE: always appends to the existing undo state.
*
@ -735,18 +733,11 @@ private:
*
* If file name defined by SCH_SCREEN::m_FileName is not set, the title is set to the
* application name appended with no file.
* Otherwise, the title is set to the hierarchical sheet path and the full file name,
* and read only is appended to the title if the user does not have write
* access to the file.
* Otherwise, the title is set to the hierarchical sheet path and the full file name, and
* read only is appended to the title if the user does not have write access to the file.
*/
void UpdateTitle();
/**
* Checks all wires and adds any junctions that are missing
* (Intended to be called only on file load)
*/
bool AddMissingJunctions( SCH_SCREEN* aScreen );
/**
* Perform all cleanup and normalization steps so that the whole schematic
* is in a good state. This should only be called when loading a file.
@ -801,8 +792,6 @@ public:
void LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy,
const wxString& aExistingFilename );
wxPoint GetLastSheetPinPosition() const { return m_lastSheetPinPosition; }
private:
/**
* Load the given filename but sets the path to the current project path.

View File

@ -24,7 +24,6 @@
#include <ee_picker_tool.h>
#include <ee_actions.h>
#include <view/view_controls.h>
#include <tool/tool_manager.h>
#include <sch_base_frame.h>
@ -149,9 +148,6 @@ void EE_PICKER_TOOL::setTransitions()
void EE_PICKER_TOOL::resetPicker()
{
m_cursorCapture = false;
m_autoPanning = false;
m_clickHandler = NULLOPT;
m_motionHandler = NULLOPT;
m_cancelHandler = NULLOPT;
@ -163,6 +159,6 @@ void EE_PICKER_TOOL::setControls()
{
KIGFX::VIEW_CONTROLS* controls = getViewControls();
controls->CaptureCursor( m_cursorCapture );
controls->SetAutoPan( m_autoPanning );
controls->CaptureCursor( false );
controls->SetAutoPan( false );
}

View File

@ -55,18 +55,6 @@ public:
///> Main event loop.
int Main( const TOOL_EVENT& aEvent );
/**
* Function SetAutoPanning()
* Sets autopanning mode for the period when the tool is active.
*/
inline void SetAutoPanning( bool aEnable ) { m_autoPanning = aEnable; }
/**
* Function SetAutoPanning()
* Toggles cursor capture mode for the period when the tool is active.
*/
inline void SetCursorCapture( bool aEnable ) { m_cursorCapture = aEnable; }
/**
* Function SetClickHandler()
* Sets a handler for mouse click event. Handler may decide to receive further click by
@ -119,9 +107,6 @@ private:
void setTransitions() override;
private:
bool m_cursorCapture;
bool m_autoPanning;
OPT<CLICK_HANDLER> m_clickHandler;
OPT<MOTION_HANDLER> m_motionHandler;
OPT<CANCEL_HANDLER> m_cancelHandler;

View File

@ -353,7 +353,7 @@ int LIB_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
LIB_ITEM* item = (LIB_ITEM*) selection.Front();
// Save copy for undo if not in edit (edit command already handle the save copy)
if( !item->InEditMode() )
if( item->GetEditFlags() == 0 )
saveCopyInUndoList( item->GetParent(), UR_LIBEDIT );
switch( item->Type() )

View File

@ -31,9 +31,7 @@
PL_PICKER_TOOL::PL_PICKER_TOOL() :
TOOL_INTERACTIVE( "plEditor.InteractivePicker" ),
m_frame( nullptr ),
m_cursorCapture( false ),
m_autoPanning( false )
m_frame( nullptr )
{
resetPicker();
}
@ -58,8 +56,6 @@ bool PL_PICKER_TOOL::Init()
void PL_PICKER_TOOL::Reset( RESET_REASON aReason )
{
m_cursorCapture = false;
m_autoPanning = false;
}
@ -175,9 +171,6 @@ void PL_PICKER_TOOL::setTransitions()
void PL_PICKER_TOOL::resetPicker()
{
m_cursorCapture = false;
m_autoPanning = false;
m_picked = NULLOPT;
m_motionHandler = NULLOPT;
m_clickHandler = NULLOPT;
@ -190,6 +183,6 @@ void PL_PICKER_TOOL::setControls()
{
KIGFX::VIEW_CONTROLS* controls = getViewControls();
controls->CaptureCursor( m_cursorCapture );
controls->SetAutoPan( m_autoPanning );
controls->CaptureCursor( false );
controls->SetAutoPan( false );
}

View File

@ -61,18 +61,6 @@ public:
///> Main event loop.
int Main( const TOOL_EVENT& aEvent );
/**
* Function SetAutoPanning()
* Sets autopanning mode for the period when the tool is active.
*/
inline void SetAutoPanning( bool aEnable ) { m_autoPanning = aEnable; }
/**
* Function SetAutoPanning()
* Toggles cursor capture mode for the period when the tool is active.
*/
inline void SetCursorCapture( bool aEnable ) { m_cursorCapture = aEnable; }
/**
* Function SetClickHandler()
* Sets a handler for mouse click event. Handler may decide to receive further click by
@ -127,9 +115,6 @@ private:
private:
PL_EDITOR_FRAME* m_frame;
bool m_cursorCapture;
bool m_autoPanning;
OPT<CLICK_HANDLER> m_clickHandler;
OPT<MOTION_HANDLER> m_motionHandler;
OPT<CANCEL_HANDLER> m_cancelHandler;

View File

@ -159,8 +159,6 @@ void PCBNEW_PICKER_TOOL::setTransitions()
void PCBNEW_PICKER_TOOL::reset()
{
m_cursorCapture = false;
m_autoPanning = false;
m_layerMask = LSET::AllLayersMask();
m_picked = NULLOPT;
@ -178,6 +176,6 @@ void PCBNEW_PICKER_TOOL::setControls()
// Ensure that the view controls do not handle our snapping as we use the GRID_HELPER
controls->SetSnapping( false );
controls->CaptureCursor( m_cursorCapture );
controls->SetAutoPan( m_autoPanning );
controls->CaptureCursor( false );
controls->SetAutoPan( false );
}

View File

@ -58,18 +58,6 @@ public:
///> Main event loop.
int Main( const TOOL_EVENT& aEvent );
/**
* Function SetAutoPanning()
* Sets autopanning mode for the period when the tool is active.
*/
inline void SetAutoPanning( bool aEnable ) { m_autoPanning = aEnable; }
/**
* Function SetAutoPanning()
* Toggles cursor capture mode for the period when the tool is active.
*/
inline void SetCursorCapture( bool aEnable ) { m_cursorCapture = aEnable; }
/**
* Function SetLayerSet()
* Sets the tool's snap layer set
@ -121,9 +109,6 @@ public:
void setTransitions() override;
private:
bool m_cursorCapture;
bool m_autoPanning;
///> The layer set to use for optional snapping
LSET m_layerMask;