Schematic object improvements and other minor fixes.

This commit is contained in:
Wayne Stambaugh 2010-12-10 14:47:44 -05:00
parent f64b3a5188
commit adb4ad1a7b
100 changed files with 1445 additions and 1454 deletions

View File

@ -4,6 +4,26 @@ KiCad ChangeLog 2010
Please add newer entries at the top, list the date and your name with
email address.
2010-dec-10 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================
++All
* Make a whole bunch of object methods const in order to make HitTest() const.
* Lots of coding policy fixes.
++common
* Add Inside override to EDA_Rect to test if another EDA_Rect is inside.
* Add additional parameter to EDA_TextStruct GetTextBox method to support
Y axis inversion and non-default thickness.
* Add accuracy parameter to EDA_TextStruct TextHitTest method.
++EESchema
* Refactor schematic object hit testing to provide coherent object interface.
* Remove redundant GetBoundaryBox from schematic component object.
* Remove redundant layer member from schematic text object.
* Create hit test override to check for rectangle intersection and
containment.
* Simplify schematic block selection hit testing.
* Make schematic and component library object enum naming consistent.
2010-dec-08 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================
++All

View File

@ -9,7 +9,6 @@
#include "fctsys.h"
#include "common.h"
#include "base_struct.h"
#include "sch_item_struct.h"
#include "class_base_screen.h"
#include "id.h"

View File

@ -1,7 +1,7 @@
/****************************************/
/* Basic classes for Kicad: */
/* EDA_ITEM */
/* EDA_TextStruct */
/* Basic classes for Kicad: */
/* EDA_ITEM */
/* EDA_TextStruct */
/****************************************/
#include "fctsys.h"
@ -143,7 +143,7 @@ std::ostream& operator<<( std::ostream& out, const wxPoint& pt )
* of nesting of this object within the overall tree.
* @param os The ostream& to output to.
*/
void EDA_ITEM::Show( int nestLevel, std::ostream& os )
void EDA_ITEM::Show( int nestLevel, std::ostream& os ) const
{
// XML output:
wxString s = GetClass();
@ -211,67 +211,64 @@ int EDA_TextStruct::LenSize( const wxString& aLine ) const
}
/**
* Function GetTextBox
* useful in multiline texts to calculate the full text or a line area (for zones filling, locate functions....)
* @return the rect containing the line of text (i.e. the position and the size of one line)
* this rectangle is calculated for 0 orient text. if orient is not 0 the rect must be rotated to match the physical area
* @param aLine : the line of text to consider.
* for single line text, aLine is unused
* If aLine == -1, the full area (considering all lines) is returned
*/
EDA_Rect EDA_TextStruct::GetTextBox( int aLine )
EDA_Rect EDA_TextStruct::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
{
EDA_Rect rect;
wxPoint pos;
wxArrayString* list = NULL;
wxString* text = &m_Text;
wxString text = m_Text;
int thickness = ( aThickness < 0 ) ? m_Thickness : aThickness;
if( m_MultilineAllowed )
{
list = wxStringSplit( m_Text, '\n' );
if ( list->GetCount() ) // GetCount() == 0 for void strings
{
if( aLine >= 0 && (aLine < (int)list->GetCount()) )
text = &list->Item( aLine );
text = list->Item( aLine );
else
text = &list->Item( 0 );
text = list->Item( 0 );
}
}
// calculate the H and V size
int dx = LenSize( *text );
int dx = LenSize( text );
int dy = GetInterline();
/* Creates bounding box (rectangle) for an horizontal text */
wxSize textsize = wxSize( dx, dy );
rect.SetOrigin( m_Pos );
if( aInvertY )
rect.SetOrigin( m_Pos.x, -m_Pos.y );
else
rect.SetOrigin( m_Pos );
// extra dy interval for letters like j and y and ]
int extra_dy = dy - m_Size.y;
rect.Move(wxPoint(0, -extra_dy/2 ) ); // move origin by the half extra interval
rect.Move( wxPoint( 0, -extra_dy / 2 ) ); // move origin by the half extra interval
// for multiline texts and aLine < 0, merge all rectangles
if( m_MultilineAllowed && list && aLine < 0 )
{
for( unsigned ii = 1; ii < list->GetCount(); ii++ )
{
text = &list->Item( ii );
dx = LenSize( *text );
text = list->Item( ii );
dx = LenSize( text );
textsize.x = MAX( textsize.x, dx );
textsize.y += dy;
}
}
delete list;
rect.SetSize( textsize );
rect.Inflate( m_Thickness/2 ); // ensure a small margin
rect.Inflate( thickness / 2 ); // ensure a small margin
/* Now, calculate the rect origin, according to text justification
* At this point the rectangle origin is the text origin (m_Pos).
* This is true only for left and top text justified texts (using top to bottom Y axis orientation).
* and must be recalculated for others justifications
* This is true only for left and top text justified texts (using top to bottom Y axis
* orientation). and must be recalculated for others justifications
* also, note the V justification is relative to the first line
*/
switch( m_HJustify )
@ -288,7 +285,8 @@ EDA_Rect EDA_TextStruct::GetTextBox( int aLine )
break;
}
dy = m_Size.y + m_Thickness;
dy = m_Size.y + thickness;
switch( m_VJustify )
{
case GR_TEXT_VJUSTIFY_TOP:
@ -304,46 +302,36 @@ EDA_Rect EDA_TextStruct::GetTextBox( int aLine )
}
rect.Normalize(); // Make h and v sizes always >= 0
return rect;
}
/*************************************************/
bool EDA_TextStruct::TextHitTest( const wxPoint& posref )
/*************************************************/
/**
* Function TextHitTest (overlayed)
* tests if the given point is inside this object.
* @param posref point to test
* @return bool - true if a hit, else false
*/
bool EDA_TextStruct::TextHitTest( const wxPoint& aPoint, int aAccuracy ) const
{
EDA_Rect rect = GetTextBox( -1 ); // Get the full text area.
wxPoint location = aPoint;
/* Is the ref point inside the text area ? */
wxPoint location = posref;
rect.Inflate( aAccuracy );
RotatePoint( &location, m_Pos, -m_Orient );
return rect.Inside ( location);
return rect.Inside( location );
}
/**
* Function TextHitTest (overlayed)
* tests if the given EDA_Rect intersect this object.
* @param refArea the given EDA_Rect to test
* @return bool - true if a hit, else false
*/
/*********************************************************/
bool EDA_TextStruct::TextHitTest( EDA_Rect& refArea )
/*********************************************************/
bool EDA_TextStruct::TextHitTest( const EDA_Rect& aRect, bool aContains, int aAccuracy ) const
{
if( refArea.Inside( m_Pos ) )
return true;
return false;
EDA_Rect rect = aRect;
rect.Inflate( aAccuracy );
if( aContains )
return rect.Inside( GetTextBox( -1 ) );
return rect.Intersects( GetTextBox( -1 ) );
}
/***************************************************************/
void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
const wxPoint& aOffset, EDA_Colors aColor,
@ -523,13 +511,11 @@ void EDA_Rect::Move( const wxPoint& aMoveVector )
m_Pos += aMoveVector;
}
/*******************************************/
bool EDA_Rect::Inside( const wxPoint& point )
/*******************************************/
/* Return TRUE if point is in Rect
* Accept rect size < 0
*/
bool EDA_Rect::Inside( const wxPoint& point ) const
{
int rel_posx = point.x - m_Pos.x;
int rel_posy = point.y - m_Pos.y;
@ -547,10 +533,16 @@ bool EDA_Rect::Inside( const wxPoint& point )
rel_posy += size.y;
}
return (rel_posx >= 0) && (rel_posy >= 0)
&& ( rel_posy <= size.y)
&& ( rel_posx <= size.x)
;
return (rel_posx >= 0) && (rel_posy >= 0) && ( rel_posy <= size.y) && ( rel_posx <= size.x);
}
bool EDA_Rect::Inside( const EDA_Rect& aRect ) const
{
wxRect rect = aRect;
wxRect me = wxRect();
return me.Contains( rect );
}
@ -710,4 +702,3 @@ void EDA_Rect::Merge( const wxPoint& aPoint )
end.y = MAX( end.y, aPoint.y );
SetEnd( end );
}

View File

@ -130,7 +130,7 @@ bool MARKER_BASE::HitTestMarker( const wxPoint& refPos )
* 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()
EDA_Rect MARKER_BASE::GetBoundingBoxMarker() const
{
wxSize realsize = m_ShapeBoundingBox.GetSize();
wxPoint realposition = m_ShapeBoundingBox.GetPosition();
@ -139,7 +139,7 @@ EDA_Rect MARKER_BASE::GetBoundingBoxMarker()
realposition.x *= m_ScalingFactor;
realposition.y *= m_ScalingFactor;
realposition += m_Pos;
return EDA_Rect( m_Pos,realsize );
return EDA_Rect( m_Pos, realsize );
}
/**********************************************************************/

View File

@ -73,7 +73,7 @@ void ReAnnotatePowerSymbolsOnly( void )
for( ; DrawList != NULL; DrawList = DrawList->Next() )
{
if( DrawList->Type() != TYPE_SCH_COMPONENT )
if( DrawList->Type() != SCH_COMPONENT_T )
continue;
SCH_COMPONENT* DrawLibItem = (SCH_COMPONENT*) DrawList;
@ -226,7 +226,7 @@ void SCH_EDIT_FRAME::DeleteAnnotation( bool aCurrentSheetOnly, bool aRedraw )
for( ; strct; strct = strct->Next() )
{
if( strct->Type() == TYPE_SCH_COMPONENT )
if( strct->Type() == SCH_COMPONENT_T )
{
if( aCurrentSheetOnly )
( (SCH_COMPONENT*) strct )->ClearAnnotation( m_CurrentSheet );
@ -368,7 +368,7 @@ int AddComponentsInSheetToList( std::vector <OBJ_CMP_TO_LIST>& aComponentsList,
for( ; DrawList != NULL; DrawList = DrawList->Next() )
{
if( DrawList->Type() == TYPE_SCH_COMPONENT )
if( DrawList->Type() == SCH_COMPONENT_T )
{
DrawLibItem = (SCH_COMPONENT*) DrawList;
Entry = CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );
@ -981,7 +981,7 @@ static bool SortItemByTimeStamp( const SCH_ITEM* item1, const SCH_ITEM* item2 )
*/
if( ii == 0 && ( item1->Type() != item2->Type() ) )
if( item1->Type() == DRAW_SHEET_STRUCT_TYPE )
if( item1->Type() == SCH_SHEET_T )
ii = -1;
return ii < 0;
@ -1014,8 +1014,8 @@ int ReplaceDuplicatedTimeStamps()
while( item )
{
if( ( item->Type() == DRAW_SHEET_STRUCT_TYPE )
|| ( item->Type() == TYPE_SCH_COMPONENT ) )
if( ( item->Type() == SCH_SHEET_T )
|| ( item->Type() == SCH_COMPONENT_T ) )
itemlist.push_back( item );
item = item->Next();
@ -1036,7 +1036,7 @@ int ReplaceDuplicatedTimeStamps()
// for a component, update its Time stamp and its paths
// (m_PathsAndReferences field)
if( item->Type() == TYPE_SCH_COMPONENT )
if( item->Type() == SCH_COMPONENT_T )
( (SCH_COMPONENT*) item )->SetTimeStamp( GetTimeStamp() );
// for a sheet, update only its time stamp (annotation of its

View File

@ -49,7 +49,7 @@ bool SCH_EDIT_FRAME::FillFootprintFieldForAllInstancesofComponent( const wxStrin
DrawList = (SCH_ITEM*) sheet->LastDrawList();
for( ; (DrawList != NULL); DrawList = DrawList->Next() )
{
if( DrawList->Type() != TYPE_SCH_COMPONENT )
if( DrawList->Type() != SCH_COMPONENT_T )
continue;
Cmp = (SCH_COMPONENT*) DrawList;

View File

@ -30,7 +30,7 @@ void MoveItemsInList( PICKED_ITEMS_LIST& aItemsList, const wxPoint aM
void RotateListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& Center );
void Mirror_X_ListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& aMirrorPoint );
void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& Center );
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 );
@ -233,7 +233,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
break;
case BLOCK_DRAG: /* Drag */
BreakSegmentOnJunction( (SCH_SCREEN*) GetScreen() );
BreakSegmentOnJunction( GetScreen() );
case BLOCK_ROTATE:
case BLOCK_MIRROR_X:
@ -371,7 +371,7 @@ void SCH_EDIT_FRAME::HandleBlockEndByPopUp( int Command, wxDC* DC )
if( block->GetCount() )
{
blockCmdFinished = false;
CollectStructsToDrag( (SCH_SCREEN*) GetScreen() );
CollectStructsToDrag( GetScreen() );
if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, false );
block->m_State = STATE_BLOCK_MOVE;
@ -571,7 +571,7 @@ void SCH_EDIT_FRAME::PasteListOfItems( wxDC* DC )
picklist.PushItem( picker );
// Clear annotation and init new time stamp for the new components:
if( Struct->Type() == TYPE_SCH_COMPONENT )
if( Struct->Type() == SCH_COMPONENT_T )
{
( (SCH_COMPONENT*) Struct )->m_TimeStamp = GetTimeStamp();
( (SCH_COMPONENT*) Struct )->ClearAnnotation( NULL );
@ -625,7 +625,7 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ )
{
Struct = (SCH_ITEM*)(SCH_ITEM*) pickedlist->GetPickedItem( ii );
if( Struct->Type() == DRAW_SEGMENT_STRUCT_TYPE )
if( Struct->Type() == SCH_LINE_T )
{
SegmStruct = (SCH_LINE*) Struct;
if( !screen->m_BlockLocate.Inside( SegmStruct->m_Start ) )
@ -646,9 +646,9 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ )
{
Struct = (SCH_ITEM*)(SCH_ITEM*) pickedlist->GetPickedItem( ii );
if( ( Struct->Type() == TYPE_SCH_LABEL )
|| ( Struct->Type() == TYPE_SCH_GLOBALLABEL )
|| ( Struct->Type() == TYPE_SCH_HIERLABEL ) )
if( ( Struct->Type() == SCH_LABEL_T )
|| ( Struct->Type() == SCH_GLOBAL_LABEL_T )
|| ( Struct->Type() == SCH_HIERARCHICAL_LABEL_T ) )
{
#undef STRUCT
#define STRUCT ( (SCH_TEXT*) Struct )
@ -658,7 +658,7 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
}
}
if( Struct->Type() == TYPE_SCH_COMPONENT )
if( Struct->Type() == SCH_COMPONENT_T )
{
// Add all pins of the selected component to list
LIB_PIN* pin;
@ -678,7 +678,7 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
}
}
if( Struct->Type() == DRAW_SHEET_STRUCT_TYPE )
if( Struct->Type() == SCH_SHEET_T )
{
SCH_SHEET* sheet = (SCH_SHEET*) Struct;
@ -689,7 +689,7 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
}
}
if( Struct->Type() == DRAW_BUSENTRY_STRUCT_TYPE )
if( Struct->Type() == SCH_BUS_ENTRY_T )
{
SCH_BUS_ENTRY* item = (SCH_BUS_ENTRY*) Struct;
AddPickedItem( screen, item->m_Pos );
@ -718,7 +718,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
switch( Struct->Type() )
{
case DRAW_SEGMENT_STRUCT_TYPE:
case SCH_LINE_T:
#undef STRUCT
#define STRUCT ( (SCH_LINE*) Struct )
if( STRUCT->m_Start == position )
@ -750,12 +750,12 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
case TYPE_NOT_INIT:
break;
case DRAW_POLYLINE_STRUCT_TYPE:
case SCH_POLYLINE_T:
if( Struct->m_Flags & SELECTED )
break;
break;
case DRAW_JUNCTION_STRUCT_TYPE:
case SCH_JUNCTION_T:
#undef STRUCT
#define STRUCT ( (SCH_JUNCTION*) Struct )
if( Struct->m_Flags & SELECTED )
@ -765,7 +765,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
pickedlist->PushItem( picker );
break;
case DRAW_SEGMENT_STRUCT_TYPE:
case SCH_LINE_T:
#undef STRUCT
#define STRUCT ( (SCH_LINE*) Struct )
if( Struct->m_Flags & SELECTED )
@ -790,13 +790,13 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
}
break;
case DRAW_BUSENTRY_STRUCT_TYPE:
case SCH_BUS_ENTRY_T:
break;
case TYPE_SCH_TEXT:
case SCH_TEXT_T:
break;
case TYPE_SCH_LABEL:
case SCH_LABEL_T:
#undef STRUCT
#define STRUCT ( (SCH_LABEL*) Struct )
if( Struct->m_Flags & SELECTED )
@ -807,8 +807,8 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
pickedlist->PushItem( picker );
break;
case TYPE_SCH_HIERLABEL:
case TYPE_SCH_GLOBALLABEL:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_GLOBAL_LABEL_T:
#undef STRUCT
#define STRUCT ( (SCH_LABEL*) Struct )
if( Struct->m_Flags & SELECTED )
@ -819,12 +819,12 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
pickedlist->PushItem( picker );
break;
case TYPE_SCH_COMPONENT:
case DRAW_SHEET_STRUCT_TYPE:
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case SCH_COMPONENT_T:
case SCH_SHEET_T:
case SCH_SHEET_LABEL_T:
break;
case TYPE_SCH_MARKER:
case SCH_MARKER_T:
#undef STRUCT
#define STRUCT ( (SCH_MARKER*) Struct )
if( Struct->m_Flags & SELECTED )
@ -835,7 +835,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
pickedlist->PushItem( picker );
break;
case DRAW_NOCONNECT_STRUCT_TYPE:
case SCH_NO_CONNECT_T:
#undef STRUCT
#define STRUCT ( (SCH_NO_CONNECT*) Struct )
if( Struct->m_Flags & SELECTED )
@ -890,11 +890,12 @@ static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
for( ; Pin != NULL; Pin = Entry->GetNextPin( Pin ) )
{
wxASSERT( Pin->Type() == COMPONENT_PIN_DRAW_TYPE );
wxASSERT( Pin->Type() == LIB_PIN_T );
/* Skip items not used for this part */
if( Multi && Pin->GetUnit() && ( Pin->GetUnit() != Multi ) )
continue;
if( convert && Pin->GetConvert() && ( Pin->GetConvert() != convert ) )
continue;

View File

@ -43,7 +43,7 @@ void BuildComponentsListFromSchematic( std::vector <OBJ_CMP_TO_LIST>& aList )
{
for( EDA_ITEM* schItem = path->LastDrawList(); schItem; schItem = schItem->Next() )
{
if( schItem->Type() != TYPE_SCH_COMPONENT )
if( schItem->Type() != SCH_COMPONENT_T )
continue;
SCH_COMPONENT* comp = (SCH_COMPONENT*) schItem;
@ -87,21 +87,21 @@ void GenListeGLabels( std::vector <LABEL_OBJECT>& aList )
{
switch( schItem->Type() )
{
case TYPE_SCH_HIERLABEL:
case TYPE_SCH_GLOBALLABEL:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_GLOBAL_LABEL_T:
lable.m_LabelType = schItem->Type();
lable.m_SheetPath = *path;
lable.m_Label = schItem;
aList.push_back( lable );
break;
case DRAW_SHEET_STRUCT_TYPE:
case SCH_SHEET_T:
{
SCH_SHEET* sheet = (SCH_SHEET*) schItem;
BOOST_FOREACH( SCH_SHEET_PIN sheetLabel, sheet->GetSheetPins() )
{
lable.m_LabelType = DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE;
lable.m_LabelType = SCH_SHEET_LABEL_T;
lable.m_SheetPath = *path;
lable.m_Label = &sheetLabel;
aList.push_back( lable );
@ -187,12 +187,12 @@ bool SortLabelsByValue( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 )
int ii;
wxString* Text1, * Text2;
if( obj1.m_LabelType == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
if( obj1.m_LabelType == SCH_SHEET_LABEL_T )
Text1 = &( (SCH_SHEET_PIN*)(obj1.m_Label) )->m_Text;
else
Text1 = &( (SCH_TEXT*)(obj1.m_Label) )->m_Text;
if( obj2.m_LabelType == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
if( obj2.m_LabelType == SCH_SHEET_LABEL_T )
Text2 = &( (SCH_SHEET_PIN*)(obj2.m_Label) )->m_Text;
else
Text2 = &( (SCH_TEXT*)(obj2.m_Label) )->m_Text;
@ -221,12 +221,12 @@ bool SortLabelsBySheet( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 )
if( ii == 0 )
{
if( obj1.m_LabelType == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
if( obj1.m_LabelType == SCH_SHEET_LABEL_T )
Text1 = ( (SCH_SHEET_PIN*) obj1.m_Label )->m_Text;
else
Text1 = ( (SCH_TEXT*) obj1.m_Label )->m_Text;
if( obj2.m_LabelType == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
if( obj2.m_LabelType == SCH_SHEET_LABEL_T )
Text2 = ( (SCH_SHEET_PIN*) obj2.m_Label )->m_Text;
else
Text2 = ( (SCH_TEXT*) obj2.m_Label )->m_Text;
@ -282,11 +282,11 @@ int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList )
{
switch( aList[ii].m_LabelType )
{
case TYPE_SCH_HIERLABEL:
case TYPE_SCH_GLOBALLABEL:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_GLOBAL_LABEL_T:
DrawTextItem = (SCH_LABEL*)(aList[ii].m_Label);
if( aList[ii].m_LabelType == TYPE_SCH_HIERLABEL )
if( aList[ii].m_LabelType == SCH_HIERARCHICAL_LABEL_T )
labeltype = wxT( "Hierarchical" );
else
labeltype = wxT( "Global " );
@ -302,7 +302,7 @@ int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList )
fputs( CONV_TO_UTF8( msg ), f );
break;
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case SCH_SHEET_LABEL_T:
{
DrawSheetLabel = (SCH_SHEET_PIN*) aList[ii].m_Label;
int jj = DrawSheetLabel->m_Shape;

View File

@ -46,8 +46,8 @@ static void RestoreOldWires( SCH_SCREEN* screen )
switch( item->Type() )
{
case DRAW_JUNCTION_STRUCT_TYPE:
case DRAW_SEGMENT_STRUCT_TYPE:
case SCH_JUNCTION_T:
case SCH_LINE_T:
screen->RemoveFromDrawList( item );
delete item;
break;
@ -133,8 +133,8 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type )
{
switch( GetScreen()->GetCurItem()->Type() )
{
case DRAW_SEGMENT_STRUCT_TYPE:
case DRAW_POLYLINE_STRUCT_TYPE:
case SCH_LINE_T:
case SCH_POLYLINE_T:
break;
default:
@ -147,8 +147,8 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type )
if( !newsegment ) /* first point : Create first wire or bus */
{
s_ConnexionStartPoint = cursorpos;
s_OldWiresList = ( (SCH_SCREEN*) GetScreen() )->ExtractWires( TRUE );
( (SCH_SCREEN*) GetScreen() )->SchematicCleanUp( NULL );
s_OldWiresList = GetScreen()->ExtractWires( TRUE );
GetScreen()->SchematicCleanUp( NULL );
switch( type )
{
@ -320,7 +320,7 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC )
alt_end_point = lastsegment->m_Start;
}
( (SCH_SCREEN*) GetScreen() )->SchematicCleanUp( NULL );
GetScreen()->SchematicCleanUp( NULL );
/* clear flags and find last segment entered, for repeat function */
segment = (SCH_LINE*) GetScreen()->GetDrawItems();
@ -360,8 +360,8 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC )
{
switch( item->Type() )
{
case DRAW_JUNCTION_STRUCT_TYPE:
case DRAW_SEGMENT_STRUCT_TYPE:
case SCH_JUNCTION_T:
case SCH_LINE_T:
DrawPanel->PostDirtyRect( item->GetBoundingBox() );
break;
@ -474,7 +474,7 @@ void SCH_EDIT_FRAME::DeleteCurrentSegment( wxDC* DC )
}
/* Cancel trace in progress */
if( GetScreen()->GetCurItem()->Type() == DRAW_POLYLINE_STRUCT_TYPE )
if( GetScreen()->GetCurItem()->Type() == SCH_POLYLINE_T )
{
Show_Polyline_in_Ghost( DrawPanel, DC, FALSE );
}
@ -483,7 +483,7 @@ void SCH_EDIT_FRAME::DeleteCurrentSegment( wxDC* DC )
DrawSegment( DrawPanel, DC, FALSE );
}
EraseStruct( (SCH_ITEM*) GetScreen()->GetCurItem(), (SCH_SCREEN*) GetScreen() );
EraseStruct( (SCH_ITEM*) GetScreen()->GetCurItem(), GetScreen() );
DrawPanel->ManageCurseur = NULL;
GetScreen()->SetCurItem( NULL );
}
@ -578,7 +578,7 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC )
switch( g_ItemToRepeat->Type() )
{
case DRAW_JUNCTION_STRUCT_TYPE:
case SCH_JUNCTION_T:
#undef STRUCT
#define STRUCT ( (SCH_JUNCTION*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy();
@ -586,7 +586,7 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC )
new_pos = STRUCT->m_Pos;
break;
case DRAW_NOCONNECT_STRUCT_TYPE:
case SCH_NO_CONNECT_T:
#undef STRUCT
#define STRUCT ( (SCH_NO_CONNECT*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy();
@ -594,7 +594,7 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC )
new_pos = STRUCT->m_Pos;
break;
case TYPE_SCH_TEXT:
case SCH_TEXT_T:
#undef STRUCT
#define STRUCT ( (SCH_TEXT*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy();
@ -604,7 +604,7 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC )
break;
case TYPE_SCH_LABEL:
case SCH_LABEL_T:
#undef STRUCT
#define STRUCT ( (SCH_LABEL*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy();
@ -614,7 +614,7 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC )
break;
case TYPE_SCH_HIERLABEL:
case SCH_HIERARCHICAL_LABEL_T:
#undef STRUCT
#define STRUCT ( (SCH_HIERLABEL*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy();
@ -623,7 +623,7 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC )
IncrementLabelMember( STRUCT->m_Text );
break;
case TYPE_SCH_GLOBALLABEL:
case SCH_GLOBAL_LABEL_T:
#undef STRUCT
#define STRUCT ( (SCH_GLOBALLABEL*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy();
@ -632,7 +632,7 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC )
IncrementLabelMember( STRUCT->m_Text );
break;
case DRAW_SEGMENT_STRUCT_TYPE:
case SCH_LINE_T:
#undef STRUCT
#define STRUCT ( (SCH_LINE*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy();
@ -641,7 +641,7 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC )
STRUCT->m_End += g_RepeatStep;
break;
case DRAW_BUSENTRY_STRUCT_TYPE:
case SCH_BUS_ENTRY_T:
#undef STRUCT
#define STRUCT ( (SCH_BUS_ENTRY*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy();
@ -649,7 +649,7 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC )
new_pos = STRUCT->m_Pos;
break;
case TYPE_SCH_COMPONENT: // In repeat command the new component is put
case SCH_COMPONENT_T: // In repeat command the new component is put
// in move mode
#undef STRUCT
#define STRUCT ( (SCH_COMPONENT*) g_ItemToRepeat )
@ -787,7 +787,7 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
return TRUE;
item = PickStruct( pos, screen, LABELITEM );
if( item && (item->Type() != TYPE_SCH_TEXT)
if( item && (item->Type() != SCH_TEXT_T)
&& ( ( (SCH_GLOBALLABEL*) item )->m_Pos.x == pos.x )
&& ( ( (SCH_GLOBALLABEL*) item )->m_Pos.y == pos.y ) )
return TRUE;

View File

@ -111,7 +111,7 @@ void SCH_EDIT_FRAME::SetBusEntryShape( wxDC* DC, SCH_BUS_ENTRY* BusEntry, int en
if( BusEntry == NULL )
return;
if( BusEntry->Type() != DRAW_BUSENTRY_STRUCT_TYPE )
if( BusEntry->Type() != SCH_BUS_ENTRY_T )
{
DisplayError( this, wxT( "SetBusEntryType: Bad StructType" ) );
return;

View File

@ -313,10 +313,10 @@ void LIB_COMPONENT::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDc, const wxPoint& aO
if( aConvert && drawItem.m_Convert && ( drawItem.m_Convert != aConvert ) )
continue;
if( drawItem.Type() == COMPONENT_FIELD_DRAW_TYPE )
if( drawItem.Type() == LIB_FIELD_T )
continue;
if( drawItem.Type() == COMPONENT_FIELD_DRAW_TYPE )
if( drawItem.Type() == LIB_FIELD_T )
{
drawItem.Draw( aPanel, aDc, aOffset, aColor, aDrawMode, (void*) NULL, aTransform );
}
@ -343,15 +343,15 @@ void LIB_COMPONENT::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDc, const wxPoint& aO
if( aConvert && drawItem.m_Convert && ( drawItem.m_Convert != aConvert ) )
continue;
if( !aDrawFields && drawItem.Type() == COMPONENT_FIELD_DRAW_TYPE )
if( !aDrawFields && drawItem.Type() == LIB_FIELD_T )
continue;
if( drawItem.Type() == COMPONENT_PIN_DRAW_TYPE )
if( drawItem.Type() == LIB_PIN_T )
{
drawItem.Draw( aPanel, aDc, aOffset, aColor, aDrawMode, (void*) aShowPinText,
aTransform );
}
else if( drawItem.Type() == COMPONENT_FIELD_DRAW_TYPE )
else if( drawItem.Type() == LIB_FIELD_T )
{
drawItem.Draw( aPanel, aDc, aOffset, aColor, aDrawMode, (void*) NULL, aTransform );
}
@ -380,7 +380,7 @@ void LIB_COMPONENT::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDc, const wxPoint& aO
/* Enable this to draw the bounding box around the component to validate
* the bounding box calculations. */
#if 0
EDA_Rect bBox = GetBoundaryBox( aMulti, aConvert );
EDA_Rect bBox = GetBoundingBox( aMulti, aConvert );
GRRect( &aPanel->m_ClipBox, aDc, bBox.GetOrigin().x, bBox.GetOrigin().y,
bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA );
#endif
@ -413,7 +413,7 @@ void LIB_COMPONENT::RemoveDrawItem( LIB_DRAW_ITEM* aItem, WinEDA_DrawPanel* aPan
// none of the MANDATOR_FIELDS may be removed in RAM, but they may be
// omitted when saving to disk.
if( aItem->Type() == COMPONENT_FIELD_DRAW_TYPE )
if( aItem->Type() == LIB_FIELD_T )
{
LIB_FIELD* field = (LIB_FIELD*) aItem;
@ -498,7 +498,7 @@ void LIB_COMPONENT::GetPins( LIB_PIN_LIST& aList, int aUnit, int aConvert )
*/
BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings )
{
if( item.Type() != COMPONENT_PIN_DRAW_TYPE ) // we search pins only
if( item.Type() != LIB_PIN_T ) // we search pins only
continue;
// Unit filtering:
@ -523,7 +523,7 @@ LIB_PIN* LIB_COMPONENT::GetPin( const wxString& aNumber, int aUnit, int aConvert
for( size_t i = 0; i < pinList.size(); i++ )
{
wxASSERT( pinList[i]->Type() == COMPONENT_PIN_DRAW_TYPE );
wxASSERT( pinList[i]->Type() == LIB_PIN_T );
pinList[i]->ReturnPinStringNum( pNumber );
@ -661,7 +661,7 @@ bool LIB_COMPONENT::Save( FILE* aFile )
BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings )
{
if( item.Type() == COMPONENT_FIELD_DRAW_TYPE )
if( item.Type() == LIB_FIELD_T )
continue;
if( !item.Save( aFile ) )
@ -970,11 +970,11 @@ bool LIB_COMPONENT::LoadFootprints( FILE* aFile, char* aLine,
* Invisible fields are not take in account
**/
/**********************************************************************/
EDA_Rect LIB_COMPONENT::GetBoundaryBox( int aUnit, int aConvert )
EDA_Rect LIB_COMPONENT::GetBoundingBox( int aUnit, int aConvert ) const
{
EDA_Rect bBox( wxPoint( 0, 0 ), wxSize( 0, 0 ) );
BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings )
BOOST_FOREACH( const LIB_DRAW_ITEM& item, drawings )
{
if( ( item.m_Unit > 0 ) && ( ( m_unitCount > 1 ) && ( aUnit > 0 )
&& ( aUnit != item.m_Unit ) ) )
@ -983,7 +983,7 @@ EDA_Rect LIB_COMPONENT::GetBoundaryBox( int aUnit, int aConvert )
if( item.m_Convert > 0 && ( ( aConvert > 0 ) && ( aConvert != item.m_Convert ) ) )
continue;
if ( ( item.Type() == COMPONENT_FIELD_DRAW_TYPE ) && !( ( LIB_FIELD& ) item ).IsVisible() )
if ( ( item.Type() == LIB_FIELD_T ) && !( ( LIB_FIELD& ) item ).IsVisible() )
continue;
bBox.Merge( item.GetBoundingBox() );
@ -999,7 +999,7 @@ void LIB_COMPONENT::deleteAllFields()
for( it = drawings.begin(); it!=drawings.end(); /* deleting */ )
{
if( it->Type() != COMPONENT_FIELD_DRAW_TYPE )
if( it->Type() != LIB_FIELD_T )
{
++it;
continue;
@ -1051,7 +1051,7 @@ void LIB_COMPONENT::GetFields( LIB_FIELD_LIST& aList )
// Now grab all the rest of fields.
BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings )
{
if( item.Type() != COMPONENT_FIELD_DRAW_TYPE )
if( item.Type() != LIB_FIELD_T )
continue;
field = ( LIB_FIELD* ) &item;
@ -1067,7 +1067,7 @@ LIB_FIELD* LIB_COMPONENT::GetField( int aId )
{
BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings )
{
if( item.Type() != COMPONENT_FIELD_DRAW_TYPE )
if( item.Type() != LIB_FIELD_T )
continue;
LIB_FIELD* field = ( LIB_FIELD* ) &item;
@ -1084,7 +1084,7 @@ LIB_FIELD* LIB_COMPONENT::FindField( const wxString& aFieldName )
{
BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings )
{
if( item.Type() != COMPONENT_FIELD_DRAW_TYPE )
if( item.Type() != LIB_FIELD_T )
continue;
LIB_FIELD* field = ( LIB_FIELD* ) &item;
@ -1205,7 +1205,7 @@ int LIB_COMPONENT::SelectItems( EDA_Rect& aRect, int aUnit, int aConvert, bool a
if( ( item.m_Unit && item.m_Unit != aUnit )
|| ( item.m_Convert && item.m_Convert != aConvert ) )
{
if( item.Type() != COMPONENT_PIN_DRAW_TYPE )
if( item.Type() != LIB_PIN_T )
continue;
// Specific rules for pins.
@ -1258,7 +1258,7 @@ void LIB_COMPONENT::DeleteSelectedItems()
// because they are not really graphic items
while( item != drawings.end() )
{
if( item->Type() == COMPONENT_FIELD_DRAW_TYPE )
if( item->Type() == LIB_FIELD_T )
{
#if 0 // Set to 1 to allows fields deletion on block delete or other global command
LIB_FIELD& field = ( LIB_FIELD& ) *item;
@ -1289,7 +1289,7 @@ void LIB_COMPONENT::CopySelectedItems( const wxPoint& aOffset )
LIB_DRAW_ITEM& item = drawings[ii];
// We *do not* copy fields because they are unique for the whole component
// so skip them (do not duplicate) if they are flagged selected.
if( item.Type() == COMPONENT_FIELD_DRAW_TYPE )
if( item.Type() == LIB_FIELD_T )
item.m_Selected = 0;
if( item.m_Selected == 0 )
@ -1455,7 +1455,7 @@ void LIB_COMPONENT::SetConversion( bool aSetConvert )
BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings )
{
/* Only pins are duplicated. */
if( item.Type() != COMPONENT_PIN_DRAW_TYPE )
if( item.Type() != LIB_PIN_T )
continue;
if( item.m_Convert == 1 )
{

View File

@ -233,7 +233,7 @@ public:
wxArrayString& GetFootPrints() { return m_FootprintList; }
EDA_Rect GetBoundaryBox( int aUnit, int aConvert );
EDA_Rect GetBoundingBox( int aUnit, int aConvert ) const;
bool SaveDateAndTime( FILE* aFile );
bool LoadDateAndTime( char* aLine );
@ -385,7 +385,7 @@ public:
*/
LIB_PIN* GetNextPin( LIB_PIN* aItem = NULL )
{
return (LIB_PIN*) GetNextDrawItem( (LIB_DRAW_ITEM*) aItem, COMPONENT_PIN_DRAW_TYPE );
return (LIB_PIN*) GetNextDrawItem( (LIB_DRAW_ITEM*) aItem, LIB_PIN_T );
}

View File

@ -34,30 +34,30 @@ void BreakSegmentOnJunction( SCH_SCREEN* Screen )
{
switch( DrawList->Type() )
{
case DRAW_JUNCTION_STRUCT_TYPE:
case SCH_JUNCTION_T:
#undef STRUCT
#define STRUCT ( (SCH_JUNCTION*) DrawList )
BreakSegment( Screen, STRUCT->m_Pos );
break;
case DRAW_BUSENTRY_STRUCT_TYPE:
case SCH_BUS_ENTRY_T:
#undef STRUCT
#define STRUCT ( (SCH_BUS_ENTRY*) DrawList )
BreakSegment( Screen, STRUCT->m_Pos );
BreakSegment( Screen, STRUCT->m_End() );
break;
case DRAW_SEGMENT_STRUCT_TYPE:
case DRAW_NOCONNECT_STRUCT_TYPE:
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
case TYPE_SCH_COMPONENT:
case DRAW_POLYLINE_STRUCT_TYPE:
case TYPE_SCH_MARKER:
case TYPE_SCH_TEXT:
case DRAW_SHEET_STRUCT_TYPE:
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case SCH_LINE_T:
case SCH_NO_CONNECT_T:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_COMPONENT_T:
case SCH_POLYLINE_T:
case SCH_MARKER_T:
case SCH_TEXT_T:
case SCH_SHEET_T:
case SCH_SHEET_LABEL_T:
break;
default:
@ -79,7 +79,7 @@ void BreakSegment( SCH_SCREEN* aScreen, wxPoint aBreakpoint )
for( SCH_ITEM* DrawList = aScreen->GetDrawItems(); DrawList; DrawList = DrawList->Next() )
{
if( DrawList->Type() != DRAW_SEGMENT_STRUCT_TYPE )
if( DrawList->Type() != SCH_LINE_T )
continue;
segment = (SCH_LINE*) DrawList;

View File

@ -59,13 +59,13 @@ SCH_ITEM* SCH_EDIT_FRAME::SchematicGeneralLocateAndDisplay( bool IncludePin )
/* Cross probing to pcbnew if a pin or a component is found */
switch( DrawStruct->Type() )
{
case DRAW_PART_TEXT_STRUCT_TYPE:
case COMPONENT_FIELD_DRAW_TYPE:
case SCH_FIELD_T:
case LIB_FIELD_T:
LibItem = (SCH_COMPONENT*) DrawStruct->GetParent();
SendMessageToPCBNEW( DrawStruct, LibItem );
break;
case TYPE_SCH_COMPONENT:
case SCH_COMPONENT_T:
Pin = LocateAnyPin( GetScreen()->GetDrawItems(), GetScreen()->m_Curseur, &LibItem );
if( Pin )
break; // Priority is probing a pin first
@ -77,7 +77,7 @@ SCH_ITEM* SCH_EDIT_FRAME::SchematicGeneralLocateAndDisplay( bool IncludePin )
Pin = LocateAnyPin( GetScreen()->GetDrawItems(), GetScreen()->m_Curseur, &LibItem );
break;
case COMPONENT_PIN_DRAW_TYPE:
case LIB_PIN_T:
Pin = (LIB_PIN*) DrawStruct;
break;
}
@ -87,6 +87,7 @@ SCH_ITEM* SCH_EDIT_FRAME::SchematicGeneralLocateAndDisplay( bool IncludePin )
/* Force display pin information (the previous display could be a
* component info) */
Pin->DisplayInfo( this );
if( LibItem )
AppendMsgPanel( LibItem->GetRef( GetSheet() ),
LibItem->GetField( VALUE )->m_Text, DARKCYAN );
@ -127,6 +128,7 @@ SCH_ITEM* SCH_EDIT_FRAME::SchematicGeneralLocateAndDisplay( const wxPoint& refpo
wxString msg;
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), MARKERITEM );
if( DrawStruct )
{
DrawStruct->DisplayInfo( this );
@ -134,6 +136,7 @@ SCH_ITEM* SCH_EDIT_FRAME::SchematicGeneralLocateAndDisplay( const wxPoint& refpo
}
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), NOCONNECTITEM );
if( DrawStruct )
{
ClearMsgPanel();
@ -141,23 +144,24 @@ SCH_ITEM* SCH_EDIT_FRAME::SchematicGeneralLocateAndDisplay( const wxPoint& refpo
}
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), JUNCTIONITEM );
if( DrawStruct )
{
ClearMsgPanel();
return DrawStruct;
}
DrawStruct = (SCH_ITEM*) PickStruct( refpoint,
GetScreen(), WIREITEM | BUSITEM |
RACCORDITEM );
if( DrawStruct ) // We have found a wire: Search for a connected pin at
// the same location
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(),
WIREITEM | BUSITEM | RACCORDITEM );
if( DrawStruct ) // We have found a wire: Search for a connected pin at the same location
{
Pin = LocateAnyPin( (SCH_ITEM*) m_CurrentSheet->LastDrawList(),
refpoint, &LibItem );
Pin = LocateAnyPin( (SCH_ITEM*) m_CurrentSheet->LastDrawList(), refpoint, &LibItem );
if( Pin )
{
Pin->DisplayInfo( this );
if( LibItem )
AppendMsgPanel( LibItem->GetRef( GetSheet() ),
LibItem->GetField( VALUE )->m_Text, DARKCYAN );
@ -169,6 +173,7 @@ SCH_ITEM* SCH_EDIT_FRAME::SchematicGeneralLocateAndDisplay( const wxPoint& refpo
}
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), FIELDCMPITEM );
if( DrawStruct )
{
SCH_FIELD* Field = (SCH_FIELD*) DrawStruct;
@ -179,6 +184,7 @@ SCH_ITEM* SCH_EDIT_FRAME::SchematicGeneralLocateAndDisplay( const wxPoint& refpo
}
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), LABELITEM | TEXTITEM );
if( DrawStruct )
{
ClearMsgPanel();
@ -186,11 +192,12 @@ SCH_ITEM* SCH_EDIT_FRAME::SchematicGeneralLocateAndDisplay( const wxPoint& refpo
}
/* search for a pin */
Pin = LocateAnyPin( (SCH_ITEM*) m_CurrentSheet->LastDrawList(), refpoint,
&LibItem );
Pin = LocateAnyPin( (SCH_ITEM*) m_CurrentSheet->LastDrawList(), refpoint, &LibItem );
if( Pin )
{
Pin->DisplayInfo( this );
if( LibItem )
AppendMsgPanel( LibItem->GetRef( GetSheet() ),
LibItem->GetField( VALUE )->m_Text, DARKCYAN );
@ -199,15 +206,17 @@ SCH_ITEM* SCH_EDIT_FRAME::SchematicGeneralLocateAndDisplay( const wxPoint& refpo
}
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), LIBITEM );
if( DrawStruct )
{
DrawStruct = LocateSmallestComponent( (SCH_SCREEN*) GetScreen() );
DrawStruct = LocateSmallestComponent( GetScreen() );
LibItem = (SCH_COMPONENT*) DrawStruct;
LibItem->DisplayInfo( this );
return DrawStruct;
}
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), SHEETITEM );
if( DrawStruct )
{
( (SCH_SHEET*) DrawStruct )->DisplayInfo( this );
@ -215,6 +224,7 @@ SCH_ITEM* SCH_EDIT_FRAME::SchematicGeneralLocateAndDisplay( const wxPoint& refpo
}
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), SEARCHALL );
if( DrawStruct )
{
return DrawStruct;

View File

@ -46,6 +46,7 @@ void RemoteCommand( const char* cmdline )
idcmd = strtok( line, " \n\r" );
text = strtok( NULL, "\"\n\r" );
if( (idcmd == NULL) || (text == NULL) )
return;
@ -56,6 +57,7 @@ void RemoteCommand( const char* cmdline )
/* look for a complement */
idcmd = strtok( NULL, " \n\r" );
if( idcmd == NULL ) // component only
{
frame->FindComponentAndItem( part_ref, true, 0, wxEmptyString, false );
@ -63,6 +65,7 @@ void RemoteCommand( const char* cmdline )
}
text = strtok( NULL, "\"\n\r" );
if( text == NULL )
return;
@ -103,8 +106,8 @@ void SCH_EDIT_FRAME::SendMessageToPCBNEW( EDA_ITEM* objectToSync, SCH_COMPONENT*
/* Cross probing to pcbnew if a pin or a component is found */
switch( objectToSync->Type() )
{
case DRAW_PART_TEXT_STRUCT_TYPE:
case COMPONENT_FIELD_DRAW_TYPE:
case SCH_FIELD_T:
case LIB_FIELD_T:
{
if( LibItem == NULL )
break;
@ -114,13 +117,13 @@ void SCH_EDIT_FRAME::SendMessageToPCBNEW( EDA_ITEM* objectToSync, SCH_COMPONENT*
}
break;
case TYPE_SCH_COMPONENT:
case SCH_COMPONENT_T:
LibItem = (SCH_COMPONENT*) objectToSync;
sprintf( Line, "$PART: %s", CONV_TO_UTF8( LibItem->GetField( REFERENCE )->m_Text ) );
SendCommand( MSG_TO_PCB, Line );
break;
case COMPONENT_PIN_DRAW_TYPE:
case LIB_PIN_T:
if( LibItem == NULL )
break;

View File

@ -44,7 +44,7 @@ static int CountConnectedItems( SCH_EDIT_FRAME* frame, SCH_ITEM* ListStruct, wxP
continue;
if( TstJunction && ( Struct->Type() == DRAW_JUNCTION_STRUCT_TYPE ) )
if( TstJunction && ( Struct->Type() == SCH_JUNCTION_T ) )
{
#define JUNCTION ( (SCH_JUNCTION*) Struct )
if( JUNCTION->m_Pos == pos )
@ -52,11 +52,11 @@ static int CountConnectedItems( SCH_EDIT_FRAME* frame, SCH_ITEM* ListStruct, wxP
#undef JUNCTION
}
if( Struct->Type() != DRAW_SEGMENT_STRUCT_TYPE )
if( Struct->Type() != SCH_LINE_T )
continue;
#define SEGM ( (SCH_LINE*) Struct )
if( SEGM->IsOneEndPointAt( pos ) )
if( SEGM->IsEndPoint( pos ) )
count++;
#undef SEGM
}
@ -81,20 +81,20 @@ static bool MarkConnected( SCH_EDIT_FRAME* frame, SCH_ITEM* ListStruct, SCH_LINE
{
if( Struct->m_Flags )
continue;
if( Struct->Type() == DRAW_JUNCTION_STRUCT_TYPE )
if( Struct->Type() == SCH_JUNCTION_T )
{
#define JUNCTION ( (SCH_JUNCTION*) Struct )
if( segment->IsOneEndPointAt( JUNCTION->m_Pos ) )
if( segment->IsEndPoint( JUNCTION->m_Pos ) )
Struct->m_Flags |= CANDIDATE;
continue;
#undef JUNCTION
}
if( Struct->Type() != DRAW_SEGMENT_STRUCT_TYPE )
if( Struct->Type() != SCH_LINE_T )
continue;
#define SEGM ( (SCH_LINE*) Struct )
if( segment->IsOneEndPointAt( SEGM->m_Start ) )
if( segment->IsEndPoint( SEGM->m_Start ) )
{
if( !frame->LocatePinEnd( ListStruct, SEGM->m_Start ) )
{
@ -102,7 +102,7 @@ static bool MarkConnected( SCH_EDIT_FRAME* frame, SCH_ITEM* ListStruct, SCH_LINE
MarkConnected( frame, ListStruct, SEGM );
}
}
if( segment->IsOneEndPointAt( SEGM->m_End ) )
if( segment->IsEndPoint( SEGM->m_End ) )
{
if( !frame->LocatePinEnd( ListStruct, SEGM->m_End ) )
{
@ -131,13 +131,13 @@ void SCH_EDIT_FRAME::DeleteConnection( bool DeleteFullConnection )
for( DelStruct = GetScreen()->GetDrawItems(); DelStruct != NULL; DelStruct = DelStruct->Next() )
DelStruct->m_Flags = 0;
BreakSegmentOnJunction( (SCH_SCREEN*) GetScreen() );
BreakSegmentOnJunction( GetScreen() );
/* Locate all the wires, bus or junction under the mouse cursor, and put
* them in a list of items to delete
*/
ITEM_PICKER picker(NULL, UR_DELETED);
SCH_SCREEN* screen = (SCH_SCREEN*) GetScreen();
SCH_SCREEN* screen = GetScreen();
// Save the list entry point of this screen
SCH_ITEM* savedItems = screen->GetDrawItems();
DelStruct = GetScreen()->GetDrawItems();
@ -171,7 +171,7 @@ void SCH_EDIT_FRAME::DeleteConnection( bool DeleteFullConnection )
#define SEGM ( (SCH_LINE*) DelStruct )
if( DelStruct->Type() != DRAW_SEGMENT_STRUCT_TYPE )
if( DelStruct->Type() != SCH_LINE_T )
continue;
MarkConnected( this, GetScreen()->GetDrawItems(), SEGM );
@ -190,7 +190,7 @@ void SCH_EDIT_FRAME::DeleteConnection( bool DeleteFullConnection )
if( !(DelStruct->m_Flags & CANDIDATE) )
continue; // Already seen
if( DelStruct->Type() != DRAW_SEGMENT_STRUCT_TYPE )
if( DelStruct->Type() != SCH_LINE_T )
continue;
DelStruct->m_Flags |= SKIP_STRUCT;
@ -207,11 +207,11 @@ void SCH_EDIT_FRAME::DeleteConnection( bool DeleteFullConnection )
if( ( removed_struct->m_Flags & STRUCT_DELETED ) == 0 )
continue;
if( removed_struct->Type() != DRAW_SEGMENT_STRUCT_TYPE )
if( removed_struct->Type() != SCH_LINE_T )
continue;
#define WIRE ( (SCH_LINE*) removed_struct )
if( WIRE->IsOneEndPointAt( SEGM->m_Start ) )
if( WIRE->IsEndPoint( SEGM->m_Start ) )
break;
}
@ -228,9 +228,9 @@ void SCH_EDIT_FRAME::DeleteConnection( bool DeleteFullConnection )
{
if( ( removed_struct->m_Flags & STRUCT_DELETED ) == 0 )
continue;
if( removed_struct->Type() != DRAW_SEGMENT_STRUCT_TYPE )
if( removed_struct->Type() != SCH_LINE_T )
continue;
if( WIRE->IsOneEndPointAt( SEGM->m_End ) )
if( WIRE->IsEndPoint( SEGM->m_End ) )
break;
}
@ -265,7 +265,7 @@ void SCH_EDIT_FRAME::DeleteConnection( bool DeleteFullConnection )
if( !(DelStruct->m_Flags & CANDIDATE) )
continue;
if( DelStruct->Type() == DRAW_JUNCTION_STRUCT_TYPE )
if( DelStruct->Type() == SCH_JUNCTION_T )
{
#define JUNCTION ( (SCH_JUNCTION*) DelStruct )
count = CountConnectedItems( this, GetScreen()->GetDrawItems(),
@ -291,7 +291,7 @@ void SCH_EDIT_FRAME::DeleteConnection( bool DeleteFullConnection )
if( DelStruct->m_Flags & STRUCT_DELETED )
continue;
if( DelStruct->Type() != TYPE_SCH_LABEL )
if( DelStruct->Type() != SCH_LABEL_T )
continue;
GetScreen()->m_Curseur = ( (SCH_TEXT*) DelStruct )->m_Pos;
@ -383,7 +383,7 @@ bool LocateAndDeleteItem( SCH_EDIT_FRAME* frame, wxDC* DC )
* Screen = pointer on the screen of belonging
*
* Note:
* DRAW_SHEET_STRUCT_TYPE structures for the screen and structures
* SCH_SHEET_T structures for the screen and structures
* Corresponding keys are not.
* They must be treated separately
*/
@ -399,7 +399,7 @@ void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Screen )
Screen->SetModify();
if( DrawStruct->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
if( DrawStruct->Type() == SCH_SHEET_LABEL_T )
{
// This structure is attached to a sheet, get the parent sheet object.
SCH_SHEET_PIN* sheetLabel = (SCH_SHEET_PIN*) DrawStruct;
@ -448,7 +448,7 @@ void DeleteAllMarkers( int type )
{
NextStruct = DrawStruct->Next();
if( DrawStruct->Type() != TYPE_SCH_MARKER )
if( DrawStruct->Type() != SCH_MARKER_T )
continue;
Marker = (SCH_MARKER*) DrawStruct;

View File

@ -30,7 +30,7 @@ void DeleteSubHierarchy( SCH_SHEET* FirstSheet, bool confirm_deletion )
if( FirstSheet == NULL )
return;
if( FirstSheet->Type() != DRAW_SHEET_STRUCT_TYPE )
if( FirstSheet->Type() != SCH_SHEET_T )
{
DisplayError( NULL, wxT( "DeleteSubHierarchy error(): NOT a Sheet" ) );
return;
@ -58,7 +58,7 @@ void DeleteSubHierarchy( SCH_SHEET* FirstSheet, bool confirm_deletion )
DrawStruct = EEDrawList;
EEDrawList = EEDrawList->Next();
if( DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE )
if( DrawStruct->Type() == SCH_SHEET_T )
{
DeleteSubHierarchy( (SCH_SHEET*) DrawStruct, confirm_deletion );
}

View File

@ -628,7 +628,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef(
if( item == NULL )
continue;
if( item->Type() != TYPE_SCH_COMPONENT )
if( item->Type() != SCH_COMPONENT_T )
continue;
SCH_COMPONENT* comp = (SCH_COMPONENT*) item;
@ -882,7 +882,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByVal(
if( schItem == NULL )
continue;
if( schItem->Type() != TYPE_SCH_COMPONENT )
if( schItem->Type() != SCH_COMPONENT_T )
continue;
DrawLibItem = (SCH_COMPONENT*) schItem;

View File

@ -32,7 +32,8 @@ void InstallCmpeditFrame( SCH_EDIT_FRAME* parent, wxPoint& pos, SCH_COMPONENT* a
return;
parent->DrawPanel->m_IgnoreMouseEvents = TRUE;
if( aComponent->Type() != TYPE_SCH_COMPONENT )
if( aComponent->Type() != SCH_COMPONENT_T )
{
DisplayError( parent,
wxT( "InstallCmpeditFrame() error: This item is not a component" ) );

View File

@ -72,15 +72,15 @@ void DialogLabelEditor::InitDialog()
switch( m_CurrentText->Type() )
{
case TYPE_SCH_GLOBALLABEL:
case SCH_GLOBAL_LABEL_T:
SetTitle( _( "Global Label Properties" ) );
break;
case TYPE_SCH_HIERLABEL:
case SCH_HIERARCHICAL_LABEL_T:
SetTitle( _( "Hierarchal Label Properties" ) );
break;
case TYPE_SCH_LABEL:
case SCH_LABEL_T:
SetTitle( _( "Label Properties" ) );
break;
@ -150,8 +150,8 @@ void DialogLabelEditor::InitDialog()
m_Parent->m_InternalUnits );
m_TextSize->SetValue( msg );
if( m_CurrentText->Type() != TYPE_SCH_GLOBALLABEL
&& m_CurrentText->Type() != TYPE_SCH_HIERLABEL )
if( m_CurrentText->Type() != SCH_GLOBAL_LABEL_T
&& m_CurrentText->Type() != SCH_HIERARCHICAL_LABEL_T )
{
m_TextShape->Show( false );
}

View File

@ -319,7 +319,7 @@ void DIALOG_ERC::DisplayERC_MarkersList()
SCH_ITEM* DrawStruct = Sheet->LastDrawList();
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
{
if( DrawStruct->Type() != TYPE_SCH_MARKER )
if( DrawStruct->Type() != SCH_MARKER_T )
continue;
SCH_MARKER* Marker = (SCH_MARKER*) DrawStruct;

View File

@ -48,10 +48,10 @@ void SCH_EDIT_FRAME::StartMoveTexte( SCH_TEXT* TextStruct, wxDC* DC )
switch( TextStruct->Type() )
{
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
case TYPE_SCH_TEXT:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_TEXT_T:
ItemInitialPosition = TextStruct->m_Pos;
OldSize = TextStruct->m_Size;
OldOrient = TextStruct->GetSchematicTextOrientation();
@ -95,10 +95,10 @@ void SCH_EDIT_FRAME::ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC )
switch( TextStruct->Type() )
{
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
case TYPE_SCH_TEXT:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_TEXT_T:
orient = TextStruct->GetSchematicTextOrientation() + 1;
orient &= 3;
TextStruct->SetSchematicTextOrientation( orient );
@ -195,10 +195,10 @@ static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/* redraw the text */
switch( TextStruct->Type() )
{
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
case TYPE_SCH_TEXT:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_TEXT_T:
( (SCH_TEXT*) TextStruct )->m_Pos = panel->GetScreen()->m_Curseur;
break;
@ -238,10 +238,10 @@ static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC )
{
switch( Struct->Type() )
{
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
case TYPE_SCH_TEXT:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_TEXT_T:
{
SCH_TEXT* Text = (SCH_TEXT*) Struct;
Text->m_Pos = ItemInitialPosition;
@ -273,19 +273,19 @@ void SCH_EDIT_FRAME::ConvertTextType( SCH_TEXT* Text, wxDC* DC, int newtype )
switch( newtype )
{
case TYPE_SCH_LABEL:
case SCH_LABEL_T:
newtext = new SCH_LABEL( Text->m_Pos, Text->m_Text );
break;
case TYPE_SCH_GLOBALLABEL:
case SCH_GLOBAL_LABEL_T:
newtext = new SCH_GLOBALLABEL( Text->m_Pos, Text->m_Text );
break;
case TYPE_SCH_HIERLABEL:
case SCH_HIERARCHICAL_LABEL_T:
newtext = new SCH_HIERLABEL( Text->m_Pos, Text->m_Text );
break;
case TYPE_SCH_TEXT:
case SCH_TEXT_T:
newtext = new SCH_TEXT( Text->m_Pos, Text->m_Text );
break;

View File

@ -182,7 +182,7 @@ void DrawStructsInGhost( WinEDA_DrawPanel* aPanel,
switch( aItem->Type() )
{
case DRAW_POLYLINE_STRUCT_TYPE:
case SCH_POLYLINE_T:
{
SCH_POLYLINE* Struct = (SCH_POLYLINE*) aItem;
GRMoveTo( Struct->m_PolyPoints[0].x + aOffset.x,
@ -198,7 +198,7 @@ void DrawStructsInGhost( WinEDA_DrawPanel* aPanel,
break;
}
case DRAW_SEGMENT_STRUCT_TYPE:
case SCH_LINE_T:
{
SCH_LINE* Struct;
Struct = (SCH_LINE*) aItem;
@ -224,7 +224,7 @@ void DrawStructsInGhost( WinEDA_DrawPanel* aPanel,
break;
}
case DRAW_BUSENTRY_STRUCT_TYPE:
case SCH_BUS_ENTRY_T:
{
SCH_BUS_ENTRY* Struct = (SCH_BUS_ENTRY*) aItem;
wxPoint start = Struct->m_Pos + aOffset;
@ -234,7 +234,7 @@ void DrawStructsInGhost( WinEDA_DrawPanel* aPanel,
break;
}
case DRAW_JUNCTION_STRUCT_TYPE:
case SCH_JUNCTION_T:
{
SCH_JUNCTION* Struct;
Struct = (SCH_JUNCTION*) aItem;
@ -242,7 +242,7 @@ void DrawStructsInGhost( WinEDA_DrawPanel* aPanel,
break;
}
case TYPE_SCH_TEXT:
case SCH_TEXT_T:
{
SCH_TEXT* Struct;
Struct = (SCH_TEXT*) aItem;
@ -250,9 +250,9 @@ void DrawStructsInGhost( WinEDA_DrawPanel* aPanel,
break;
}
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
{
SCH_LABEL* Struct;
Struct = (SCH_LABEL*) aItem;
@ -260,7 +260,7 @@ void DrawStructsInGhost( WinEDA_DrawPanel* aPanel,
break;
}
case DRAW_NOCONNECT_STRUCT_TYPE:
case SCH_NO_CONNECT_T:
{
SCH_NO_CONNECT* Struct;
Struct = (SCH_NO_CONNECT*) aItem;
@ -268,7 +268,7 @@ void DrawStructsInGhost( WinEDA_DrawPanel* aPanel,
break;
}
case TYPE_SCH_COMPONENT:
case SCH_COMPONENT_T:
{
SCH_COMPONENT* Component = (SCH_COMPONENT*) aItem;
@ -279,7 +279,7 @@ void DrawStructsInGhost( WinEDA_DrawPanel* aPanel,
break;
}
case DRAW_SHEET_STRUCT_TYPE:
case SCH_SHEET_T:
{
SCH_SHEET* Struct = (SCH_SHEET*) aItem;
GRRect( &aPanel->m_ClipBox,
@ -293,8 +293,8 @@ void DrawStructsInGhost( WinEDA_DrawPanel* aPanel,
break;
}
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case TYPE_SCH_MARKER:
case SCH_SHEET_LABEL_T:
case SCH_MARKER_T:
break;
default:

View File

@ -174,13 +174,13 @@ int TestDuplicateSheetNames( bool aCreateMarker )
ref_item = ref_item->Next() )
{
// search for a sheet;
if( ref_item->Type() != DRAW_SHEET_STRUCT_TYPE )
if( ref_item->Type() != SCH_SHEET_T )
continue;
for( SCH_ITEM* item_to_test = ref_item->Next();
item_to_test != NULL;
item_to_test = item_to_test->Next() )
{
if( item_to_test->Type() != DRAW_SHEET_STRUCT_TYPE )
if( item_to_test->Type() != SCH_SHEET_T )
continue;
// We have found a second sheet: compare names
@ -532,7 +532,7 @@ bool WriteDiagnosticERC( const wxString& FullFileName )
DrawStruct = Sheet->LastDrawList();
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
{
if( DrawStruct->Type() != TYPE_SCH_MARKER )
if( DrawStruct->Type() != SCH_MARKER_T )
continue;
Marker = (SCH_MARKER*) DrawStruct;

View File

@ -31,7 +31,7 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event )
switch( curr_item->Type() )
{
case TYPE_SCH_COMPONENT:
case SCH_COMPONENT_T:
{
SCH_COMPONENT* newitem;
newitem = ((SCH_COMPONENT*) curr_item)->GenCopy();
@ -46,10 +46,10 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event )
}
break;
case TYPE_SCH_TEXT:
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
case SCH_TEXT_T:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
{
SCH_TEXT* newitem = ((SCH_TEXT*) curr_item)->GenCopy();
newitem->m_Flags = IS_NEW;

View File

@ -30,7 +30,7 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* screen, int FileSave )
FILE* f;
if( screen == NULL )
screen = (SCH_SCREEN*) GetScreen();
screen = GetScreen();
/* If no name exists in the window yet - save as new. */
if( screen->m_FileName.IsEmpty() )
@ -169,10 +169,12 @@ bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& FileName, bool IsNew )
{
SAFE_DELETE( g_RootSheet );
}
CreateScreens();
screen = (SCH_SCREEN*) GetScreen();
screen = GetScreen();
wxFileName fn = FullFileName;
if( fn.IsRelative() )
{
fn.MakeAbsolute();

View File

@ -46,12 +46,12 @@ void SCH_EDIT_FRAME::OnFindDrcMarker( wxFindDialogEvent& event )
if( event.GetFlags() & FR_CURRENT_SHEET_ONLY )
{
sheetFoundIn = m_CurrentSheet;
lastMarker = (SCH_MARKER*) m_CurrentSheet->FindNextItem( TYPE_SCH_MARKER,
lastMarker = (SCH_MARKER*) m_CurrentSheet->FindNextItem( SCH_MARKER_T,
lastMarker, wrap );
}
else
{
lastMarker = (SCH_MARKER*) schematic.FindNextItem( TYPE_SCH_MARKER, &sheetFoundIn,
lastMarker = (SCH_MARKER*) schematic.FindNextItem( SCH_MARKER_T, &sheetFoundIn,
lastMarker, wrap );
}
@ -126,7 +126,7 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere
for( ; ( DrawList != NULL ) && ( NotFound == true );
DrawList = DrawList->Next() )
{
if( DrawList->Type() == TYPE_SCH_COMPONENT )
if( DrawList->Type() == SCH_COMPONENT_T )
{
SCH_COMPONENT* pSch;
pSch = (SCH_COMPONENT*) DrawList;

View File

@ -411,7 +411,7 @@ void SCH_EDIT_FRAME::StartMovePart( SCH_COMPONENT* Component, wxDC* DC )
if( Component == NULL )
return;
if( Component->Type() != TYPE_SCH_COMPONENT )
if( Component->Type() != SCH_COMPONENT_T )
return;
if( Component->m_Flags == 0 )

View File

@ -201,7 +201,7 @@ void WinEDA_HierFrame::BuildSheetsTree( SCH_SHEET_PATH* list,
SCH_ITEM* schitem = list->LastDrawList();
while( schitem && m_nbsheets < NB_MAX_SHEET )
{
if( schitem->Type() == DRAW_SHEET_STRUCT_TYPE )
if( schitem->Type() == SCH_SHEET_T )
{
SCH_SHEET* sheet = (SCH_SHEET*) schitem;
m_nbsheets++;

View File

@ -507,7 +507,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
}
if( DrawStruct && DrawStruct->IsNew() && ( m_ID_current_state == ID_BUS_BUTT ) )
{
if( DrawStruct->Type() == DRAW_SEGMENT_STRUCT_TYPE )
if( DrawStruct->Type() == SCH_LINE_T )
{
SCH_LINE* segment = (SCH_LINE*) DrawStruct;
if( segment->GetLayer() != LAYER_BUS )
@ -530,7 +530,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
}
if( DrawStruct && DrawStruct->IsNew() && ( m_ID_current_state == ID_WIRE_BUTT ) )
{
if( DrawStruct->Type() == DRAW_SEGMENT_STRUCT_TYPE )
if( DrawStruct->Type() == SCH_LINE_T )
{
SCH_LINE* segment = (SCH_LINE*) DrawStruct;
if( segment->GetLayer() != LAYER_WIRE )
@ -564,7 +564,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
if( DrawStruct == NULL )
break;
if( DrawStruct->Type() == TYPE_SCH_COMPONENT )
if( DrawStruct->Type() == SCH_COMPONENT_T )
DrawStruct = LocateSmallestComponent( GetScreen() );
if( DrawStruct == NULL )
@ -585,21 +585,21 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
switch( DrawStruct->Type() )
{
case DRAW_SHEET_STRUCT_TYPE: //TODO allow sheet rotate on hotkey
case SCH_SHEET_T: //TODO allow sheet rotate on hotkey
//wxPostEvent( this, eventRotateSheet );
break;
case TYPE_SCH_COMPONENT:
case SCH_COMPONENT_T:
wxPostEvent( this, eventRotateComponent );
break;
case TYPE_SCH_TEXT:
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
case SCH_TEXT_T:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
wxPostEvent( this, eventRotateText );
break;
case DRAW_PART_TEXT_STRUCT_TYPE:
case SCH_FIELD_T:
wxPostEvent( this, eventRotateField );
default:
@ -616,7 +616,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
break;
}
if( DrawStruct == NULL )
DrawStruct = LocateSmallestComponent( (SCH_SCREEN*) GetScreen() );
DrawStruct = LocateSmallestComponent( GetScreen() );
if( DrawStruct )
{
if( DrawStruct->m_Flags == 0 )
@ -675,11 +675,11 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
if( DrawStruct == NULL )
break;
if( DrawStruct->Type() == TYPE_SCH_COMPONENT )
if( DrawStruct->Type() == SCH_COMPONENT_T )
DrawStruct = LocateSmallestComponent( GetScreen() );
if( DrawStruct == NULL )
break;
if( DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE )
if( DrawStruct->Type() == SCH_SHEET_T )
{
// If it's a sheet, then check if a pinsheet is under the cursor
SCH_SHEET_PIN* slabel = LocateSheetLabel( (SCH_SHEET*) DrawStruct,
@ -687,7 +687,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
if( slabel )
DrawStruct = slabel;
}
if( DrawStruct->Type() == DRAW_JUNCTION_STRUCT_TYPE )
if( DrawStruct->Type() == SCH_JUNCTION_T )
{
// If it's a junction, pick the underlying wire instead
DrawStruct = PickStruct( GetScreen()->m_Curseur, GetScreen(), WIREITEM );
@ -723,30 +723,30 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
{
// select the correct event for moving an schematic object
// and add it to the event queue
case DRAW_SHEET_STRUCT_TYPE:
case TYPE_SCH_COMPONENT:
case SCH_SHEET_T:
case SCH_COMPONENT_T:
wxPostEvent( this, eventMoveOrDragComponent );
break;
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
wxPostEvent( this, eventMoveOrDragComponent );
break;
case TYPE_SCH_TEXT:
case DRAW_PART_TEXT_STRUCT_TYPE:
case DRAW_BUSENTRY_STRUCT_TYPE:
case SCH_TEXT_T:
case SCH_FIELD_T:
case SCH_BUS_ENTRY_T:
if( HK_Descr->m_Idcommand != HK_DRAG )
wxPostEvent( this, eventMoveItem );
break;
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case SCH_SHEET_LABEL_T:
if( HK_Descr->m_Idcommand != HK_DRAG )
wxPostEvent( this, eventMovePinsheet );
break;
case DRAW_SEGMENT_STRUCT_TYPE:
case SCH_LINE_T:
if( ( (SCH_ITEM*) DrawStruct )->GetLayer() == LAYER_WIRE )
wxPostEvent( this, eventDragWire );
break;
@ -768,7 +768,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
LIBITEM | TEXTITEM | LABELITEM | SHEETITEM );
if( DrawStruct == NULL )
break;
if( DrawStruct->Type() == TYPE_SCH_COMPONENT )
if( DrawStruct->Type() == SCH_COMPONENT_T )
DrawStruct = LocateSmallestComponent( GetScreen() );
if( DrawStruct == NULL )
break;
@ -781,19 +781,19 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
switch( DrawStruct->Type() )
{
case TYPE_SCH_COMPONENT:
case SCH_COMPONENT_T:
InstallCmpeditFrame( this, MousePos, (SCH_COMPONENT*) DrawStruct );
break;
case DRAW_SHEET_STRUCT_TYPE:
case SCH_SHEET_T:
GetScreen()->SetCurItem( (SCH_ITEM*) DrawStruct );
wxPostEvent( this, eventEditPinsheet );
break;
case TYPE_SCH_TEXT:
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
case SCH_TEXT_T:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
EditSchematicText( (SCH_TEXT*) DrawStruct );
break;
@ -917,7 +917,7 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
case HK_REPEAT_LAST:
if( m_lastDrawItem && (m_lastDrawItem->m_Flags == 0)
&& ( m_lastDrawItem->Type() == COMPONENT_PIN_DRAW_TYPE ) )
&& ( m_lastDrawItem->Type() == LIB_PIN_T ) )
RepeatPinItem( DC, (LIB_PIN*) m_lastDrawItem );
break;
@ -928,21 +928,21 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
{
switch( m_drawItem->Type() )
{
case COMPONENT_PIN_DRAW_TYPE:
case LIB_PIN_T:
cmd.SetId( ID_LIBEDIT_EDIT_PIN );
GetEventHandler()->ProcessEvent( cmd );
break;
case COMPONENT_ARC_DRAW_TYPE:
case COMPONENT_CIRCLE_DRAW_TYPE:
case COMPONENT_RECT_DRAW_TYPE:
case COMPONENT_POLYLINE_DRAW_TYPE:
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
case LIB_ARC_T:
case LIB_CIRCLE_T:
case LIB_RECTANGLE_T:
case LIB_POLYLINE_T:
case LIB_TEXT_T:
cmd.SetId( ID_POPUP_LIBEDIT_BODY_EDIT_ITEM );
GetEventHandler()->ProcessEvent( cmd );
break;
case COMPONENT_FIELD_DRAW_TYPE:
case LIB_FIELD_T:
cmd.SetId( ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM );
GetEventHandler()->ProcessEvent( cmd );
break;
@ -960,17 +960,17 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
{
switch( m_drawItem->Type() )
{
case COMPONENT_PIN_DRAW_TYPE:
case LIB_PIN_T:
cmd.SetId( ID_LIBEDIT_ROTATE_PIN );
GetEventHandler()->ProcessEvent( cmd );
break;
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
case LIB_TEXT_T:
cmd.SetId( ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT );
GetEventHandler()->ProcessEvent( cmd );
break;
case COMPONENT_FIELD_DRAW_TYPE:
case LIB_FIELD_T:
cmd.SetId( ID_POPUP_LIBEDIT_FIELD_ROTATE_ITEM );
GetEventHandler()->ProcessEvent( cmd );
break;

View File

@ -53,7 +53,7 @@ static wxPoint calcCenter( const wxPoint& A, const wxPoint& B, const wxPoint& C
}
LIB_ARC::LIB_ARC( LIB_COMPONENT* aParent ) : LIB_DRAW_ITEM( COMPONENT_ARC_DRAW_TYPE, aParent )
LIB_ARC::LIB_ARC( LIB_COMPONENT* aParent ) : LIB_DRAW_ITEM( LIB_ARC_T, aParent )
{
m_Radius = 0;
m_t1 = 0;
@ -246,7 +246,7 @@ LIB_DRAW_ITEM* LIB_ARC::DoGenCopy()
int LIB_ARC::DoCompare( const LIB_DRAW_ITEM& aOther ) const
{
wxASSERT( aOther.Type() == COMPONENT_ARC_DRAW_TYPE );
wxASSERT( aOther.Type() == LIB_ARC_T );
const LIB_ARC* tmp = ( LIB_ARC* ) &aOther;
@ -427,7 +427,7 @@ void LIB_ARC::drawGraphic( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& a
}
EDA_Rect LIB_ARC::GetBoundingBox()
EDA_Rect LIB_ARC::GetBoundingBox() const
{
int minX, minY, maxX, maxY, angleStart, angleEnd;
EDA_Rect rect;

View File

@ -96,7 +96,7 @@ public:
*/
virtual bool HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTransform );
virtual EDA_Rect GetBoundingBox();
virtual EDA_Rect GetBoundingBox() const;
virtual void DisplayInfo( WinEDA_DrawFrame* frame );
/**

View File

@ -19,7 +19,7 @@
LIB_BEZIER::LIB_BEZIER( LIB_COMPONENT* aParent ) :
LIB_DRAW_ITEM( COMPONENT_BEZIER_DRAW_TYPE, aParent )
LIB_DRAW_ITEM( LIB_BEZIER_T, aParent )
{
m_Fill = NO_FILL;
m_Width = 0;
@ -129,7 +129,7 @@ LIB_DRAW_ITEM* LIB_BEZIER::DoGenCopy()
int LIB_BEZIER::DoCompare( const LIB_DRAW_ITEM& aOther ) const
{
wxASSERT( aOther.Type() == COMPONENT_BEZIER_DRAW_TYPE );
wxASSERT( aOther.Type() == LIB_BEZIER_T );
const LIB_BEZIER* tmp = ( LIB_BEZIER* ) &aOther;
@ -340,7 +340,7 @@ bool LIB_BEZIER::HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTra
* Function GetBoundingBox
* @return the boundary box for this, in library coordinates
*/
EDA_Rect LIB_BEZIER::GetBoundingBox()
EDA_Rect LIB_BEZIER::GetBoundingBox() const
{
EDA_Rect rect;
int xmin, xmax, ymin, ymax;

View File

@ -67,7 +67,7 @@ public:
/**
* @return the boundary box for this, in library coordinates
*/
virtual EDA_Rect GetBoundingBox();
virtual EDA_Rect GetBoundingBox() const;
/**
* @return the size of the "pen" that be used to draw or plot this item

View File

@ -17,7 +17,7 @@
LIB_CIRCLE::LIB_CIRCLE( LIB_COMPONENT* aParent ) :
LIB_DRAW_ITEM( COMPONENT_CIRCLE_DRAW_TYPE, aParent )
LIB_DRAW_ITEM( LIB_CIRCLE_T, aParent )
{
m_Radius = 0;
m_Fill = NO_FILL;
@ -124,7 +124,7 @@ LIB_DRAW_ITEM* LIB_CIRCLE::DoGenCopy()
int LIB_CIRCLE::DoCompare( const LIB_DRAW_ITEM& aOther ) const
{
wxASSERT( aOther.Type() == COMPONENT_CIRCLE_DRAW_TYPE );
wxASSERT( aOther.Type() == LIB_CIRCLE_T );
const LIB_CIRCLE* tmp = ( LIB_CIRCLE* ) &aOther;
@ -239,7 +239,7 @@ void LIB_CIRCLE::drawGraphic( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint
}
EDA_Rect LIB_CIRCLE::GetBoundingBox()
EDA_Rect LIB_CIRCLE::GetBoundingBox() const
{
EDA_Rect rect;

View File

@ -69,7 +69,7 @@ public:
*/
virtual int GetPenSize( );
virtual EDA_Rect GetBoundingBox();
virtual EDA_Rect GetBoundingBox() const;
virtual void DisplayInfo( WinEDA_DrawFrame* aFrame );
/**

View File

@ -227,10 +227,7 @@ public:
/**
* @return the boundary box for this, in library coordinates
*/
virtual EDA_Rect GetBoundingBox()
{
return EDA_ITEM::GetBoundingBox();
}
virtual EDA_Rect GetBoundingBox() const { return EDA_ITEM::GetBoundingBox(); }
/**
* Displays basic info (type, part and convert) about item

View File

@ -41,13 +41,13 @@
* others = free fields
*/
LIB_FIELD::LIB_FIELD(LIB_COMPONENT * aParent, int idfield ) :
LIB_DRAW_ITEM( COMPONENT_FIELD_DRAW_TYPE, aParent )
LIB_DRAW_ITEM( LIB_FIELD_T, aParent )
{
Init( idfield );
}
LIB_FIELD::LIB_FIELD( int idfield ) : LIB_DRAW_ITEM( COMPONENT_FIELD_DRAW_TYPE, NULL )
LIB_FIELD::LIB_FIELD( int idfield ) : LIB_DRAW_ITEM( LIB_FIELD_T, NULL )
{
Init( idfield );
}
@ -444,7 +444,7 @@ void LIB_FIELD::Copy( LIB_FIELD* Target ) const
int LIB_FIELD::DoCompare( const LIB_DRAW_ITEM& other ) const
{
wxASSERT( other.Type() == COMPONENT_FIELD_DRAW_TYPE );
wxASSERT( other.Type() == LIB_FIELD_T );
const LIB_FIELD* tmp = ( LIB_FIELD* ) &other;
@ -529,7 +529,7 @@ wxString LIB_FIELD::GetFullText( int unit )
}
EDA_Rect LIB_FIELD::GetBoundingBox()
EDA_Rect LIB_FIELD::GetBoundingBox() const
{
EDA_Rect rect = GetTextBox();
rect.m_Pos.y *= -1;

View File

@ -119,7 +119,7 @@ public:
* Return the bounding rectangle of the field text.
* @return Bounding rectangle.
*/
virtual EDA_Rect GetBoundingBox();
virtual EDA_Rect GetBoundingBox() const;
/**
* Displays info (type, part convert filed name and value)

View File

@ -160,7 +160,7 @@ extern void PlotPinSymbol( PLOTTER* plotter, const wxPoint& pos,
LIB_PIN::LIB_PIN( LIB_COMPONENT * aParent ) :
LIB_DRAW_ITEM( COMPONENT_PIN_DRAW_TYPE, aParent )
LIB_DRAW_ITEM( LIB_PIN_T, aParent )
{
m_length = 300; /* default Pin len */
m_orientation = PIN_RIGHT; /* Pin orient: Up, Down, Left, Right */
@ -1640,7 +1640,7 @@ LIB_DRAW_ITEM* LIB_PIN::DoGenCopy()
int LIB_PIN::DoCompare( const LIB_DRAW_ITEM& other ) const
{
wxASSERT( other.Type() == COMPONENT_PIN_DRAW_TYPE );
wxASSERT( other.Type() == LIB_PIN_T );
const LIB_PIN* tmp = ( LIB_PIN* ) &other;
@ -1771,7 +1771,7 @@ void LIB_PIN::DisplayInfo( WinEDA_DrawFrame* frame )
* Function GetBoundingBox
* @return the boundary box for this, in schematic coordinates
*/
EDA_Rect LIB_PIN::GetBoundingBox()
EDA_Rect LIB_PIN::GetBoundingBox() const
{
wxPoint pt = m_position;

View File

@ -153,7 +153,9 @@ public:
virtual bool HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTransform );
virtual void DisplayInfo( WinEDA_DrawFrame* frame );
virtual EDA_Rect GetBoundingBox();
virtual EDA_Rect GetBoundingBox() const;
wxPoint ReturnPinEndPoint() const;
int ReturnPinDrawOrient( const TRANSFORM& aTransform );

View File

@ -20,7 +20,7 @@
LIB_POLYLINE::LIB_POLYLINE( LIB_COMPONENT* aParent ) :
LIB_DRAW_ITEM( COMPONENT_POLYLINE_DRAW_TYPE, aParent )
LIB_DRAW_ITEM( LIB_POLYLINE_T, aParent )
{
m_Fill = NO_FILL;
m_Width = 0;
@ -132,7 +132,7 @@ LIB_DRAW_ITEM* LIB_POLYLINE::DoGenCopy()
int LIB_POLYLINE::DoCompare( const LIB_DRAW_ITEM& aOther ) const
{
wxASSERT( aOther.Type() == COMPONENT_POLYLINE_DRAW_TYPE );
wxASSERT( aOther.Type() == LIB_POLYLINE_T );
const LIB_POLYLINE* tmp = ( LIB_POLYLINE* ) &aOther;
@ -358,7 +358,7 @@ bool LIB_POLYLINE::HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aT
* Function GetBoundingBox
* @return the boundary box for this, in library coordinates
*/
EDA_Rect LIB_POLYLINE::GetBoundingBox()
EDA_Rect LIB_POLYLINE::GetBoundingBox() const
{
EDA_Rect rect;
int xmin, xmax, ymin, ymax;

View File

@ -81,7 +81,7 @@ public:
/**
* @return the boundary box for this, in library coordinates
*/
virtual EDA_Rect GetBoundingBox();
virtual EDA_Rect GetBoundingBox() const;
/**
* @return the size of the "pen" that be used to draw or plot this item

View File

@ -17,7 +17,7 @@
LIB_RECTANGLE::LIB_RECTANGLE( LIB_COMPONENT* aParent ) :
LIB_DRAW_ITEM( COMPONENT_RECT_DRAW_TYPE, aParent )
LIB_DRAW_ITEM( LIB_RECTANGLE_T, aParent )
{
m_Width = 0;
m_Fill = NO_FILL;
@ -90,7 +90,7 @@ LIB_DRAW_ITEM* LIB_RECTANGLE::DoGenCopy()
int LIB_RECTANGLE::DoCompare( const LIB_DRAW_ITEM& aOther ) const
{
wxASSERT( aOther.Type() == COMPONENT_RECT_DRAW_TYPE );
wxASSERT( aOther.Type() == LIB_RECTANGLE_T );
const LIB_RECTANGLE* tmp = ( LIB_RECTANGLE* ) &aOther;
@ -229,7 +229,7 @@ void LIB_RECTANGLE::DisplayInfo( WinEDA_DrawFrame* aFrame )
}
EDA_Rect LIB_RECTANGLE::GetBoundingBox()
EDA_Rect LIB_RECTANGLE::GetBoundingBox() const
{
EDA_Rect rect;

View File

@ -74,7 +74,8 @@ public:
*/
virtual int GetPenSize( );
virtual EDA_Rect GetBoundingBox();
virtual EDA_Rect GetBoundingBox() const;
virtual void DisplayInfo( WinEDA_DrawFrame* aFrame );
/**

View File

@ -25,7 +25,7 @@
LIB_TEXT::LIB_TEXT(LIB_COMPONENT * aParent) :
LIB_DRAW_ITEM( COMPONENT_GRAPHIC_TEXT_DRAW_TYPE, aParent ),
LIB_DRAW_ITEM( LIB_TEXT_T, aParent ),
EDA_TextStruct()
{
m_Size = wxSize( 50, 50 );
@ -198,7 +198,7 @@ LIB_DRAW_ITEM* LIB_TEXT::DoGenCopy()
int LIB_TEXT::DoCompare( const LIB_DRAW_ITEM& other ) const
{
wxASSERT( other.Type() == COMPONENT_GRAPHIC_TEXT_DRAW_TYPE );
wxASSERT( other.Type() == LIB_TEXT_T );
const LIB_TEXT* tmp = ( LIB_TEXT* ) &other;
@ -378,15 +378,12 @@ void LIB_TEXT::DisplayInfo( WinEDA_DrawFrame* frame )
/**
* @return the boundary box for this, in schematic coordinates
*/
EDA_Rect LIB_TEXT::GetBoundingBox()
EDA_Rect LIB_TEXT::GetBoundingBox() const
{
/* remenber Y coordinates in lib are bottom to top, so we must
* negate the Y position befire calling GetTextBox() that works using top to bottom
* Y axis orientation
/* Y coordinates for LIB_ITEMS are bottom to top, so we must invert the Y position when
* calling GetTextBox() that works using top to bottom Y axis orientation.
*/
NEGATE(m_Pos.y );
EDA_Rect rect = GetTextBox();
NEGATE(m_Pos.y ); // restore Y cooordinate for the graphic text
EDA_Rect rect = GetTextBox( -1, -1, true );
wxPoint orig = rect.GetOrigin();
wxPoint end = rect.GetEnd();

View File

@ -98,7 +98,7 @@ public:
virtual void DisplayInfo( WinEDA_DrawFrame* aFrame );
virtual EDA_Rect GetBoundingBox();
virtual EDA_Rect GetBoundingBox() const;
void Rotate();

View File

@ -40,7 +40,7 @@ bool LibArchive( wxWindow* frame, const wxString& ArchFullFileName )
{
for( SCH_ITEM* SchItem = screen->GetDrawItems(); SchItem; SchItem = SchItem->Next() )
{
if( SchItem->Type() != TYPE_SCH_COMPONENT )
if( SchItem->Type() != SCH_COMPONENT_T )
continue;
SCH_COMPONENT* component = (SCH_COMPONENT*) SchItem;

View File

@ -31,7 +31,7 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
{
switch( DrawEntry->Type() )
{
case COMPONENT_PIN_DRAW_TYPE:
case LIB_PIN_T:
PlacePin( DC );
DrawEntry = NULL;
break;
@ -113,7 +113,7 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
SaveCopyInUndoList( m_component );
if( DrawEntry->Type() == COMPONENT_PIN_DRAW_TYPE )
if( DrawEntry->Type() == LIB_PIN_T )
DeletePin( DC, m_component, (LIB_PIN*) DrawEntry );
else
m_component->RemoveDrawItem( DrawEntry, DrawPanel, DC );
@ -175,7 +175,7 @@ void LIB_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
switch( m_drawItem->Type() )
{
case COMPONENT_PIN_DRAW_TYPE:
case LIB_PIN_T:
if( m_drawItem->m_Flags == 0 )
{
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
@ -184,17 +184,16 @@ void LIB_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
}
break;
case COMPONENT_ARC_DRAW_TYPE:
case COMPONENT_CIRCLE_DRAW_TYPE:
case COMPONENT_RECT_DRAW_TYPE:
case LIB_ARC_T:
case LIB_CIRCLE_T:
case LIB_RECTANGLE_T:
if( m_drawItem->m_Flags == 0 )
{
EditGraphicSymbol( DC, m_drawItem );
}
break;
case COMPONENT_LINE_DRAW_TYPE:
case COMPONENT_POLYLINE_DRAW_TYPE:
case LIB_POLYLINE_T:
if( m_drawItem->m_Flags == 0 )
{
EditGraphicSymbol( DC, m_drawItem );
@ -205,14 +204,14 @@ void LIB_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
}
break;
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
case LIB_TEXT_T:
if( m_drawItem->m_Flags == 0 )
{
EditSymbolText( DC, m_drawItem );
}
break;
case COMPONENT_FIELD_DRAW_TYPE:
case LIB_FIELD_T:
if( m_drawItem->m_Flags == 0 )
{
EditField( DC, (LIB_FIELD*) m_drawItem );

View File

@ -74,189 +74,146 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu )
switch( DrawEntry->Type() )
{
case COMPONENT_PIN_DRAW_TYPE:
case LIB_PIN_T:
AddMenusForPin( PopMenu, (LIB_PIN*) DrawEntry, this );
break;
case COMPONENT_ARC_DRAW_TYPE:
case LIB_ARC_T:
if( DrawEntry->m_Flags == 0 )
{
msg = AddHotkeyName( _( "Move Arc" ), s_Libedit_Hokeys_Descr,
HK_LIBEDIT_MOVE_GRAPHIC_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST,
msg, move_arc_xpm );
msg = AddHotkeyName( _( "Drag Arc Size" ), s_Libedit_Hokeys_Descr,
HK_DRAG );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MODIFY_ITEM,
msg, move_arc_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST, msg, move_arc_xpm );
msg = AddHotkeyName( _( "Drag Arc Size" ), s_Libedit_Hokeys_Descr, HK_DRAG );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MODIFY_ITEM, msg, move_arc_xpm );
}
msg = AddHotkeyName( _( "Edit Arc Options" ), s_Libedit_Hokeys_Descr,
HK_EDIT );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_BODY_EDIT_ITEM,
msg, options_arc_xpm );
msg = AddHotkeyName( _( "Edit Arc Options" ), s_Libedit_Hokeys_Descr, HK_EDIT );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_BODY_EDIT_ITEM, msg, options_arc_xpm );
if( DrawEntry->m_Flags == 0 )
{
msg = AddHotkeyName( _( "Delete Arc" ), s_Libedit_Hokeys_Descr,
HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM,
msg, delete_arc_xpm );
msg = AddHotkeyName( _( "Delete Arc" ), s_Libedit_Hokeys_Descr, HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM, msg, delete_arc_xpm );
}
break;
case COMPONENT_CIRCLE_DRAW_TYPE:
case LIB_CIRCLE_T:
if( DrawEntry->m_Flags == 0 )
{
msg = AddHotkeyName( _( "Move Circle" ), s_Libedit_Hokeys_Descr,
HK_LIBEDIT_MOVE_GRAPHIC_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST,
msg, move_circle_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST, msg, move_circle_xpm );
}
if( DrawEntry->m_Flags == 0 )
{
msg = AddHotkeyName( _( "Drag Circle Outline" ), s_Libedit_Hokeys_Descr,
HK_DRAG );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MODIFY_ITEM,
msg, move_rectangle_xpm );
msg = AddHotkeyName( _( "Drag Circle Outline" ), s_Libedit_Hokeys_Descr, HK_DRAG );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MODIFY_ITEM, msg, move_rectangle_xpm );
}
msg = AddHotkeyName( _( "Edit Circle Options" ), s_Libedit_Hokeys_Descr,
HK_EDIT );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_BODY_EDIT_ITEM,
msg, options_circle_xpm );
msg = AddHotkeyName( _( "Edit Circle Options" ), s_Libedit_Hokeys_Descr, HK_EDIT );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_BODY_EDIT_ITEM, msg, options_circle_xpm );
if( DrawEntry->m_Flags == 0 )
{
msg = AddHotkeyName( _( "Delete Circle" ),
s_Libedit_Hokeys_Descr, HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM,
msg, delete_circle_xpm );
msg = AddHotkeyName( _( "Delete Circle" ), s_Libedit_Hokeys_Descr, HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM, msg, delete_circle_xpm );
}
break;
case COMPONENT_RECT_DRAW_TYPE:
case LIB_RECTANGLE_T:
if( DrawEntry->m_Flags == 0 )
{
msg = AddHotkeyName( _( "Move Rectangle" ), s_Libedit_Hokeys_Descr,
HK_LIBEDIT_MOVE_GRAPHIC_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST,
msg, move_rectangle_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST, msg, move_rectangle_xpm );
}
msg = AddHotkeyName( _( "Edit Rectangle Options" ), s_Libedit_Hokeys_Descr,
HK_EDIT );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_BODY_EDIT_ITEM,
msg, options_rectangle_xpm );
msg = AddHotkeyName( _( "Edit Rectangle Options" ), s_Libedit_Hokeys_Descr, HK_EDIT );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_BODY_EDIT_ITEM, msg, options_rectangle_xpm );
if( DrawEntry->m_Flags == 0 )
{
msg = AddHotkeyName( _( "Drag Rectangle Edge" ), s_Libedit_Hokeys_Descr,
HK_DRAG );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MODIFY_ITEM,
msg, move_rectangle_xpm );
msg = AddHotkeyName( _( "Drag Rectangle Edge" ), s_Libedit_Hokeys_Descr, HK_DRAG );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MODIFY_ITEM, msg, move_rectangle_xpm );
}
if( DrawEntry->m_Flags == 0 )
{
msg = AddHotkeyName( _( "Delete Rectangle" ), s_Libedit_Hokeys_Descr,
HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM,
msg, delete_rectangle_xpm );
msg = AddHotkeyName( _( "Delete Rectangle" ), s_Libedit_Hokeys_Descr, HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM, msg, delete_rectangle_xpm );
}
break;
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
case LIB_TEXT_T:
if( DrawEntry->m_Flags == 0 )
{
msg = AddHotkeyName( _( "Move Text" ), s_Libedit_Hokeys_Descr,
HK_LIBEDIT_MOVE_GRAPHIC_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST,
msg, move_text_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST, msg, move_text_xpm );
}
msg = AddHotkeyName( _( "Edit Text" ), s_Libedit_Hokeys_Descr,
HK_EDIT );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_BODY_EDIT_ITEM,
msg, edit_text_xpm );
msg = AddHotkeyName( _( "Edit Text" ), s_Libedit_Hokeys_Descr, HK_EDIT );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_BODY_EDIT_ITEM, msg, edit_text_xpm );
msg = AddHotkeyName( _( "Rotate Text" ), s_Libedit_Hokeys_Descr,
HK_ROTATE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT,
msg, edit_text_xpm );
msg = AddHotkeyName( _( "Rotate Text" ), s_Libedit_Hokeys_Descr, HK_ROTATE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT, msg, edit_text_xpm );
if( DrawEntry->m_Flags == 0 )
{
msg = AddHotkeyName( _( "Delete Text" ), s_Libedit_Hokeys_Descr,
HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM,
msg, delete_text_xpm );
msg = AddHotkeyName( _( "Delete Text" ), s_Libedit_Hokeys_Descr, HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM, msg, delete_text_xpm );
}
break;
case COMPONENT_POLYLINE_DRAW_TYPE:
case LIB_POLYLINE_T:
if( DrawEntry->m_Flags == 0 )
{
msg = AddHotkeyName( _( "Move Line" ), s_Libedit_Hokeys_Descr,
HK_LIBEDIT_MOVE_GRAPHIC_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST,
msg, move_line_xpm );
msg = AddHotkeyName( _( "Drag Edge Point" ), s_Libedit_Hokeys_Descr,
HK_DRAG );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MODIFY_ITEM,
msg, move_line_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST, msg, move_line_xpm );
msg = AddHotkeyName( _( "Drag Edge Point" ), s_Libedit_Hokeys_Descr, HK_DRAG );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MODIFY_ITEM, msg, move_line_xpm );
}
if( DrawEntry->m_Flags & IS_NEW )
{
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_END_CREATE_ITEM,
_( "Line End" ), apply_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_END_CREATE_ITEM, _( "Line End" ), apply_xpm );
}
msg = AddHotkeyName( _( "Edit Line Options" ), s_Libedit_Hokeys_Descr,
HK_EDIT );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_BODY_EDIT_ITEM,
msg, options_segment_xpm );
msg = AddHotkeyName( _( "Edit Line Options" ), s_Libedit_Hokeys_Descr, HK_EDIT );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_BODY_EDIT_ITEM, msg, options_segment_xpm );
if( DrawEntry->m_Flags == 0 )
{
msg = AddHotkeyName( _( "Delete Line " ), s_Libedit_Hokeys_Descr,
HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM,
msg, delete_segment_xpm );
msg = AddHotkeyName( _( "Delete Line " ), s_Libedit_Hokeys_Descr, HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM, msg, delete_segment_xpm );
}
else if( (DrawEntry->m_Flags & IS_NEW) )
{
if( ( (LIB_POLYLINE*) DrawEntry )->GetCornerCount() > 2 )
{
msg = AddHotkeyName( _( "Delete Segment" ),
s_Libedit_Hokeys_Descr, HK_DELETE );
ADD_MENUITEM( PopMenu,
ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT,
msg = AddHotkeyName( _( "Delete Segment" ), s_Libedit_Hokeys_Descr, HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT,
msg, delete_segment_xpm );
}
}
break;
case COMPONENT_FIELD_DRAW_TYPE:
case LIB_FIELD_T:
if( DrawEntry->m_Flags == 0 )
{
msg = AddHotkeyName( _( "Move Field" ), s_Libedit_Hokeys_Descr,
HK_LIBEDIT_MOVE_GRAPHIC_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST,
msg, move_field_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST, msg, move_field_xpm );
}
msg = AddHotkeyName( _( "Field Rotate" ), s_Libedit_Hokeys_Descr,
HK_ROTATE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_FIELD_ROTATE_ITEM,
msg, rotate_field_xpm );
msg = AddHotkeyName( _( "Field Edit" ), s_Libedit_Hokeys_Descr,
HK_EDIT );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM,
msg, edit_text_xpm );
msg = AddHotkeyName( _( "Field Rotate" ), s_Libedit_Hokeys_Descr, HK_ROTATE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_FIELD_ROTATE_ITEM, msg, rotate_field_xpm );
msg = AddHotkeyName( _( "Field Edit" ), s_Libedit_Hokeys_Descr, HK_EDIT );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM, msg, edit_text_xpm );
break;
@ -284,23 +241,21 @@ void AddMenusForPin( wxMenu* PopMenu, LIB_PIN* Pin, LIB_EDIT_FRAME* frame )
{
msg = AddHotkeyName( _( "Move Pin " ), s_Libedit_Hokeys_Descr,
HK_LIBEDIT_MOVE_GRAPHIC_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST,
msg, move_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST, msg, move_xpm );
}
msg = AddHotkeyName( _( "Edit Pin " ), s_Libedit_Hokeys_Descr, HK_EDIT);
ADD_MENUITEM( PopMenu, ID_LIBEDIT_EDIT_PIN, msg, edit_xpm );
msg = AddHotkeyName( _( "Rotate Pin " ), s_Libedit_Hokeys_Descr, HK_ROTATE );
ADD_MENUITEM( PopMenu, ID_LIBEDIT_ROTATE_PIN, msg, rotate_pin_xpm );
ADD_MENUITEM( PopMenu, ID_LIBEDIT_ROTATE_PIN, msg, rotate_pin_xpm );
if( not_in_move )
{
msg = AddHotkeyName( _( "Delete Pin " ), s_Libedit_Hokeys_Descr,
HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM,
msg, delete_pin_xpm );
msg = AddHotkeyName( _( "Delete Pin " ), s_Libedit_Hokeys_Descr, HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM, msg, delete_pin_xpm );
}
wxMenu* global_pin_change = new wxMenu;
ADD_MENUITEM_WITH_SUBMENU( PopMenu, global_pin_change,
ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_ITEM,
@ -324,8 +279,7 @@ void AddMenusForPin( wxMenu* PopMenu, LIB_PIN* Pin, LIB_EDIT_FRAME* frame )
void AddMenusForBlock( wxMenu* PopMenu, LIB_EDIT_FRAME* frame )
{
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_CANCEL_EDITING,
_( "Cancel Block" ), cancel_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_CANCEL_EDITING, _( "Cancel Block" ), cancel_xpm );
if( frame->GetScreen()->m_BlockLocate.m_Command == BLOCK_MOVE )
ADD_MENUITEM( PopMenu, ID_POPUP_ZOOM_BLOCK,
@ -334,18 +288,13 @@ void AddMenusForBlock( wxMenu* PopMenu, LIB_EDIT_FRAME* frame )
PopMenu->AppendSeparator();
ADD_MENUITEM( PopMenu, ID_POPUP_PLACE_BLOCK, _( "Place Block" ),
apply_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_PLACE_BLOCK, _( "Place Block" ), apply_xpm );
if( frame->GetScreen()->m_BlockLocate.m_Command == BLOCK_MOVE )
{
ADD_MENUITEM( PopMenu, ID_POPUP_SELECT_ITEMS_BLOCK,
_( "Select Items" ), green_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_COPY_BLOCK,
_( "Copy Block" ), copyblock_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_MIRROR_Y_BLOCK,
_( "Mirror Block ||" ), mirror_H_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_DELETE_BLOCK,
_( "Delete Block" ), delete_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SELECT_ITEMS_BLOCK, _( "Select Items" ), green_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_COPY_BLOCK, _( "Copy Block" ), copyblock_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_MIRROR_Y_BLOCK, _( "Mirror Block ||" ), mirror_H_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_DELETE_BLOCK, _( "Delete Block" ), delete_xpm );
}
}

View File

@ -47,8 +47,8 @@ void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event )
fn.SetExt( file_ext );
FullFileName = EDA_FileSelector( _( "Filename:" ), wxGetCwd(),
fn.GetFullName(), file_ext, mask, this,
wxFD_SAVE, TRUE );
fn.GetFullName(), file_ext, mask, this,
wxFD_SAVE, TRUE );
if( FullFileName.IsEmpty() )
return;
@ -67,8 +67,8 @@ void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event )
wxFileName fn( cmp->GetName() );
fn.SetExt( file_ext );
FullFileName = EDA_FileSelector( _( "Filename:" ), wxGetCwd(),
fn.GetFullName(), file_ext, mask, this,
wxFD_SAVE, TRUE );
fn.GetFullName(), file_ext, mask, this,
wxFD_SAVE, TRUE );
if( FullFileName.IsEmpty() )
return;
@ -77,8 +77,8 @@ void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event )
* the margin is 10% the size of the component size
*/
wxSize pagesize = GetScreen()->ReturnPageSize( );
wxSize componentSize =
m_component->GetBoundaryBox(m_unit, m_convert).m_Size;
wxSize componentSize = m_component->GetBoundingBox( m_unit, m_convert ).m_Size;
// Add a small margin to the plot bounding box
componentSize.x = (int)(componentSize.x * 1.2);
componentSize.y = (int)(componentSize.y * 1.2);

View File

@ -344,7 +344,7 @@ int LIB_EDIT_FRAME::BestZoom()
if( m_component )
{
BoundaryBox = m_component->GetBoundaryBox( m_unit, m_convert );
BoundaryBox = m_component->GetBoundingBox( m_unit, m_convert );
dx = BoundaryBox.GetWidth();
dy = BoundaryBox.GetHeight();
GetScreen()->m_Curseur = BoundaryBox.Centre();
@ -729,15 +729,14 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
switch( m_drawItem->Type() )
{
case COMPONENT_ARC_DRAW_TYPE:
case COMPONENT_CIRCLE_DRAW_TYPE:
case COMPONENT_RECT_DRAW_TYPE:
case COMPONENT_POLYLINE_DRAW_TYPE:
case COMPONENT_LINE_DRAW_TYPE:
case LIB_ARC_T:
case LIB_CIRCLE_T:
case LIB_RECTANGLE_T:
case LIB_POLYLINE_T:
EditGraphicSymbol( &dc, m_drawItem );
break;
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
case LIB_TEXT_T:
EditSymbolText( &dc, m_drawItem );
break;
@ -782,7 +781,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
DrawPanel->MouseToCursorSchema();
DrawPanel->CursorOff( &dc );
SaveCopyInUndoList( m_component );
if( m_drawItem->Type() == COMPONENT_PIN_DRAW_TYPE )
if( m_drawItem->Type() == LIB_PIN_T )
{
DeletePin( &dc, m_component, (LIB_PIN*) m_drawItem );
}
@ -803,7 +802,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
if( m_drawItem == NULL )
break;
DrawPanel->MouseToCursorSchema();
if( m_drawItem->Type() == COMPONENT_PIN_DRAW_TYPE )
if( m_drawItem->Type() == LIB_PIN_T )
StartMovePin( &dc );
else
StartMoveDrawSymbol( &dc );
@ -815,10 +814,10 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
DrawPanel->MouseToCursorSchema();
if( m_drawItem->Type() == COMPONENT_RECT_DRAW_TYPE
|| m_drawItem->Type() == COMPONENT_CIRCLE_DRAW_TYPE
|| m_drawItem->Type() == COMPONENT_POLYLINE_DRAW_TYPE
|| m_drawItem->Type() == COMPONENT_ARC_DRAW_TYPE
if( m_drawItem->Type() == LIB_RECTANGLE_T
|| m_drawItem->Type() == LIB_CIRCLE_T
|| m_drawItem->Type() == LIB_POLYLINE_T
|| m_drawItem->Type() == LIB_ARC_T
)
{
StartModifyDrawSymbol( &dc );
@ -827,7 +826,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT:
if( m_drawItem == NULL && m_drawItem->Type() != COMPONENT_GRAPHIC_TEXT_DRAW_TYPE )
if( m_drawItem == NULL && m_drawItem->Type() != LIB_TEXT_T )
break;
DrawPanel->MouseToCursorSchema();
if( !m_drawItem->InEditMode() )
@ -842,7 +841,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_LIBEDIT_FIELD_ROTATE_ITEM:
{
if( m_drawItem == NULL || ( m_drawItem->Type() != COMPONENT_FIELD_DRAW_TYPE ) )
if( m_drawItem == NULL || ( m_drawItem->Type() != LIB_FIELD_T ) )
break;
DrawPanel->MouseToCursorSchema();
@ -861,7 +860,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
if( m_drawItem == NULL )
break;
DrawPanel->CursorOff( &dc );
if( m_drawItem->Type() == COMPONENT_FIELD_DRAW_TYPE )
if( m_drawItem->Type() == LIB_FIELD_T )
{
EditField( &dc, (LIB_FIELD*) m_drawItem );
}
@ -873,7 +872,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM:
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM:
if( (m_drawItem == NULL )
|| (m_drawItem->Type() != COMPONENT_PIN_DRAW_TYPE) )
|| (m_drawItem->Type() != LIB_PIN_T) )
break;
SaveCopyInUndoList( m_component );
GlobalSetPins( &dc, (LIB_PIN*) m_drawItem, id );
@ -986,8 +985,10 @@ void LIB_EDIT_FRAME::RestoreComponent()
{
if( m_tempCopyComponent == NULL )
return;
if( m_component )
delete m_component;
m_component = m_tempCopyComponent;
m_tempCopyComponent = NULL;
}
@ -1013,14 +1014,13 @@ void LIB_EDIT_FRAME::SVG_Print_Component( const wxString& FullFileName )
void LIB_EDIT_FRAME::EditSymbolText( wxDC* DC, LIB_DRAW_ITEM* DrawItem )
{
if ( ( DrawItem == NULL ) || ( DrawItem->Type() != COMPONENT_GRAPHIC_TEXT_DRAW_TYPE ) )
if ( ( DrawItem == NULL ) || ( DrawItem->Type() != LIB_TEXT_T ) )
return;
/* Deleting old text. */
if( DC && !DrawItem->InEditMode() )
DrawItem->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, NULL, DefaultTransform );
DIALOG_LIB_EDIT_TEXT* frame = new DIALOG_LIB_EDIT_TEXT( this, (LIB_TEXT*) DrawItem );
frame->ShowModal();
frame->Destroy();

View File

@ -19,8 +19,6 @@
#include "template_fieldnames.h"
static bool IsItemInBox(EDA_Rect& aBox, SCH_ITEM* DrawStruct );
static SCH_ITEM* LastSnappedStruct = NULL;
static bool SnapPoint2( const wxPoint& aPosRef, int SearchMask,
SCH_ITEM* DrawList, double aScaleFactor );
@ -56,12 +54,12 @@ SCH_COMPONENT* LocateSmallestComponent( SCH_SCREEN* Screen )
if( lastcomponent == NULL ) // First time a component is located
{
lastcomponent = component;
BoundaryBox = lastcomponent->GetBoundaryBox();
BoundaryBox = lastcomponent->GetBoundingBox();
sizeref = ABS( (float) BoundaryBox.GetWidth() * BoundaryBox.GetHeight() );
}
else
{
BoundaryBox = component->GetBoundaryBox();
BoundaryBox = component->GetBoundingBox();
sizecurr = ABS( (float) BoundaryBox.GetWidth() * BoundaryBox.GetHeight() );
if( sizeref > sizecurr ) // a smallest component is found
@ -134,19 +132,18 @@ int PickItemsInBlock( BLOCK_SELECTOR& aBlock, SCH_SCREEN* aScreen )
EDA_Rect area;
area.SetOrigin( aBlock.GetOrigin());
area.SetSize( aBlock.GetSize() );
area.Normalize();
ITEM_PICKER picker;
SCH_ITEM* DrawStruct = aScreen->GetDrawItems();
SCH_ITEM* item = aScreen->GetDrawItems();
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
for( ; item != NULL; item = item->Next() )
{
if( IsItemInBox( area, DrawStruct ) )
if( item->HitTest( area ) )
{
/* Put this structure in the picked list: */
picker.m_PickedItem = DrawStruct;
picker.m_PickedItemType = DrawStruct->Type();
picker.m_PickedItem = item;
picker.m_PickedItemType = item->Type();
aBlock.PushItem( picker );
itemcount++;
}
@ -172,7 +169,7 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, SCH_ITEM* DrawList, dou
switch( DrawList->Type() )
{
case DRAW_POLYLINE_STRUCT_TYPE:
case SCH_POLYLINE_T:
#undef STRUCT
#define STRUCT ( (SCH_POLYLINE*) DrawList )
if( !( SearchMask & (DRAWITEM | WIREITEM | BUSITEM) ) )
@ -190,7 +187,7 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, SCH_ITEM* DrawList, dou
break;
case DRAW_SEGMENT_STRUCT_TYPE:
case SCH_LINE_T:
#undef STRUCT
#define STRUCT ( (SCH_LINE*) DrawList )
if( !( SearchMask & (DRAWITEM | WIREITEM | BUSITEM) ) )
@ -198,26 +195,15 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, SCH_ITEM* DrawList, dou
if( TestSegmentHit( aPosRef, STRUCT->m_Start, STRUCT->m_End, 0 ) )
{
if( ( ( SearchMask & DRAWITEM )
&& ( STRUCT->GetLayer() == LAYER_NOTES ) )
|| ( ( SearchMask & WIREITEM )
&& ( STRUCT->GetLayer() == LAYER_WIRE ) )
|| ( ( SearchMask & BUSITEM )
&& ( STRUCT->GetLayer() == LAYER_BUS ) )
)
if( ( ( SearchMask & DRAWITEM ) && ( STRUCT->GetLayer() == LAYER_NOTES ) )
|| ( ( SearchMask & WIREITEM ) && ( STRUCT->GetLayer() == LAYER_WIRE ) )
|| ( ( SearchMask & BUSITEM ) && ( STRUCT->GetLayer() == LAYER_BUS ) ) )
{
if( SearchMask & EXCLUDE_WIRE_BUS_ENDPOINTS )
{
if( aPosRef == STRUCT->m_Start
|| aPosRef == STRUCT->m_End )
break;
}
if( SearchMask & EXCLUDE_WIRE_BUS_ENDPOINTS && STRUCT->IsEndPoint( aPosRef ) )
break;
if( SearchMask & WIRE_BUS_ENDPOINTS_ONLY )
{
if( !STRUCT->IsOneEndPointAt( aPosRef ) )
break;
}
if( SearchMask & WIRE_BUS_ENDPOINTS_ONLY && !STRUCT->IsEndPoint( aPosRef ) )
break;
LastSnappedStruct = DrawList;
return true;
@ -226,21 +212,20 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, SCH_ITEM* DrawList, dou
break;
case DRAW_BUSENTRY_STRUCT_TYPE:
case SCH_BUS_ENTRY_T:
#undef STRUCT
#define STRUCT ( (SCH_BUS_ENTRY*) DrawList )
if( !( SearchMask & (RACCORDITEM) ) )
break;
if( TestSegmentHit( aPosRef, STRUCT->m_Pos, STRUCT->m_End(),
hitminDist ) )
if( TestSegmentHit( aPosRef, STRUCT->m_Pos, STRUCT->m_End(), hitminDist ) )
{
LastSnappedStruct = DrawList;
return true;
}
break;
case DRAW_JUNCTION_STRUCT_TYPE:
case SCH_JUNCTION_T:
#undef STRUCT
#define STRUCT ( (SCH_JUNCTION*) DrawList )
if( !(SearchMask & JUNCTIONITEM) )
@ -252,7 +237,7 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, SCH_ITEM* DrawList, dou
}
break;
case DRAW_NOCONNECT_STRUCT_TYPE:
case SCH_NO_CONNECT_T:
#undef STRUCT
#define STRUCT ( (SCH_NO_CONNECT*) DrawList )
if( !(SearchMask & NOCONNECTITEM) )
@ -264,7 +249,7 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, SCH_ITEM* DrawList, dou
}
break;
case TYPE_SCH_MARKER:
case SCH_MARKER_T:
{
#undef STRUCT
#define STRUCT ( (SCH_MARKER*) DrawList )
@ -278,7 +263,7 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, SCH_ITEM* DrawList, dou
break;
}
case TYPE_SCH_TEXT:
case SCH_TEXT_T:
#undef STRUCT
#define STRUCT ( (SCH_TEXT*) DrawList )
if( !( SearchMask & TEXTITEM) )
@ -291,9 +276,9 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, SCH_ITEM* DrawList, dou
break;
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
#undef STRUCT
#define STRUCT ( (SCH_TEXT*) DrawList ) // SCH_TEXT is the base
// class of these labels
@ -306,7 +291,7 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, SCH_ITEM* DrawList, dou
}
break;
case TYPE_SCH_COMPONENT:
case SCH_COMPONENT_T:
if( !( SearchMask & (LIBITEM | FIELDCMPITEM) ) )
break;
@ -323,7 +308,8 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, SCH_ITEM* DrawList, dou
if( field->IsVoid() )
continue;
EDA_Rect BoundaryBox = field->GetBoundaryBox();
EDA_Rect BoundaryBox = field->GetBoundingBox();
if( BoundaryBox.Inside( aPosRef ) )
{
LastSnappedStruct = field;
@ -335,7 +321,8 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, SCH_ITEM* DrawList, dou
{
#undef STRUCT
#define STRUCT ( (SCH_COMPONENT*) DrawList )
EDA_Rect BoundaryBox = STRUCT->GetBoundaryBox();
EDA_Rect BoundaryBox = STRUCT->GetBoundingBox();
if( BoundaryBox.Inside( aPosRef ) )
{
LastSnappedStruct = DrawList;
@ -344,7 +331,7 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, SCH_ITEM* DrawList, dou
}
break;
case DRAW_SHEET_STRUCT_TYPE:
case SCH_SHEET_T:
#undef STRUCT
#define STRUCT ( (SCH_SHEET*) DrawList )
if( !(SearchMask & SHEETITEM) )
@ -372,92 +359,6 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, SCH_ITEM* DrawList, dou
}
/*****************************************************************************
* Routine to test if an object has non empty intersection with the box *
* defined by x1/y1 and x2/y2 (x1 < x2, y1 < y2), and return true if so. This *
* routine is used to pick all points in a given box. *
*****************************************************************************/
bool IsItemInBox( EDA_Rect& aBox, SCH_ITEM* DrawStruct )
{
EDA_Rect BoundaryBox;
switch( DrawStruct->Type() )
{
case DRAW_POLYLINE_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (SCH_POLYLINE*) DrawStruct )
for( unsigned i = 0; i < STRUCT->GetCornerCount(); i++ )
{
if( aBox.Inside(STRUCT->m_PolyPoints[i]) )
return true;
}
break;
case DRAW_SEGMENT_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (SCH_LINE*) DrawStruct )
if( aBox.Inside(STRUCT->m_Start) )
return true;
if( aBox.Inside(STRUCT->m_End) )
return true;
break;
case DRAW_BUSENTRY_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (SCH_BUS_ENTRY*) DrawStruct )
if( aBox.Inside(STRUCT->m_Pos) )
return true;
if( aBox.Inside(STRUCT->m_End() ) )
return true;
break;
case DRAW_JUNCTION_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (SCH_JUNCTION*) DrawStruct )
if( aBox.Inside(STRUCT->m_Pos) )
return true;
break;
case DRAW_NOCONNECT_STRUCT_TYPE:
case TYPE_SCH_LABEL:
case TYPE_SCH_TEXT:
case TYPE_SCH_HIERLABEL:
case TYPE_SCH_GLOBALLABEL:
case DRAW_SHEET_STRUCT_TYPE:
case TYPE_SCH_MARKER:
BoundaryBox = DrawStruct->GetBoundingBox();
if( aBox.Intersects( BoundaryBox ) )
return true;
break;
case TYPE_SCH_COMPONENT:
// Use a more restrictive area than GetBoundingBox()
// Area is restricted to the body area, excludint fields outside this area
BoundaryBox = ((SCH_COMPONENT*)DrawStruct)->GetBoundaryBox();
if( aBox.Intersects( BoundaryBox ) )
return true;
break;
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
break;
default:
{
wxString msg;
msg.Printf( wxT( "IsItemInBox() Err: unexpected StructType %d (" ),
DrawStruct->Type() );
msg << DrawStruct->GetClass() << wxT( ")" );
wxMessageBox( msg );
break;
}
}
return FALSE;
}
SCH_SHEET_PIN* LocateSheetLabel( SCH_SHEET* Sheet, const wxPoint& pos )
{
return Sheet->GetLabel( pos );
@ -473,7 +374,7 @@ LIB_PIN* LocateAnyPin( SCH_ITEM* DrawList, const wxPoint& RefPos, SCH_COMPONENT*
for( DrawStruct = DrawList; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
{
if( DrawStruct->Type() != TYPE_SCH_COMPONENT )
if( DrawStruct->Type() != SCH_COMPONENT_T )
continue;
schItem = (SCH_COMPONENT*) DrawStruct;
@ -490,7 +391,7 @@ LIB_PIN* LocateAnyPin( SCH_ITEM* DrawList, const wxPoint& RefPos, SCH_COMPONENT*
wxPoint libPos = RefPos - schItem->m_Pos;
Pin = (LIB_PIN*) Entry->LocateDrawItem( schItem->m_Multi,
schItem->m_Convert,
COMPONENT_PIN_DRAW_TYPE,
LIB_PIN_T,
libPos, schItem->m_Transform );
if( Pin )
break;
@ -510,7 +411,7 @@ SCH_SHEET_PIN* LocateAnyPinSheet( const wxPoint& RefPos, SCH_ITEM* DrawList )
for( DrawStruct = DrawList; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
{
if( DrawStruct->Type() != DRAW_SHEET_STRUCT_TYPE )
if( DrawStruct->Type() != SCH_SHEET_T )
continue;
PinSheet = LocateSheetLabel( (SCH_SHEET*) DrawStruct, RefPos );

View File

@ -494,7 +494,7 @@ SCH_COMPONENT* EXPORT_HELP::findNextComponent( EDA_ITEM* aItem, SCH_SHEET_PATH*
// continue searching from the middle of a linked list (the draw list)
for( ; aItem; aItem = aItem->Next() )
{
if( aItem->Type() != TYPE_SCH_COMPONENT )
if( aItem->Type() != SCH_COMPONENT_T )
continue;
// found next component
@ -544,7 +544,7 @@ SCH_COMPONENT* EXPORT_HELP::findNextComponentAndCreatPinList( EDA_ITEM* aI
// continue searching from the middle of a linked list (the draw list)
for( ; aItem; aItem = aItem->Next() )
{
if( aItem->Type() != TYPE_SCH_COMPONENT )
if( aItem->Type() != SCH_COMPONENT_T )
continue;
// found next component
@ -591,7 +591,7 @@ SCH_COMPONENT* EXPORT_HELP::findNextComponentAndCreatPinList( EDA_ITEM* aI
{
LIB_PIN* pin = pins[i];
wxASSERT( pin->Type() == COMPONENT_PIN_DRAW_TYPE );
wxASSERT( pin->Type() == LIB_PIN_T );
addPinToComponentPinList( comp, aSheetPath, pin );
}
@ -1203,7 +1203,7 @@ bool EXPORT_HELP::WriteNetListPspice( SCH_EDIT_FRAME* frame, FILE* f, bool use_n
for( EDA_ITEM* item = sheet->LastDrawList(); item; item = item->Next() )
{
wxChar ident;
if( item->Type() != TYPE_SCH_TEXT )
if( item->Type() != SCH_TEXT_T )
continue;
SCH_TEXT* drawText = (SCH_TEXT*) item;
@ -1570,7 +1570,7 @@ void EXPORT_HELP::findAllInstancesOfComponent( SCH_COMPONENT* aComponent,
{
for( EDA_ITEM* item = sheet->LastDrawList(); item; item = item->Next() )
{
if( item->Type() != TYPE_SCH_COMPONENT )
if( item->Type() != SCH_COMPONENT_T )
continue;
SCH_COMPONENT* comp2 = (SCH_COMPONENT*) item;
@ -1583,7 +1583,7 @@ void EXPORT_HELP::findAllInstancesOfComponent( SCH_COMPONENT* aComponent,
for( LIB_PIN* pin = aEntry->GetNextPin(); pin; pin = aEntry->GetNextPin( pin ) )
{
wxASSERT( pin->Type() == COMPONENT_PIN_DRAW_TYPE );
wxASSERT( pin->Type() == LIB_PIN_T );
if( pin->GetUnit() && pin->GetUnit() != unit2 )
continue;

View File

@ -514,7 +514,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
{
switch( DrawList->Type() )
{
case DRAW_SEGMENT_STRUCT_TYPE:
case SCH_LINE_T:
#undef STRUCT
#define STRUCT ( (SCH_LINE*) DrawList )
if( (STRUCT->GetLayer() != LAYER_BUS)
@ -539,7 +539,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
aNetItemBuffer.push_back( new_item );
break;
case DRAW_JUNCTION_STRUCT_TYPE:
case SCH_JUNCTION_T:
#undef STRUCT
#define STRUCT ( (SCH_JUNCTION*) DrawList )
new_item = new NETLIST_OBJECT();
@ -553,7 +553,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
aNetItemBuffer.push_back( new_item );
break;
case DRAW_NOCONNECT_STRUCT_TYPE:
case SCH_NO_CONNECT_T:
#undef STRUCT
#define STRUCT ( (SCH_NO_CONNECT*) DrawList )
new_item = new NETLIST_OBJECT();
@ -567,7 +567,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
aNetItemBuffer.push_back( new_item );
break;
case TYPE_SCH_LABEL:
case SCH_LABEL_T:
#undef STRUCT
#define STRUCT ( (SCH_LABEL*) DrawList )
ii = IsBusLabel( STRUCT->m_Text );
@ -578,9 +578,9 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
new_item->m_Comp = STRUCT;
new_item->m_Type = NET_LABEL;
if( STRUCT->m_Layer == LAYER_GLOBLABEL )
if( STRUCT->GetLayer() == LAYER_GLOBLABEL )
new_item->m_Type = NET_GLOBLABEL;
if( STRUCT->m_Layer == LAYER_HIERLABEL )
if( STRUCT->GetLayer() == LAYER_HIERLABEL )
new_item->m_Type = NET_HIERLABEL;
new_item->m_Label = STRUCT->m_Text;
@ -594,8 +594,8 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
break;
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
#undef STRUCT
#define STRUCT ( (SCH_LABEL*) DrawList )
ii = IsBusLabel( STRUCT->m_Text );
@ -607,9 +607,9 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
// this is not the simplest way of doing it
// (look at the case statement above).
if( STRUCT->m_Layer == LAYER_GLOBLABEL )
if( STRUCT->GetLayer() == LAYER_GLOBLABEL )
new_item->m_Type = NET_GLOBLABEL;
if( STRUCT->m_Layer == LAYER_HIERLABEL )
if( STRUCT->GetLayer() == LAYER_HIERLABEL )
new_item->m_Type = NET_HIERLABEL;
new_item->m_Label = STRUCT->m_Text;
@ -623,7 +623,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
break;
case TYPE_SCH_COMPONENT:
case SCH_COMPONENT_T:
DrawLibItem = (SCH_COMPONENT*) DrawList;
Entry = CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );
@ -632,7 +632,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
for( LIB_PIN* pin = Entry->GetNextPin(); pin; pin = Entry->GetNextPin( pin ) )
{
wxASSERT( pin->Type() == COMPONENT_PIN_DRAW_TYPE );
wxASSERT( pin->Type() == LIB_PIN_T );
if( pin->GetUnit() &&
( pin->GetUnit() != DrawLibItem->GetUnitSelection( sheetlist ) ) )
@ -674,13 +674,13 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
}
break;
case DRAW_POLYLINE_STRUCT_TYPE:
case DRAW_BUSENTRY_STRUCT_TYPE:
case TYPE_SCH_MARKER:
case TYPE_SCH_TEXT:
case SCH_POLYLINE_T:
case SCH_BUS_ENTRY_T:
case SCH_MARKER_T:
case SCH_TEXT_T:
break;
case DRAW_SHEET_STRUCT_TYPE:
case SCH_SHEET_T:
{
#undef STRUCT
#define STRUCT ( (SCH_SHEET*) DrawList )
@ -710,7 +710,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
break;
}
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case SCH_SHEET_LABEL_T:
default:
{
wxString msg;

View File

@ -39,29 +39,28 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
{
switch( DrawStruct->Type() )
{
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
case TYPE_SCH_TEXT:
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case DRAW_SHEET_STRUCT_TYPE:
case DRAW_BUSENTRY_STRUCT_TYPE:
case DRAW_JUNCTION_STRUCT_TYPE:
case TYPE_SCH_COMPONENT:
case DRAW_PART_TEXT_STRUCT_TYPE:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_TEXT_T:
case SCH_SHEET_LABEL_T:
case SCH_SHEET_T:
case SCH_BUS_ENTRY_T:
case SCH_JUNCTION_T:
case SCH_COMPONENT_T:
case SCH_FIELD_T:
DrawStruct->Place( this, DC );
GetScreen()->SetCurItem( NULL );
TestDanglingEnds( GetScreen()->GetDrawItems(), NULL );
DrawPanel->Refresh( TRUE );
return;
case SCREEN_STRUCT_TYPE:
DisplayError( this,
wxT( "OnLeftClick err: unexpected type for Place" ) );
case SCH_SCREEN_T:
DisplayError( this, wxT( "OnLeftClick err: unexpected type for Place" ) );
DrawStruct->m_Flags = 0;
break;
case DRAW_SEGMENT_STRUCT_TYPE: // May already be drawing segment.
case SCH_LINE_T: // May already be drawing segment.
break;
default:
@ -93,7 +92,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
if( DrawStruct && DrawStruct->m_Flags )
break;
DrawStruct = SchematicGeneralLocateAndDisplay();
if( DrawStruct && ( DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE ) )
if( DrawStruct && ( DrawStruct->Type() == SCH_SHEET_T ) )
{
InstallNextScreen( (SCH_SHEET*) DrawStruct );
}
@ -120,9 +119,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
case ID_JUNCTION_BUTT:
if( ( DrawStruct == NULL ) || ( DrawStruct->m_Flags == 0 ) )
{
g_ItemToRepeat = CreateNewJunctionStruct( DC,
GetScreen()->m_Curseur,
TRUE );
g_ItemToRepeat = CreateNewJunctionStruct( DC, GetScreen()->m_Curseur, TRUE );
GetScreen()->SetCurItem( g_ItemToRepeat );
DrawPanel->m_AutoPAN_Request = TRUE;
}
@ -139,10 +136,9 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
case ID_BUSTOBUS_ENTRY_BUTT:
if( ( DrawStruct == NULL ) || ( DrawStruct->m_Flags == 0 ) )
{
DrawStruct =
CreateBusEntry( DC,
(m_ID_current_state == ID_WIRETOBUS_ENTRY_BUTT) ?
WIRE_TO_BUS : BUS_TO_BUS );
DrawStruct = CreateBusEntry( DC,
(m_ID_current_state == ID_WIRETOBUS_ENTRY_BUTT) ?
WIRE_TO_BUS : BUS_TO_BUS );
GetScreen()->SetCurItem( DrawStruct );
DrawPanel->m_AutoPAN_Request = TRUE;
}
@ -249,18 +245,15 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
if( DrawStruct == NULL )
break;
if( (DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE)
if( (DrawStruct->Type() == SCH_SHEET_T)
&& (DrawStruct->m_Flags == 0) )
{
if( m_ID_current_state == ID_IMPORT_HLABEL_BUTT )
GetScreen()->SetCurItem(
Import_PinSheet( (SCH_SHEET*) DrawStruct, DC ) );
GetScreen()->SetCurItem( Import_PinSheet( (SCH_SHEET*) DrawStruct, DC ) );
else
GetScreen()->SetCurItem(
Create_PinSheet( (SCH_SHEET*) DrawStruct, DC ) );
GetScreen()->SetCurItem( Create_PinSheet( (SCH_SHEET*) DrawStruct, DC ) );
}
else if( (DrawStruct->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE)
&& (DrawStruct->m_Flags != 0) )
else if( (DrawStruct->Type() == SCH_SHEET_LABEL_T) && (DrawStruct->m_Flags != 0) )
{
DrawStruct->Place( this, DC );
TestDanglingEnds( GetScreen()->GetDrawItems(), NULL );
@ -271,8 +264,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
case ID_COMPONENT_BUTT:
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
GetScreen()->SetCurItem( Load_Component( DC, wxEmptyString,
s_CmpNameList, TRUE ) );
GetScreen()->SetCurItem( Load_Component( DC, wxEmptyString, s_CmpNameList, TRUE ) );
DrawPanel->m_AutoPAN_Request = TRUE;
}
else
@ -287,8 +279,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
case ID_PLACE_POWER_BUTT:
if( ( DrawStruct == NULL ) || ( DrawStruct->m_Flags == 0 ) )
{
GetScreen()->SetCurItem(
Load_Component( DC, wxT( "power" ), s_PowerNameList, FALSE ) );
GetScreen()->SetCurItem( Load_Component( DC, wxT( "power" ), s_PowerNameList, FALSE ) );
DrawPanel->m_AutoPAN_Request = TRUE;
}
else
@ -340,28 +331,28 @@ void SCH_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
switch( DrawStruct->Type() )
{
case DRAW_SHEET_STRUCT_TYPE:
case SCH_SHEET_T:
InstallNextScreen( (SCH_SHEET*) DrawStruct );
break;
case TYPE_SCH_COMPONENT:
case SCH_COMPONENT_T:
InstallCmpeditFrame( this, pos, (SCH_COMPONENT*) DrawStruct );
DrawPanel->MouseToCursorSchema();
break;
case TYPE_SCH_TEXT:
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
case SCH_TEXT_T:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
EditSchematicText( (SCH_TEXT*) DrawStruct );
break;
case DRAW_PART_TEXT_STRUCT_TYPE:
case SCH_FIELD_T:
EditCmpFieldText( (SCH_FIELD*) DrawStruct, DC );
DrawPanel->MouseToCursorSchema();
break;
case TYPE_SCH_MARKER:
case SCH_MARKER_T:
( (SCH_MARKER*) DrawStruct )->DisplayMarkerInfo( this );
break;

View File

@ -65,7 +65,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu )
{
DrawStruct = SchematicGeneralLocateAndDisplay( false );
if( DrawStruct && (DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE) )
if( DrawStruct && (DrawStruct->Type() == SCH_SHEET_T) )
{
SCH_SHEET_PIN* slabel;
slabel = LocateSheetLabel( (SCH_SHEET*) DrawStruct, GetScreen()->m_Curseur );
@ -113,16 +113,16 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu )
switch( DrawStruct->Type() )
{
case DRAW_NOCONNECT_STRUCT_TYPE:
case SCH_NO_CONNECT_T:
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Noconn" ), delete_xpm );
break;
case DRAW_JUNCTION_STRUCT_TYPE:
case SCH_JUNCTION_T:
AddMenusForJunction( PopMenu, (SCH_JUNCTION*) DrawStruct, this );
break;
case DRAW_BUSENTRY_STRUCT_TYPE:
case SCH_BUS_ENTRY_T:
if( !flags )
{
wxString msg = AddHotkeyName( _( "Move Bus Entry" ), s_Schematic_Hokeys_Descr,
@ -137,36 +137,36 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Bus Entry" ), delete_bus_xpm );
break;
case TYPE_SCH_MARKER:
case SCH_MARKER_T:
AddMenusForMarkers( PopMenu, (SCH_MARKER*) DrawStruct, this );
break;
case TYPE_SCH_TEXT:
case SCH_TEXT_T:
AddMenusForText( PopMenu, (SCH_TEXT*) DrawStruct );
break;
case TYPE_SCH_LABEL:
case SCH_LABEL_T:
AddMenusForLabel( PopMenu, (SCH_LABEL*) DrawStruct );
break;
case TYPE_SCH_GLOBALLABEL:
case SCH_GLOBAL_LABEL_T:
AddMenusForGLabel( PopMenu, (SCH_GLOBALLABEL*) DrawStruct );
break;
case TYPE_SCH_HIERLABEL:
case SCH_HIERARCHICAL_LABEL_T:
AddMenusForHLabel( PopMenu, (SCH_HIERLABEL*) DrawStruct );
break;
case DRAW_PART_TEXT_STRUCT_TYPE:
case SCH_FIELD_T:
{
AddMenusForComponentField( PopMenu, (SCH_FIELD*) DrawStruct );
if( flags )
break;
// Many fields are inside a component. If this is the case, add the
// component menu
SCH_COMPONENT* Component =
LocateSmallestComponent( (SCH_SCREEN*) GetScreen() );
SCH_COMPONENT* Component = LocateSmallestComponent( GetScreen() );
if( Component )
{
@ -176,11 +176,11 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu )
}
break;
case TYPE_SCH_COMPONENT:
case SCH_COMPONENT_T:
AddMenusForComponent( PopMenu, (SCH_COMPONENT*) DrawStruct );
break;
case DRAW_SEGMENT_STRUCT_TYPE:
case SCH_LINE_T:
// if( !flags ) PopMenu->Append(ID_POPUP_SCH_MOVE_ITEM_REQUEST, "Move");
switch( DrawStruct->GetLayer() )
@ -202,11 +202,11 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu )
break;
case DRAW_SHEET_STRUCT_TYPE:
case SCH_SHEET_T:
AddMenusForHierchicalSheet( PopMenu, (SCH_SHEET*) DrawStruct );
break;
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case SCH_SHEET_LABEL_T:
AddMenusForPinSheet( PopMenu, (SCH_SHEET_PIN*) DrawStruct );
break;
@ -243,7 +243,7 @@ void AddMenusForComponentField( wxMenu* PopMenu, SCH_FIELD* Field )
void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
{
if( Component->Type() != TYPE_SCH_COMPONENT )
if( Component->Type() != SCH_COMPONENT_T )
{
wxASSERT( 0 );
return;

View File

@ -92,11 +92,11 @@ void DeleteItemsInList( WinEDA_DrawPanel* panel, PICKED_ITEMS_LIST& aItemsList )
itemWrapper.m_PickedItem = item;
itemWrapper.m_UndoRedoStatus = UR_DELETED;
if( item->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
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 \
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE" ) );
SCH_SHEET_LABEL_T" ) );
}
else
{
@ -124,7 +124,7 @@ void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM* DrawStruct )
if( !DrawStruct )
return;
if( DrawStruct->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
if( DrawStruct->Type() == SCH_SHEET_LABEL_T )
{
/* This structure is attached to a node, and is not accessible by
* the global list directly. */
@ -168,21 +168,21 @@ void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList,
{
switch( newitem->Type() )
{
case DRAW_POLYLINE_STRUCT_TYPE:
case DRAW_JUNCTION_STRUCT_TYPE:
case DRAW_SEGMENT_STRUCT_TYPE:
case DRAW_BUSENTRY_STRUCT_TYPE:
case TYPE_SCH_TEXT:
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case TYPE_SCH_MARKER:
case DRAW_NOCONNECT_STRUCT_TYPE:
case SCH_POLYLINE_T:
case SCH_JUNCTION_T:
case SCH_LINE_T:
case SCH_BUS_ENTRY_T:
case SCH_TEXT_T:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_SHEET_LABEL_T:
case SCH_MARKER_T:
case SCH_NO_CONNECT_T:
default:
break;
case DRAW_SHEET_STRUCT_TYPE:
case SCH_SHEET_T:
{
SCH_SHEET* sheet = (SCH_SHEET*) newitem;
sheet->m_TimeStamp = GetTimeStamp();
@ -190,7 +190,7 @@ void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList,
break;
}
case TYPE_SCH_COMPONENT:
case SCH_COMPONENT_T:
( (SCH_COMPONENT*) newitem )->m_TimeStamp = GetTimeStamp();
( (SCH_COMPONENT*) newitem )->ClearAnnotation( NULL );
break;
@ -228,51 +228,51 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* aDrawStruct, bool aClone )
switch( aDrawStruct->Type() )
{
case DRAW_POLYLINE_STRUCT_TYPE:
case SCH_POLYLINE_T:
NewDrawStruct = ( (SCH_POLYLINE*) aDrawStruct )->GenCopy();
break;
case DRAW_SEGMENT_STRUCT_TYPE:
case SCH_LINE_T:
NewDrawStruct = ( (SCH_LINE*) aDrawStruct )->GenCopy();
break;
case DRAW_BUSENTRY_STRUCT_TYPE:
case SCH_BUS_ENTRY_T:
NewDrawStruct = ( (SCH_BUS_ENTRY*) aDrawStruct )->GenCopy();
break;
case DRAW_JUNCTION_STRUCT_TYPE:
case SCH_JUNCTION_T:
NewDrawStruct = ( (SCH_JUNCTION*) aDrawStruct )->GenCopy();
break;
case TYPE_SCH_MARKER:
case SCH_MARKER_T:
NewDrawStruct = ( (SCH_MARKER*) aDrawStruct )->GenCopy();
break;
case DRAW_NOCONNECT_STRUCT_TYPE:
case SCH_NO_CONNECT_T:
NewDrawStruct = ( (SCH_NO_CONNECT*) aDrawStruct )->GenCopy();
break;
case TYPE_SCH_TEXT:
case SCH_TEXT_T:
NewDrawStruct = ( (SCH_TEXT*) aDrawStruct )->GenCopy();
break;
case TYPE_SCH_LABEL:
case SCH_LABEL_T:
NewDrawStruct = ( (SCH_LABEL*) aDrawStruct )->GenCopy();
break;
case TYPE_SCH_HIERLABEL:
case SCH_HIERARCHICAL_LABEL_T:
NewDrawStruct = ( (SCH_HIERLABEL*) aDrawStruct )->GenCopy();
break;
case TYPE_SCH_GLOBALLABEL:
case SCH_GLOBAL_LABEL_T:
NewDrawStruct = ( (SCH_GLOBALLABEL*) aDrawStruct )->GenCopy();
break;
case TYPE_SCH_COMPONENT:
case SCH_COMPONENT_T:
NewDrawStruct = ( (SCH_COMPONENT*) aDrawStruct )->GenCopy();
break;
case DRAW_SHEET_STRUCT_TYPE:
case SCH_SHEET_T:
NewDrawStruct = ( (SCH_SHEET*) aDrawStruct )->GenCopy();
if( aClone )
{

View File

@ -43,7 +43,7 @@ void LIB_EDIT_FRAME::OnRotatePin( wxCommandEvent& event )
{
// Check, if the item is a pin, else return
if( m_drawItem == NULL || m_drawItem->Type() != COMPONENT_PIN_DRAW_TYPE )
if( m_drawItem == NULL || m_drawItem->Type() != LIB_PIN_T )
return;
// save flags to restore them after rotating
@ -77,7 +77,7 @@ void LIB_EDIT_FRAME::OnRotatePin( wxCommandEvent& event )
void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event )
{
if( m_drawItem == NULL || m_drawItem->Type() != COMPONENT_PIN_DRAW_TYPE )
if( m_drawItem == NULL || m_drawItem->Type() != LIB_PIN_T )
return;
int item_flags = m_drawItem->m_Flags; // save flags to restore them after editing
@ -186,7 +186,7 @@ static void AbortPinMove( WinEDA_DrawPanel* Panel, wxDC* DC )
LIB_PIN* CurrentPin = (LIB_PIN*) parent->GetDrawItem();
if( CurrentPin == NULL || CurrentPin->Type() != COMPONENT_PIN_DRAW_TYPE )
if( CurrentPin == NULL || CurrentPin->Type() != LIB_PIN_T )
return;
if( CurrentPin->m_Flags & IS_NEW )
@ -215,7 +215,7 @@ void LIB_EDIT_FRAME::PlacePin( wxDC* DC )
bool status;
// Some tests
if( (CurrentPin == NULL) || (CurrentPin->Type() != COMPONENT_PIN_DRAW_TYPE) )
if( (CurrentPin == NULL) || (CurrentPin->Type() != LIB_PIN_T) )
{
wxMessageBox( wxT("LIB_EDIT_FRAME::PlacePin() error") );
return;
@ -346,7 +346,7 @@ static void DrawMovePin( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
LIB_PIN* CurrentPin = (LIB_PIN*) parent->GetDrawItem();
if( CurrentPin == NULL || CurrentPin->Type() != COMPONENT_PIN_DRAW_TYPE )
if( CurrentPin == NULL || CurrentPin->Type() != LIB_PIN_T )
return;
wxPoint pinpos = CurrentPin->GetPosition();
@ -543,7 +543,7 @@ void LIB_EDIT_FRAME::GlobalSetPins( wxDC* DC, LIB_PIN* MasterPin, int id )
if( ( m_component == NULL ) || ( MasterPin == NULL ) )
return;
if( MasterPin->Type() != COMPONENT_PIN_DRAW_TYPE )
if( MasterPin->Type() != LIB_PIN_T )
return;
OnModify( );
@ -588,7 +588,7 @@ void LIB_EDIT_FRAME::RepeatPinItem( wxDC* DC, LIB_PIN* SourcePin )
LIB_PIN* Pin;
wxString msg;
if( m_component == NULL || SourcePin == NULL || SourcePin->Type() != COMPONENT_PIN_DRAW_TYPE )
if( m_component == NULL || SourcePin == NULL || SourcePin->Type() != LIB_PIN_T )
return;
Pin = (LIB_PIN*) SourcePin->GenCopy();

View File

@ -108,7 +108,7 @@ static void PlotTextField( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem,
* so the more easily way is to use no justifications ( Centered text )
* and use GetBoundaryBox to know the text coordinate considered as centered
*/
EDA_Rect BoundaryBox = field->GetBoundaryBox();
EDA_Rect BoundaryBox = field->GetBoundingBox();
GRTextHorizJustifyType hjustify = GR_TEXT_HJUSTIFY_CENTER;
GRTextVertJustifyType vjustify = GR_TEXT_VJUSTIFY_CENTER;
wxPoint textpos = BoundaryBox.Centre();
@ -246,11 +246,11 @@ static void PlotTextStruct( PLOTTER* plotter, SCH_TEXT* aSchText )
switch( aSchText->Type() )
{
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
case TYPE_SCH_LABEL:
case TYPE_SCH_TEXT:
case SCH_SHEET_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_LABEL_T:
case SCH_TEXT_T:
break;
default:
@ -258,7 +258,7 @@ static void PlotTextStruct( PLOTTER* plotter, SCH_TEXT* aSchText )
}
EDA_Colors color = UNSPECIFIED_COLOR;
color = ReturnLayerColor( aSchText->m_Layer );
color = ReturnLayerColor( aSchText->GetLayer() );
wxPoint textpos = aSchText->m_Pos + aSchText->GetSchematicTextOffset();
int thickness = aSchText->GetPenSize();
@ -387,9 +387,9 @@ void PlotDrawlist( PLOTTER* plotter, SCH_ITEM* aDrawlist )
plotter->set_current_line_width( aDrawlist->GetPenSize() );
switch( aDrawlist->Type() )
{
case DRAW_BUSENTRY_STRUCT_TYPE:
case DRAW_SEGMENT_STRUCT_TYPE:
if( aDrawlist->Type() == DRAW_BUSENTRY_STRUCT_TYPE )
case SCH_BUS_ENTRY_T:
case SCH_LINE_T:
if( aDrawlist->Type() == SCH_BUS_ENTRY_T )
{
#undef STRUCT
#define STRUCT ( (SCH_BUS_ENTRY*) aDrawlist )
@ -417,39 +417,39 @@ void PlotDrawlist( PLOTTER* plotter, SCH_ITEM* aDrawlist )
break;
case DRAW_JUNCTION_STRUCT_TYPE:
case SCH_JUNCTION_T:
#undef STRUCT
#define STRUCT ( (SCH_JUNCTION*) aDrawlist )
plotter->set_color( ReturnLayerColor( STRUCT->GetLayer() ) );
plotter->circle( STRUCT->m_Pos, STRUCT->m_Size.x, FILLED_SHAPE );
break;
case TYPE_SCH_TEXT:
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
case SCH_TEXT_T:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
PlotTextStruct( plotter, (SCH_TEXT*) aDrawlist );
break;
case TYPE_SCH_COMPONENT:
case SCH_COMPONENT_T:
DrawLibItem = (SCH_COMPONENT*) aDrawlist;
PlotLibPart( plotter, DrawLibItem );
break;
case DRAW_POLYLINE_STRUCT_TYPE:
case SCH_POLYLINE_T:
break;
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case SCH_SHEET_LABEL_T:
break;
case TYPE_SCH_MARKER:
case SCH_MARKER_T:
break;
case DRAW_SHEET_STRUCT_TYPE:
case SCH_SHEET_T:
PlotSheetStruct( plotter, (SCH_SHEET*) aDrawlist );
break;
case DRAW_NOCONNECT_STRUCT_TYPE:
case SCH_NO_CONNECT_T:
plotter->set_color( ReturnLayerColor( LAYER_NOCONNECT ) );
PlotNoConnectStruct( plotter, (SCH_NO_CONNECT*) aDrawlist );
break;

View File

@ -64,7 +64,7 @@ void CreateDummyCmp()
SCH_COMPONENT::SCH_COMPONENT( const wxPoint& aPos, SCH_ITEM* aParent ) :
SCH_ITEM( aParent, TYPE_SCH_COMPONENT )
SCH_ITEM( aParent, SCH_COMPONENT_T )
{
Init( aPos );
}
@ -73,7 +73,7 @@ SCH_COMPONENT::SCH_COMPONENT( const wxPoint& aPos, SCH_ITEM* aParent ) :
SCH_COMPONENT::SCH_COMPONENT( LIB_COMPONENT& libComponent,
SCH_SHEET_PATH* sheet, int unit, int convert,
const wxPoint& pos, bool setNewItemFlag ) :
SCH_ITEM( NULL, TYPE_SCH_COMPONENT )
SCH_ITEM( NULL, SCH_COMPONENT_T )
{
Init( pos );
@ -132,7 +132,7 @@ SCH_COMPONENT::SCH_COMPONENT( LIB_COMPONENT& libComponent,
SCH_COMPONENT::SCH_COMPONENT( const SCH_COMPONENT& aTemplate ) :
SCH_ITEM( NULL, TYPE_SCH_COMPONENT )
SCH_ITEM( NULL, SCH_COMPONENT_T )
{
/* assignment of all fields, including field vector elements, and linked
* list pointers */
@ -237,18 +237,18 @@ void SCH_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
/* Draw the component boundary box */
{
EDA_Rect BoundaryBox;
BoundaryBox = GetBoundaryBox();
BoundaryBox = GetBoundingBox();
GRRect( &panel->m_ClipBox, DC, BoundaryBox, BROWN );
#if 1
if( GetField( REFERENCE )->IsVisible() )
{
BoundaryBox = GetField( REFERENCE )->GetBoundaryBox();
BoundaryBox = GetField( REFERENCE )->GetBoundingBox();
GRRect( &panel->m_ClipBox, DC, BoundaryBox, BROWN );
}
if( GetField( VALUE )->IsVisible() )
{
BoundaryBox = GetField( VALUE )->GetBoundaryBox();
BoundaryBox = GetField( VALUE )->GetBoundingBox();
GRRect( &panel->m_ClipBox, DC, BoundaryBox, BROWN );
}
#endif
@ -549,60 +549,6 @@ LIB_PIN* SCH_COMPONENT::GetPin( const wxString& number )
}
/**
* Function GetBoundaryBox
* returns the orthogonal, bounding box of this object for display purposes.
* This box should be an enclosing perimeter for graphic items and pins.
* this include only fields defined in library
* use GetBoundingBox() to include fields in schematic
*/
EDA_Rect SCH_COMPONENT::GetBoundaryBox() const
{
LIB_COMPONENT* Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
EDA_Rect BoundaryBox;
int x0, xm, y0, ym;
/* Get the basic Boundary box */
if( Entry )
{
BoundaryBox = Entry->GetBoundaryBox( m_Multi, m_Convert );
x0 = BoundaryBox.GetX();
xm = BoundaryBox.GetRight();
// We must reverse Y values, because matrix orientation
// suppose Y axis normal for the library items coordinates,
// m_Transform reverse Y values, but BoundaryBox is already reversed!
y0 = -BoundaryBox.GetY();
ym = -BoundaryBox.GetBottom();
}
else /* if lib Entry not found, give a reasonable size */
{
x0 = y0 = -50;
xm = ym = 50;
}
/* Compute the real Boundary box (rotated, mirrored ...)*/
int x1 = m_Transform.x1 * x0 + m_Transform.y1 * y0;
int y1 = m_Transform.x2 * x0 + m_Transform.y2 * y0;
int x2 = m_Transform.x1 * xm + m_Transform.y1 * ym;
int y2 = m_Transform.x2 * xm + m_Transform.y2 * ym;
// H and W must be > 0:
if( x2 < x1 )
EXCHG( x2, x1 );
if( y2 < y1 )
EXCHG( y2, y1 );
BoundaryBox.SetX( x1 );
BoundaryBox.SetY( y1 );
BoundaryBox.SetWidth( x2 - x1 );
BoundaryBox.SetHeight( y2 - y1 );
BoundaryBox.Offset( m_Pos );
return BoundaryBox;
}
/* Used in undo / redo command:
* swap data between this and copyitem
*/
@ -1416,31 +1362,61 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
/**
* Function GetBoundingBox
* Function GetBoundaryBox
* 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.
* This box should be an enclosing perimeter for graphic items and pins.
* this include only fields defined in library
* use GetBoundingBox() to include fields in schematic
*/
EDA_Rect SCH_COMPONENT::GetBoundingBox()
EDA_Rect SCH_COMPONENT::GetBoundingBox() const
{
const int PADDING = 40;
LIB_COMPONENT* Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
EDA_Rect bBox;
int x0, xm, y0, ym;
// This gives a reasonable approximation (but some things are missing so...)
EDA_Rect bbox = GetBoundaryBox();
if( Entry == NULL )
return EDA_Rect( wxPoint( 0, 0 ), wxSize( 0, 0 ) );
/* Get the basic Boundary box */
bBox = Entry->GetBoundingBox( m_Multi, m_Convert );
x0 = bBox.GetX();
xm = bBox.GetRight();
// We must reverse Y values, because matrix orientation
// suppose Y axis normal for the library items coordinates,
// m_Transform reverse Y values, but bBox is already reversed!
y0 = -bBox.GetY();
ym = -bBox.GetBottom();
/* Compute the real Boundary box (rotated, mirrored ...)*/
int x1 = m_Transform.x1 * x0 + m_Transform.y1 * y0;
int y1 = m_Transform.x2 * x0 + m_Transform.y2 * y0;
int x2 = m_Transform.x1 * xm + m_Transform.y1 * ym;
int y2 = m_Transform.x2 * xm + m_Transform.y2 * ym;
// H and W must be > 0:
if( x2 < x1 )
EXCHG( x2, x1 );
if( y2 < y1 )
EXCHG( y2, y1 );
bBox.SetX( x1 );
bBox.SetY( y1 );
bBox.SetWidth( x2 - x1 );
bBox.SetHeight( y2 - y1 );
bBox.Offset( m_Pos );
// Include BoundingBoxes of fields
for( int ii = 0; ii < GetFieldCount(); ii++ )
{
if( !GetField( ii )->IsVisible() )
continue;
bbox.Merge( GetField( ii )->GetBoundaryBox() );
bBox.Merge( GetField( ii )->GetBoundingBox() );
}
// ... add padding
bbox.Inflate( PADDING );
return bbox;
return bBox;
}
@ -1546,7 +1522,8 @@ void SCH_COMPONENT::Rotate( wxPoint rotationPoint )
}
bool SCH_COMPONENT::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint * aFindLocation )
bool SCH_COMPONENT::Matches( wxFindReplaceData& aSearchData, void* aAuxData,
wxPoint* aFindLocation )
{
// Search reference.
// reference is a special field because a part identifier is added
@ -1622,7 +1599,7 @@ void SCH_COMPONENT::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
for( LIB_PIN* Pin = Entry->GetNextPin(); Pin != NULL; Pin = Entry->GetNextPin( Pin ) )
{
wxASSERT( Pin->Type() == COMPONENT_PIN_DRAW_TYPE );
wxASSERT( Pin->Type() == LIB_PIN_T );
if( Pin->GetUnit() && m_Multi && ( m_Multi != Pin->GetUnit() ) )
continue;
@ -1639,7 +1616,7 @@ void SCH_COMPONENT::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
wxPoint SCH_COMPONENT::GetPinPhysicalPosition( LIB_PIN* Pin )
{
wxCHECK_MSG( Pin != NULL && Pin->Type() == COMPONENT_PIN_DRAW_TYPE, wxPoint( 0, 0 ),
wxCHECK_MSG( Pin != NULL && Pin->Type() == LIB_PIN_T, wxPoint( 0, 0 ),
wxT( "Cannot get physical position of pin." ) );
return m_Transform.TransformCoordinate( Pin->GetPosition() ) + m_Pos;
@ -1672,7 +1649,7 @@ void SCH_COMPONENT::GetConnectionPoints( vector< wxPoint >& aPoints ) const
for( pin = component->GetNextPin(); pin != NULL; pin = component->GetNextPin( pin ) )
{
wxCHECK_RET( pin->Type() == COMPONENT_PIN_DRAW_TYPE,
wxCHECK_RET( pin->Type() == LIB_PIN_T,
wxT( "GetNextPin() did not return a pin object. Bad programmer!" ) );
// Skip items not used for this part.
@ -1685,3 +1662,26 @@ void SCH_COMPONENT::GetConnectionPoints( vector< wxPoint >& aPoints ) const
aPoints.push_back( m_Transform.TransformCoordinate( pin->GetPosition() ) + m_Pos );
}
}
bool SCH_COMPONENT::DoHitTest( const wxPoint& aPoint, int aAccuracy ) const
{
EDA_Rect rect = GetBoundingBox();
rect.Inflate( aAccuracy );
return rect.Inside( aPoint );
}
bool SCH_COMPONENT::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const
{
EDA_Rect rect = aRect;
rect.Inflate( aAccuracy );
if( aContained )
return rect.Inside( GetBoundingBox() );
return rect.Intersects( GetBoundingBox() );
}

View File

@ -159,13 +159,12 @@ public:
* set to NULL.
* @return SCH_COMPONENT* - a copy of me.
*/
SCH_COMPONENT* GenCopy()
SCH_COMPONENT* GenCopy() const
{
return new SCH_COMPONENT( *this );
}
void SetOrientation( int aOrientation );
void SetOrientation( int aOrientation );
/**
* Function GetOrientation
@ -217,7 +216,7 @@ public:
* 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();
EDA_Rect GetBoundingBox() const;
//-----<Fields>-----------------------------------------------------------
@ -274,16 +273,15 @@ public:
*/
LIB_PIN* GetPin( const wxString& number );
virtual void Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
const wxPoint& offset,
int draw_mode,
int Color = -1 )
virtual void Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
const wxPoint& offset,
int draw_mode,
int Color = -1 )
{
Draw( panel, DC, offset, draw_mode, Color, true );
}
void Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
const wxPoint& offset,
@ -326,14 +324,6 @@ public:
// Set the unit selection, for the given sheet path.
void SetUnitSelection( SCH_SHEET_PATH* aSheet, int aUnitSelection );
/**
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
* for a component, has no meaning, but it is necessary to satisfy the
* SCH_ITEM class requirements.
*/
virtual int GetPenSize() { return 0; }
// Geometric transforms (used in block operations):
/** virtual function Move
@ -377,7 +367,7 @@ public:
virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const;
#if defined(DEBUG)
#if defined(DEBUG)
/**
* Function Show
@ -389,6 +379,10 @@ public:
void Show( int nestLevel, std::ostream& os );
#endif
private:
virtual bool DoHitTest( const wxPoint& aPoint, int aAccuracy ) const;
virtual bool DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const;
};

View File

@ -31,7 +31,7 @@
SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId,
SCH_COMPONENT* aParent, wxString aName ) :
SCH_ITEM( aParent, DRAW_PART_TEXT_STRUCT_TYPE ),
SCH_ITEM( aParent, SCH_FIELD_T ),
EDA_TextStruct()
{
m_Pos = aPos;
@ -53,7 +53,7 @@ SCH_FIELD::~SCH_FIELD()
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
int SCH_FIELD::GetPenSize()
int SCH_FIELD::GetPenSize() const
{
int pensize = m_Thickness;
@ -122,7 +122,7 @@ void SCH_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
* so the more easily way is to use no justifications ( Centered text )
* and use GetBoundaryBox to know the text coordinate considered as centered
*/
EDA_Rect BoundaryBox = GetBoundaryBox();
EDA_Rect BoundaryBox = GetBoundingBox();
GRTextHorizJustifyType hjustify = GR_TEXT_HJUSTIFY_CENTER;
GRTextVertJustifyType vjustify = GR_TEXT_VJUSTIFY_CENTER;
textpos = BoundaryBox.Centre();
@ -226,11 +226,10 @@ void SCH_FIELD::SwapData( SCH_FIELD* copyitem )
/**
* Function GetBoundaryBox
* @return an EDA_Rect contains the real (user coordinates) boundary box for
* a text field,
* @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::GetBoundaryBox() const
EDA_Rect SCH_FIELD::GetBoundingBox() const
{
EDA_Rect BoundaryBox;
int hjustify, vjustify;
@ -251,8 +250,7 @@ EDA_Rect SCH_FIELD::GetBoundaryBox() const
pos2 = pos + parentComponent->m_Transform.TransformCoordinate( pos1 );
/* Calculate the text orientation, according to the component
* orientation/mirror */
// Calculate the text orientation, according to the component orientation/mirror.
if( parentComponent->m_Transform.y1 )
{
if( orient == TEXT_ORIENT_HORIZ )
@ -261,14 +259,15 @@ EDA_Rect SCH_FIELD::GetBoundaryBox() const
orient = TEXT_ORIENT_HORIZ;
}
/* Calculate the text justification, according to the component
* orientation/mirror */
// Calculate the text justification, according to the component orientation/mirror.
if( parentComponent->m_Transform.y1 )
{
/* is it mirrored (for text justify)*/
EXCHG( hjustify, vjustify );
if( parentComponent->m_Transform.x2 < 0 )
NEGATE( vjustify );
if( parentComponent->m_Transform.y1 > 0 )
NEGATE( hjustify );
}
@ -276,6 +275,7 @@ EDA_Rect SCH_FIELD::GetBoundaryBox() const
{
if( parentComponent->m_Transform.x1 < 0 )
NEGATE( hjustify );
if( parentComponent->m_Transform.y2 > 0 )
NEGATE( vjustify );
}
@ -334,6 +334,7 @@ bool SCH_FIELD::Save( FILE* aFile ) const
hjustify = 'R';
char vjustify = 'C';
if( m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM )
vjustify = 'B';
else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP )
@ -391,9 +392,11 @@ void SCH_FIELD::Place( SCH_EDIT_FRAME* frame, wxDC* DC )
fieldNdx = m_FieldId;
m_AddExtraText = 0;
if( fieldNdx == REFERENCE )
{
Entry = CMP_LIBRARY::FindLibraryComponent( component->m_ChipName );
if( Entry != NULL )
{
if( Entry->GetPartCount() > 1 )
@ -412,6 +415,7 @@ void SCH_FIELD::Place( SCH_EDIT_FRAME* frame, wxDC* DC )
bool SCH_FIELD::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint * aFindLocation )
{
bool match;
if( aAuxData && m_FieldId == REFERENCE )
{
// reference is a special field because:
@ -421,6 +425,7 @@ bool SCH_FIELD::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint
SCH_COMPONENT* pSch = (SCH_COMPONENT*) m_Parent;
SCH_SHEET_PATH* sheet = (SCH_SHEET_PATH*) aAuxData;
wxString fulltext = pSch->GetRef( sheet );
if( m_AddExtraText )
{
/* For more than one part per package, we must add the part selection
@ -428,18 +433,22 @@ bool SCH_FIELD::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint
int part_id = pSch->GetUnitSelection( sheet );
fulltext << LIB_COMPONENT::ReturnSubReference( part_id );
}
match = SCH_ITEM::Matches( fulltext, aSearchData );
}
else
match = SCH_ITEM::Matches( m_Text, aSearchData );
if( match )
{
EDA_Rect BoundaryBox = GetBoundaryBox();
EDA_Rect BoundaryBox = GetBoundingBox();
if( aFindLocation )
*aFindLocation = GetBoundaryBox().Centre();
*aFindLocation = GetBoundingBox().Centre();
return true;
}
return false;
}
@ -448,3 +457,34 @@ void SCH_FIELD::Rotate( wxPoint rotationPoint )
{
RotatePoint( &m_Pos, rotationPoint, 900 );
}
bool SCH_FIELD::DoHitTest( const wxPoint& aPoint, int aAccuracy ) const
{
// Do not hit test hidden fields.
if( !IsVisible() )
return false;
EDA_Rect rect = GetBoundingBox();
rect.Inflate( aAccuracy );
return rect.Inside( aPoint );
}
bool SCH_FIELD::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const
{
// Do not hit test hidden fields.
if( !IsVisible() )
return false;
EDA_Rect rect = aRect;
rect.Inflate( aAccuracy );
if( aContained )
return rect.Inside( GetBoundingBox() );
return rect.Intersects( GetBoundingBox() );
}

View File

@ -15,7 +15,6 @@
#include "sch_item_struct.h"
#include "general.h"
@ -36,7 +35,6 @@ class SCH_FIELD : public SCH_ITEM, public EDA_TextStruct
public:
int m_FieldId; ///< Field index, @see enum NumFieldType
wxString m_Name;
bool m_AddExtraText; /**< for REFERENCE, add extra info
@ -53,16 +51,15 @@ public:
return wxT( "SCH_FIELD" );
}
void Place( SCH_EDIT_FRAME* frame, wxDC* DC );
void Place( SCH_EDIT_FRAME* frame, wxDC* DC );
EDA_Rect GetBoundaryBox() const;
EDA_Rect GetBoundingBox() const;
/**
* Function IsVoid
* returns true if the field is either empty or holds "~".
*/
bool IsVoid()
bool IsVoid() const
{
size_t len = m_Text.Len();
@ -84,13 +81,13 @@ public:
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
int GetPenSize();
int GetPenSize() const;
/**
* Function IsVisible
* @return true is this field is visible, false if flagged invisible
*/
bool IsVisible()
bool IsVisible() const
{
return (m_Attributs & TEXT_NO_VISIBLE) == 0 ? true : false;
}
@ -99,11 +96,11 @@ public:
/**
* Function Draw
*/
void Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
const wxPoint& offset,
int draw_mode,
int Color = -1 );
void Draw( WinEDA_DrawPanel* aPanel,
wxDC* aDC,
const wxPoint& aOffset,
int aDrawMode,
int aColor = -1 );
/**
* Function Save
@ -136,7 +133,6 @@ public:
* master class */
}
/** virtual function Mirror_Y
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
@ -149,7 +145,6 @@ public:
* master class */
}
/**
* Compare schematic field text against search string.
*
@ -163,6 +158,10 @@ public:
*/
virtual bool Matches( wxFindReplaceData& aSearchData,
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;
};

View File

@ -31,7 +31,7 @@
/***********************/
SCH_BUS_ENTRY::SCH_BUS_ENTRY( const wxPoint& pos, int shape, int id ) :
SCH_ITEM( NULL, DRAW_BUSENTRY_STRUCT_TYPE )
SCH_ITEM( NULL, SCH_BUS_ENTRY_T )
{
m_Pos = pos;
m_Size.x = 100;
@ -138,7 +138,7 @@ bool SCH_BUS_ENTRY::Load( LINE_READER& aLine, wxString& aErrorMsg )
}
EDA_Rect SCH_BUS_ENTRY::GetBoundingBox()
EDA_Rect SCH_BUS_ENTRY::GetBoundingBox() const
{
EDA_Rect box;
@ -157,7 +157,7 @@ EDA_Rect SCH_BUS_ENTRY::GetBoundingBox()
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
int SCH_BUS_ENTRY::GetPenSize()
int SCH_BUS_ENTRY::GetPenSize() const
{
int pensize = ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width;
@ -246,11 +246,30 @@ void SCH_BUS_ENTRY::GetConnectionPoints( vector< wxPoint >& aPoints ) const
}
bool SCH_BUS_ENTRY::DoHitTest( const wxPoint& aPoint, int aAccuracy ) const
{
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.Inside( GetBoundingBox() );
return rect.Intersects( GetBoundingBox() );
}
/**********************/
/* class SCH_JUNCTION */
/**********************/
SCH_JUNCTION::SCH_JUNCTION( const wxPoint& pos ) : SCH_ITEM( NULL, DRAW_JUNCTION_STRUCT_TYPE )
SCH_JUNCTION::SCH_JUNCTION( const wxPoint& pos ) : SCH_ITEM( NULL, SCH_JUNCTION_T )
{
#define DRAWJUNCTION_DIAMETER 32 /* Diameter of junction symbol between wires */
m_Pos = pos;
@ -311,7 +330,7 @@ bool SCH_JUNCTION::Load( LINE_READER& aLine, wxString& aErrorMsg )
}
EDA_Rect SCH_JUNCTION::GetBoundingBox()
EDA_Rect SCH_JUNCTION::GetBoundingBox() const
{
EDA_Rect rect;
@ -322,31 +341,6 @@ EDA_Rect SCH_JUNCTION::GetBoundingBox()
}
/**
* Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool SCH_JUNCTION::HitTest( const wxPoint& aPosRef )
{
wxPoint dist = aPosRef - m_Pos;
return sqrt( ( (double) ( dist.x * dist.x ) ) +
( (double) ( dist.y * dist.y ) ) ) < ( m_Size.x / 2 );
}
/**
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
* has no meaning for SCH_JUNCTION
*/
int SCH_JUNCTION::GetPenSize()
{
return 0;
}
/*****************************************************************************
* Routine to redraw connection struct. *
*****************************************************************************/
@ -370,7 +364,7 @@ void SCH_JUNCTION::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
void SCH_JUNCTION::Mirror_X( int aXaxis_position )
{
m_Pos.y -= aXaxis_position;
NEGATE( m_Pos.y );
NEGATE( m_Pos.y );
m_Pos.y += aXaxis_position;
}
@ -378,7 +372,7 @@ void SCH_JUNCTION::Mirror_X( int aXaxis_position )
void SCH_JUNCTION::Mirror_Y( int aYaxis_position )
{
m_Pos.x -= aYaxis_position;
NEGATE( m_Pos.x );
NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position;
}
@ -424,16 +418,37 @@ void SCH_JUNCTION::Show( int nestLevel, std::ostream& os )
NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << m_Pos << "/>\n";
}
#endif
bool SCH_JUNCTION::DoHitTest( const wxPoint& aPoint, int aAccuracy ) const
{
EDA_Rect rect = GetBoundingBox();
rect.Inflate( aAccuracy );
return rect.Inside( aPoint );
}
bool SCH_JUNCTION::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const
{
EDA_Rect rect = aRect;
rect.Inflate( aAccuracy );
if( aContained )
return rect.Inside( GetBoundingBox() );
return rect.Intersects( GetBoundingBox() );
}
/************************/
/* class SCH_NO_CONNECT */
/************************/
SCH_NO_CONNECT::SCH_NO_CONNECT( const wxPoint& pos ) : SCH_ITEM( NULL, DRAW_NOCONNECT_STRUCT_TYPE )
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;
@ -453,7 +468,7 @@ SCH_NO_CONNECT* SCH_NO_CONNECT::GenCopy()
}
EDA_Rect SCH_NO_CONNECT::GetBoundingBox()
EDA_Rect SCH_NO_CONNECT::GetBoundingBox() const
{
int delta = ( GetPenSize() + m_Size.x ) / 2;
EDA_Rect box;
@ -465,24 +480,6 @@ EDA_Rect SCH_NO_CONNECT::GetBoundingBox()
}
/**
* Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool SCH_NO_CONNECT::HitTest( const wxPoint& aPosRef )
{
int width = g_DrawDefaultLineThickness;
int delta = ( m_Size.x + width ) / 2;
wxPoint dist = aPosRef - m_Pos;
if( ( ABS( dist.x ) <= delta ) && ( ABS( dist.y ) <= delta ) )
return true;
return false;
}
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.sch" format.
@ -526,7 +523,7 @@ bool SCH_NO_CONNECT::Load( LINE_READER& aLine, wxString& aErrorMsg )
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
int SCH_NO_CONNECT::GetPenSize()
int SCH_NO_CONNECT::GetPenSize() const
{
return g_DrawDefaultLineThickness;
}
@ -596,12 +593,38 @@ void SCH_NO_CONNECT::GetConnectionPoints( vector< wxPoint >& aPoints ) const
}
bool SCH_NO_CONNECT::DoHitTest( const wxPoint& aPoint, int aAccuracy ) const
{
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.Inside( GetBoundingBox() );
return rect.Intersects( GetBoundingBox() );
}
/******************/
/* Class SCH_LINE */
/******************/
SCH_LINE::SCH_LINE( const wxPoint& pos, int layer ) :
SCH_ITEM( NULL, DRAW_SEGMENT_STRUCT_TYPE )
SCH_ITEM( NULL, SCH_LINE_T )
{
m_Start = pos;
m_End = pos;
@ -635,13 +658,19 @@ SCH_LINE* SCH_LINE::GenCopy()
}
bool SCH_LINE::IsOneEndPointAt( const wxPoint& pos )
void SCH_LINE::Move( const wxPoint& aOffset )
{
if( ( pos.x == m_Start.x ) && ( pos.y == m_Start.y ) )
return TRUE;
if( ( pos.x == m_End.x ) && ( pos.y == m_End.y ) )
return TRUE;
return FALSE;
if( (m_Flags & STARTPOINT) == 0 && aOffset != wxPoint( 0, 0 ) )
{
m_Start += aOffset;
SetModified();
}
if( (m_Flags & ENDPOINT) == 0 && aOffset != wxPoint( 0, 0 ) )
{
m_End += aOffset;
SetModified();
}
}
@ -654,7 +683,7 @@ bool SCH_LINE::IsOneEndPointAt( const wxPoint& pos )
* of nesting of this object within the overall tree.
* @param os The ostream& to output to.
*/
void SCH_LINE::Show( int nestLevel, std::ostream& os )
void SCH_LINE::Show( int nestLevel, std::ostream& os ) const
{
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
<< " layer=\"" << m_Layer << '"'
@ -671,7 +700,7 @@ void SCH_LINE::Show( int nestLevel, std::ostream& os )
#endif
EDA_Rect SCH_LINE::GetBoundingBox()
EDA_Rect SCH_LINE::GetBoundingBox() const
{
int width = 25;
@ -703,12 +732,15 @@ bool SCH_LINE::Save( FILE* aFile ) const
if( GetLayer() == LAYER_WIRE )
layer = "Wire";
if( GetLayer() == LAYER_BUS )
layer = "Bus";
if( fprintf( aFile, "Wire %s %s\n", layer, width ) == EOF )
{
success = false;
}
if( fprintf( aFile, "\t%-4d %-4d %-4d %-4d\n", m_Start.x, m_Start.y,
m_End.x, m_End.y ) == EOF )
{
@ -740,6 +772,7 @@ bool SCH_LINE::Load( LINE_READER& aLine, wxString& aErrorMsg )
if( Name1[0] == 'W' )
m_Layer = LAYER_WIRE;
if( Name1[0] == 'B' )
m_Layer = LAYER_BUS;
@ -760,7 +793,7 @@ bool SCH_LINE::Load( LINE_READER& aLine, wxString& aErrorMsg )
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
int SCH_LINE::GetPenSize()
int SCH_LINE::GetPenSize() const
{
int pensize = ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width;
@ -835,7 +868,7 @@ void SCH_LINE::Rotate( wxPoint rotationPoint )
bool SCH_LINE::MergeOverlap( SCH_LINE* aLine )
{
wxCHECK_MSG( aLine != NULL && aLine->Type() == DRAW_SEGMENT_STRUCT_TYPE, false,
wxCHECK_MSG( aLine != NULL && aLine->Type() == SCH_LINE_T, false,
wxT( "Cannot test line segment for overlap." ) );
if( this == aLine || GetLayer() != aLine->GetLayer() )
@ -974,11 +1007,30 @@ void SCH_LINE::GetConnectionPoints( vector< wxPoint >& aPoints ) const
}
bool SCH_LINE::DoHitTest( const wxPoint& aPoint, int aAccuracy ) const
{
return TestSegmentHit( aPoint, m_Start, m_End, aAccuracy );
}
bool SCH_LINE::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const
{
EDA_Rect rect = aRect;
rect.Inflate( aAccuracy );
if( aContained )
return rect.Inside( GetBoundingBox() );
return rect.Intersects( GetBoundingBox() );
}
/**********************/
/* Class SCH_POLYLINE */
/**********************/
SCH_POLYLINE::SCH_POLYLINE( int layer ) : SCH_ITEM( NULL, DRAW_POLYLINE_STRUCT_TYPE )
SCH_POLYLINE::SCH_POLYLINE( int layer ) : SCH_ITEM( NULL, SCH_POLYLINE_T )
{
m_Width = 0;
@ -1093,7 +1145,7 @@ bool SCH_POLYLINE::Load( LINE_READER& aLine, wxString& aErrorMsg )
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
int SCH_POLYLINE::GetPenSize()
int SCH_POLYLINE::GetPenSize() const
{
int pensize = ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width;
@ -1101,18 +1153,18 @@ int SCH_POLYLINE::GetPenSize()
}
void SCH_POLYLINE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int DrawMode, int Color )
void SCH_POLYLINE::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset,
int aDrawMode, int aColor )
{
int color;
int width = GetPenSize();
if( Color >= 0 )
color = Color;
if( aColor >= 0 )
color = aColor;
else
color = ReturnLayerColor( m_Layer );
GRSetDrawMode( DC, DrawMode );
GRSetDrawMode( aDC, aDrawMode );
if( m_Layer == LAYER_BUS )
{
@ -1124,14 +1176,14 @@ void SCH_POLYLINE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
if( m_Layer == LAYER_NOTES )
{
for( unsigned i = 1; i < GetCornerCount(); i++ )
GRDashedLineTo( &panel->m_ClipBox, DC, m_PolyPoints[i].x + offset.x,
m_PolyPoints[i].y + offset.y, width, color );
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( &panel->m_ClipBox, DC, m_PolyPoints[i].x + offset.x,
m_PolyPoints[i].y + offset.y, width, color );
GRLineTo( &aPanel->m_ClipBox, aDC, m_PolyPoints[i].x + aOffset.x,
m_PolyPoints[i].y + aOffset.y, width, color );
}
}
@ -1165,3 +1217,28 @@ void SCH_POLYLINE::Rotate( wxPoint rotationPoint )
RotatePoint( &m_PolyPoints[ii], rotationPoint, 900 );
}
}
bool SCH_POLYLINE::DoHitTest( const wxPoint& aPoint, int aAccuracy ) const
{
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.Inside( GetBoundingBox() );
return rect.Intersects( GetBoundingBox() );
}

View File

@ -43,15 +43,14 @@ public:
return wxT( "SCH_LINE" );
}
bool IsOneEndPointAt( const wxPoint& pos );
SCH_LINE* GenCopy();
bool IsNull()
bool IsEndPoint( const wxPoint& aPoint ) const
{
return m_Start == m_End;
return aPoint == m_Start || aPoint == m_End;
}
SCH_LINE* GenCopy();
bool IsNull() const { return m_Start == m_End; }
/**
* Function GetBoundingBox
@ -60,19 +59,18 @@ public:
* 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();
EDA_Rect GetBoundingBox() const;
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int draw_mode, int Color = -1 );
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.
* 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;
bool Save( FILE* aFile ) const;
/**
* Load schematic line from \a aLine in a .sch file.
@ -88,7 +86,7 @@ public:
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
virtual int GetPenSize();
virtual int GetPenSize() const;
// Geometric transforms (used in block operations):
@ -96,14 +94,7 @@ public:
* move item to a new position.
* @param aMoveVector = the displacement vector
*/
virtual void Move( const wxPoint& aMoveVector )
{
if( (m_Flags & STARTPOINT) == 0 )
m_Start += aMoveVector;
if( (m_Flags & ENDPOINT) == 0 )
m_End += aMoveVector;
}
virtual void Move( const wxPoint& aMoveVector );
/** virtual function Mirror_Y
* mirror item relative to an Y axis
@ -136,9 +127,12 @@ public:
virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const;
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os );
void Show( int nestLevel, std::ostream& os ) const;
#endif
private:
virtual bool DoHitTest( const wxPoint& aPoint, int aAccuracy ) const;
virtual bool DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const;
};
@ -151,23 +145,22 @@ public:
public:
SCH_NO_CONNECT( const wxPoint& pos = wxPoint( 0, 0 ) );
~SCH_NO_CONNECT() { }
virtual wxString GetClass() const
{
return wxT( "SCH_NO_CONNECT" );
}
SCH_NO_CONNECT* GenCopy();
/**
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
virtual int GetPenSize();
virtual int GetPenSize() const;
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int draw_mode,
int Color = -1 );
virtual void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& affset,
int aDrawMode, int aColor = -1 );
/**
* Function Save
@ -176,7 +169,7 @@ public:
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
bool Save( FILE* aFile ) const;
/**
* Load schematic no connect entry from \a aLine in a .sch file.
@ -188,13 +181,6 @@ public:
*/
virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg );
/**
* Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool HitTest( const wxPoint& aPosRef );
/**
* Function GetBoundingBox
* returns the orthogonal, bounding box of this object for display
@ -203,7 +189,7 @@ public:
* schematic coordinate system. It is OK to overestimate the size
* by a few counts.
*/
EDA_Rect GetBoundingBox();
EDA_Rect GetBoundingBox() const;
// Geometric transforms (used in block operations):
@ -216,7 +202,6 @@ public:
m_Pos += aMoveVector;
}
/** virtual function Mirror_Y
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
@ -228,6 +213,10 @@ public:
virtual bool IsSelectStateChanged( const wxRect& aRect );
virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const;
private:
virtual bool DoHitTest( const wxPoint& aPoint, int aAccuracy ) const;
virtual bool DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const;
};
@ -254,10 +243,11 @@ public:
SCH_BUS_ENTRY* GenCopy();
wxPoint m_End() const;
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int draw_mode,
int Color = -1 );
wxPoint m_End() const;
virtual void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset,
int aDrawMode, int aColor = -1 );
/**
* Function Save
@ -266,7 +256,7 @@ public:
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
bool Save( FILE* aFile ) const;
/**
* Load schematic bus entry from \a aLine in a .sch file.
@ -286,13 +276,13 @@ public:
* schematic coordinate system. It is OK to overestimate the size
* by a few counts.
*/
EDA_Rect GetBoundingBox();
EDA_Rect GetBoundingBox() const;
/**
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
virtual int GetPenSize();
virtual int GetPenSize() const;
// Geometric transforms (used in block operations):
@ -319,6 +309,10 @@ public:
virtual bool IsSelectStateChanged( const wxRect& aRect );
virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const;
private:
virtual bool DoHitTest( const wxPoint& aPoint, int aAccuracy ) const;
virtual bool DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const;
};
class SCH_POLYLINE : public SCH_ITEM
@ -338,9 +332,9 @@ public:
SCH_POLYLINE* GenCopy();
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int draw_mode,
int Color = -1 );
virtual void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset,
int aDrawMode, int aColor = -1 );
/**
* Function Save
@ -349,7 +343,7 @@ public:
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
bool Save( FILE* aFile ) const;
/**
* Load schematic poly line entry from \a aLine in a .sch file.
@ -365,7 +359,7 @@ public:
* Function AddPoint
* add a corner to m_PolyPoints
*/
void AddPoint( const wxPoint& point )
void AddPoint( const wxPoint& point )
{
m_PolyPoints.push_back( point );
}
@ -382,7 +376,7 @@ public:
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
virtual int GetPenSize();
virtual int GetPenSize() const;
// Geometric transforms (used in block operations):
@ -404,6 +398,10 @@ public:
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 ) const;
virtual bool DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const;
};
@ -422,14 +420,6 @@ public:
return wxT( "SCH_JUNCTION" );
}
/**
* Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool HitTest( const wxPoint& aPosRef );
/**
* Function GetBoundingBox
* returns the orthogonal, bounding box of this object for display
@ -438,18 +428,12 @@ public:
* schematic coordinate system. It is OK to overestimate the size
* by a few counts.
*/
EDA_Rect GetBoundingBox();
EDA_Rect GetBoundingBox() const;
SCH_JUNCTION* GenCopy();
/**
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
virtual int GetPenSize();
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int draw_mode, int Color = -1 );
virtual void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset,
int aDrawMode, int aColor = -1 );
/**
* Function Save
@ -458,7 +442,7 @@ public:
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
bool Save( FILE* aFile ) const;
/**
* Load schematic junction entry from \a aLine in a .sch file.
@ -500,6 +484,10 @@ public:
void Show( int nestLevel, std::ostream& os );
#endif
private:
virtual bool DoHitTest( const wxPoint& aPoint, int aAccuracy ) const;
virtual bool DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const;
};

View File

@ -32,13 +32,13 @@ const wxChar* NameMarqueurType[] =
/* class SCH_MARKER */
/**************************/
SCH_MARKER::SCH_MARKER() : SCH_ITEM( NULL, TYPE_SCH_MARKER ), MARKER_BASE()
SCH_MARKER::SCH_MARKER() : SCH_ITEM( NULL, SCH_MARKER_T ), MARKER_BASE()
{
}
SCH_MARKER::SCH_MARKER( const wxPoint& pos, const wxString& text ) :
SCH_ITEM( NULL, TYPE_SCH_MARKER ),
SCH_ITEM( NULL, SCH_MARKER_T ),
MARKER_BASE( 0, pos, text, pos )
{
}
@ -140,7 +140,7 @@ bool SCH_MARKER::Matches( wxFindReplaceData& aSearchData, wxPoint * aFindLocatio
* 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 SCH_MARKER::GetBoundingBox()
EDA_Rect SCH_MARKER::GetBoundingBox() const
{
return GetBoundingBoxMarker();
}

View File

@ -31,19 +31,18 @@ public:
SCH_MARKER();
SCH_MARKER( const wxPoint& aPos, const wxString& aText );
~SCH_MARKER();
virtual wxString GetClass() const
{
return wxT( "SCH_MARKER" );
}
SCH_MARKER* GenCopy();
SCH_MARKER* GenCopy();
virtual void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
const wxPoint& aOffset, int aDraw_mode,
int aColor = -1 );
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.sch"
@ -53,14 +52,6 @@ public:
*/
bool Save( FILE* aFile ) const;
/**
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
* for a marker, has no meaning, but it is necessary to satisfy the
* SCH_ITEM class requirements
*/
virtual int GetPenSize() { return 0; };
/**
* Function HitTest
* @return true if the point aPosRef is within item area
@ -71,7 +62,6 @@ public:
return HitTestMarker( aPosRef );
}
/**
* Function GetBoundingBox
* returns the orthogonal, bounding box of this object for display purposes.
@ -79,8 +69,7 @@ public:
* object, and the units should be in the pcb or schematic coordinate system.
* It is OK to overestimate the size by a few counts.
*/
virtual EDA_Rect GetBoundingBox();
virtual EDA_Rect GetBoundingBox() const;
// Geometric transforms (used in block operations):

View File

@ -23,22 +23,22 @@ void SetaParent( SCH_ITEM* Struct, SCH_SCREEN* Screen )
{
switch( Struct->Type() )
{
case DRAW_POLYLINE_STRUCT_TYPE:
case DRAW_JUNCTION_STRUCT_TYPE:
case TYPE_SCH_TEXT:
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
case TYPE_SCH_COMPONENT:
case DRAW_SEGMENT_STRUCT_TYPE:
case DRAW_BUSENTRY_STRUCT_TYPE:
case DRAW_SHEET_STRUCT_TYPE:
case TYPE_SCH_MARKER:
case DRAW_NOCONNECT_STRUCT_TYPE:
case SCH_POLYLINE_T:
case SCH_JUNCTION_T:
case SCH_TEXT_T:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_COMPONENT_T:
case SCH_LINE_T:
case SCH_BUS_ENTRY_T:
case SCH_SHEET_T:
case SCH_MARKER_T:
case SCH_NO_CONNECT_T:
Struct->SetParent( Screen );
break;
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case SCH_SHEET_LABEL_T:
break;
default:
@ -194,15 +194,15 @@ SCH_ITEM* SCH_SCREEN::ExtractWires( bool CreateCopy )
switch( item->Type() )
{
case DRAW_JUNCTION_STRUCT_TYPE:
case DRAW_SEGMENT_STRUCT_TYPE:
case SCH_JUNCTION_T:
case SCH_LINE_T:
RemoveFromDrawList( item );
item->SetNext( List );
List = item;
if( CreateCopy )
{
if( item->Type() == DRAW_JUNCTION_STRUCT_TYPE )
if( item->Type() == SCH_JUNCTION_T )
new_item = ( (SCH_JUNCTION*) item )->GenCopy();
else
new_item = ( (SCH_LINE*) item )->GenCopy();
@ -234,13 +234,13 @@ bool SCH_SCREEN::SchematicCleanUp( wxDC* DC )
for( ; DrawList != NULL; DrawList = DrawList->Next() )
{
if( DrawList->Type() == DRAW_SEGMENT_STRUCT_TYPE )
if( DrawList->Type() == SCH_LINE_T )
{
TstDrawList = DrawList->Next();
while( TstDrawList )
{
if( TstDrawList->Type() == DRAW_SEGMENT_STRUCT_TYPE )
if( TstDrawList->Type() == SCH_LINE_T )
{
SCH_LINE* line = (SCH_LINE*) DrawList;
@ -438,13 +438,13 @@ void SCH_SCREENS::AddScreenToList( SCH_SCREEN* aScreen )
void SCH_SCREENS::BuildScreenList( EDA_ITEM* aItem )
{
if( aItem && aItem->Type() == DRAW_SHEET_STRUCT_TYPE )
if( aItem && aItem->Type() == SCH_SHEET_T )
{
SCH_SHEET* ds = (SCH_SHEET*) aItem;
aItem = ds->m_AssociatedScreen;
}
if( aItem && aItem->Type() == SCREEN_STRUCT_TYPE )
if( aItem && aItem->Type() == SCH_SCREEN_T )
{
SCH_SCREEN* screen = (SCH_SCREEN*) aItem;
AddScreenToList( screen );
@ -452,7 +452,7 @@ void SCH_SCREENS::BuildScreenList( EDA_ITEM* aItem )
while( strct )
{
if( strct->Type() == DRAW_SHEET_STRUCT_TYPE )
if( strct->Type() == SCH_SHEET_T )
{
BuildScreenList( strct );
}

View File

@ -29,7 +29,7 @@
#include "sch_component.h"
SCH_SHEET::SCH_SHEET( const wxPoint& pos ) : SCH_ITEM( NULL, DRAW_SHEET_STRUCT_TYPE )
SCH_SHEET::SCH_SHEET( const wxPoint& pos ) : SCH_ITEM( NULL, SCH_SHEET_T )
{
m_Layer = LAYER_SHEET;
m_Pos = pos;
@ -280,6 +280,7 @@ SCH_SHEET* SCH_SHEET::GenCopy()
/* don't copy screen data - just reference it. */
newitem->m_AssociatedScreen = m_AssociatedScreen;
if( m_AssociatedScreen )
m_AssociatedScreen->m_RefCount++;
@ -316,7 +317,7 @@ void SCH_SHEET::SwapData( SCH_SHEET* copyitem )
void SCH_SHEET::AddLabel( SCH_SHEET_PIN* aLabel )
{
wxASSERT( aLabel != NULL );
wxASSERT( aLabel->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE );
wxASSERT( aLabel->Type() == SCH_SHEET_LABEL_T );
m_labels.push_back( aLabel );
renumberLabels();
@ -326,7 +327,7 @@ void SCH_SHEET::AddLabel( SCH_SHEET_PIN* aLabel )
void SCH_SHEET::RemoveLabel( SCH_SHEET_PIN* aLabel )
{
wxASSERT( aLabel != NULL );
wxASSERT( aLabel->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE );
wxASSERT( aLabel->Type() == SCH_SHEET_LABEL_T );
SCH_SHEET_PIN_LIST::iterator i;
@ -356,6 +357,7 @@ bool SCH_SHEET::HasLabel( const wxString& aName )
return false;
}
bool SCH_SHEET::IsVerticalOrientation()
{
BOOST_FOREACH( SCH_SHEET_PIN label, m_labels )
@ -377,7 +379,7 @@ bool SCH_SHEET::HasUndefinedLabels()
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
{
if( DrawStruct->Type() != TYPE_SCH_HIERLABEL )
if( DrawStruct->Type() != SCH_HIERARCHICAL_LABEL_T )
continue;
HLabel = (SCH_HIERLABEL*) DrawStruct;
@ -454,7 +456,7 @@ void SCH_SHEET::CleanupSheet()
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
{
if( DrawStruct->Type() != TYPE_SCH_HIERLABEL )
if( DrawStruct->Type() != SCH_HIERARCHICAL_LABEL_T )
continue;
HLabel = (SCH_HIERLABEL*) DrawStruct;
@ -489,7 +491,7 @@ SCH_SHEET_PIN* SCH_SHEET::GetLabel( const wxPoint& aPosition )
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
int SCH_SHEET::GetPenSize()
int SCH_SHEET::GetPenSize() const
{
return g_DrawDefaultLineThickness;
}
@ -561,6 +563,7 @@ void SCH_SHEET::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
color = aColor;
else
color = ReturnLayerColor( m_Layer );
GRSetDrawMode( aDC, aDrawMode );
GRRect( &aPanel->m_ClipBox, aDC, pos.x, pos.y,
@ -592,6 +595,7 @@ void SCH_SHEET::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
txtcolor = aColor;
else
txtcolor = ReturnLayerColor( LAYER_SHEETFILENAME );
Text = wxT( "File: " ) + m_FileName;
DrawGraphicText( aPanel, aDC, pos_filename,
(EDA_Colors) txtcolor, Text, name_orientation,
@ -613,7 +617,7 @@ void SCH_SHEET::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
* Function GetBoundingBox
* @return an EDA_Rect giving the bounding box of the sheet
*/
EDA_Rect SCH_SHEET::GetBoundingBox()
EDA_Rect SCH_SHEET::GetBoundingBox() const
{
int dx, dy;
@ -633,19 +637,6 @@ EDA_Rect SCH_SHEET::GetBoundingBox()
}
/**
* Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool SCH_SHEET::HitTest( const wxPoint& aPosRef )
{
EDA_Rect rect = GetBoundingBox();
return rect.Inside( aPosRef );
}
/**
* Function ComponentCount
* count our own components, without the power components.
@ -661,14 +652,15 @@ int SCH_SHEET::ComponentCount()
for( bs = m_AssociatedScreen->GetDrawItems(); bs != NULL; bs = bs->Next() )
{
if( bs->Type() == TYPE_SCH_COMPONENT )
if( bs->Type() == SCH_COMPONENT_T )
{
SCH_COMPONENT* Cmp = (SCH_COMPONENT*) bs;
if( Cmp->GetField( VALUE )->m_Text.GetChar( 0 ) != '#' )
n++;
}
if( bs->Type() == DRAW_SHEET_STRUCT_TYPE )
if( bs->Type() == SCH_SHEET_T )
{
SCH_SHEET* sheet = (SCH_SHEET*) bs;
n += sheet->ComponentCount();
@ -695,7 +687,7 @@ bool SCH_SHEET::SearchHierarchy( wxString aFilename, SCH_SCREEN** aScreen )
while( strct )
{
if( strct->Type() == DRAW_SHEET_STRUCT_TYPE )
if( strct->Type() == SCH_SHEET_T )
{
SCH_SHEET* ss = (SCH_SHEET*) strct;
if( ss->m_AssociatedScreen
@ -740,7 +732,7 @@ bool SCH_SHEET::LocatePathOfScreen( SCH_SCREEN* aScreen, SCH_SHEET_PATH* aList )
while( strct )
{
if( strct->Type() == DRAW_SHEET_STRUCT_TYPE )
if( strct->Type() == SCH_SHEET_T )
{
SCH_SHEET* ss = (SCH_SHEET*) strct;
@ -774,6 +766,7 @@ bool SCH_SHEET::Load( SCH_EDIT_FRAME* aFrame )
{
SCH_SCREEN* screen = NULL;
g_RootSheet->SearchHierarchy( m_FileName, &screen );
if( screen )
{
m_AssociatedScreen = screen;
@ -793,7 +786,7 @@ bool SCH_SHEET::Load( SCH_EDIT_FRAME* aFrame )
while( bs )
{
if( bs->Type() == DRAW_SHEET_STRUCT_TYPE )
if( bs->Type() == SCH_SHEET_T )
{
SCH_SHEET* sheetstruct = (SCH_SHEET*) bs;
@ -827,7 +820,7 @@ int SCH_SHEET::CountSheets()
for( ; strct; strct = strct->Next() )
{
if( strct->Type() == DRAW_SHEET_STRUCT_TYPE )
if( strct->Type() == SCH_SHEET_T )
{
SCH_SHEET* subsheet = (SCH_SHEET*) strct;
count += subsheet->CountSheets();
@ -864,7 +857,6 @@ bool SCH_SHEET::ChangeFileName( SCH_EDIT_FRAME* aFrame, const wxString& aFileNam
wxString msg;
bool LoadFromFile = false;
// do we reload the data from the existing hierarchy
if( g_RootSheet->SearchHierarchy( aFileName, &Screen_to_use ) )
{
@ -875,18 +867,17 @@ data in this sheet will be replaced)?" ),
GetChars( aFileName ) );
if( !IsOK( NULL, msg ) )
{
DisplayInfoMessage( (wxWindow*) NULL,
_( "Sheet Filename Renaming Aborted" ) );
DisplayInfoMessage( (wxWindow*) NULL, _( "Sheet Filename Renaming Aborted" ) );
return false;
}
}
}
else if( wxFileExists( aFileName ) ) // do we reload the data from
// an existing file
else if( wxFileExists( aFileName ) ) // do we reload the data from an existing file
{
msg.Printf( _( "A file named %s exists, load it (otherwise keep \
current sheet data if possible)?" ),
GetChars( aFileName ) );
if( IsOK( NULL, msg ) )
{
LoadFromFile = true;
@ -895,9 +886,11 @@ current sheet data if possible)?" ),
if( m_AssociatedScreen )
{
m_AssociatedScreen->m_RefCount--; // be careful with these
if( m_AssociatedScreen->m_RefCount == 0 )
SAFE_DELETE( m_AssociatedScreen );
m_AssociatedScreen = NULL; // will be created later
m_AssociatedScreen = NULL; // will be created later
}
}
}
@ -923,7 +916,6 @@ otherwise delete current sheet data)" );
m_AssociatedScreen = NULL; //will be created later
}
SetFileName( aFileName );
// if we use new data (from file or from internal hierarchy), delete the
@ -931,8 +923,10 @@ otherwise delete current sheet data)" );
if( m_AssociatedScreen && (LoadFromFile || Screen_to_use) )
{
m_AssociatedScreen->m_RefCount--;
if( m_AssociatedScreen->m_RefCount == 0 )
SAFE_DELETE( m_AssociatedScreen );
m_AssociatedScreen = NULL; // so that we reload..
}
@ -944,13 +938,13 @@ otherwise delete current sheet data)" );
m_AssociatedScreen->m_RefCount++;
}
//just make a new screen if needed.
if( !m_AssociatedScreen )
{
m_AssociatedScreen = new SCH_SCREEN();
m_AssociatedScreen->m_RefCount++; // be careful with these
}
m_AssociatedScreen->m_FileName = aFileName;
return true;
@ -995,6 +989,7 @@ void SCH_SHEET::Mirror_X( int aXaxis_position )
NEGATE( m_Pos.y );
m_Pos.y += aXaxis_position;
m_Pos.y -= m_Size.y;
BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, m_labels )
{
sheetPin.Mirror_X( aXaxis_position );
@ -1012,7 +1007,6 @@ void SCH_SHEET::Mirror_Y( int aYaxis_position )
m_Pos.x -= aYaxis_position;
NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position;
m_Pos.x -= m_Size.x;
BOOST_FOREACH( SCH_SHEET_PIN& label, m_labels )
@ -1050,6 +1044,7 @@ bool SCH_SHEET::Matches( wxFindReplaceData& aSearchData,
{
if( aFindLocation )
*aFindLocation = GetFileNamePosition();
return true;
}
@ -1057,6 +1052,7 @@ bool SCH_SHEET::Matches( wxFindReplaceData& aSearchData,
{
if( aFindLocation )
*aFindLocation = GetSheetNamePosition();
return true;
}
@ -1084,7 +1080,7 @@ void SCH_SHEET::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
{
SCH_SHEET_PIN &pinsheet = GetSheetPins()[ii];
wxCHECK2_MSG( pinsheet.Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE, continue,
wxCHECK2_MSG( pinsheet.Type() == SCH_SHEET_LABEL_T, continue,
wxT( "Invalid item in schematic sheet pin list. Bad programmer!" ) );
pinsheet.GetEndPoints( aItemList );
@ -1140,6 +1136,29 @@ void SCH_SHEET::GetConnectionPoints( vector< wxPoint >& aPoints ) const
}
bool SCH_SHEET::DoHitTest( const wxPoint& aPoint, int aAccuracy ) const
{
EDA_Rect rect = GetBoundingBox();
rect.Inflate( aAccuracy );
return rect.Inside( aPoint );
}
bool SCH_SHEET::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const
{
EDA_Rect rect = aRect;
rect.Inflate( aAccuracy );
if( aContained )
return rect.Inside( GetBoundingBox() );
return rect.Intersects( GetBoundingBox() );
}
#if defined(DEBUG)
void SCH_SHEET::Show( int nestLevel, std::ostream& os )

View File

@ -146,7 +146,7 @@ public:
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
virtual int GetPenSize();
virtual int GetPenSize() const;
/**
* Function CreateGraphicShape
@ -235,12 +235,12 @@ public:
public:
SCH_SHEET( const wxPoint& pos = wxPoint( 0, 0 ) );
~SCH_SHEET();
virtual wxString GetClass() const
{
return wxT( "SCH_SHEET" );
}
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.sch"
@ -248,7 +248,7 @@ public:
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
bool Save( FILE* aFile ) const;
/**
* Load schematic sheet from \a aLine in a .sch file.
@ -259,14 +259,16 @@ public:
*/
virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg );
void Place( SCH_EDIT_FRAME* frame, wxDC* DC );
SCH_SHEET* GenCopy();
void DisplayInfo( WinEDA_DrawFrame* frame );
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
* format, we detect orientation based on pin edges
*/
bool IsVerticalOrientation();
bool IsVerticalOrientation();
/**
* Add aLabel to this sheet.
@ -277,7 +279,7 @@ public:
*
* @param aLabel - The label to add to the sheet.
*/
void AddLabel( SCH_SHEET_PIN* aLabel );
void AddLabel( SCH_SHEET_PIN* aLabel );
SCH_SHEET_PIN_LIST& GetSheetPins() { return m_labels; }
@ -291,7 +293,7 @@ public:
*
* @param aSheetLabel - The sheet label to remove from the list.
*/
void RemoveLabel( SCH_SHEET_PIN* aSheetLabel );
void RemoveLabel( SCH_SHEET_PIN* aSheetLabel );
/**
* Delete sheet label which do not have a corresponding hierarchical label.
@ -299,7 +301,7 @@ public:
* Note: Make sure you save a copy of the sheet in the undo list before calling
* CleanupSheet() otherwise any unrefernced sheet labels will be lost.
*/
void CleanupSheet();
void CleanupSheet();
/**
* Return the label found at aPosition in this sheet.
@ -317,7 +319,7 @@ public:
*
* @return - True if label found, otherwise false.
*/
bool HasLabel( const wxString& aName );
bool HasLabel( const wxString& aName );
bool HasLabels() { return !m_labels.empty(); }
@ -326,13 +328,13 @@ public:
*
* @return True if there are any undefined labels.
*/
bool HasUndefinedLabels();
bool HasUndefinedLabels();
/**
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
virtual int GetPenSize();
virtual int GetPenSize() const;
/**
* Function Draw
@ -344,33 +346,26 @@ public:
* @param aColor = color used to draw sheet. Usually -1 to use the normal
* color for sheet items
*/
void Draw( WinEDA_DrawPanel* aPanel,
wxDC* aDC,
const wxPoint& aOffset,
int aDrawMode,
int aColor = -1 );
/**
* Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool HitTest( const wxPoint& aPosRef );
void Draw( WinEDA_DrawPanel* aPanel,
wxDC* aDC,
const wxPoint& aOffset,
int aDrawMode,
int aColor = -1 );
/**
* Function GetBoundingBox
* @return an EDA_Rect giving the bounding box of the sheet
*/
EDA_Rect GetBoundingBox();
EDA_Rect GetBoundingBox() const;
void SwapData( SCH_SHEET* copyitem );
void SwapData( SCH_SHEET* copyitem );
/**
* Function ComponentCount
* count our own components, without the power components.
* @return the component count.
*/
int ComponentCount();
int ComponentCount();
/**
* Function Load.
@ -379,21 +374,19 @@ public:
* m_AssociatedScreen point on the screen, and its m_RefCount is
* incremented
* else creates a new associated screen and load the data file.
* @param aFrame = a SCH_EDIT_FRAME pointer to the maim schematic
* frame
* @param aFrame = a SCH_EDIT_FRAME pointer to the maim schematic frame
* @return true if OK
*/
bool Load( SCH_EDIT_FRAME* aFrame );
bool Load( SCH_EDIT_FRAME* aFrame );
/**
* Function SearchHierarchy
* search the existing hierarchy for an instance of screen "FileName".
* @param aFilename = the filename to find
* @param aFilename = a location to return a pointer to the screen (if
* found)
* @param aFilename = a location to return a pointer to the screen (if found)
* @return bool if found, and a pointer to the screen
*/
bool SearchHierarchy( wxString aFilename, SCH_SCREEN** aScreen );
bool SearchHierarchy( wxString aFilename, SCH_SCREEN** aScreen );
/**
* Function LocatePathOfScreen
@ -406,8 +399,7 @@ public:
* @param aList = the SCH_SHEET_PATH* that must be used
* @return true if found
*/
bool LocatePathOfScreen( SCH_SCREEN* aScreen,
SCH_SHEET_PATH* aList );
bool LocatePathOfScreen( SCH_SCREEN* aScreen, SCH_SHEET_PATH* aList );
/**
* Function CountSheets
@ -415,7 +407,7 @@ public:
* this number includes the full subsheets count
* @return the full count of sheets+subsheets contained by "this"
*/
int CountSheets();
int CountSheets();
/**
* Function GetFileName
@ -430,7 +422,6 @@ public:
m_FileName = aFilename;
}
/**
* Function ChangeFileName
* Set a new filename and manage data and associated screen
@ -464,7 +455,6 @@ public:
}
}
/** virtual function Mirror_Y
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
@ -491,7 +481,7 @@ public:
*
* @param aSize - The new size for this sheet.
*/
void Resize( const wxSize& aSize );
void Resize( const wxSize& aSize );
/**
* Function GetSheetNamePosition
@ -532,6 +522,10 @@ protected:
* label is added or removed.
*/
void renumberLabels();
private:
virtual bool DoHitTest( const wxPoint& aPoint, int aAccuracy ) const;
virtual bool DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const;
};
#endif /* CLASS_DRAWSHEET_H */

View File

@ -57,7 +57,7 @@ bool SCH_SHEET_PATH::BuildSheetPathInfoFromSheetPathValue( const wxString& aPath
SCH_ITEM* schitem = LastDrawList();
while( schitem && GetSheetsCount() < NB_MAX_SHEET )
{
if( schitem->Type() == DRAW_SHEET_STRUCT_TYPE )
if( schitem->Type() == SCH_SHEET_T )
{
SCH_SHEET* sheet = (SCH_SHEET*) schitem;
Push( sheet );
@ -259,7 +259,7 @@ void SCH_SHEET_PATH::UpdateAllScreenReferences()
while( t )
{
if( t->Type() == TYPE_SCH_COMPONENT )
if( t->Type() == SCH_COMPONENT_T )
{
SCH_COMPONENT* component = (SCH_COMPONENT*) t;
component->GetField( REFERENCE )->m_Text = component->GetRef( this );
@ -536,7 +536,7 @@ void SCH_SHEET_LIST::BuildSheetList( SCH_SHEET* aSheet )
while( strct )
{
if( strct->Type() == DRAW_SHEET_STRUCT_TYPE )
if( strct->Type() == SCH_SHEET_T )
{
SCH_SHEET* sheet = (SCH_SHEET*) strct;
BuildSheetList( sheet );

View File

@ -36,7 +36,7 @@
*/
SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos, const wxString& text ) :
SCH_HIERLABEL( pos, text, DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
SCH_HIERLABEL( pos, text, SCH_SHEET_LABEL_T )
{
SetParent( parent );
wxASSERT( parent );
@ -103,7 +103,7 @@ bool SCH_SHEET_PIN::operator==( const SCH_SHEET_PIN* aPin ) const
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
int SCH_SHEET_PIN::GetPenSize()
int SCH_SHEET_PIN::GetPenSize() const
{
return g_DrawDefaultLineThickness;
}

View File

@ -87,17 +87,6 @@ SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) :
}
/**
* Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool SCH_TEXT::HitTest( const wxPoint& aPosRef )
{
return TextHitTest( aPosRef );
}
SCH_TEXT* SCH_TEXT::GenCopy()
{
SCH_TEXT* newitem;
@ -105,19 +94,19 @@ SCH_TEXT* SCH_TEXT::GenCopy()
switch( Type() )
{
default:
case TYPE_SCH_TEXT:
case SCH_TEXT_T:
newitem = new SCH_TEXT( m_Pos, m_Text );
break;
case TYPE_SCH_GLOBALLABEL:
case SCH_GLOBAL_LABEL_T:
newitem = new SCH_GLOBALLABEL( m_Pos, m_Text );
break;
case TYPE_SCH_HIERLABEL:
case SCH_HIERARCHICAL_LABEL_T:
newitem = new SCH_HIERLABEL( m_Pos, m_Text );
break;
case TYPE_SCH_LABEL:
case SCH_LABEL_T:
newitem = new SCH_LABEL( m_Pos, m_Text );
break;
}
@ -403,7 +392,7 @@ void SCH_TEXT::Place( SCH_EDIT_FRAME* frame, wxDC* DC )
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
int SCH_TEXT::GetPenSize()
int SCH_TEXT::GetPenSize() const
{
int pensize = m_Thickness;
@ -443,6 +432,7 @@ void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aOffset,
EXCHG( linewidth, m_Thickness ); // Set the minimum width
EDA_TextStruct::Draw( panel, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR );
EXCHG( linewidth, m_Thickness ); // set initial value
if( m_IsDangling )
DrawDanglingSymbol( panel, DC, m_Pos + aOffset, color );
@ -475,6 +465,7 @@ bool SCH_TEXT::Save( FILE* aFile ) const
for( ; ; )
{
int i = text.find( '\n' );
if( i == wxNOT_FOUND )
break;
@ -545,6 +536,7 @@ bool SCH_TEXT::Load( LINE_READER& aLine, wxString& aErrorMsg )
if( i == wxNOT_FOUND )
break;
val.erase( i, 2 );
val.insert( i, wxT( "\n" ) );
}
@ -570,7 +562,7 @@ bool SCH_TEXT::Load( LINE_READER& aLine, wxString& aErrorMsg )
void SCH_TEXT::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
{
// Normal text labels cannot be tested for dangling ends.
if( Type() == TYPE_SCH_TEXT )
if( Type() == SCH_TEXT_T )
return;
DANGLING_END_ITEM item( LABEL_END, this );
@ -582,7 +574,7 @@ void SCH_TEXT::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
bool SCH_TEXT::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList )
{
// Normal text labels cannot be tested for dangling ends.
if( Type() == TYPE_SCH_TEXT )
if( Type() == SCH_TEXT_T )
return false;
bool previousState = m_IsDangling;
@ -647,23 +639,22 @@ bool SCH_TEXT::IsSelectStateChanged( const wxRect& aRect )
void SCH_TEXT::GetConnectionPoints( vector< wxPoint >& aPoints ) const
{
// Normal text labels do not have connection points. All others do.
if( Type() == TYPE_SCH_TEXT )
if( Type() == SCH_TEXT_T )
return;
aPoints.push_back( m_Pos );
}
EDA_Rect SCH_TEXT::GetBoundingBox()
EDA_Rect SCH_TEXT::GetBoundingBox() const
{
// We must pass the effective text thickness to GetTextBox
// when calculating the bounding box
int linewidth = ( m_Thickness == 0 ) ? g_DrawDefaultLineThickness : m_Thickness;
linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold );
EXCHG( linewidth, m_Thickness ); // Set the real width
EDA_Rect rect = GetTextBox( -1 );
EXCHG( linewidth, m_Thickness ); // set initial value
EDA_Rect rect = GetTextBox( -1, linewidth );
if( m_Orient ) // Rotate rect
{
@ -680,6 +671,18 @@ EDA_Rect SCH_TEXT::GetBoundingBox()
}
bool SCH_TEXT::DoHitTest( const wxPoint& aPoint, int aAccuracy ) const
{
return TextHitTest( aPoint, aAccuracy );
}
bool SCH_TEXT::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const
{
return TextHitTest( aRect, aContained, aAccuracy );
}
#if defined(DEBUG)
void SCH_TEXT::Show( int nestLevel, std::ostream& os )
@ -733,7 +736,7 @@ void SCH_LABEL::SetSchematicTextOrientation( int aSchematicOrientation )
SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) :
SCH_TEXT( pos, text, TYPE_SCH_LABEL )
SCH_TEXT( pos, text, SCH_LABEL_T )
{
m_Layer = LAYER_LOCLABEL;
m_Shape = NET_INPUT;
@ -867,7 +870,7 @@ void SCH_LABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
}
EDA_Rect SCH_LABEL::GetBoundingBox()
EDA_Rect SCH_LABEL::GetBoundingBox() const
{
int x, y, dx, dy, length, height;
@ -916,7 +919,7 @@ EDA_Rect SCH_LABEL::GetBoundingBox()
SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) :
SCH_TEXT( pos, text, TYPE_SCH_GLOBALLABEL )
SCH_TEXT( pos, text, SCH_GLOBAL_LABEL_T )
{
m_Layer = LAYER_GLOBLABEL;
m_Shape = NET_BIDI;
@ -1014,19 +1017,6 @@ bool SCH_GLOBALLABEL::Load( LINE_READER& aLine, wxString& aErrorMsg )
}
/**
* Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool SCH_GLOBALLABEL::HitTest( const wxPoint& aPosRef )
{
EDA_Rect rect = GetBoundingBox();
return rect.Inside( aPosRef );
}
/**
* Function Mirror_Y (virtual)
* mirror item relative to an Y axis
@ -1317,7 +1307,7 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
}
EDA_Rect SCH_GLOBALLABEL::GetBoundingBox()
EDA_Rect SCH_GLOBALLABEL::GetBoundingBox() const
{
int x, y, dx, dy, length, height;
@ -1467,19 +1457,6 @@ bool SCH_HIERLABEL::Load( LINE_READER& aLine, wxString& aErrorMsg )
}
/**
* Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool SCH_HIERLABEL::HitTest( const wxPoint& aPosRef )
{
EDA_Rect rect = GetBoundingBox();
return rect.Inside( aPosRef );
}
/**
* Function SetTextOrientAndJustifyParmeters
* Set m_SchematicOrientation, and initialize
@ -1598,7 +1575,7 @@ void SCH_HIERLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
}
}
EDA_Rect SCH_HIERLABEL::GetBoundingBox()
EDA_Rect SCH_HIERLABEL::GetBoundingBox() const
{
int x, y, dx, dy, length, height;

View File

@ -31,7 +31,6 @@ extern const char* SheetLabelType[]; /* names of types of labels */
class SCH_TEXT : public SCH_ITEM, public EDA_TextStruct
{
public:
int m_Layer;
int m_Shape;
bool m_IsDangling; // true if not connected (used to draw the "not
// connected" symbol
@ -56,7 +55,7 @@ protected:
public:
SCH_TEXT( const wxPoint& pos = wxPoint( 0, 0 ),
const wxString& text = wxEmptyString,
KICAD_T aType = TYPE_SCH_TEXT );
KICAD_T aType = SCH_TEXT_T );
~SCH_TEXT() { }
virtual wxString GetClass() const
@ -78,9 +77,9 @@ public:
* position of 0
* 3 = bottom . This can be seen as the mirrored position of up
*/
virtual void SetSchematicTextOrientation( int aSchematicOrientation );
virtual void SetSchematicTextOrientation( int aSchematicOrientation );
int GetSchematicTextOrientation() { return m_SchematicOrientation; }
int GetSchematicTextOrientation() { return m_SchematicOrientation; }
/**
* Function GetSchematicTextOffset (virtual)
@ -92,12 +91,13 @@ public:
*/
virtual wxPoint GetSchematicTextOffset();
SCH_TEXT* GenCopy();
virtual void Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
const wxPoint& offset,
int draw_mode,
int Color = -1 );
SCH_TEXT* GenCopy();
virtual void Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
const wxPoint& offset,
int draw_mode,
int Color = -1 );
/**
* Function CreateGraphicShape
@ -107,21 +107,14 @@ public:
* for texts and labels: do nothing
* Mainly for derived classes (SCH_SHEET_PIN and Hierarchical labels)
*/
virtual void CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
const wxPoint& Pos )
virtual void CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint& Pos )
{
aCorner_list.clear();
}
void SwapData( SCH_TEXT* copyitem );
void Place( SCH_EDIT_FRAME* frame, wxDC* DC );
void SwapData( SCH_TEXT* copyitem );
/**
* Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool HitTest( const wxPoint& aPosRef );
void Place( SCH_EDIT_FRAME* frame, wxDC* DC );
/**
* Function GetBoundingBox
@ -130,7 +123,7 @@ public:
* 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();
EDA_Rect GetBoundingBox() const;
/**
* Function Save
@ -139,7 +132,7 @@ public:
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
bool Save( FILE* aFile ) const;
/**
* Load schematic text entry from \a aLine in a .sch file.
@ -155,7 +148,7 @@ public:
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
int GetPenSize();
int GetPenSize() const;
// Geometric transforms (used in block operations):
@ -200,17 +193,20 @@ public:
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os );
#endif
private:
virtual bool DoHitTest( const wxPoint& aPoint, int aAccuracy ) const;
virtual bool DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const;
};
class SCH_LABEL : public SCH_TEXT
{
public:
SCH_LABEL( const wxPoint& pos = wxPoint( 0, 0 ),
const wxString& text = wxEmptyString );
SCH_LABEL( const wxPoint& pos = wxPoint( 0, 0 ), const wxString& text = wxEmptyString );
~SCH_LABEL() { }
virtual void Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
const wxPoint& offset,
@ -257,7 +253,7 @@ public:
* 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();
EDA_Rect GetBoundingBox() const;
/**
* Function Save
@ -283,9 +279,9 @@ public:
class SCH_GLOBALLABEL : public SCH_TEXT
{
public:
SCH_GLOBALLABEL( const wxPoint& pos = wxPoint( 0, 0 ),
const wxString& text = wxEmptyString );
SCH_GLOBALLABEL( const wxPoint& pos = wxPoint( 0, 0 ), const wxString& text = wxEmptyString );
~SCH_GLOBALLABEL() { }
virtual void Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
const wxPoint& offset,
@ -342,13 +338,6 @@ public:
*/
virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg );
/**
* Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool HitTest( const wxPoint& aPosRef );
/**
* Function GetBoundingBox
* returns the orthogonal, bounding box of this object for display purposes.
@ -356,7 +345,7 @@ public:
* 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();
EDA_Rect GetBoundingBox() const;
/**
* Function CreateGraphicShape (virual)
@ -381,7 +370,9 @@ class SCH_HIERLABEL : public SCH_TEXT
{
public:
SCH_HIERLABEL( const wxPoint& pos = wxPoint( 0, 0 ),
const wxString& text = wxEmptyString, KICAD_T aType = TYPE_SCH_HIERLABEL );
const wxString& text = wxEmptyString,
KICAD_T aType = SCH_HIERARCHICAL_LABEL_T );
~SCH_HIERLABEL() { }
virtual void Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
@ -448,13 +439,6 @@ public:
*/
virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg );
/**
* Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool HitTest( const wxPoint& aPosRef );
/**
* Function GetBoundingBox
* returns the orthogonal, bounding box of this object for display purposes.
@ -462,7 +446,7 @@ public:
* 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();
EDA_Rect GetBoundingBox() const;
/** virtual function Mirror_Y
* mirror item relative to an Y axis

View File

@ -277,22 +277,22 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL:
DrawPanel->MouseToCursorSchema();
ConvertTextType( (SCH_TEXT*) screen->GetCurItem(), &dc, TYPE_SCH_LABEL );
ConvertTextType( (SCH_TEXT*) screen->GetCurItem(), &dc, SCH_LABEL_T );
break;
case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL:
DrawPanel->MouseToCursorSchema();
ConvertTextType( (SCH_TEXT*) screen->GetCurItem(), &dc, TYPE_SCH_GLOBALLABEL );
ConvertTextType( (SCH_TEXT*) screen->GetCurItem(), &dc, SCH_GLOBAL_LABEL_T );
break;
case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL:
DrawPanel->MouseToCursorSchema();
ConvertTextType( (SCH_TEXT*) screen->GetCurItem(), &dc, TYPE_SCH_HIERLABEL );
ConvertTextType( (SCH_TEXT*) screen->GetCurItem(), &dc, SCH_HIERARCHICAL_LABEL_T );
break;
case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT:
DrawPanel->MouseToCursorSchema();
ConvertTextType( (SCH_TEXT*) screen->GetCurItem(), &dc, TYPE_SCH_TEXT );
ConvertTextType( (SCH_TEXT*) screen->GetCurItem(), &dc, SCH_TEXT_T );
break;
case ID_POPUP_SCH_SET_SHAPE_TEXT:
@ -338,7 +338,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
// Ensure the struct is a component (could be a struct of a
// component, like Field, text..)
if( screen->GetCurItem()->Type() != TYPE_SCH_COMPONENT )
if( screen->GetCurItem()->Type() != SCH_COMPONENT_T )
screen->SetCurItem( LocateSmallestComponent( screen ) );
case ID_POPUP_SCH_DELETE:
@ -378,12 +378,12 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_IMPORT_GLABEL:
if( screen->GetCurItem() && screen->GetCurItem()->Type() == DRAW_SHEET_STRUCT_TYPE )
if( screen->GetCurItem() && screen->GetCurItem()->Type() == SCH_SHEET_T )
GetScreen()->SetCurItem( Import_PinSheet( (SCH_SHEET*) screen->GetCurItem(), &dc ) );
break;
case ID_POPUP_SCH_CLEANUP_SHEET:
if( screen->GetCurItem() && screen->GetCurItem()->Type() == DRAW_SHEET_STRUCT_TYPE )
if( screen->GetCurItem() && screen->GetCurItem()->Type() == SCH_SHEET_T )
{
SCH_SHEET* sheet = (SCH_SHEET*) screen->GetCurItem();
@ -420,11 +420,11 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
// Ensure the struct is a component (could be a struct of a
// component, like Field, text..) or a hierachical sheet
// or a label
if( (screen->GetCurItem()->Type() != TYPE_SCH_COMPONENT)
&& (screen->GetCurItem()->Type() != TYPE_SCH_LABEL)
&& (screen->GetCurItem()->Type() != TYPE_SCH_GLOBALLABEL)
&& (screen->GetCurItem()->Type() != TYPE_SCH_HIERLABEL)
&& (screen->GetCurItem()->Type() != DRAW_SHEET_STRUCT_TYPE) )
if( (screen->GetCurItem()->Type() != SCH_COMPONENT_T)
&& (screen->GetCurItem()->Type() != SCH_LABEL_T)
&& (screen->GetCurItem()->Type() != SCH_GLOBAL_LABEL_T)
&& (screen->GetCurItem()->Type() != SCH_HIERARCHICAL_LABEL_T)
&& (screen->GetCurItem()->Type() != SCH_SHEET_T) )
screen->SetCurItem( LocateSmallestComponent( screen ) );
if( screen->GetCurItem() == NULL )
@ -487,7 +487,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
// Ensure the struct is a component (could be a struct of a
// component, like Field, text..)
if( screen->GetCurItem()->Type() != TYPE_SCH_COMPONENT )
if( screen->GetCurItem()->Type() != SCH_COMPONENT_T )
screen->SetCurItem( LocateSmallestComponent( screen ) );
if( screen->GetCurItem() == NULL )
@ -504,7 +504,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
// Ensure the struct is a component (could be a struct of a
// component, like Field, text..)
if( screen->GetCurItem()->Type() != TYPE_SCH_COMPONENT )
if( screen->GetCurItem()->Type() != SCH_COMPONENT_T )
screen->SetCurItem( LocateSmallestComponent( screen ) );
if( screen->GetCurItem() == NULL )
@ -548,7 +548,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
// Ensure the struct is a component (could be a struct of a
// component, like Field, text..)
if( screen->GetCurItem()->Type() != TYPE_SCH_COMPONENT )
if( screen->GetCurItem()->Type() != SCH_COMPONENT_T )
screen->SetCurItem( LocateSmallestComponent( screen ) );
if( screen->GetCurItem() == NULL )
@ -561,7 +561,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
// Ensure the struct is a component (could be a struct of a
// component, like Field, text..)
if( screen->GetCurItem()->Type() != TYPE_SCH_COMPONENT )
if( screen->GetCurItem()->Type() != SCH_COMPONENT_T )
screen->SetCurItem( LocateSmallestComponent( screen ) );
if( screen->GetCurItem() == NULL )
@ -574,7 +574,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
// Ensure the struct is a component (could be a struct of a
// component, like Field, text..)
if( screen->GetCurItem()->Type() != TYPE_SCH_COMPONENT )
if( screen->GetCurItem()->Type() != SCH_COMPONENT_T )
screen->SetCurItem( LocateSmallestComponent( screen ) );
if( screen->GetCurItem() == NULL )
@ -588,7 +588,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
// Ensure the struct is a component (could be a struct of a
// component, like Field, text..)
if( screen->GetCurItem()->Type() != TYPE_SCH_COMPONENT )
if( screen->GetCurItem()->Type() != SCH_COMPONENT_T )
screen->SetCurItem( LocateSmallestComponent( screen ) );
if( screen->GetCurItem() == NULL )
@ -627,7 +627,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
// Ensure the struct is a component (could be a struct of a
// component, like Field, text..)
if( screen->GetCurItem()->Type() != TYPE_SCH_COMPONENT )
if( screen->GetCurItem()->Type() != SCH_COMPONENT_T )
screen->SetCurItem( LocateSmallestComponent( screen ) );
if( screen->GetCurItem() == NULL )
@ -642,7 +642,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
// Ensure the struct is a component (could be a piece of a
// component, like Field, text..)
if( screen->GetCurItem()->Type() != TYPE_SCH_COMPONENT )
if( screen->GetCurItem()->Type() != SCH_COMPONENT_T )
screen->SetCurItem( LocateSmallestComponent( screen ) );
if( screen->GetCurItem() == NULL )
@ -664,7 +664,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
EDA_ITEM* DrawStruct = screen->GetCurItem();
if( DrawStruct && (DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE) )
if( DrawStruct && (DrawStruct->Type() == SCH_SHEET_T) )
{
InstallNextScreen( (SCH_SHEET*) DrawStruct );
}
@ -744,7 +744,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_SCH_GETINFO_MARKER:
if( screen->GetCurItem() && screen->GetCurItem()->Type() == TYPE_SCH_MARKER )
if( screen->GetCurItem() && screen->GetCurItem()->Type() == SCH_MARKER_T )
( (SCH_MARKER*) screen->GetCurItem() )->DisplayMarkerInfo( this );
break;
@ -772,40 +772,40 @@ void SCH_EDIT_FRAME::Process_Move_Item( SCH_ITEM* DrawStruct, wxDC* DC )
switch( DrawStruct->Type() )
{
case DRAW_JUNCTION_STRUCT_TYPE:
case SCH_JUNCTION_T:
break;
case DRAW_BUSENTRY_STRUCT_TYPE:
case SCH_BUS_ENTRY_T:
StartMoveBusEntry( (SCH_BUS_ENTRY*) DrawStruct, DC );
break;
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
case TYPE_SCH_TEXT:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_TEXT_T:
StartMoveTexte( (SCH_TEXT*) DrawStruct, DC );
break;
case TYPE_SCH_COMPONENT:
case SCH_COMPONENT_T:
StartMovePart( (SCH_COMPONENT*) DrawStruct, DC );
break;
case DRAW_SEGMENT_STRUCT_TYPE:
case SCH_LINE_T:
break;
case DRAW_SHEET_STRUCT_TYPE:
case SCH_SHEET_T:
StartMoveSheet( (SCH_SHEET*) DrawStruct, DC );
break;
case DRAW_NOCONNECT_STRUCT_TYPE:
case SCH_NO_CONNECT_T:
break;
case DRAW_PART_TEXT_STRUCT_TYPE:
case SCH_FIELD_T:
StartMoveCmpField( (SCH_FIELD*) DrawStruct, DC );
break;
case TYPE_SCH_MARKER:
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case SCH_MARKER_T:
case SCH_SHEET_LABEL_T:
default:
wxString msg;
msg.Printf( wxT( "SCH_EDIT_FRAME::Move_Item Error: Bad DrawType %d" ),

View File

@ -88,14 +88,14 @@ void SwapData( EDA_ITEM* aItem, EDA_ITEM* aImage )
switch( aItem->Type() )
{
case DRAW_POLYLINE_STRUCT_TYPE:
case SCH_POLYLINE_T:
#undef SOURCE
#undef DEST
#define SOURCE ( (SCH_POLYLINE*) aItem )
#define DEST ( (SCH_POLYLINE*) aImage )
break;
case DRAW_JUNCTION_STRUCT_TYPE:
case SCH_JUNCTION_T:
#undef SOURCE
#undef DEST
#define SOURCE ( (SCH_JUNCTION*) aItem )
@ -103,10 +103,10 @@ void SwapData( EDA_ITEM* aItem, EDA_ITEM* aImage )
EXCHG( SOURCE->m_Pos, DEST->m_Pos );
break;
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
case TYPE_SCH_TEXT:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_TEXT_T:
#undef SOURCE
#undef DEST
#define SOURCE ( (SCH_TEXT*) aItem )
@ -114,7 +114,7 @@ void SwapData( EDA_ITEM* aItem, EDA_ITEM* aImage )
DEST->SwapData( SOURCE );
break;
case TYPE_SCH_COMPONENT:
case SCH_COMPONENT_T:
#undef SOURCE
#undef DEST
#define SOURCE ( (SCH_COMPONENT*) aItem )
@ -122,7 +122,7 @@ void SwapData( EDA_ITEM* aItem, EDA_ITEM* aImage )
DEST->SwapData( SOURCE );
break;
case DRAW_SEGMENT_STRUCT_TYPE:
case SCH_LINE_T:
#undef SOURCE
#undef DEST
#define SOURCE ( (SCH_LINE*) aItem )
@ -131,7 +131,7 @@ void SwapData( EDA_ITEM* aItem, EDA_ITEM* aImage )
EXCHG( SOURCE->m_End, DEST->m_End );
break;
case DRAW_BUSENTRY_STRUCT_TYPE:
case SCH_BUS_ENTRY_T:
#undef SOURCE
#undef DEST
#define SOURCE ( (SCH_BUS_ENTRY*) aItem )
@ -140,7 +140,7 @@ void SwapData( EDA_ITEM* aItem, EDA_ITEM* aImage )
EXCHG( SOURCE->m_Size, DEST->m_Size );
break;
case DRAW_SHEET_STRUCT_TYPE:
case SCH_SHEET_T:
#undef SOURCE
#undef DEST
#define SOURCE ( (SCH_SHEET*) aItem )
@ -148,7 +148,7 @@ void SwapData( EDA_ITEM* aItem, EDA_ITEM* aImage )
DEST->SwapData( SOURCE );
break;
case TYPE_SCH_MARKER:
case SCH_MARKER_T:
#undef SOURCE
#undef DEST
#define SOURCE ( (SCH_MARKER*) aItem )
@ -156,7 +156,7 @@ void SwapData( EDA_ITEM* aItem, EDA_ITEM* aImage )
EXCHG( SOURCE->m_Pos, DEST->m_Pos );
break;
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case SCH_SHEET_LABEL_T:
#undef SOURCE
#undef DEST
#define SOURCE ( (SCH_SHEET_PIN*) aItem )
@ -164,7 +164,7 @@ void SwapData( EDA_ITEM* aItem, EDA_ITEM* aImage )
DEST->SwapData( SOURCE );
break;
case DRAW_NOCONNECT_STRUCT_TYPE:
case SCH_NO_CONNECT_T:
#undef SOURCE
#undef DEST
#define SOURCE ( (SCH_NO_CONNECT*) aItem )
@ -172,7 +172,7 @@ void SwapData( EDA_ITEM* aItem, EDA_ITEM* aImage )
EXCHG( SOURCE->m_Pos, DEST->m_Pos );
break;
case DRAW_PART_TEXT_STRUCT_TYPE:
case SCH_FIELD_T:
break;
// not directly used in schematic:

View File

@ -244,7 +244,7 @@ void SCH_EDIT_FRAME::ReSizeSheet( SCH_SHEET* aSheet, wxDC* aDC )
if( aSheet == NULL || aSheet->m_Flags & IS_NEW )
return;
if( aSheet->Type() != DRAW_SHEET_STRUCT_TYPE )
if( aSheet->Type() != SCH_SHEET_T )
{
DisplayError( this, wxT( "SCH_EDIT_FRAME::ReSizeSheet: Bad SructType" ) );
return;
@ -280,7 +280,7 @@ void SCH_EDIT_FRAME::ReSizeSheet( SCH_SHEET* aSheet, wxDC* aDC )
void SCH_EDIT_FRAME::StartMoveSheet( SCH_SHEET* aSheet, wxDC* aDC )
{
if( ( aSheet == NULL ) || ( aSheet->Type() != DRAW_SHEET_STRUCT_TYPE ) )
if( ( aSheet == NULL ) || ( aSheet->Type() != SCH_SHEET_T ) )
return;
DrawPanel->CursorOff( aDC );

View File

@ -65,7 +65,7 @@ void SCH_SHEET_PIN::Place( SCH_EDIT_FRAME* frame, wxDC* DC )
{
SCH_SHEET* Sheet = (SCH_SHEET*) GetParent();
wxASSERT( Sheet != NULL && Sheet->Type() == DRAW_SHEET_STRUCT_TYPE );
wxASSERT( Sheet != NULL && Sheet->Type() == SCH_SHEET_T );
SAFE_DELETE( g_ItemToUndoCopy );
int flags = m_Flags;
@ -213,7 +213,7 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::Import_PinSheet( SCH_SHEET* Sheet, wxDC* DC )
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
{
if( DrawStruct->Type() != TYPE_SCH_HIERLABEL )
if( DrawStruct->Type() != SCH_HIERARCHICAL_LABEL_T )
continue;
HLabel = (SCH_HIERLABEL*) DrawStruct;
@ -260,7 +260,7 @@ void SCH_EDIT_FRAME::DeleteSheetLabel( bool aRedraw, SCH_SHEET_PIN* aSheetLabelT
SCH_SHEET* parent = (SCH_SHEET*) aSheetLabelToDel->GetParent();
wxASSERT( parent );
wxASSERT( parent->Type() == DRAW_SHEET_STRUCT_TYPE );
wxASSERT( parent->Type() == SCH_SHEET_T );
#if 0 && defined(DEBUG)
std::cout << "\n\nbefore deleting:\n" << std::flush;

View File

@ -90,7 +90,7 @@ void LIB_EDIT_FRAME::LoadOneSymbol( void )
BOOST_FOREACH( LIB_DRAW_ITEM& item, drawList )
{
if( item.Type() == COMPONENT_FIELD_DRAW_TYPE )
if( item.Type() == LIB_FIELD_T )
continue;
if( item.GetUnit() )
item.SetUnit( m_unit );
@ -200,11 +200,13 @@ void LIB_EDIT_FRAME::SaveOneSymbol()
BOOST_FOREACH( LIB_DRAW_ITEM& item, drawList )
{
if( item.Type() == COMPONENT_FIELD_DRAW_TYPE )
if( item.Type() == LIB_FIELD_T )
continue;
/* Don't save unused parts or alternate body styles. */
if( m_unit && item.GetUnit() && ( item.GetUnit() != m_unit ) )
continue;
if( m_convert && item.GetConvert() && ( item.GetConvert() != m_convert ) )
continue;
@ -212,8 +214,7 @@ void LIB_EDIT_FRAME::SaveOneSymbol()
return;
}
if( !file.Write( wxT( "ENDDRAW\n" ) )
|| !file.Write( wxT( "ENDDEF\n" ) ) )
if( !file.Write( wxT( "ENDDRAW\n" ) ) || !file.Write( wxT( "ENDDEF\n" ) ) )
return;
}

View File

@ -347,10 +347,11 @@ int LIB_VIEW_FRAME::BestZoom()
{
if( m_clientSize == wxSize( -1, -1 ) )
m_clientSize = DrawPanel->GetClientSize();
size = m_clientSize;
}
EDA_Rect BoundaryBox = component->GetBoundaryBox( m_unit, m_convert );
EDA_Rect BoundaryBox = component->GetBoundingBox( m_unit, m_convert );
// Reserve a 25 mils margin around component bounding box.
size -= wxSize( 25, 25 );

View File

@ -113,7 +113,7 @@ GERBER_DRAW_ITEM* GERBER_DRAW_ITEM::Copy() const
* @return const wxPoint& - The position in A,B axis.
* Because draw axis is top to bottom, the final y coordinates is negated
*/
wxPoint GERBER_DRAW_ITEM::GetABPosition( const wxPoint& aXYPosition )
wxPoint GERBER_DRAW_ITEM::GetABPosition( const wxPoint& aXYPosition ) const
{
/* Note: RS274Xrevd_e is obscure about the order of transforms:
* For instance: Rotation must be made after or before mirroring ?
@ -255,7 +255,7 @@ D_CODE* GERBER_DRAW_ITEM::GetDcodeDescr()
}
EDA_Rect GERBER_DRAW_ITEM::GetBoundingBox()
EDA_Rect GERBER_DRAW_ITEM::GetBoundingBox() const
{
// return a rectangle which is (pos,dim) in nature. therefore the +1
EDA_Rect bbox( m_Start, wxSize( 1, 1 ) );

View File

@ -168,7 +168,7 @@ public:
* @param aXYPosition = position in X,Y gerber axis
* @return const wxPoint - The given position in plotter A,B axis.
*/
wxPoint GetABPosition(const wxPoint& aXYPosition );
wxPoint GetABPosition( const wxPoint& aXYPosition ) const;
/**
* Function GetXYPosition
@ -178,7 +178,7 @@ public:
* @param aABPosition = position in A,B plotter axis
* @return const wxPoint - The given position in X,Y axis.
*/
wxPoint GetXYPosition(const wxPoint& aABPosition );
wxPoint GetXYPosition( const wxPoint& aABPosition );
/**
* Function GetDcodeDescr
@ -187,7 +187,7 @@ public:
*/
D_CODE* GetDcodeDescr();
EDA_Rect GetBoundingBox();
EDA_Rect GetBoundingBox() const;
/* Display on screen: */
void Draw( WinEDA_DrawPanel* aPanel,

View File

@ -44,23 +44,23 @@ enum KICAD_T {
TYPE_BOARD_ITEM_LIST, // a list of board items
// Draw Items in schematic
DRAW_POLYLINE_STRUCT_TYPE,
DRAW_JUNCTION_STRUCT_TYPE,
TYPE_SCH_TEXT,
TYPE_SCH_LABEL,
TYPE_SCH_GLOBALLABEL,
TYPE_SCH_HIERLABEL,
TYPE_SCH_COMPONENT,
DRAW_SEGMENT_STRUCT_TYPE,
DRAW_BUSENTRY_STRUCT_TYPE,
DRAW_SHEET_STRUCT_TYPE,
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE,
TYPE_SCH_MARKER,
DRAW_NOCONNECT_STRUCT_TYPE,
DRAW_PART_TEXT_STRUCT_TYPE,
SCH_POLYLINE_T,
SCH_JUNCTION_T,
SCH_TEXT_T,
SCH_LABEL_T,
SCH_GLOBAL_LABEL_T,
SCH_HIERARCHICAL_LABEL_T,
SCH_COMPONENT_T,
SCH_LINE_T,
SCH_BUS_ENTRY_T,
SCH_SHEET_T,
SCH_SHEET_LABEL_T,
SCH_MARKER_T,
SCH_NO_CONNECT_T,
SCH_FIELD_T,
// General
SCREEN_STRUCT_TYPE,
SCH_SCREEN_T,
BLOCK_LOCATE_STRUCT_TYPE,
/*
@ -73,20 +73,19 @@ enum KICAD_T {
*/
LIB_COMPONENT_T,
LIB_ALIAS_T,
COMPONENT_ARC_DRAW_TYPE,
COMPONENT_CIRCLE_DRAW_TYPE,
COMPONENT_GRAPHIC_TEXT_DRAW_TYPE,
COMPONENT_RECT_DRAW_TYPE,
COMPONENT_POLYLINE_DRAW_TYPE,
COMPONENT_LINE_DRAW_TYPE,
COMPONENT_BEZIER_DRAW_TYPE,
COMPONENT_PIN_DRAW_TYPE,
LIB_ARC_T,
LIB_CIRCLE_T,
LIB_TEXT_T,
LIB_RECTANGLE_T,
LIB_POLYLINE_T,
LIB_BEZIER_T,
LIB_PIN_T,
/*
* Fields are not saved inside the "DRAW/ENDDRAW". Add new draw item
* types before this line.
*/
COMPONENT_FIELD_DRAW_TYPE,
LIB_FIELD_T,
/*
* For Gerbview: items type:
@ -175,14 +174,15 @@ public:
void Move( const wxPoint& aMoveVector );
void Normalize(); // Ensure the height and width are >= 0
bool Inside( const wxPoint& point ); // Return TRUE if point is in Rect
bool Inside( const wxPoint& point ) const; // Return TRUE if point is in Rect
bool Inside( int x, int y ) { return Inside( wxPoint( x, y ) ); }
wxSize GetSize() { return m_Size; }
bool Inside( int x, int y ) const { return Inside( wxPoint( x, y ) ); }
bool Inside( const EDA_Rect& aRect ) const;
wxSize GetSize() const { return m_Size; }
int GetX() const { return m_Pos.x; }
int GetY() const { return m_Pos.y; }
wxPoint GetOrigin() { return m_Pos; }
wxPoint GetPosition() { return m_Pos; }
wxPoint GetOrigin() const { return m_Pos; }
wxPoint GetPosition() const { return m_Pos; }
wxPoint GetEnd() const { return wxPoint( GetRight(), GetBottom() ); }
int GetWidth() const { return m_Size.x; }
int GetHeight() const { return m_Size.y; }
@ -427,12 +427,11 @@ public:
* system.
* It is OK to overestimate the size by a few counts.
*/
virtual EDA_Rect GetBoundingBox()
virtual EDA_Rect GetBoundingBox() const
{
#if defined(DEBUG)
printf( "Missing GetBoundingBox()\n" );
Show( 0, std::cout ); // tell me which classes still need
// GetBoundingBox support
Show( 0, std::cout ); // tell me which classes still need GetBoundingBox support
#endif
// return a zero-sized box per default. derived classes should override
@ -502,7 +501,7 @@ public:
* of nesting of this object within the overall tree.
* @param os The ostream& to output to.
*/
virtual void Show( int nestLevel, std::ostream& os );
virtual void Show( int nestLevel, std::ostream& os ) const;
/**
@ -589,7 +588,7 @@ public:
EDA_TextStruct( const wxString& text = wxEmptyString );
virtual ~EDA_TextStruct();
int GetLength() const { return m_Text.Length(); };
int GetLength() const { return m_Text.Length(); };
/**
* Function Draw
@ -634,20 +633,23 @@ public:
/**
* Function TextHitTest
* tests if the given wxPoint is within the bounds of this object.
* @param ref_pos A wxPoint to test
* Test if \a aPoint is within the bounds of this object.
* @param aPoint- A wxPoint to test
* @param aAccuracy - Amount to inflate the bounding box.
* @return bool - true if a hit, else false
*/
bool TextHitTest( const wxPoint& ref_pos );
bool TextHitTest( const wxPoint& aPoint, int aAccuracy = 0 ) const;
/**
* Function TextHitTest (overloaded)
* tests if the given EDA_Rect intersect this object.
* For now, the anchor must be inside this rect.
* @param refArea : the given EDA_Rect
* Tests if object bounding box is contained within or intersects \a aRect.
*
* @param aRect - Rect to test against.
* @param aContains - Test for containment instead of intersection if true.
* @param aAccuracy - Amount to inflate the bounding box.
* @return bool - true if a hit, else false
*/
bool TextHitTest( EDA_Rect& refArea );
bool TextHitTest( const EDA_Rect& aRect, bool aContains = false, int aAccuracy = 0 ) const;
/**
* Function LenSize
@ -655,7 +657,7 @@ public:
* @param aLine : the line of text to consider.
* For single line text, this parameter is always m_Text
*/
int LenSize( const wxString& aLine ) const;
int LenSize( const wxString& aLine ) const;
/**
* Function GetTextBox
@ -668,15 +670,17 @@ public:
* @param aLine : the line of text to consider.
* for single line text, aLine is unused
* If aLine == -1, the full area (considering all lines) is returned
* @param aThickness - Overrides the current thickness when greater than 0.
* @param aInvertY - Invert the Y axis when calculating bounding box.
*/
EDA_Rect GetTextBox( int aLine = -1 );
EDA_Rect GetTextBox( int aLine = -1, int aThickness = -1, bool aInvertY = false ) const;
/**
* Function GetInterline
* return the distance between 2 text lines
* has meaning only for multiline texts
*/
int GetInterline()
int GetInterline() const
{
return (( m_Size.y * 14 ) / 10) + m_Thickness;
}

View File

@ -146,7 +146,7 @@ public:
bool m_IsPrinting;
public:
BASE_SCREEN( KICAD_T aType = SCREEN_STRUCT_TYPE );
BASE_SCREEN( KICAD_T aType = TYPE_SCREEN );
~BASE_SCREEN();
/**

View File

@ -187,7 +187,7 @@ public:
* 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 GetBoundingBoxMarker();
EDA_Rect GetBoundingBoxMarker() const;
};

View File

@ -20,7 +20,7 @@ public:
int m_RefCount; ///< Number of sheets referencing this screen.
///< Delete when it goes to zero.
SCH_SCREEN( KICAD_T aType = SCREEN_STRUCT_TYPE );
SCH_SCREEN( KICAD_T aType = SCH_SCREEN_T );
~SCH_SCREEN();
/**

View File

@ -83,26 +83,26 @@ public:
* sets the layer this item is on.
* @param aLayer The layer number.
*/
void SetLayer( int aLayer ) { m_Layer = aLayer; }
void SetLayer( int aLayer ) { m_Layer = aLayer; }
/**
* Function GetPenSize virtual pure
* @return the size of the "pen" that be used to draw or plot this item
*/
virtual int GetPenSize( ) = 0;
virtual int GetPenSize() const { return 0; }
/**
* Function Draw
*/
virtual void Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
const wxPoint& offset,
int draw_mode,
int Color = -1 ) = 0;
virtual void Draw( WinEDA_DrawPanel* aPanel,
wxDC* aDC,
const wxPoint& aOffset,
int aDrawMode,
int aColor = -1 ) = 0;
/* Place function */
virtual void Place( SCH_EDIT_FRAME* frame, wxDC* DC );
virtual void Place( SCH_EDIT_FRAME* aFrame, wxDC* aDC );
// Geometric transforms (used in block operations):
/** virtual function Move
@ -127,7 +127,7 @@ public:
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
virtual bool Save( FILE* aFile ) const = 0;
virtual bool Save( FILE* aFile ) const = 0;
/**
* Load schematic item from \a aLine in a .sch file.
@ -222,6 +222,46 @@ public:
* Do not use the vector erase method on the connection list.
*/
void ClearConnections() { m_connections.release(); }
/**
* Function HitTest().
* Test if \a aPoint is contained within the bounding box or on an item.
*
* @param aPoint - Point to test.
* @param aAccuracy - Increase the item bounding box by this amount.
* @return True if \aPoint is within the item.
*/
bool HitTest( const wxPoint& aPoint, int aAccuracy = 0 ) const
{
return DoHitTest( aPoint, aAccuracy );
}
/**
* Function HitTest().
* Test if \a aRect intersects or is contained within the bounding box of an item.
*
* @param aRect - Rectangle to test.
* @param aContained - Set to true to test for containment instead of an intersection.
* @param aAccuracy - Increase the item bounding box by this amount.
* @return True if \aRect contains or intersects the item bounding box.
*/
bool HitTest( const EDA_Rect& aRect, bool aContained = false, int aAccuracy = 0 ) const
{
return DoHitTest( aRect, aContained, aAccuracy );
}
/**
* @note - The DoXXX() functions below are used to enforce the interface while retaining
* the ability of change the implementation behavior of derived classes. See
* Herb Sutters explanation of virtuality as to why you might want to do this at:
* http://www.gotw.ca/publications/mill18.htm.
*/
private:
virtual bool DoHitTest( const wxPoint& aPoint, int aAccuracy ) const { return false; }
virtual bool DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const
{
return false;
}
};
#endif /* SCH_ITEM_STRUCT_H */

View File

@ -62,7 +62,7 @@ void EDGE_MODULE::Copy( EDGE_MODULE* source )
* 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 EDGE_MODULE::GetBoundingBox()
EDA_Rect EDGE_MODULE::GetBoundingBox() const
{
EDA_Rect bbox;

View File

@ -80,7 +80,7 @@ public:
* object, and the units should be in the pcb or schematic coordinate system.
* It is OK to overestimate the size by a few counts.
*/
virtual EDA_Rect GetBoundingBox();
virtual EDA_Rect GetBoundingBox() const;
/**
* Function HitTest

View File

@ -714,6 +714,31 @@ void MODULE::Set_Rectangle_Encadrement()
}
EDA_Rect MODULE::GetFootPrintRect() const
{
EDA_Rect area;
area.m_Pos = m_Pos;
area.SetEnd( m_Pos );
area.Inflate( 500 ); // Give a min size
for( EDGE_MODULE* edge = (EDGE_MODULE*) m_Drawings.GetFirst(); edge; edge = edge->Next() )
{
if( edge->Type() != TYPE_EDGE_MODULE ) // Shoud not occur
continue;
area.Merge( edge->GetBoundingBox() );
}
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{
area.Merge( pad->GetBoundingBox() );
}
return area;
}
/* Equivalent to Module::Set_Rectangle_Encadrement() but in board coordinates:
* Updates the module bounding box on the board
* The rectangle is the rectangle with outlines and pads, but not the fields
@ -721,29 +746,9 @@ void MODULE::Set_Rectangle_Encadrement()
*/
void MODULE::SetRectangleExinscrit()
{
m_RealBoundaryBox.m_Pos = m_Pos;
m_RealBoundaryBox.SetEnd( m_Pos );
m_RealBoundaryBox.Inflate( 500 ); // Give a min size
m_RealBoundaryBox = GetFootPrintRect();
for( EDGE_MODULE* edge = (EDGE_MODULE*) m_Drawings.GetFirst();
edge; edge = edge->Next() )
{
if( edge->Type() != TYPE_EDGE_MODULE ) // Shoud not occur
continue;
EDA_Rect rect = edge->GetBoundingBox();
m_RealBoundaryBox.Merge( rect );
}
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{
EDA_Rect rect = pad->GetBoundingBox();
m_RealBoundaryBox.Merge( rect );
}
m_Surface = ABS( (double) m_RealBoundaryBox.GetWidth()
* m_RealBoundaryBox.GetHeight() );
m_Surface = ABS( (double) m_RealBoundaryBox.GetWidth() * m_RealBoundaryBox.GetHeight() );
}
@ -752,11 +757,9 @@ void MODULE::SetRectangleExinscrit()
* returns the full bounding box of this Footprint, including fields
* Mainly used to redraw the screen area occupied by the footprint
*/
EDA_Rect MODULE::GetBoundingBox()
EDA_Rect MODULE::GetBoundingBox() const
{
// Calculate area without text fields:
SetRectangleExinscrit();
EDA_Rect area = m_RealBoundaryBox;
EDA_Rect area = GetFootPrintRect();;
// Calculate extended area including text field:
EDA_Rect text_area;
@ -766,11 +769,11 @@ EDA_Rect MODULE::GetBoundingBox()
text_area = m_Value->GetBoundingBox();
area.Merge( text_area );
for( EDGE_MODULE* edge = (EDGE_MODULE*) m_Drawings.GetFirst(); edge;
edge = edge->Next() )
for( EDGE_MODULE* edge = (EDGE_MODULE*) m_Drawings.GetFirst(); edge; edge = edge->Next() )
{
if( edge->Type() != TYPE_TEXTE_MODULE )
continue;
text_area = ( (TEXTE_MODULE*) edge )->GetBoundingBox();
area.Merge( text_area );
}
@ -797,11 +800,11 @@ void MODULE::DisplayInfo( WinEDA_DrawFrame* frame )
BOARD* board = GetBoard();
frame->EraseMsgBox();
if( frame->m_Ident != PCB_FRAME )
flag = TRUE;
frame->AppendMsgPanel( m_Reference->m_Text, m_Value->m_Text,
DARKCYAN );
frame->AppendMsgPanel( m_Reference->m_Text, m_Value->m_Text, DARKCYAN );
if( flag ) // Display last date the component was edited( useful in Module Editor)
{

View File

@ -123,12 +123,18 @@ public:
*/
void SetRectangleExinscrit();
/**
* Function GetFootPrintRect()
* Returns the area of the module footprint excluding any text.
*/
EDA_Rect GetFootPrintRect() const;
/**
* Function GetBoundingBox
* returns the bounding box of this Footprint
* Mainly used to redraw the screen area occupied by the footprint
*/
EDA_Rect GetBoundingBox();
EDA_Rect GetBoundingBox() const;
/**
* Function GetPosition

View File

@ -55,32 +55,41 @@ D_PAD::~D_PAD()
/* Calculate the radius of the circle containing the pad.
*/
void D_PAD::ComputeShapeMaxRadius()
int D_PAD::GetMaxRadius() const
{
int x, y, radius;
switch( m_PadShape & 0x7F )
{
case PAD_CIRCLE:
m_ShapeMaxRadius = m_Size.x / 2;
radius = m_Size.x / 2;
break;
case PAD_OVAL:
m_ShapeMaxRadius = MAX( m_Size.x, m_Size.y ) / 2;
radius = MAX( m_Size.x, m_Size.y ) / 2;
break;
case PAD_RECT:
m_ShapeMaxRadius = 1 + (int) ( sqrt( (double) m_Size.y * m_Size.y
+ (double) m_Size.x * m_Size.x ) / 2 );
radius = 1 + (int) ( sqrt( (double) m_Size.y * m_Size.y
+ (double) m_Size.x * m_Size.x ) / 2 );
break;
case PAD_TRAPEZOID:
{ wxSize fullsize = m_Size;
fullsize.x += ABS(m_DeltaSize.y); // Remember: m_DeltaSize.y is the m_Size.x change
fullsize.y += ABS(m_DeltaSize.x); // Remember: m_DeltaSize.x is the m_Size.y change
m_ShapeMaxRadius = 1 + (int) ( sqrt( (double) m_Size.y * m_Size.y
+ (double) m_Size.x * m_Size.x ) / 2 );
}
x = m_Size.x + ABS( m_DeltaSize.y ); // Remember: m_DeltaSize.y is the m_Size.x change
y = m_Size.y + ABS( m_DeltaSize.x ); // Remember: m_DeltaSize.x is the m_Size.y change
radius = 1 + (int) ( sqrt( (double) y * y + (double) x * x ) / 2 );
break;
}
return radius;
}
/* Calculate the radius of the circle containing the pad.
*/
void D_PAD::ComputeShapeMaxRadius()
{
m_ShapeMaxRadius = GetMaxRadius();
}
@ -89,14 +98,13 @@ void D_PAD::ComputeShapeMaxRadius()
* returns the bounding box of this pad
* Mainly used to redraw the screen area occupied by the pad
*/
EDA_Rect D_PAD::GetBoundingBox()
EDA_Rect D_PAD::GetBoundingBox() const
{
// Calculate area:
ComputeShapeMaxRadius(); // calculate the radius of the area, considered as a
// circle
EDA_Rect area;
int radius = GetMaxRadius(); // Calculate the radius of the area, considered as a circle
area.SetOrigin( m_Pos );
area.Inflate( m_ShapeMaxRadius, m_ShapeMaxRadius );
area.Inflate( radius );
return area;
}

View File

@ -271,6 +271,9 @@ public:
wxString ReturnStringPadName(); // Return pad name as string in a wxString
void ReturnStringPadName( wxString& text ); // Return pad name as string in a buffer
void ComputeShapeMaxRadius(); // compute radius
int GetMaxRadius() const;
const wxPoint ReturnShapePos();
@ -321,13 +324,12 @@ public:
return wxT( "PAD" );
}
/**
* Function GetBoundingBox
* returns the bounding box of this pad
* Mainly used to redraw the screen area occupied by the pad
*/
EDA_Rect GetBoundingBox();
EDA_Rect GetBoundingBox() const;
/**
* Function Compare

View File

@ -194,7 +194,7 @@ void TEXTE_MODULE::Copy( TEXTE_MODULE* source )
}
int TEXTE_MODULE:: GetLength()
int TEXTE_MODULE:: GetLength() const
{
return m_Text.Len();
}
@ -250,7 +250,7 @@ void TEXTE_MODULE:: SetLocalCoord()
* @return an EDA_Rect which gives the position and size of the text area
* (for the footprint orientation)
*/
EDA_Rect TEXTE_MODULE::GetTextRect( void )
EDA_Rect TEXTE_MODULE::GetTextRect( void ) const
{
EDA_Rect area;
@ -303,7 +303,7 @@ bool TEXTE_MODULE::HitTest( const wxPoint& refPos )
* returns the bounding box of this Text (according to text and footprint
* orientation)
*/
EDA_Rect TEXTE_MODULE::GetBoundingBox()
EDA_Rect TEXTE_MODULE::GetBoundingBox() const
{
// Calculate area without text fields:
EDA_Rect text_area;
@ -438,18 +438,19 @@ void TEXTE_MODULE::DrawUmbilical( WinEDA_DrawPanel* aPanel,
/* Return text rotation for drawings and plotting
*/
int TEXTE_MODULE::GetDrawRotation()
int TEXTE_MODULE::GetDrawRotation() const
{
int rotation;
MODULE* Module = (MODULE*) m_Parent;
rotation = m_Orient;
if( Module )
rotation += Module->m_Orient;
NORMALIZE_ANGLE_POS( rotation );
// For angle = 0 .. 180 deg
// For angle = 0 .. 180 deg
while( rotation > 900 )
rotation -= 1800;

View File

@ -47,23 +47,24 @@ public: TEXTE_MODULE( MODULE* parent, int text_type = TEXT_is_DIVERS );
/* Gestion du texte */
void SetWidth( int new_width );
int GetLength(); /* text length */
int GetDrawRotation(); // Return text rotation for drawings and
// plotting
int GetLength() const; /* text length */
int GetDrawRotation() const; // Return text rotation for drawings and plotting
/**
* Function GetTextRect
* @return an EDA_Rect which gives the position and size of the text area
* (for the 0 orient text and footprint)
*/
EDA_Rect GetTextRect( void );
EDA_Rect GetTextRect( void ) const;
/**
* Function GetBoundingBox
* returns the bounding box of this Text (according to text and footprint
* orientation)
*/
EDA_Rect GetBoundingBox();
EDA_Rect GetBoundingBox() const;
void SetDrawCoord(); // Set absolute coordinates.

View File

@ -212,7 +212,7 @@ int TRACK::IsPointOnEnds( const wxPoint& point, int min_dist )
}
EDA_Rect TRACK::GetBoundingBox()
EDA_Rect TRACK::GetBoundingBox() const
{
// end of track is round, this is its radius, rounded up
int radius = ( m_Width + 1 ) / 2;

View File

@ -97,9 +97,7 @@ public:
return m_Start; // it had to be start or end.
}
EDA_Rect GetBoundingBox();
EDA_Rect GetBoundingBox() const;
/**
* Function Save

View File

@ -641,18 +641,19 @@ void ZONE_CONTAINER::DrawFilledArea( WinEDA_DrawPanel* panel,
{
wxPoint start = m_FillSegmList[ic].m_Start + offset;
wxPoint end = m_FillSegmList[ic].m_End + offset;
if( !DisplayOpt.DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
GRCSegm( &panel->m_ClipBox, DC, start.x, start.y, end.x, end.y, m_ZoneMinThickness, color );
GRCSegm( &panel->m_ClipBox, DC, start.x, start.y, end.x, end.y,
m_ZoneMinThickness, color );
else
GRFillCSegm( &panel->m_ClipBox, DC, start.x, start.y, end.x, end.y, m_ZoneMinThickness, color );
GRFillCSegm( &panel->m_ClipBox, DC, start.x, start.y, end.x, end.y,
m_ZoneMinThickness, color );
}
}
}
/****************************************/
EDA_Rect ZONE_CONTAINER::GetBoundingBox()
/****************************************/
EDA_Rect ZONE_CONTAINER::GetBoundingBox() const
{
const int PRELOAD = 0x7FFFFFFF; // Biggest integer (32 bits)

View File

@ -124,7 +124,7 @@ public:
/* Function GetBoundingBox
* @return an EDA_Rect that is the bounding box of the zone outline
*/
EDA_Rect GetBoundingBox();
EDA_Rect GetBoundingBox() const;
/**
* Function Test_For_Copper_Island_And_Remove__Insulated_Islands
@ -324,7 +324,7 @@ public:
/** Acces to m_Poly parameters
*/
int GetNumCorners( void )
int GetNumCorners( void ) const
{
return m_Poly->GetNumCorners();
}
@ -336,7 +336,7 @@ public:
}
wxPoint GetCornerPosition( int aCornerIndex )
wxPoint GetCornerPosition( int aCornerIndex ) const
{
return wxPoint( m_Poly->GetX( aCornerIndex ), m_Poly->GetY( aCornerIndex ) );
}