Commit adb4ad1a authored by Wayne Stambaugh's avatar Wayne Stambaugh

Schematic object improvements and other minor fixes.

parent f64b3a51
......@@ -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
......
......@@ -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"
......
......@@ -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 );
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 );
}
......@@ -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 );
}
/**********************************************************************/
......
......@@ -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
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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 )
{
......
......@@ -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 );
}
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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 );
}
......
......@@ -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;
......
......@@ -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" ) );
......
......@@ -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 );
}
......
......@@ -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;
......
......@@ -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;
......
......@@ -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:
......
......@@ -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;
......
......@@ -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;
......
......@@ -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();
......
......@@ -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;
......
......@@ -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 )
......
......@@ -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++;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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 );
/**
......
......@@ -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;
......
......@@ -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
......
......@@ -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;
......
......@@ -69,7 +69,7 @@ public:
*/
virtual int GetPenSize( );
virtual EDA_Rect GetBoundingBox();
virtual EDA_Rect GetBoundingBox() const;
virtual void DisplayInfo( WinEDA_DrawFrame* aFrame );
/**
......
......@@ -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
......
......@@ -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;
......
......@@ -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)
......
......@@ -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;
......
......@@ -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 );
......
......@@ -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;
......
......@@ -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
......
......@@ -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;
......
......@@ -74,7 +74,8 @@ public:
*/
virtual int GetPenSize( );
virtual EDA_Rect GetBoundingBox();
virtual EDA_Rect GetBoundingBox() const;
virtual void DisplayInfo( WinEDA_DrawFrame* aFrame );
/**
......
......@@ -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();
......
......@@ -98,7 +98,7 @@ public:
virtual void DisplayInfo( WinEDA_DrawFrame* aFrame );
virtual EDA_Rect GetBoundingBox();
virtual EDA_Rect GetBoundingBox() const;
void Rotate();
......
......@@ -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;
......
......@@ -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 );
......
This diff is collapsed.
......@@ -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);
......
......@@ -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();
......
This diff is collapsed.
......@@ -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;
......
......@@ -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;
......
......@@ -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,8 +136,7 @@ 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,
DrawStruct = CreateBusEntry( DC,
(m_ID_current_state == ID_WIRETOBUS_ENTRY_BUTT) ?
WIRE_TO_BUS : BUS_TO_BUS );
GetScreen()->SetCurItem( DrawStruct );
......@@ -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;
......
......@@ -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;
......
......@@ -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 )
{
......
......@@ -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();
......
......@@ -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;
......
......@@ -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;
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();
// This gives a reasonable approximation (but some things are missing so...)
EDA_Rect bbox = GetBoundaryBox();
/* 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() );
}
// ... add padding
bbox.Inflate( PADDING );
bBox.Merge( GetField( ii )->GetBoundingBox() );
}
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() );
}
......@@ -159,12 +159,11 @@ 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 );
/**
......@@ -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>-----------------------------------------------------------
......@@ -283,7 +282,6 @@ public:
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;
};
......
......@@ -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() );
}
......@@ -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 );
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;
};
......
This diff is collapsed.
......@@ -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,15 +59,14 @@ 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.
*/
......@@ -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
......@@ -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 );
virtual void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset,
int aDrawMode, int aColor = -1 );
/**
* Function Save
......@@ -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
......@@ -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
......@@ -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;
};
......
......@@ -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();
}
......
......@@ -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();
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):
......
......@@ -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 );
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -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 );
......
......@@ -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;
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -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 );
......
This diff is collapsed.
This diff is collapsed.
......@@ -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 );
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment