Commit b98538ec authored by Wayne Stambaugh's avatar Wayne Stambaugh

Add copy constructors and cloning to schematic objects and other minor fixes.

parent c699c726
......@@ -4,6 +4,20 @@ KiCad ChangeLog 2010
Please add newer entries at the top, list the date and your name with
email address.
2010-dec-21 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================
++all
* Doxygen comment warning fixes.
* Coding policy fixes.
++common
* Add clone method to EDA_ITEM object.
++EESchema
* Replace GenCopy() method with Clone() in all items derived from SCH_ITEM.
* Simplify repeat last schematic item with new Clone() method.
* Simplify duplicate schematic item method with new Clone() method.
* Separate objects in sch_items.h/cpp into separate files per object.
2010-dec-20, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================
common:
......
This diff is collapsed.
......@@ -282,7 +282,7 @@ void WinEDA_BasicFrame::GetKicadHelp( wxCommandEvent& event )
/*
*
*/
void WinEDA_BasicFrame::GetKicadAbout( wxCommandEvent& WXUNUSED(event) )
void WinEDA_BasicFrame::GetKicadAbout( wxCommandEvent& event )
{
bool ShowAboutDialog(wxWindow * parent);
ShowAboutDialog(this);
......@@ -364,7 +364,7 @@ static inline const char* KICAD_BUILD_OPTIONS_SIGNATURE()
#endif
void WinEDA_BasicFrame::CopyVersionInfoToClipboard( wxCommandEvent& WXUNUSED( event ) )
void WinEDA_BasicFrame::CopyVersionInfoToClipboard( wxCommandEvent& event )
{
if( !wxTheClipboard->Open() )
{
......
......@@ -59,6 +59,17 @@ void MARKER_BASE::init()
}
MARKER_BASE::MARKER_BASE( const MARKER_BASE& aMarker )
{
m_Pos = aMarker.m_Pos;
m_Corners = aMarker.m_Corners;
m_MarkerType = aMarker.m_MarkerType;
m_Color = aMarker.m_Color;
m_ShapeBoundingBox = aMarker.m_ShapeBoundingBox;
m_ScalingFactor = aMarker.m_ScalingFactor;
}
MARKER_BASE::MARKER_BASE()
{
m_ScalingFactor = M_SHAPE_SCALE;
......@@ -122,13 +133,6 @@ bool MARKER_BASE::HitTestMarker( const wxPoint& refPos ) const
}
/**
* Function GetBoundingBoxMarker
* returns the orthogonal, bounding box of this object for display purposes.
* This box should be an enclosing perimeter for visible components of this
* object, and the units should be in the pcb or schematic coordinate system.
* It is OK to overestimate the size by a few counts.
*/
EDA_Rect MARKER_BASE::GetBoundingBoxMarker() const
{
wxSize realsize = m_ShapeBoundingBox.GetSize();
......@@ -141,15 +145,8 @@ EDA_Rect MARKER_BASE::GetBoundingBoxMarker() const
return EDA_Rect( m_Pos, realsize );
}
/**********************************************************************/
void MARKER_BASE::DrawMarker( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode,
const wxPoint& aOffset )
/**********************************************************************/
/**
* Function DrawMarker
* The shape is the polygon defined in m_Corners (array of wxPoints)
*/
{
wxPoint corners[CORNERS_COUNT];
......@@ -172,16 +169,11 @@ void MARKER_BASE::DrawMarker( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode
}
/**
* Function DisplayMarkerInfo
* Displays the full info of this marker, within an HTML window
*/
void MARKER_BASE::DisplayMarkerInfo( WinEDA_DrawFrame* aFrame )
{
wxString msg = m_drc.ShowHtml();
DIALOG_DISPLAY_HTML_TEXT_BASE
infodisplay( (wxWindow*)aFrame, wxID_ANY, _("Marker Info"),
wxGetMousePosition(), wxSize( 550, 140 ) );
DIALOG_DISPLAY_HTML_TEXT_BASE infodisplay( (wxWindow*)aFrame, wxID_ANY, _( "Marker Info" ),
wxGetMousePosition(), wxSize( 550, 140 ) );
infodisplay.m_htmlWindow->SetPage( msg );
infodisplay.ShowModal();
......
......@@ -879,7 +879,7 @@ void wxSVGFileDC::DoDrawIcon( const class wxIcon& myIcon, wxCoord x, wxCoord y )
void wxSVGFileDC::DoDrawBitmap( const class wxBitmap& bmp,
wxCoord x,
wxCoord y,
bool WXUNUSED ( bTransparent) /*=0*/ )
bool bTransparent /*=0*/ )
{
if( m_graphics_changed )
NewGraphics();
......
......@@ -29,6 +29,13 @@ SCH_ITEM::SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType ) :
}
SCH_ITEM::SCH_ITEM( const SCH_ITEM& aItem ) :
EDA_ITEM( aItem )
{
m_Layer = aItem.m_Layer;
}
SCH_ITEM::~SCH_ITEM()
{
// Do not let the connections container go out of scope with any ojbects or they
......@@ -101,5 +108,5 @@ bool SCH_ITEM::IsConnected( const wxPoint& aPosition ) const
if( m_Flags & STRUCT_DELETED || m_Flags & SKIP_STRUCT )
return false;
return DoIsConnected( aPosition );
return doIsConnected( aPosition );
}
......@@ -115,10 +115,14 @@ set(EESCHEMA_SRCS
operations_on_items_lists.cpp
pinedit.cpp
plot.cpp
sch_bus_entry.cpp
sch_component.cpp
sch_field.cpp
sch_items.cpp
sch_line.cpp
sch_marker.cpp
sch_no_connect.cpp
sch_polyline.cpp
sch_screen.cpp
sch_sheet.cpp
sch_sheet_path.cpp
......
......@@ -16,8 +16,11 @@
#include "class_library.h"
#include "lib_pin.h"
#include "protos.h"
#include "sch_bus_entry.h"
#include "sch_marker.h"
#include "sch_items.h"
#include "sch_line.h"
#include "sch_no_connect.h"
#include "sch_text.h"
#include "sch_component.h"
#include "sch_sheet.h"
......
......@@ -14,16 +14,18 @@
#include "lib_pin.h"
#include "general.h"
#include "protos.h"
#include "sch_bus_entry.h"
#include "sch_items.h"
#include "sch_line.h"
#include "sch_no_connect.h"
#include "sch_polyline.h"
#include "sch_text.h"
#include "sch_component.h"
#include "sch_sheet.h"
/* Routines Locales */
static void Show_Polyline_in_Ghost( WinEDA_DrawPanel* panel,
wxDC* DC,
bool erase );
static void Show_Polyline_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void AbortCreateNewLine( WinEDA_DrawPanel* Panel, wxDC* DC );
static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer );
static bool IsJunctionNeeded( SCH_EDIT_FRAME* frame, wxPoint& pos );
......@@ -172,7 +174,7 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type )
if( g_HVLines ) // We need 2 segments to go from a given start pin to an end point
{
nextsegment = newsegment->GenCopy();
nextsegment = new SCH_LINE( *newsegment );
nextsegment->m_Flags = IS_NEW;
newsegment->SetNext( nextsegment );
nextsegment->SetBack( newsegment );
......@@ -220,7 +222,7 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type )
/* Create a new segment, and chain it after the current new segment */
if( nextsegment )
{
newsegment = nextsegment->GenCopy();
newsegment = new SCH_LINE( *nextsegment );
nextsegment->m_Start = newsegment->m_End;
nextsegment->SetNext( NULL );
nextsegment->SetBack( newsegment );
......@@ -229,7 +231,7 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type )
}
else
{
newsegment = oldsegment->GenCopy();
newsegment = new SCH_LINE( *oldsegment );
newsegment->m_Start = oldsegment->m_End;
}
......@@ -332,6 +334,7 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC )
if( !g_ItemToRepeat )
g_ItemToRepeat = segment;
}
segment->m_Flags = 0;
segment = segment->Next();
}
......@@ -372,7 +375,6 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC )
item = item->Next();
}
DrawPanel->CursorOn( DC ); // Display schematic cursor
SaveCopyInUndoList( s_OldWiresList, UR_WIRE_IMAGE );
......@@ -442,6 +444,7 @@ static void Show_Polyline_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool eras
GRSetDrawMode( DC, g_XorMode );
int idx = NewPoly->GetCornerCount() - 1;
if( g_HVLines )
{
/* Coerce the line to vertical or horizontal one: */
......@@ -571,111 +574,30 @@ static void AbortCreateNewLine( WinEDA_DrawPanel* Panel, wxDC* DC )
*/
void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC )
{
wxPoint new_pos;
if( g_ItemToRepeat == NULL )
return;
switch( g_ItemToRepeat->Type() )
{
case SCH_JUNCTION_T:
#undef STRUCT
#define STRUCT ( (SCH_JUNCTION*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos += g_RepeatStep;
new_pos = STRUCT->m_Pos;
break;
case SCH_NO_CONNECT_T:
#undef STRUCT
#define STRUCT ( (SCH_NO_CONNECT*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos += g_RepeatStep;
new_pos = STRUCT->m_Pos;
break;
case SCH_TEXT_T:
#undef STRUCT
#define STRUCT ( (SCH_TEXT*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos += g_RepeatStep;
new_pos = STRUCT->m_Pos;
IncrementLabelMember( STRUCT->m_Text );
break;
case SCH_LABEL_T:
#undef STRUCT
#define STRUCT ( (SCH_LABEL*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos += g_RepeatStep;
new_pos = STRUCT->m_Pos;
IncrementLabelMember( STRUCT->m_Text );
break;
case SCH_HIERARCHICAL_LABEL_T:
#undef STRUCT
#define STRUCT ( (SCH_HIERLABEL*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos += g_RepeatStep;
new_pos = STRUCT->m_Pos;
IncrementLabelMember( STRUCT->m_Text );
break;
case SCH_GLOBAL_LABEL_T:
#undef STRUCT
#define STRUCT ( (SCH_GLOBALLABEL*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos += g_RepeatStep;
new_pos = STRUCT->m_Pos;
IncrementLabelMember( STRUCT->m_Text );
break;
case SCH_LINE_T:
#undef STRUCT
#define STRUCT ( (SCH_LINE*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Start += g_RepeatStep;
new_pos = STRUCT->m_Start;
STRUCT->m_End += g_RepeatStep;
break;
case SCH_BUS_ENTRY_T:
#undef STRUCT
#define STRUCT ( (SCH_BUS_ENTRY*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos += g_RepeatStep;
new_pos = STRUCT->m_Pos;
break;
case SCH_COMPONENT_T: // In repeat command the new component is put
// in move mode
#undef STRUCT
#define STRUCT ( (SCH_COMPONENT*) g_ItemToRepeat )
// Create the duplicate component, position = mouse cursor
g_ItemToRepeat = STRUCT->GenCopy();
new_pos.x = GetScreen()->m_Curseur.x - STRUCT->m_Pos.x;
new_pos.y = GetScreen()->m_Curseur.y - STRUCT->m_Pos.y;
STRUCT->m_Pos = GetScreen()->m_Curseur;
STRUCT->m_Flags = IS_NEW;
STRUCT->m_TimeStamp = GetTimeStamp();
for( int ii = 0; ii < STRUCT->GetFieldCount(); ii++ )
{
STRUCT->GetField( ii )->m_Pos += new_pos;
}
g_ItemToRepeat = g_ItemToRepeat->Clone();
RedrawOneStruct( DrawPanel, DC, STRUCT, g_XorMode );
StartMovePart( STRUCT, DC );
if( g_ItemToRepeat->Type() == SCH_COMPONENT_T ) // If repeat component then put in move mode
{
wxPoint pos = GetScreen()->m_Curseur - ( (SCH_COMPONENT*) g_ItemToRepeat )->m_Pos;
g_ItemToRepeat->m_Flags = IS_NEW;
( (SCH_COMPONENT*) g_ItemToRepeat )->m_TimeStamp = GetTimeStamp();
g_ItemToRepeat->Move( pos );
RedrawOneStruct( DrawPanel, DC, g_ItemToRepeat, g_XorMode );
StartMovePart( (SCH_COMPONENT*) g_ItemToRepeat, DC );
return;
break;
}
default:
g_ItemToRepeat = NULL;
DisplayError( this, wxT( "Repeat Type Error" ), 10 );
break;
g_ItemToRepeat->Move( wxPoint( g_RepeatStep.GetWidth(), g_RepeatStep.GetHeight() ) );
if( g_ItemToRepeat->Type() == SCH_TEXT_T
|| g_ItemToRepeat->Type() == SCH_LABEL_T
|| g_ItemToRepeat->Type() == SCH_HIERARCHICAL_LABEL_T
|| g_ItemToRepeat->Type() == SCH_GLOBAL_LABEL_T )
{
( (SCH_TEXT*) g_ItemToRepeat )->IncrementLabel();
}
if( g_ItemToRepeat )
......@@ -686,9 +608,6 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC )
RedrawOneStruct( DrawPanel, DC, g_ItemToRepeat, GR_DEFAULT_DRAWMODE );
SaveCopyInUndoList( g_ItemToRepeat, UR_NEW );
g_ItemToRepeat->m_Flags = 0;
// GetScreen()->Curseur = new_pos;
// DrawPanel->MouseTo( DrawPanel->CursorScreenPosition() );
}
}
......@@ -702,6 +621,7 @@ void IncrementLabelMember( wxString& name )
long number = 0;
ii = name.Len() - 1; nn = 0;
if( !isdigit( name.GetChar( ii ) ) )
return;
......@@ -712,6 +632,7 @@ void IncrementLabelMember( wxString& name )
ii++; /* digits are starting at ii position */
wxString litt_number = name.Right( nn );
if( litt_number.ToLong( &number ) )
{
number += g_RepeatDeltaLabel;
......@@ -778,11 +699,13 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
itempos = LibItem->GetScreenCoord( pin->GetPosition() );
itempos.x += LibItem->m_Pos.x;
itempos.y += LibItem->m_Pos.y;
if( ( itempos.x == pos.x ) && ( itempos.y == pos.y ) )
return TRUE;
}
item = PickStruct( pos, screen, WIREITEM );
if( item )
return TRUE;
......
......@@ -13,7 +13,7 @@
#include "general.h"
#include "protos.h"
#include "sch_items.h"
#include "sch_bus_entry.h"
static int s_LastShape = '\\';
......@@ -85,7 +85,7 @@ void SCH_EDIT_FRAME::StartMoveBusEntry( SCH_BUS_ENTRY* BusEntry, wxDC* DC )
if( (BusEntry->m_Flags & IS_NEW) == 0 ) // not already in edit, save shape
{
delete g_ItemToUndoCopy;
g_ItemToUndoCopy = BusEntry->GenCopy();
g_ItemToUndoCopy = BusEntry->Clone();
}
BusEntry->m_Flags |= IS_MOVED;
......
......@@ -12,7 +12,9 @@
#include "general.h"
#include "protos.h"
#include "netlist.h"
#include "sch_bus_entry.h"
#include "sch_items.h"
#include "sch_line.h"
/* Routine to start/end segment (BUS or wires) on junctions.
......@@ -91,11 +93,11 @@ void BreakSegment( SCH_SCREEN* aScreen, wxPoint aBreakpoint )
* Segment connecte: doit etre coupe en 2 si px,py
* n'est
* pas une extremite */
if( ( segment->m_Start == aBreakpoint )
|| ( segment->m_End == aBreakpoint ) )
if( ( segment->m_Start == aBreakpoint ) || ( segment->m_End == aBreakpoint ) )
continue;
/* Here we must cut the segment into 2. */
NewSegment = segment->GenCopy();
NewSegment = new SCH_LINE( *segment );
NewSegment->m_Start = aBreakpoint;
segment->m_End = NewSegment->m_Start;
NewSegment->SetNext( segment->Next() );
......
......@@ -12,6 +12,7 @@
#include "protos.h"
#include "sch_marker.h"
#include "sch_items.h"
#include "sch_line.h"
#include "sch_sheet.h"
#include "sch_text.h"
......
......@@ -297,7 +297,7 @@ void DIALOG_COLOR_CONFIG::UpdateLayerSettings()
}
void DIALOG_COLOR_CONFIG::OnOkClick( wxCommandEvent& WXUNUSED( event ) )
void DIALOG_COLOR_CONFIG::OnOkClick( wxCommandEvent& event )
{
UpdateLayerSettings();
m_Parent->DrawPanel->Refresh();
......@@ -305,13 +305,13 @@ void DIALOG_COLOR_CONFIG::OnOkClick( wxCommandEvent& WXUNUSED( event ) )
}
void DIALOG_COLOR_CONFIG::OnCancelClick( wxCommandEvent& WXUNUSED( event ) )
void DIALOG_COLOR_CONFIG::OnCancelClick( wxCommandEvent& event )
{
EndModal( -1 );
}
void DIALOG_COLOR_CONFIG::OnApplyClick( wxCommandEvent& WXUNUSED( event ) )
void DIALOG_COLOR_CONFIG::OnApplyClick( wxCommandEvent& event )
{
UpdateLayerSettings();
m_Parent->DrawPanel->Refresh();
......
......@@ -239,7 +239,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
}
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::CopyDocToAlias( wxCommandEvent& WXUNUSED (event) )
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::CopyDocToAlias( wxCommandEvent& event )
{
if( m_Parent == NULL )
return;
......@@ -261,7 +261,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::CopyDocToAlias( wxCommandEvent& WXUNUSED
}
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllAliasOfPart( wxCommandEvent& WXUNUSED (event) )
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllAliasOfPart( wxCommandEvent& event )
{
if( m_PartAliasListCtrl->FindString( m_Parent->GetAliasName() ) != wxNOT_FOUND )
{
......@@ -284,7 +284,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllAliasOfPart( wxCommandEvent& WXU
/* Add a new name to the alias list box
* New name cannot be the root name, and must not exists
*/
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& WXUNUSED (event) )
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& event )
{
wxString aliasname;
LIB_COMPONENT* component = m_Parent->GetComponent();
......@@ -324,7 +324,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& WXUNUSED
}
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAliasOfPart( wxCommandEvent& WXUNUSED (event) )
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAliasOfPart( wxCommandEvent& event )
{
wxString aliasname = m_PartAliasListCtrl->GetStringSelection();
......@@ -444,7 +444,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::BrowseAndSelectDocFile( wxCommandEvent& e
}
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllFootprintFilter( wxCommandEvent& WXUNUSED (event) )
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllFootprintFilter( wxCommandEvent& event )
{
if( IsOK( this, _( "Ok to Delete FootprintFilter LIST" ) ) )
{
......@@ -458,7 +458,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllFootprintFilter( wxCommandEvent&
/* Add a new name to the footprint filter list box
* Obvioulsy, cannot be void
*/
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddFootprintFilter( wxCommandEvent& WXUNUSED (event) )
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddFootprintFilter( wxCommandEvent& event )
{
wxString Line;
LIB_COMPONENT* component = m_Parent->GetComponent();
......@@ -494,7 +494,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddFootprintFilter( wxCommandEvent& WXUNU
}
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteOneFootprintFilter( wxCommandEvent& WXUNUSED( event ) )
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteOneFootprintFilter( wxCommandEvent& event )
{
LIB_COMPONENT* component = m_Parent->GetComponent();
int ii = m_FootprintFilterListBox->GetSelection();
......
......@@ -42,7 +42,7 @@ void SCH_EDIT_FRAME::StartMoveCmpField( SCH_FIELD* aField, wxDC* DC )
SCH_COMPONENT* comp = (SCH_COMPONENT*) aField->GetParent();
SAFE_DELETE( g_ItemToUndoCopy );
g_ItemToUndoCopy = comp->GenCopy();
g_ItemToUndoCopy = new SCH_COMPONENT( *comp );
pos = comp->m_Pos;
......
......@@ -41,7 +41,7 @@ void SCH_EDIT_FRAME::StartMoveTexte( SCH_TEXT* TextStruct, wxDC* DC )
if( (TextStruct->m_Flags & IS_NEW) == 0 )
{
delete g_ItemToUndoCopy;
g_ItemToUndoCopy = TextStruct->GenCopy();
g_ItemToUndoCopy = TextStruct->Clone();
}
TextStruct->m_Flags |= IS_MOVED;
......
......@@ -14,10 +14,14 @@
#include "general.h"
#include "protos.h"
#include "class_library.h"
#include "sch_sheet.h"
#include "sch_sheet_path.h"
#include "sch_bus_entry.h"
#include "sch_component.h"
#include "sch_items.h"
#include "sch_line.h"
#include "sch_no_connect.h"
#include "sch_polyline.h"
#include "sch_sheet.h"
#include "sch_sheet_path.h"
#include "build_version.h"
......@@ -185,8 +189,8 @@ void DrawStructsInGhost( WinEDA_DrawPanel* aPanel,
case SCH_POLYLINE_T:
{
SCH_POLYLINE* Struct = (SCH_POLYLINE*) aItem;
GRMoveTo( Struct->m_PolyPoints[0].x + aOffset.x,
Struct->m_PolyPoints[0].y + aOffset.y );
GRMoveTo( Struct->m_PolyPoints[0].x + aOffset.x, Struct->m_PolyPoints[0].y + aOffset.y );
for( unsigned ii = 1; ii < Struct->GetCornerCount(); ii++ )
GRLineTo( &aPanel->m_ClipBox,
aDC,
......@@ -202,15 +206,16 @@ void DrawStructsInGhost( WinEDA_DrawPanel* aPanel,
{
SCH_LINE* Struct;
Struct = (SCH_LINE*) aItem;
if( (Struct->m_Flags & STARTPOINT) == 0 )
{
GRMoveTo( Struct->m_Start.x + aOffset.x,
Struct->m_Start.y + aOffset.y );
GRMoveTo( Struct->m_Start.x + aOffset.x, Struct->m_Start.y + aOffset.y );
}
else
{
GRMoveTo( Struct->m_Start.x, Struct->m_Start.y );
}
if( (Struct->m_Flags & ENDPOINT) == 0 )
{
GRLineTo( &aPanel->m_ClipBox, aDC, Struct->m_End.x + aOffset.x,
......
......@@ -34,7 +34,7 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event )
case SCH_COMPONENT_T:
{
SCH_COMPONENT* newitem;
newitem = ((SCH_COMPONENT*) curr_item)->GenCopy();
newitem = new SCH_COMPONENT( *( (SCH_COMPONENT*) curr_item ) );
newitem->m_TimeStamp = GetTimeStamp();
newitem->ClearAnnotation( NULL );
newitem->m_Flags = IS_NEW;
......@@ -51,7 +51,7 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event )
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
{
SCH_TEXT* newitem = ((SCH_TEXT*) curr_item)->GenCopy();
SCH_TEXT* newitem = (SCH_TEXT*) curr_item->Clone();
newitem->m_Flags = IS_NEW;
StartMoveTexte( newitem, &dc );
/* Redraw the original part in XOR mode */
......
......@@ -420,7 +420,8 @@ void SCH_EDIT_FRAME::StartMovePart( SCH_COMPONENT* Component, wxDC* DC )
{
SAFE_DELETE( g_ItemToUndoCopy );
}
g_ItemToUndoCopy = Component->GenCopy();
g_ItemToUndoCopy = Component->Clone();
}
DrawPanel->CursorOff( DC );
......
......@@ -13,6 +13,7 @@
#include "libeditframe.h"
#include "class_libentry.h"
#include "sch_items.h"
#include "sch_line.h"
#include "sch_component.h"
#include "sch_sheet.h"
......@@ -510,8 +511,10 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
if( DrawStruct->Type() == SCH_LINE_T )
{
SCH_LINE* segment = (SCH_LINE*) DrawStruct;
if( segment->GetLayer() != LAYER_BUS )
break;
// Bus in progress:
OnLeftClick( DC, MousePos );
}
......
......@@ -11,9 +11,13 @@
#include "general.h"
#include "protos.h"
#include "sch_bus_entry.h"
#include "sch_marker.h"
#include "sch_items.h"
#include "sch_line.h"
#include "sch_no_connect.h"
#include "sch_component.h"
#include "sch_polyline.h"
#include "sch_text.h"
#include "sch_sheet.h"
......
......@@ -11,9 +11,13 @@
#include "general.h"
#include "protos.h"
#include "class_library.h"
#include "sch_bus_entry.h"
#include "sch_marker.h"
#include "sch_items.h"
#include "sch_component.h"
#include "sch_line.h"
#include "sch_no_connect.h"
#include "sch_polyline.h"
#include "sch_sheet.h"
#include "lib_pin.h"
#include "template_fieldnames.h"
......
......@@ -14,6 +14,8 @@
#include "lib_pin.h"
#include "sch_items.h"
#include "sch_component.h"
#include "sch_line.h"
#include "sch_no_connect.h"
#include "sch_text.h"
#include "sch_sheet.h"
......
......@@ -12,9 +12,12 @@
#include "general.h"
#include "protos.h"
#include "sch_bus_entry.h"
#include "sch_text.h"
#include "sch_marker.h"
#include "sch_items.h"
#include "sch_line.h"
#include "sch_no_connect.h"
#include "sch_component.h"
#include "sch_sheet.h"
......
......@@ -15,10 +15,13 @@
#include "protos.h"
#include "hotkeys.h"
#include "class_library.h"
#include "sch_bus_entry.h"
#include "sch_marker.h"
#include "sch_text.h"
#include "sch_items.h"
#include "sch_component.h"
#include "sch_line.h"
#include "sch_no_connect.h"
#include "sch_sheet.h"
#include "sch_sheet_path.h"
......
......@@ -13,7 +13,11 @@
#include "general.h"
#include "protos.h"
#include "sch_bus_entry.h"
#include "sch_marker.h"
#include "sch_line.h"
#include "sch_no_connect.h"
#include "sch_polyline.h"
#include "sch_sheet.h"
#include "sch_component.h"
#include "sch_items.h"
......@@ -30,8 +34,7 @@ void RotateListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& rotationPoint )
}
void DeleteItemsInList( WinEDA_DrawPanel* panel,
PICKED_ITEMS_LIST& aItemsList );
void DeleteItemsInList( WinEDA_DrawPanel* panel, PICKED_ITEMS_LIST& aItemsList );
void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList,
const wxPoint aMoveVector );
......@@ -95,8 +98,7 @@ void DeleteItemsInList( WinEDA_DrawPanel* panel, PICKED_ITEMS_LIST& aItemsList )
if( item->Type() == SCH_SHEET_LABEL_T )
{
/* this item is depending on a sheet, and is not in global list */
wxMessageBox( wxT("DeleteItemsInList() err: unexpected \
SCH_SHEET_LABEL_T" ) );
wxMessageBox( wxT( "DeleteItemsInList() err: unexpected SCH_SHEET_LABEL_T" ) );
}
else
{
......@@ -218,82 +220,15 @@ void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList,
*/
SCH_ITEM* DuplicateStruct( SCH_ITEM* aDrawStruct, bool aClone )
{
SCH_ITEM* NewDrawStruct = NULL;
wxCHECK_MSG( aDrawStruct != NULL, NULL,
wxT( "Cannot duplicate NULL schematic item! Bad programmer." ) );
if( aDrawStruct == NULL )
{
wxMessageBox( wxT( "DuplicateStruct error: NULL struct" ) );
return NULL;
}
switch( aDrawStruct->Type() )
{
case SCH_POLYLINE_T:
NewDrawStruct = ( (SCH_POLYLINE*) aDrawStruct )->GenCopy();
break;
case SCH_LINE_T:
NewDrawStruct = ( (SCH_LINE*) aDrawStruct )->GenCopy();
break;
case SCH_BUS_ENTRY_T:
NewDrawStruct = ( (SCH_BUS_ENTRY*) aDrawStruct )->GenCopy();
break;
case SCH_JUNCTION_T:
NewDrawStruct = ( (SCH_JUNCTION*) aDrawStruct )->GenCopy();
break;
case SCH_MARKER_T:
NewDrawStruct = ( (SCH_MARKER*) aDrawStruct )->GenCopy();
break;
case SCH_NO_CONNECT_T:
NewDrawStruct = ( (SCH_NO_CONNECT*) aDrawStruct )->GenCopy();
break;
case SCH_TEXT_T:
NewDrawStruct = ( (SCH_TEXT*) aDrawStruct )->GenCopy();
break;
case SCH_LABEL_T:
NewDrawStruct = ( (SCH_LABEL*) aDrawStruct )->GenCopy();
break;
case SCH_HIERARCHICAL_LABEL_T:
NewDrawStruct = ( (SCH_HIERLABEL*) aDrawStruct )->GenCopy();
break;
case SCH_GLOBAL_LABEL_T:
NewDrawStruct = ( (SCH_GLOBALLABEL*) aDrawStruct )->GenCopy();
break;
case SCH_COMPONENT_T:
NewDrawStruct = ( (SCH_COMPONENT*) aDrawStruct )->GenCopy();
break;
case SCH_SHEET_T:
NewDrawStruct = ( (SCH_SHEET*) aDrawStruct )->GenCopy();
if( aClone )
{
( (SCH_SHEET*) NewDrawStruct )->m_SheetName =
( (SCH_SHEET*) aDrawStruct )->m_SheetName;
}
break;
default:
{
wxString msg;
msg << wxT( "DuplicateStruct error: unexpected StructType " )
<< aDrawStruct->Type() << wxT( " " ) << aDrawStruct->GetClass();
wxMessageBox( msg );
}
break;
}
SCH_ITEM* NewDrawStruct = aDrawStruct->Clone();
if( aClone )
NewDrawStruct->m_TimeStamp = aDrawStruct->m_TimeStamp;
NewDrawStruct->m_Image = aDrawStruct;
return NewDrawStruct;
}
......@@ -14,7 +14,10 @@
#include "protos.h"
#include "class_library.h"
#include "lib_pin.h"
#include "sch_bus_entry.h"
#include "sch_items.h"
#include "sch_line.h"
#include "sch_no_connect.h"
#include "sch_component.h"
#include "sch_sheet.h"
#include "sch_text.h"
......
/***********************/
/* class SCH_BUS_ENTRY */
/***********************/
#include "fctsys.h"
#include "gr_basic.h"
#include "macros.h"
#include "class_drawpanel.h"
#include "trigo.h"
#include "common.h"
#include "richio.h"
#include "general.h"
#include "protos.h"
#include "sch_bus_entry.h"
SCH_BUS_ENTRY::SCH_BUS_ENTRY( const wxPoint& pos, int shape, int id ) :
SCH_ITEM( NULL, SCH_BUS_ENTRY_T )
{
m_Pos = pos;
m_Size.x = 100;
m_Size.y = 100;
m_Layer = LAYER_WIRE;
m_Width = 0;
if( id == BUS_TO_BUS )
{
m_Layer = LAYER_BUS;
}
if( shape == '/' )
m_Size.y = -100;
}
SCH_BUS_ENTRY::SCH_BUS_ENTRY( const SCH_BUS_ENTRY& aBusEntry ) :
SCH_ITEM( aBusEntry )
{
m_Pos = aBusEntry.m_Pos;
m_Size = aBusEntry.m_Size;
m_Width = aBusEntry.m_Width;
}
EDA_ITEM* SCH_BUS_ENTRY::doClone() const
{
return new SCH_BUS_ENTRY( *this );
}
wxPoint SCH_BUS_ENTRY::m_End() const
{
return wxPoint( m_Pos.x + m_Size.x, m_Pos.y + m_Size.y );
}
bool SCH_BUS_ENTRY::Save( FILE* aFile ) const
{
bool success = true;
const char* layer = "Wire";
const char* width = "Line";
if( GetLayer() == LAYER_BUS )
{
layer = "Bus"; width = "Bus";
}
if( fprintf( aFile, "Entry %s %s\n", layer, width ) == EOF )
{
success = false;
}
if( fprintf( aFile, "\t%-4d %-4d %-4d %-4d\n",
m_Pos.x, m_Pos.y, m_End().x, m_End().y ) == EOF )
{
success = false;
}
return success;
}
bool SCH_BUS_ENTRY::Load( LINE_READER& aLine, wxString& aErrorMsg )
{
char Name1[256];
char Name2[256];
char* line = (char*) aLine;
while( (*line != ' ' ) && *line )
line++;
if( sscanf( line, "%s %s", Name1, Name2 ) != 2 )
{
aErrorMsg.Printf( wxT( "EESchema file bus entry load error at line %d" ),
aLine.LineNumber() );
aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( (char*) aLine );
return false;
}
m_Layer = LAYER_WIRE;
if( Name1[0] == 'B' )
m_Layer = LAYER_BUS;
if( !aLine.ReadLine() || sscanf( (char*) aLine, "%d %d %d %d ", &m_Pos.x, &m_Pos.y,
&m_Size.x, &m_Size.y ) != 4 )
{
aErrorMsg.Printf( wxT( "EESchema file bus entry load error at line %d" ),
aLine.LineNumber() );
aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( (char*) aLine );
return false;
}
m_Size.x -= m_Pos.x;
m_Size.y -= m_Pos.y;
return true;
}
EDA_Rect SCH_BUS_ENTRY::GetBoundingBox() const
{
EDA_Rect box;
box.SetOrigin( m_Pos );
box.SetEnd( m_End() );
box.Normalize();
int width = ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width;
box.Inflate( width / 2 );
return box;
}
int SCH_BUS_ENTRY::GetPenSize() const
{
int pensize = ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width;
if( m_Layer == LAYER_BUS && m_Width == 0 )
{
pensize = wxRound( g_DrawDefaultLineThickness * BUS_WIDTH_EXPAND );
pensize = MAX( pensize, 3 );
}
return pensize;
}
void SCH_BUS_ENTRY::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset,
int aDrawMode, int aColor )
{
int color;
if( aColor >= 0 )
color = aColor;
else
color = ReturnLayerColor( m_Layer );
GRSetDrawMode( aDC, aDrawMode );
GRLine( &aPanel->m_ClipBox, aDC, m_Pos.x + aOffset.x, m_Pos.y + aOffset.y,
m_End().x + aOffset.x, m_End().y + aOffset.y, GetPenSize(), color );
}
void SCH_BUS_ENTRY::Mirror_X( int aXaxis_position )
{
m_Pos.y -= aXaxis_position;
NEGATE( m_Pos.y );
m_Pos.y += aXaxis_position;
NEGATE( m_Size.y );
}
void SCH_BUS_ENTRY::Mirror_Y( int aYaxis_position )
{
m_Pos.x -= aYaxis_position;
NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position;
NEGATE( m_Size.x );
}
void SCH_BUS_ENTRY::Rotate( wxPoint rotationPoint )
{
RotatePoint( &m_Pos, rotationPoint, 900 );
RotatePoint( &m_Size.x, &m_Size.y, 900 );
}
void SCH_BUS_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList )
{
DANGLING_END_ITEM item( ENTRY_END, this );
item.m_Pos = m_Pos;
DANGLING_END_ITEM item1( ENTRY_END, this );
item1.m_Pos = m_End();
aItemList.push_back( item );
aItemList.push_back( item1 );
}
bool SCH_BUS_ENTRY::IsSelectStateChanged( const wxRect& aRect )
{
bool previousState = IsSelected();
// If either end of the bus entry is inside the selection rectangle, the entire
// bus entry is selected. Bus entries have a fixed length and angle.
if( aRect.Contains( m_Pos ) || aRect.Contains( m_End() ) )
m_Flags |= SELECTED;
else
m_Flags &= ~SELECTED;
return previousState != IsSelected();
}
void SCH_BUS_ENTRY::GetConnectionPoints( vector< wxPoint >& aPoints ) const
{
aPoints.push_back( m_Pos );
aPoints.push_back( m_End() );
}
bool SCH_BUS_ENTRY::doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const
{
if( !( aFilter & BUS_ENTRY_T ) )
return false;
return TestSegmentHit( aPoint, m_Pos, m_End(), aAccuracy );
}
bool SCH_BUS_ENTRY::doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const
{
EDA_Rect rect = aRect;
rect.Inflate( aAccuracy );
if( aContained )
return rect.Contains( GetBoundingBox() );
return rect.Intersects( GetBoundingBox() );
}
/**
* @file sch_bus_entry.h
*
*/
#ifndef _SCH_BUS_ENTRY_H_
#define _SCH_BUS_ENTRY_H_
#include "sch_item_struct.h"
/* Flags for BUS ENTRY (bus to bus or wire to bus */
#define WIRE_TO_BUS 0
#define BUS_TO_BUS 1
/**
* Class SCH_BUS_ENTRY
*
* Defines a bus or wire entry.
*/
class SCH_BUS_ENTRY : public SCH_ITEM
{
public:
int m_Width;
wxPoint m_Pos;
wxSize m_Size;
public:
SCH_BUS_ENTRY( const wxPoint& pos = wxPoint( 0, 0 ), int shape = '\\', int id = WIRE_TO_BUS );
SCH_BUS_ENTRY( const SCH_BUS_ENTRY& aBusEntry );
~SCH_BUS_ENTRY() { }
virtual wxString GetClass() const
{
return wxT( "SCH_BUS_ENTRY" );
}
wxPoint m_End() const;
virtual void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset,
int aDrawMode, int aColor = -1 );
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.sch"
* format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
/**
* Load schematic bus entry from \a aLine in a .sch file.
*
* @param aLine - Essentially this is file to read schematic bus entry from.
* @param aErrorMsg - Description of the error if an error occurs while loading the
* schematic bus entry.
* @return True if the schematic bus entry loaded successfully.
*/
virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg );
/**
* Function GetBoundingBox
* returns the orthogonal, bounding box of this object for display
* purposes. This box should be an enclosing perimeter for visible
* components of this object, and the units should be in the pcb or
* schematic coordinate system. It is OK to overestimate the size
* by a few counts.
*/
EDA_Rect GetBoundingBox() const;
/**
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
virtual int GetPenSize() const;
/**
* Function Move
* moves and item to a new position by \a aMoveVector.
* @param aMoveVector The displacement vector.
*/
virtual void Move( const wxPoint& aMoveVector )
{
m_Pos += aMoveVector;
}
/**
* Function Mirror_Y
* mirrors the item relative to \a aYaxis_position.
* @param aYaxis_position The Y axis coordinate to mirror around.
*/
virtual void Mirror_Y( int aYaxis_position );
virtual void Mirror_X( int aXaxis_position );
virtual void Rotate( wxPoint rotationPoint );
virtual void GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList );
virtual bool IsSelectStateChanged( const wxRect& aRect );
virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const;
private:
virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const;
virtual bool doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const;
virtual EDA_ITEM* doClone() const;
};
#endif // _SCH_BUS_ENTRY_H_
......@@ -130,20 +130,21 @@ SCH_COMPONENT::SCH_COMPONENT( LIB_COMPONENT& libComponent, SCH_SHEET_PATH* sheet
}
SCH_COMPONENT::SCH_COMPONENT( const SCH_COMPONENT& aTemplate ) :
SCH_ITEM( NULL, SCH_COMPONENT_T )
SCH_COMPONENT::SCH_COMPONENT( const SCH_COMPONENT& aComponent ) :
SCH_ITEM( aComponent )
{
/* assignment of all fields, including field vector elements, and linked
* list pointers */
*this = aTemplate;
/* set linked list pointers to null, before this they were copies of
* aTemplate's */
Pback = NULL;
Pnext = NULL;
m_Son = NULL;
// Re-parent the fields, which before this had aTemplate as parent
m_Parent = aComponent.m_Parent;
m_Pos = aComponent.m_Pos;
m_unit = aComponent.m_unit;
m_convert = aComponent.m_convert;
m_ChipName = aComponent.m_ChipName;
m_TimeStamp = aComponent.m_TimeStamp;
m_transform = aComponent.m_transform;
m_prefix = aComponent.m_prefix;
m_PathsAndReferences = aComponent.m_PathsAndReferences;
m_Fields = aComponent.m_Fields;
// Re-parent the fields, which before this had aComponent as parent
for( int i = 0; i<GetFieldCount(); ++i )
{
GetField( i )->SetParent( this );
......@@ -180,6 +181,12 @@ void SCH_COMPONENT::Init( const wxPoint& pos )
}
EDA_ITEM* SCH_COMPONENT::doClone() const
{
return new SCH_COMPONENT( *this );
}
void SCH_COMPONENT::SetLibName( const wxString& aName )
{
if( m_ChipName != aName )
......@@ -273,18 +280,18 @@ void SCH_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offs
{
EDA_Rect BoundaryBox;
BoundaryBox = GetBoundingBox();
GRRect( &panel->m_ClipBox, DC, BoundaryBox, BROWN );
GRRect( &panel->m_ClipBox, DC, BoundaryBox, 0, BROWN );
#if 1
if( GetField( REFERENCE )->IsVisible() )
{
BoundaryBox = GetField( REFERENCE )->GetBoundingBox();
GRRect( &panel->m_ClipBox, DC, BoundaryBox, BROWN );
GRRect( &panel->m_ClipBox, DC, BoundaryBox, 0, BROWN );
}
if( GetField( VALUE )->IsVisible() )
{
BoundaryBox = GetField( VALUE )->GetBoundingBox();
GRRect( &panel->m_ClipBox, DC, BoundaryBox, BROWN );
GRRect( &panel->m_ClipBox, DC, BoundaryBox, 0, BROWN );
}
#endif
}
......@@ -1367,6 +1374,7 @@ EDA_Rect SCH_COMPONENT::GetBodyBoundingBox() const
// H and W must be > 0:
if( x2 < x1 )
EXCHG( x2, x1 );
if( y2 < y1 )
EXCHG( y2, y1 );
......@@ -1649,7 +1657,7 @@ LIB_DRAW_ITEM* SCH_COMPONENT::GetDrawItem( const wxPoint& aPosition, KICAD_T aTy
}
bool SCH_COMPONENT::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const
bool SCH_COMPONENT::doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const
{
EDA_Rect bBox;
......@@ -1682,7 +1690,7 @@ bool SCH_COMPONENT::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_
}
bool SCH_COMPONENT::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const
bool SCH_COMPONENT::doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const
{
EDA_Rect rect = aRect;
......@@ -1695,7 +1703,7 @@ bool SCH_COMPONENT::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccu
}
bool SCH_COMPONENT::DoIsConnected( const wxPoint& aPosition ) const
bool SCH_COMPONENT::doIsConnected( const wxPoint& aPosition ) const
{
vector< wxPoint > pts;
......
......@@ -60,14 +60,11 @@ class SCH_COMPONENT : public SCH_ITEM
TRANSFORM m_transform; ///< The rotation/mirror transformation matrix.
SCH_FIELDS m_Fields; ///< Variable length list of fields.
/* Hierarchical references.
* format is
* path reference multi
* with:
* path = /<timestamp1>/<timestamp2> (subsheet path, = / for the root sheet)
* reference = reference for this path (C23, R5, U78 ... )
* multi = part selection in multi parts per package (0 or 1 for one part
* per package)
/**
* Defines the hierarchical path and reference of the component. This allowa support
* for hierarchical sheets that reference the same schematic. The foramt for the path
* is /&ltsheet time stamp&gt/&ltsheet time stamp&gt/... A single / denotes the root
* sheet.
*/
wxArrayString m_PathsAndReferences;
......@@ -103,12 +100,12 @@ public:
/**
* Copy Constructor
* clones \a aTemplate into this object. All fields are copied as is except
* clones \a aComponent into a new object. All fields are copied as is except
* for the linked list management pointers which are set to NULL, and the
* SCH_FIELD's m_Parent pointers which are set to the new parent,
* i.e. this new object.
*/
SCH_COMPONENT( const SCH_COMPONENT& aTemplate );
SCH_COMPONENT( const SCH_COMPONENT& aComponent );
~SCH_COMPONENT() { }
......@@ -152,16 +149,6 @@ public:
*/
virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg );
/**
* Function GenCopy
* returns a copy of this object but with the linked list pointers set to NULL.
* @return SCH_COMPONENT* - a copy of me.
*/
SCH_COMPONENT* GenCopy() const
{
return new SCH_COMPONENT( *this );
}
/**
* Function SetOrientation
* computes the new transform matrix based on \a aOrientation for the component which is
......@@ -260,7 +247,6 @@ public:
m_Fields = aFields; // vector copying, length is changed possibly
}
//-----</Fields>----------------------------------------------------------
/**
......@@ -409,9 +395,10 @@ public:
#endif
private:
virtual bool DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const;
virtual bool DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const;
virtual bool DoIsConnected( const wxPoint& aPosition ) const;
virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const;
virtual bool doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const;
virtual bool doIsConnected( const wxPoint& aPosition ) const;
virtual EDA_ITEM* doClone() const;
};
......
......@@ -29,8 +29,7 @@
#include "template_fieldnames.h"
SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId,
SCH_COMPONENT* aParent, wxString aName ) :
SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent, wxString aName ) :
SCH_ITEM( aParent, SCH_FIELD_T ),
EDA_TextStruct()
{
......@@ -44,15 +43,27 @@ SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId,
}
SCH_FIELD::SCH_FIELD( const SCH_FIELD& aField ) :
SCH_ITEM( aField ),
EDA_TextStruct( aField )
{
m_FieldId = aField.m_FieldId;
m_Name = aField.m_Name;
m_AddExtraText = aField.m_AddExtraText;
}
SCH_FIELD::~SCH_FIELD()
{
}
/**
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
EDA_ITEM* SCH_FIELD::doClone() const
{
return new SCH_FIELD( *this );
}
int SCH_FIELD::GetPenSize() const
{
int pensize = m_Thickness;
......@@ -71,9 +82,6 @@ int SCH_FIELD::GetPenSize() const
}
/**
* Draw schematic component fields.
*/
void SCH_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int DrawMode, int Color )
{
......@@ -103,6 +111,7 @@ void SCH_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
/* Calculate the text orientation, according to the component
* orientation/mirror */
orient = m_Orient;
if( parentComponent->GetTransform().y1 ) // Rotate component 90 degrees.
{
if( orient == TEXT_ORIENT_HORIZ )
......@@ -136,9 +145,7 @@ void SCH_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
if( !m_AddExtraText || ( m_FieldId != REFERENCE ) )
{
DrawGraphicText( panel, DC, textpos, color, m_Text,
orient,
m_Size, hjustify, vjustify,
DrawGraphicText( panel, DC, textpos, color, m_Text, orient, m_Size, hjustify, vjustify,
LineWidth, m_Italic, m_Bold );
}
else
......@@ -148,9 +155,7 @@ void SCH_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
wxString fulltext = m_Text;
fulltext << LIB_COMPONENT::ReturnSubReference( parentComponent->GetUnit() );
DrawGraphicText( panel, DC, textpos, color, fulltext,
orient,
m_Size, hjustify, vjustify,
DrawGraphicText( panel, DC, textpos, color, fulltext, orient, m_Size, hjustify, vjustify,
LineWidth, m_Italic, m_Bold );
}
......@@ -182,13 +187,6 @@ void SCH_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
}
/**
* Function ImportValues
* copy parameters from a source.
* Pointers and specific values (position, texts) are not copied
* used to init a field from the model read from a lib entry
* @param aSource = the LIB_FIELD to read
*/
void SCH_FIELD::ImportValues( const LIB_FIELD& aSource )
{
m_Orient = aSource.m_Orient;
......@@ -197,38 +195,29 @@ void SCH_FIELD::ImportValues( const LIB_FIELD& aSource )
m_VJustify = aSource.m_VJustify;
m_Italic = aSource.m_Italic;
m_Bold = aSource.m_Bold;
m_Thickness = aSource.m_Thickness;
m_Thickness = aSource.m_Thickness;
m_Attributs = aSource.m_Attributs;
m_Mirror = aSource.m_Mirror;
}
/**
* Used if undo / redo command:
* swap data between this and copyitem
*/
void SCH_FIELD::SwapData( SCH_FIELD* copyitem )
void SCH_FIELD::SwapData( SCH_FIELD* aField )
{
EXCHG( m_Text, copyitem->m_Text );
EXCHG( m_Layer, copyitem->m_Layer );
EXCHG( m_Pos, copyitem->m_Pos );
EXCHG( m_Size, copyitem->m_Size );
EXCHG( m_Thickness, copyitem->m_Thickness );
EXCHG( m_Orient, copyitem->m_Orient );
EXCHG( m_Mirror, copyitem->m_Mirror );
EXCHG( m_Attributs, copyitem->m_Attributs );
EXCHG( m_Italic, copyitem->m_Italic );
EXCHG( m_Bold, copyitem->m_Bold );
EXCHG( m_HJustify, copyitem->m_HJustify );
EXCHG( m_VJustify, copyitem->m_VJustify );
EXCHG( m_Text, aField->m_Text );
EXCHG( m_Layer, aField->m_Layer );
EXCHG( m_Pos, aField->m_Pos );
EXCHG( m_Size, aField->m_Size );
EXCHG( m_Thickness, aField->m_Thickness );
EXCHG( m_Orient, aField->m_Orient );
EXCHG( m_Mirror, aField->m_Mirror );
EXCHG( m_Attributs, aField->m_Attributs );
EXCHG( m_Italic, aField->m_Italic );
EXCHG( m_Bold, aField->m_Bold );
EXCHG( m_HJustify, aField->m_HJustify );
EXCHG( m_VJustify, aField->m_VJustify );
}
/**
* Function GetBoundaryBox
* @return an EDA_Rect contains the real (user coordinates) boundary box for a text field.
* according to the component position, rotation, mirror ...
*/
EDA_Rect SCH_FIELD::GetBoundingBox() const
{
EDA_Rect BoundaryBox;
......@@ -459,7 +448,7 @@ void SCH_FIELD::Rotate( wxPoint rotationPoint )
}
bool SCH_FIELD::DoHitTest( const wxPoint& aPoint, int aAccuracy ) const
bool SCH_FIELD::doHitTest( const wxPoint& aPoint, int aAccuracy ) const
{
// Do not hit test hidden fields.
if( !IsVisible() )
......@@ -473,7 +462,7 @@ bool SCH_FIELD::DoHitTest( const wxPoint& aPoint, int aAccuracy ) const
}
bool SCH_FIELD::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const
bool SCH_FIELD::doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const
{
// Do not hit test hidden fields.
if( !IsVisible() )
......
......@@ -5,14 +5,6 @@
#ifndef CLASS_SCH_FIELD_H
#define CLASS_SCH_FIELD_H
/* Fields are texts attached to a component, having a special meaning
* Fields 0 and 1 are very important: reference and value
* Field 2 is used as default footprint name.
* Field 3 is reserved (not currently used
* Fields 4 and more are user fields.
* They can be renamed and can appear in reports
*/
#include "sch_item_struct.h"
#include "general.h"
......@@ -25,11 +17,16 @@ class LIB_FIELD;
/**
* Class SCH_FIELD
* instances are attached to a component and provide a place for the
* component's value,
* reference designator, footprint, and user definable name-value pairs of
* arbitrary purpose.
* instances are attached to a component and provide a place for the component's value,
* reference designator, footprint, and user definable name-value pairs of arbitrary purpose.
*
* <ul> <li>Field 0 is reserved for the component reference.</li>
* <li>Field 1 is reserved for the component value.</li>
* <li>Field 2 is reserved for the component footprint.</li>
* <li>Field 3 is reserved for the component data sheet file.</li>
* <li>Fields 4 and higher are user defineable.</li></ul>
*/
class SCH_FIELD : public SCH_ITEM, public EDA_TextStruct
{
public:
......@@ -44,6 +41,8 @@ public:
SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent,
wxString aName = wxEmptyString );
SCH_FIELD( const SCH_FIELD& aField );
~SCH_FIELD();
virtual wxString GetClass() const
......@@ -66,8 +65,13 @@ public:
return len == 0 || ( len == 1 && m_Text[0] == wxChar( '~' ) );
}
void SwapData( SCH_FIELD* copyitem );
/**
* Function SwapData
* exchanges the date between the field and \a aField.
*
* @param aField The field to exchange data with.
*/
void SwapData( SCH_FIELD* aField );
/**
* Function ImportValues
......@@ -160,8 +164,9 @@ public:
void* aAuxData, wxPoint * aFindLocation );
private:
virtual bool DoHitTest( const wxPoint& aPoint, int aAccuracy ) const;
virtual bool DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const;
virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy ) const;
virtual bool doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const;
virtual EDA_ITEM* doClone() const;
};
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/**
* @file sch_line.h
*
*/
#ifndef _SCH_LINE_H_
#define _SCH_LINE_H_
#include "sch_item_struct.h"
/**
* Class SCH_LINE
* is a segment description base class to describe items which have 2 end
* points (track, wire, draw line ...)
*/
class SCH_LINE : public SCH_ITEM
{
bool m_StartIsDangling;
bool m_EndIsDangling; // TRUE if not connected (wires, tracks...)
public:
int m_Width; // 0 = line, > 0 = tracks, bus ...
wxPoint m_Start; // Line start point
wxPoint m_End; // Line end point
public:
SCH_LINE( const wxPoint& pos = wxPoint( 0, 0 ), int layer = LAYER_NOTES );
SCH_LINE( const SCH_LINE& aLine );
~SCH_LINE() { }
SCH_LINE* Next() const { return (SCH_LINE*) Pnext; }
SCH_LINE* Back() const { return (SCH_LINE*) Pback; }
virtual wxString GetClass() const
{
return wxT( "SCH_LINE" );
}
bool IsEndPoint( const wxPoint& aPoint ) const
{
return aPoint == m_Start || aPoint == m_End;
}
bool IsNull() const { return m_Start == m_End; }
/**
* Function GetBoundingBox
* returns the orthogonal, bounding box of this object for display purposes.
* This box should be an enclosing perimeter for visible components of this
* object, and the units should be in the pcb or schematic coordinate system.
* It is OK to overestimate the size by a few counts.
*/
EDA_Rect GetBoundingBox() const;
virtual void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset,
int aDrawMode, int aColor = -1 );
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.sch" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
/**
* Load schematic line from \a aLine in a .sch file.
*
* @param aLine - Essentially this is file to read schematic line from.
* @param aErrorMsg - Description of the error if an error occurs while loading the
* schematic line.
* @return True if the schematic line loaded successfully.
*/
virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg );
/**
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
virtual int GetPenSize() const;
/**
* Function Move
* moves the item by \a aMoveVector.
* @param aMoveVector The displacement vector
*/
virtual void Move( const wxPoint& aMoveVector );
virtual void Mirror_X( int aXaxis_position );
/**
* Function Mirror_Y
* mirrors the item relative to \a aYaxis_position.
* @param aYaxis_position = the y axis position
*/
virtual void Mirror_Y( int aYaxis_position );
virtual void Rotate( wxPoint rotationPoint );
/**
* Check line against \a aLine to see if it overlaps and merge if it does.
*
* This method will change the line to be equivalent of the line and \a aLine if the
* two lines overlap. This method is used to merge multple line segments into a single
* line.
*
* @param aLine - Line to compare.
* @return True if lines overlap and the line was merged with \a aLine.
*/
bool MergeOverlap( SCH_LINE* aLine );
virtual void GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList );
virtual bool IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList );
virtual bool IsDangling() const { return m_StartIsDangling || m_EndIsDangling; }
virtual bool IsSelectStateChanged( const wxRect& aRect );
virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const;
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const;
#endif
private:
virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const;
virtual bool doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const;
virtual bool doIsConnected( const wxPoint& aPosition ) const;
virtual EDA_ITEM* doClone() const;
};
#endif // _SCH_LINE_H_
......@@ -44,19 +44,21 @@ SCH_MARKER::SCH_MARKER( const wxPoint& pos, const wxString& text ) :
}
SCH_MARKER::~SCH_MARKER()
SCH_MARKER::SCH_MARKER( const SCH_MARKER& aMarker ) :
SCH_ITEM( aMarker ),
MARKER_BASE( aMarker )
{
}
SCH_MARKER* SCH_MARKER::GenCopy()
SCH_MARKER::~SCH_MARKER()
{
SCH_MARKER* newitem = new SCH_MARKER( GetPos(), GetReporter().GetMainText() );
}
newitem->SetMarkerType( GetMarkerType() );
newitem->SetErrorLevel( GetErrorLevel() );
return newitem;
EDA_ITEM* SCH_MARKER::doClone() const
{
return new SCH_MARKER( *this );
}
......@@ -76,7 +78,6 @@ void SCH_MARKER::Show( int nestLevel, std::ostream& os )
<< GetPos() << "/>\n";
}
#endif
/**
......@@ -194,7 +195,7 @@ bool SCH_MARKER::IsSelectStateChanged( const wxRect& aRect )
}
bool SCH_MARKER::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const
bool SCH_MARKER::doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const
{
if( !( aFilter & MARKER_T ) )
return false;
......
......@@ -30,6 +30,7 @@ class SCH_MARKER : public SCH_ITEM, public MARKER_BASE
public:
SCH_MARKER();
SCH_MARKER( const wxPoint& aPos, const wxString& aText );
SCH_MARKER( const SCH_MARKER& aMarker );
~SCH_MARKER();
virtual wxString GetClass() const
......@@ -37,11 +38,8 @@ public:
return wxT( "SCH_MARKER" );
}
SCH_MARKER* GenCopy();
virtual void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
const wxPoint& aOffset, int aDraw_mode,
int aColor = -1 );
virtual void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset,
int aDraw_mode, int aColor = -1 );
/**
* Function Save
......@@ -104,7 +102,8 @@ public:
#endif
virtual bool DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const;
virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const;
virtual EDA_ITEM* doClone() const;
};
#endif /* _TYPE_SCH_MARKER_H_ */
/************************/
/* Class SCH_NO_CONNECT */
/************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "macros.h"
#include "class_drawpanel.h"
#include "common.h"
#include "trigo.h"
#include "richio.h"
#include "general.h"
#include "protos.h"
#include "sch_no_connect.h"
SCH_NO_CONNECT::SCH_NO_CONNECT( const wxPoint& pos ) :
SCH_ITEM( NULL, SCH_NO_CONNECT_T )
{
#define DRAWNOCONNECT_SIZE 48 /* No symbol connection range. */
m_Pos = pos;
m_Size.x = m_Size.y = DRAWNOCONNECT_SIZE;
#undef DRAWNOCONNECT_SIZE
}
SCH_NO_CONNECT::SCH_NO_CONNECT( const SCH_NO_CONNECT& aNoConnect ) :
SCH_ITEM( aNoConnect )
{
m_Pos = aNoConnect.m_Pos;
m_Size = aNoConnect.m_Size;
}
EDA_ITEM* SCH_NO_CONNECT::doClone() const
{
return new SCH_NO_CONNECT( *this );
}
EDA_Rect SCH_NO_CONNECT::GetBoundingBox() const
{
int delta = ( GetPenSize() + m_Size.x ) / 2;
EDA_Rect box;
box.SetOrigin( m_Pos );
box.Inflate( delta );
return box;
}
bool SCH_NO_CONNECT::Save( FILE* aFile ) const
{
bool success = true;
if( fprintf( aFile, "NoConn ~ %-4d %-4d\n", m_Pos.x, m_Pos.y ) == EOF )
{
success = false;
}
return success;
}
bool SCH_NO_CONNECT::Load( LINE_READER& aLine, wxString& aErrorMsg )
{
char name[256];
char* line = (char*) aLine;
while( (*line != ' ' ) && *line )
line++;
if( sscanf( line, "%s %d %d", name, &m_Pos.x, &m_Pos.y ) != 3 )
{
aErrorMsg.Printf( wxT( "EESchema file No Connect load error at line %d" ),
aLine.LineNumber() );
aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( ((char*)aLine) );
return false;
}
return true;
}
int SCH_NO_CONNECT::GetPenSize() const
{
return g_DrawDefaultLineThickness;
}
void SCH_NO_CONNECT::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset,
int aDrawMode, int aColor )
{
int pX, pY, color;
int delta = m_Size.x / 2;
int width = g_DrawDefaultLineThickness;
pX = m_Pos.x + aOffset.x;
pY = m_Pos.y + aOffset.y;
if( aColor >= 0 )
color = aColor;
else
color = ReturnLayerColor( LAYER_NOCONNECT );
GRSetDrawMode( aDC, aDrawMode );
GRLine( &aPanel->m_ClipBox, aDC, pX - delta, pY - delta, pX + delta, pY + delta, width, color );
GRLine( &aPanel->m_ClipBox, aDC, pX + delta, pY - delta, pX - delta, pY + delta, width, color );
}
void SCH_NO_CONNECT::Mirror_X( int aXaxis_position )
{
m_Pos.y -= aXaxis_position;
NEGATE( m_Pos.y );
m_Pos.y += aXaxis_position;
}
void SCH_NO_CONNECT::Mirror_Y( int aYaxis_position )
{
m_Pos.x -= aYaxis_position;
NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position;
}
void SCH_NO_CONNECT::Rotate( wxPoint rotationPoint )
{
RotatePoint( &m_Pos, rotationPoint, 900 );
}
bool SCH_NO_CONNECT::IsSelectStateChanged( const wxRect& aRect )
{
bool previousState = IsSelected();
if( aRect.Contains( m_Pos ) )
m_Flags |= SELECTED;
else
m_Flags &= ~SELECTED;
return previousState != IsSelected();
}
void SCH_NO_CONNECT::GetConnectionPoints( vector< wxPoint >& aPoints ) const
{
aPoints.push_back( m_Pos );
}
bool SCH_NO_CONNECT::doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const
{
if( !( aFilter & NO_CONNECT_T ) )
return false;
int delta = ( ( m_Size.x + g_DrawDefaultLineThickness ) / 2 ) + aAccuracy;
wxPoint dist = aPoint - m_Pos;
if( ( ABS( dist.x ) <= delta ) && ( ABS( dist.y ) <= delta ) )
return true;
return false;
}
bool SCH_NO_CONNECT::doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const
{
EDA_Rect rect = aRect;
rect.Inflate( aAccuracy );
if( aContained )
return rect.Contains( GetBoundingBox() );
return rect.Intersects( GetBoundingBox() );
}
/**
* @file sch_no_connect.h
*
*/
#ifndef _SCH_NO_CONNECT_H_
#define _SCH_NO_CONNECT_H_
#include "sch_item_struct.h"
class SCH_NO_CONNECT : public SCH_ITEM
{
public:
wxPoint m_Pos; /* XY coordinates of NoConnect. */
wxSize m_Size; // size of this symbol
public:
SCH_NO_CONNECT( const wxPoint& pos = wxPoint( 0, 0 ) );
SCH_NO_CONNECT( const SCH_NO_CONNECT& aNoConnect );
~SCH_NO_CONNECT() { }
virtual wxString GetClass() const
{
return wxT( "SCH_NO_CONNECT" );
}
/**
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
virtual int GetPenSize() const;
virtual void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset,
int aDrawMode, int aColor = -1 );
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.sch"
* format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
/**
* Load schematic no connect entry from \a aLine in a .sch file.
*
* @param aLine - Essentially this is file to read schematic no connect from.
* @param aErrorMsg - Description of the error if an error occurs while loading the
* schematic no connect.
* @return True if the schematic no connect loaded successfully.
*/
virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg );
/**
* Function GetBoundingBox
* returns the orthogonal, bounding box of this object for display
* purposes. This box should be an enclosing perimeter for visible
* components of this object, and the units should be in the pcb or
* schematic coordinate system. It is OK to overestimate the size
* by a few counts.
*/
EDA_Rect GetBoundingBox() const;
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the displacement vector
*/
virtual void Move( const wxPoint& aMoveVector )
{
m_Pos += aMoveVector;
}
/**
* Function Mirror_Y
* mirrors item relative to \a aYaxis_position.
* @param aYaxis_position = the y axis position
*/
virtual void Mirror_Y( int aYaxis_position );
virtual void Mirror_X( int aXaxis_position );
virtual void Rotate( wxPoint rotationPoint );
virtual bool IsSelectStateChanged( const wxRect& aRect );
virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const;
private:
virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const;
virtual bool doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const;
virtual EDA_ITEM* doClone() const;
};
#endif // _SCH_NO_CONNECT_H_
/**********************/
/* Class SCH_POLYLINE */
/**********************/
#include "fctsys.h"
#include "gr_basic.h"
#include "macros.h"
#include "class_drawpanel.h"
#include "trigo.h"
#include "common.h"
#include "richio.h"
#include "general.h"
#include "protos.h"
#include "sch_polyline.h"
SCH_POLYLINE::SCH_POLYLINE( int layer ) :
SCH_ITEM( NULL, SCH_POLYLINE_T )
{
m_Width = 0;
switch( layer )
{
default:
m_Layer = LAYER_NOTES;
break;
case LAYER_WIRE:
case LAYER_NOTES:
case LAYER_BUS:
m_Layer = layer;
break;
}
}
SCH_POLYLINE::SCH_POLYLINE( const SCH_POLYLINE& aPolyLine ) :
SCH_ITEM( aPolyLine )
{
m_Width = aPolyLine.m_Width;
m_PolyPoints = aPolyLine.m_PolyPoints;
}
SCH_POLYLINE::~SCH_POLYLINE()
{
}
EDA_ITEM* SCH_POLYLINE::doClone() const
{
return new SCH_POLYLINE( *this );
}
bool SCH_POLYLINE::Save( FILE* aFile ) const
{
bool success = true;
const char* layer = "Notes";
const char* width = "Line";
if( GetLayer() == LAYER_WIRE )
layer = "Wire";
if( GetLayer() == LAYER_BUS )
layer = "Bus";
if( fprintf( aFile, "Poly %s %s %d\n", width, layer, GetCornerCount() ) == EOF )
{
return false;
}
for( unsigned ii = 0; ii < GetCornerCount(); ii++ )
{
if( fprintf( aFile, "\t%-4d %-4d\n", m_PolyPoints[ii ].x, m_PolyPoints[ii].y ) == EOF )
{
success = false;
break;
}
}
return success;
}
bool SCH_POLYLINE::Load( LINE_READER& aLine, wxString& aErrorMsg )
{
char Name1[256];
char Name2[256];
wxPoint pt;
int ii;
char* line = (char*) aLine;
while( (*line != ' ' ) && *line )
line++;
if( sscanf( line, "%s %s %d", Name1, Name2, &ii ) != 3 )
{
aErrorMsg.Printf( wxT( "EESchema file polyline struct error at line %d, aborted" ),
aLine.LineNumber() );
aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( (char*) aLine );
return false;
}
m_Layer = LAYER_NOTES;
if( Name2[0] == 'W' )
m_Layer = LAYER_WIRE;
if( Name2[0] == 'B' )
m_Layer = LAYER_BUS;
for( unsigned jj = 0; jj < (unsigned)ii; jj++ )
{
wxPoint point;
if( !aLine.ReadLine() || sscanf( ((char*) aLine), "%d %d", &pt.x, &pt.y ) != 2 )
{
aErrorMsg.Printf( wxT( "EESchema file polyline struct error at line %d, aborted" ),
aLine.LineNumber() );
aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( (char*) aLine );
return false;
}
AddPoint( pt );
}
return true;
}
int SCH_POLYLINE::GetPenSize() const
{
int pensize = ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width;
return pensize;
}
void SCH_POLYLINE::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset,
int aDrawMode, int aColor )
{
int color;
int width = GetPenSize();
if( aColor >= 0 )
color = aColor;
else
color = ReturnLayerColor( m_Layer );
GRSetDrawMode( aDC, aDrawMode );
if( m_Layer == LAYER_BUS )
{
width *= 3;
}
GRMoveTo( m_PolyPoints[0].x, m_PolyPoints[0].y );
if( m_Layer == LAYER_NOTES )
{
for( unsigned i = 1; i < GetCornerCount(); i++ )
GRDashedLineTo( &aPanel->m_ClipBox, aDC, m_PolyPoints[i].x + aOffset.x,
m_PolyPoints[i].y + aOffset.y, width, color );
}
else
{
for( unsigned i = 1; i < GetCornerCount(); i++ )
GRLineTo( &aPanel->m_ClipBox, aDC, m_PolyPoints[i].x + aOffset.x,
m_PolyPoints[i].y + aOffset.y, width, color );
}
}
void SCH_POLYLINE::Mirror_X( int aXaxis_position )
{
for( unsigned ii = 0; ii < GetCornerCount(); ii++ )
{
m_PolyPoints[ii].y -= aXaxis_position;
NEGATE( m_PolyPoints[ii].y );
m_PolyPoints[ii].y = aXaxis_position;
}
}
void SCH_POLYLINE::Mirror_Y( int aYaxis_position )
{
for( unsigned ii = 0; ii < GetCornerCount(); ii++ )
{
m_PolyPoints[ii].x -= aYaxis_position;
NEGATE( m_PolyPoints[ii].x );
m_PolyPoints[ii].x = aYaxis_position;
}
}
void SCH_POLYLINE::Rotate( wxPoint rotationPoint )
{
for( unsigned ii = 0; ii < GetCornerCount(); ii++ )
{
RotatePoint( &m_PolyPoints[ii], rotationPoint, 900 );
}
}
bool SCH_POLYLINE::doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const
{
if( !( aFilter & ( DRAW_ITEM_T | WIRE_T | BUS_T ) ) )
return false;
for( size_t i = 0; i < m_PolyPoints.size() - 1; i++ )
{
if( TestSegmentHit( aPoint, m_PolyPoints[i], m_PolyPoints[i + 1], aAccuracy ) )
return true;
}
return false;
}
bool SCH_POLYLINE::doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const
{
EDA_Rect rect = aRect;
rect.Inflate( aAccuracy );
if( aContained )
return rect.Contains( GetBoundingBox() );
return rect.Intersects( GetBoundingBox() );
}
/**
* @file sch_polyline.h
*
*/
#ifndef _SCH_POLYLINE_H_
#define _SCH_POLYLINE_H_
#include "sch_item_struct.h"
class SCH_POLYLINE : public SCH_ITEM
{
public:
int m_Width; /* Thickness */
std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
public:
SCH_POLYLINE( int layer = LAYER_NOTES );
SCH_POLYLINE( const SCH_POLYLINE& aPolyLine );
~SCH_POLYLINE();
virtual wxString GetClass() const
{
return wxT( "SCH_POLYLINE" );
}
virtual void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset,
int aDrawMode, int aColor = -1 );
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.sch"
* format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
/**
* Load schematic poly line entry from \a aLine in a .sch file.
*
* @param aLine - Essentially this is file to read schematic poly line from.
* @param aErrorMsg - Description of the error if an error occurs while loading the
* schematic poly line.
* @return True if the schematic poly line loaded successfully.
*/
virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg );
/**
* Function AddPoint
* add a corner to m_PolyPoints
*/
void AddPoint( const wxPoint& point )
{
m_PolyPoints.push_back( point );
}
/**
* Function GetCornerCount
* @return the number of corners
*/
unsigned GetCornerCount() const { return m_PolyPoints.size(); }
/**
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
virtual int GetPenSize() const;
/**
* Function Move
* moves an item to a new position by \a aMoveVector.
* @param aMoveVector = the displacement vector
*/
virtual void Move( const wxPoint& aMoveVector )
{
for( unsigned ii = 0; ii < GetCornerCount(); ii++ )
m_PolyPoints[ii] += aMoveVector;
}
/**
* Function Mirror_Y
* mirrors an item relative to \a aYaxis_position.
* @param aYaxis_position The y axis position to mirror around.
*/
virtual void Mirror_Y( int aYaxis_position );
virtual void Mirror_X( int aXaxis_position );
virtual void Rotate( wxPoint rotationPoint );
private:
virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const;
virtual bool doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const;
virtual EDA_ITEM* doClone() const;
};
#endif // _SCH_POLYLINE_H_
......@@ -14,6 +14,7 @@
#include "protos.h"
#include "class_library.h"
#include "sch_items.h"
#include "sch_line.h"
#include "sch_sheet.h"
#include "sch_component.h"
......@@ -203,11 +204,7 @@ SCH_ITEM* SCH_SCREEN::ExtractWires( bool CreateCopy )
if( CreateCopy )
{
if( item->Type() == SCH_JUNCTION_T )
new_item = ( (SCH_JUNCTION*) item )->GenCopy();
else
new_item = ( (SCH_LINE*) item )->GenCopy();
new_item = item->Clone();
new_item->SetNext( GetDrawItems() );
SetDrawItems( new_item );
}
......
This diff is collapsed.
......@@ -47,11 +47,15 @@ private:
* orientation.
*/
virtual EDA_ITEM* doClone() const;
public:
SCH_SHEET_PIN( SCH_SHEET* parent,
const wxPoint& pos = wxPoint( 0, 0 ),
const wxString& text = wxEmptyString );
SCH_SHEET_PIN( const SCH_SHEET_PIN& aSheetLabel );
~SCH_SHEET_PIN() { }
virtual wxString GetClass() const
......@@ -59,10 +63,7 @@ public:
return wxT( "SCH_SHEET_PIN" );
}
bool operator ==( const SCH_SHEET_PIN* aPin ) const;
SCH_SHEET_PIN* GenCopy();
bool operator ==( const SCH_SHEET_PIN* aPin ) const;
virtual void Draw( WinEDA_DrawPanel* aPanel,
wxDC* aDC,
......@@ -101,6 +102,12 @@ public:
void SetNumber( int aNumber );
void SetEdge( int aEdge );
int GetEdge();
/**
* Function ConstraintOnEdge
* is used to adjust label position to egde based on proximity to vertical / horizontal edge
* of the parent sheet.
*/
void ConstraintOnEdge( wxPoint Pos );
/**
......@@ -223,6 +230,9 @@ public:
public:
SCH_SHEET( const wxPoint& pos = wxPoint( 0, 0 ) );
SCH_SHEET( const SCH_SHEET& aSheet );
~SCH_SHEET();
virtual wxString GetClass() const
......@@ -250,8 +260,6 @@ public:
void Place( SCH_EDIT_FRAME* frame, wxDC* DC );
SCH_SHEET* GenCopy();
void DisplayInfo( WinEDA_DrawFrame* frame );
/* there is no member for orientation in sch_sheet, to preserve file
......@@ -513,8 +521,9 @@ protected:
void renumberLabels();
private:
virtual bool DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const;
virtual bool DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const;
virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const;
virtual bool doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const;
virtual EDA_ITEM* doClone() const;
};
#endif /* CLASS_DRAWSHEET_H */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -17,9 +17,11 @@
#include "eeschema_id.h"
#include "protos.h"
#include "class_library.h"
#include "sch_bus_entry.h"
#include "sch_marker.h"
#include "sch_component.h"
#include "sch_items.h"
#include "sch_line.h"
#include "sch_sheet.h"
......
......@@ -10,9 +10,13 @@
#include "general.h"
#include "protos.h"
#include "sch_bus_entry.h"
#include "sch_marker.h"
#include "sch_items.h"
#include "sch_line.h"
#include "sch_no_connect.h"
#include "sch_component.h"
#include "sch_polyline.h"
#include "sch_sheet.h"
......
......@@ -124,7 +124,7 @@ WinEDA_ConfigFrame::WinEDA_ConfigFrame( WinEDA_GerberFrame* parent,
}
void WinEDA_ConfigFrame::OnOkClick( wxCommandEvent &event )
void WinEDA_ConfigFrame::OnOkClick( wxCommandEvent& event )
{
g_DrillFilenameExt = TextDrillExt->GetValue();
g_PhotoFilenameExt = TextPhotoExt->GetValue();
......@@ -134,7 +134,7 @@ void WinEDA_ConfigFrame::OnOkClick( wxCommandEvent &event )
}
void WinEDA_ConfigFrame::OnCancelClick( wxCommandEvent &event )
void WinEDA_ConfigFrame::OnCancelClick( wxCommandEvent& event )
{
EndModal( -1 );
}
......
This diff is collapsed.
......@@ -14,22 +14,11 @@
#include "block_commande.h"
#include "common.h"
#include <boost/ptr_container/ptr_vector.hpp>
// Forward declarations:
class Ki_PageDescr;
/**
* Define list of drawing items for screens.
*
* The Boost containter was choosen over the statand C++ contain because you can detach
* the pointer from a list with the release method.
*/
typedef boost::ptr_vector< EDA_ITEM > EDA_ITEMS;
/* Simple class for handling grid arrays. */
class GRID_TYPE
{
......
This diff is collapsed.
This diff is collapsed.
......@@ -139,7 +139,7 @@ public:
~WinEDA_PcbFrame();
void OnQuit( wxCommandEvent & WXUNUSED(event) );
void OnQuit( wxCommandEvent& event );
/**
* Function ToPlotter
......
/**
* @file pcbnew/dialog_display_options.h
* @file pcbnew/dialogs/dialog_display_options.h
*/
#include "dialog_display_options_base.h"
......
......@@ -129,7 +129,7 @@ void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties()
}
void DIALOG_MODULE_BOARD_EDITOR::OnCancelClick( wxCommandEvent& WXUNUSED( event ) )
void DIALOG_MODULE_BOARD_EDITOR::OnCancelClick( wxCommandEvent& event )
{
EndModal( -1 );
}
......
......@@ -307,7 +307,7 @@ void DIALOG_MODULE_MODULE_EDITOR::BrowseAndAdd3DLib( wxCommandEvent& event )
/**********************************************************************/
void DIALOG_MODULE_MODULE_EDITOR::OnCancelClick( wxCommandEvent& WXUNUSED (event) )
void DIALOG_MODULE_MODULE_EDITOR::OnCancelClick( wxCommandEvent& event )
/**********************************************************************/
{
EndModal( -1 );
......
......@@ -139,7 +139,7 @@ DIMENSION_EDITOR_DIALOG::DIMENSION_EDITOR_DIALOG( WinEDA_PcbFrame* parent,
/**********************************************************************/
void DIMENSION_EDITOR_DIALOG::OnCancelClick( wxCommandEvent& WXUNUSED (event) )
void DIMENSION_EDITOR_DIALOG::OnCancelClick( wxCommandEvent& event )
/**********************************************************************/
{
EndModal( -1 );
......
......@@ -124,7 +124,7 @@ TARGET_PROPERTIES_DIALOG_EDITOR::TARGET_PROPERTIES_DIALOG_EDITOR(
}
void TARGET_PROPERTIES_DIALOG_EDITOR::OnCancelClick( wxCommandEvent& WXUNUSED( event ) )
void TARGET_PROPERTIES_DIALOG_EDITOR::OnCancelClick( wxCommandEvent& event )
{
EndModal( -1 );
}
......
......@@ -797,7 +797,7 @@ WinEDA_SetParamShapeFrame::WinEDA_SetParamShapeFrame( WinEDA_PcbFrame* parent,
}
void WinEDA_SetParamShapeFrame::OnCancelClick( wxCommandEvent& WXUNUSED(event) )
void WinEDA_SetParamShapeFrame::OnCancelClick( wxCommandEvent& event )
{
if( PolyEdges )
free( PolyEdges );
......
......@@ -414,7 +414,7 @@ void WinEDA_PcbFrame::ReFillLayerWidget()
}
void WinEDA_PcbFrame::OnQuit( wxCommandEvent & WXUNUSED(event) )
void WinEDA_PcbFrame::OnQuit( wxCommandEvent& event )
{
Close( true );
}
......
......@@ -303,7 +303,7 @@ void DIALOG_PLOT::Init_Dialog()
}
void DIALOG_PLOT::OnQuit( wxCommandEvent& WXUNUSED( event ) )
void DIALOG_PLOT::OnQuit( wxCommandEvent& event )
{
Close( true ); // true is to force the frame to close
}
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment