Commit 42d7bf6c authored by Wayne Stambaugh's avatar Wayne Stambaugh

Pcbnew encapsulation and code cleaning.

* Encapsulate most of the MODULE class.
* Start encapsulating the DIMENSION class.
* Lay some groundwork for EDA_TEXT encapsulation.
* Move cleverly hidden MODULE functions into class_module.cpp.
* Use std::swap to exchange TEXTE_PCB values for undo/redo.
* Remove unused members from MODULE class.
* The usual coding policy and documentation fixes.
parent 8287775b
......@@ -634,7 +634,7 @@ void EDA_3D_CANVAS::Draw3D_DrawText( TEXTE_PCB* text )
if( text->m_MultilineAllowed )
{
wxPoint pos = text->m_Pos;
wxArrayString* list = wxStringSplit( text->m_Text, '\n' );
wxArrayString* list = wxStringSplit( text->GetText(), '\n' );
wxPoint offset;
offset.y = text->GetInterline();
......@@ -657,7 +657,7 @@ void EDA_3D_CANVAS::Draw3D_DrawText( TEXTE_PCB* text )
else
{
DrawGraphicText( NULL, NULL, text->m_Pos, (EDA_COLOR_T) color,
text->m_Text, text->GetOrientation(), size,
text->GetText(), text->GetOrientation(), size,
text->m_HJustify, text->m_VJustify,
text->GetThickness(), text->m_Italic,
true,
......@@ -766,11 +766,13 @@ void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
corner.y = m_PolyPoints[ii].y;
RotatePoint( &corner.x, &corner.y, module->GetOrientation() );
if( module )
{
corner.x += module->m_Pos.x;
corner.y += module->m_Pos.y;
corner.x += module->GetPosition().x;
corner.y += module->GetPosition().y;
}
polycorners.push_back( corner );
}
......
......@@ -95,6 +95,23 @@ public:
EDA_TEXT( const EDA_TEXT& aText );
virtual ~EDA_TEXT();
wxString& Text() { return m_Text; }
wxString& Text() const { return *(const_cast<wxString*> (&m_Text)); }
void SetText( const wxString& aText ) { m_Text = aText; }
/**
* Function GetText
* returns the string associated with the text object.
* <p>
* This function is virtual to allow derived classes to override getting the
* string to provide a way for modifying the base string by adding a suffix or
* prefix to the base string.
* </p>
* @return a const wxString object containing the string of the item.
*/
virtual const wxString GetText() const { return m_Text; }
/**
* Function SetThickness
* sets text thickness.
......@@ -147,9 +164,15 @@ public:
*/
const wxSize GetSize() const { return m_Size; };
void SetWidth( int aWidth ) { m_Size.x = aWidth; }
int GetWidth() const { return m_Size.x; }
void SetHeight( int aHeight ) { m_Size.y = aHeight; }
int GetHeight() const { return m_Size.y; }
/// named differently than the ones using multiple inheritance and including this class
void SetPos( const wxPoint& aPoint ) { m_Pos = aPoint; }
const wxPoint GetPos() const { return m_Pos; }
void SetPosition( const wxPoint& aPoint ) { m_Pos = aPoint; }
const wxPoint GetPosition() const { return m_Pos; }
int GetLength() const { return m_Text.Length(); };
......@@ -252,20 +275,6 @@ public:
*/
wxString GetTextStyleName();
void SetText( const wxString& aText ) { m_Text = aText; }
/**
* Function GetText
* returns the string associated with the text object.
* <p>
* This function is virtual to allow derived classes to override getting the
* string to provide a way for modifying the base string by adding a suffix or
* prefix to the base string.
* </p>
* @return a const wxString object containing the string of the item.
*/
virtual const wxString GetText() const { return m_Text; }
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const { return m_HJustify; };
EDA_TEXT_VJUSTIFY_T GetVertJustify() const { return m_VJustify; };
......
......@@ -240,11 +240,11 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
if( PlaceModulesHorsPcb && edgesExist )
{
if( bbbox.Contains( Module->m_Pos ) )
if( bbbox.Contains( Module->GetPosition() ) )
continue;
}
surface += Module->m_Surface;
surface += Module->GetArea();
}
Xsize_allowed = (int) ( sqrt( surface ) * 4.0 / 3.0 );
......@@ -261,7 +261,7 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
if( PlaceModulesHorsPcb && edgesExist )
{
if( bbbox.Contains( Module->m_Pos ) )
if( bbbox.Contains( Module->GetPosition() ) )
continue;
}
......@@ -276,17 +276,17 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
Ymax_size = 0;
}
GetScreen()->SetCrossHairPosition( current + Module->m_Pos -
Module->m_BoundaryBox.GetPosition() );
GetScreen()->SetCrossHairPosition( current + Module->GetPosition() -
Module->GetBoundingBox().GetPosition() );
Ymax_size = std::max( Ymax_size, Module->m_BoundaryBox.GetHeight() );
Ymax_size = std::max( Ymax_size, Module->GetBoundingBox().GetHeight() );
PlaceModule( Module, NULL, true );
// Undo: add new Module to undo
newList.PushItem( picker );
current.x += Module->m_BoundaryBox.GetWidth() + pas_grille;
current.x += Module->GetBoundingBox().GetWidth() + pas_grille;
}
// Undo: commit
......@@ -313,7 +313,7 @@ void PCB_EDIT_FRAME::LockModule( MODULE* aModule, bool aLocked )
for( ; aModule != NULL; aModule = aModule->Next() )
{
if( WildCompareString( ModulesMaskSelection, aModule->m_Reference->m_Text ) )
if( WildCompareString( ModulesMaskSelection, aModule->GetReference() ) )
{
aModule->SetLocked( aLocked );
OnModify();
......@@ -325,5 +325,5 @@ void PCB_EDIT_FRAME::LockModule( MODULE* aModule, bool aLocked )
static bool sortModulesbySize( MODULE* ref, MODULE* compare )
{
return compare->m_Surface < ref->m_Surface;
return compare->GetArea() < ref->GetArea();
}
......@@ -119,7 +119,8 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
if( currModule == NULL )
return;
currModule->m_ModuleStatus &= ~(MODULE_is_PLACED | MODULE_to_PLACE);
currModule->SetIsPlaced( false );
currModule->SetNeedsPlaced( false );
break;
case PLACE_OUT_OF_BOARD:
......@@ -157,7 +158,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
for( ; Module != NULL; Module = Module->Next() )
{
Module->m_ModuleStatus &= ~MODULE_to_PLACE;
Module->SetNeedsPlaced( false );
switch( place_mode )
{
......@@ -167,8 +168,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
// Module will be placed, add to undo.
picker.SetItem( currModule );
newList.PushItem( picker );
Module->m_ModuleStatus |= MODULE_to_PLACE;
Module->SetNeedsPlaced( true );
}
break;
......@@ -179,13 +179,12 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
if( Module->IsLocked() )
break;
if( !RoutingMatrix.m_BrdBox.Contains( Module->m_Pos ) )
if( !RoutingMatrix.m_BrdBox.Contains( Module->GetPosition() ) )
{
// Module will be placed, add to undo.
picker.SetItem( Module );
newList.PushItem( picker );
Module->m_ModuleStatus |= MODULE_to_PLACE;
Module->SetNeedsPlaced( true );
}
break;
......@@ -199,8 +198,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
// Module will be placed, add to undo.
picker.SetItem( Module );
newList.PushItem( picker );
Module->m_ModuleStatus |= MODULE_to_PLACE;
Module->SetNeedsPlaced( true );
break;
case PLACE_INCREMENTAL:
......@@ -210,20 +208,19 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
break;
}
if( !(Module->m_ModuleStatus & MODULE_is_PLACED) )
if( !Module->NeedsPlaced() )
{
// Module will be placed, add to undo.
picker.SetItem( Module );
newList.PushItem( picker );
Module->m_ModuleStatus |= MODULE_to_PLACE;
Module->SetNeedsPlaced( true );
}
break;
}
if( Module->m_ModuleStatus & MODULE_to_PLACE ) // Erase from screen
if( Module->NeedsPlaced() ) // Erase from screen
{
moduleCount++;
Module->Draw( m_canvas, DC, GR_XOR );
......@@ -259,7 +256,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
goto end_of_tst;
/* Determine if the best orientation of a module is 180. */
ii = Module->m_CntRot180 & 0x0F;
ii = Module->GetPlacementCost180() & 0x0F;
if( ii != 0 )
{
......@@ -285,7 +282,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
}
/* Determine if the best orientation of a module is 90. */
ii = Module->m_CntRot90 & 0x0F;
ii = Module->GetPlacementCost90() & 0x0F;
if( ii != 0 )
{
......@@ -310,7 +307,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
}
/* Determine if the best orientation of a module is 270. */
ii = (Module->m_CntRot90 >> 4 ) & 0x0F;
ii = (Module->GetPlacementCost90() >> 4 ) & 0x0F;
if( ii != 0 )
{
......@@ -349,7 +346,7 @@ end_of_tst:
GenModuleOnBoard( Module );
Module->SetIsPlaced( true );
Module->m_ModuleStatus &= ~MODULE_to_PLACE;
Module->SetNeedsPlaced( false );
}
CurrPosition = memopos;
......@@ -521,10 +518,10 @@ void PCB_EDIT_FRAME::GenModuleOnBoard( MODULE* Module )
int layerMask;
D_PAD* Pad;
ox = Module->m_BoundaryBox.GetX() - marge;
fx = Module->m_BoundaryBox.GetRight() + marge;
oy = Module->m_BoundaryBox.GetY() - marge;
fy = Module->m_BoundaryBox.GetBottom() + marge;
ox = Module->GetBoundingBox().GetX() - marge;
fx = Module->GetBoundingBox().GetRight() + marge;
oy = Module->GetBoundingBox().GetY() - marge;
fy = Module->GetBoundingBox().GetBottom() + marge;
if( ox < RoutingMatrix.m_BrdBox.GetX() )
ox = RoutingMatrix.m_BrdBox.GetX();
......@@ -597,11 +594,12 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC )
LastPosOK.x = RoutingMatrix.m_BrdBox.GetX();
LastPosOK.y = RoutingMatrix.m_BrdBox.GetY();
cx = aModule->m_Pos.x; cy = aModule->m_Pos.y;
ox = aModule->m_BoundaryBox.GetX() - cx;
fx = aModule->m_BoundaryBox.GetWidth() + ox;
oy = aModule->m_BoundaryBox.GetY() - cy;
fy = aModule->m_BoundaryBox.GetHeight() + oy;
cx = aModule->GetPosition().x;
cy = aModule->GetPosition().y;
ox = aModule->GetBoundingBox().GetX() - cx;
fx = aModule->GetBoundingBox().GetWidth() + ox;
oy = aModule->GetBoundingBox().GetY() - cy;
fy = aModule->GetBoundingBox().GetHeight() + oy;
CurrPosition.x = RoutingMatrix.m_BrdBox.GetX() - ox;
CurrPosition.y = RoutingMatrix.m_BrdBox.GetY() - oy;
......@@ -656,9 +654,10 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC )
m_canvas->SetAbortRequest( false );
}
cx = aModule->m_Pos.x; cy = aModule->m_Pos.y;
aModule->m_BoundaryBox.SetX( ox + CurrPosition.x );
aModule->m_BoundaryBox.SetY( oy + CurrPosition.y );
cx = aModule->GetPosition().x;
cy = aModule->GetPosition().y;
aModule->GetBoundingBox().SetX( ox + CurrPosition.x );
aModule->GetBoundingBox().SetY( oy + CurrPosition.y );
DrawModuleOutlines( m_canvas, aDC, aModule );
......@@ -681,8 +680,8 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC )
Compute_Ratsnest_PlaceModule( aDC );
#endif
showRat = 0;
aModule->m_BoundaryBox.SetX( ox + CurrPosition.x );
aModule->m_BoundaryBox.SetY( oy + CurrPosition.y );
aModule->GetBoundingBox().SetX( ox + CurrPosition.x );
aModule->GetBoundingBox().SetY( oy + CurrPosition.y );
g_Offset_Module.y = cy - CurrPosition.y;
#ifndef USE_WX_OVERLAY
......@@ -726,8 +725,8 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC )
Compute_Ratsnest_PlaceModule( aDC );
/* Regeneration of the modified variable. */
aModule->m_BoundaryBox.SetX( ox + cx );
aModule->m_BoundaryBox.SetY( oy + cy );
aModule->GetBoundingBox().SetX( ox + cx );
aModule->GetBoundingBox().SetY( oy + cy );
CurrPosition = LastPosOK;
GetBoard()->m_Status_Pcb &= ~( RATSNEST_ITEM_LOCAL_OK | LISTE_PAD_OK );
......@@ -865,10 +864,10 @@ int TstModuleOnBoard( BOARD* Pcb, MODULE* Module, bool TstOtherSide )
side = BOTTOM; otherside = TOP;
}
ox = Module->m_BoundaryBox.GetX();
fx = Module->m_BoundaryBox.GetRight();
oy = Module->m_BoundaryBox.GetY();
fy = Module->m_BoundaryBox.GetBottom();
ox = Module->GetBoundingBox().GetX();
fx = Module->GetBoundingBox().GetRight();
oy = Module->GetBoundingBox().GetY();
fy = Module->GetBoundingBox().GetBottom();
error = TstRectangle( Pcb, ox, oy, fx, fy, side );
......@@ -1063,8 +1062,9 @@ static bool Tri_PlaceModules( MODULE* ref, MODULE* compare )
{
double ff1, ff2;
ff1 = ref->m_Surface * ref->GetPadCount();
ff2 = compare->m_Surface * compare->GetPadCount();
ff1 = ref->GetArea() * ref->GetPadCount();
ff2 = compare->GetArea() * compare->GetPadCount();
return ff2 < ff1;
}
......@@ -1073,8 +1073,8 @@ static bool Tri_RatsModules( MODULE* ref, MODULE* compare )
{
double ff1, ff2;
ff1 = ref->m_Surface * ref->flag;
ff2 = compare->m_Surface * compare->flag;
ff1 = ref->GetArea() * ref->GetFlag();
ff2 = compare->GetArea() * compare->GetFlag();
return ff2 < ff1;
}
......@@ -1105,9 +1105,9 @@ static MODULE* PickModule( PCB_EDIT_FRAME* pcbframe, wxDC* DC )
for( unsigned ii = 0; ii < moduleList.size(); ii++ )
{
Module = moduleList[ii];
Module->flag = 0;
Module->SetFlag( 0 );
if( !( Module->m_ModuleStatus & MODULE_to_PLACE ) )
if( !Module->NeedsPlaced() )
continue;
pcbframe->GetBoard()->m_Status_Pcb &= ~RATSNEST_ITEM_LOCAL_OK;
......@@ -1119,7 +1119,7 @@ static MODULE* PickModule( PCB_EDIT_FRAME* pcbframe, wxDC* DC )
{
if( ( pcbframe->GetBoard()->m_LocalRatsnest[ii].m_Status &
LOCAL_RATSNEST_ITEM ) == 0 )
Module->flag++;
Module->IncrementFlag();
}
}
......@@ -1135,12 +1135,12 @@ static MODULE* PickModule( PCB_EDIT_FRAME* pcbframe, wxDC* DC )
{
Module = moduleList[ii];
if( !( Module->m_ModuleStatus & MODULE_to_PLACE ) )
if( !Module->NeedsPlaced() )
continue;
altModule = Module;
if( Module->flag == 0 )
if( Module->GetFlag() == 0 )
continue;
bestModule = Module;
......
......@@ -317,12 +317,12 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag )
layerMask = GetLayerMask( PtText->GetLayer() );
TraceFilledRectangle( ux0 - marge, uy0 - marge, ux1 + marge,
uy1 + marge, (int) (PtText->m_Orient),
uy1 + marge, (int) (PtText->GetOrientation()),
layerMask, HOLE, WRITE_CELL );
TraceFilledRectangle( ux0 - via_marge, uy0 - via_marge,
ux1 + via_marge, uy1 + via_marge,
(int) (PtText->m_Orient),
(int) (PtText->GetOrientation()),
layerMask, VIA_IMPOSSIBLE, WRITE_OR_CELL );
}
break;
......
......@@ -247,10 +247,19 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
TRACK* image = (TRACK*) aImage;
// swap start, end, width and shape for track and image.
wxPoint exchp = track->GetStart(); track->SetStart( image->GetStart() ); image->SetStart( exchp );
exchp = track->GetEnd(); track->SetEnd( image->GetEnd() ); image->SetEnd( exchp );
int atmp = track->GetWidth(); track->SetWidth( image->GetWidth() ); image->SetWidth( atmp );
atmp = track->GetShape(); track->SetShape( image->GetShape() ); image->SetShape( atmp );
wxPoint exchp = track->GetStart();
track->SetStart( image->GetStart() );
image->SetStart( exchp );
exchp = track->GetEnd();
track->SetEnd( image->GetEnd() );
image->SetEnd( exchp );
int atmp = track->GetWidth();
track->SetWidth( image->GetWidth() );
image->SetWidth( atmp );
atmp = track->GetShape();
track->SetShape( image->GetShape() );
image->SetShape( atmp );
atmp = track->GetDrillValue();
......@@ -277,16 +286,17 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
break;
case PCB_TEXT_T:
EXCHG( ( (TEXTE_PCB*) aItem )->m_Mirror, ( (TEXTE_PCB*) aImage )->m_Mirror );
EXCHG( ( (TEXTE_PCB*) aItem )->m_Size, ( (TEXTE_PCB*) aImage )->m_Size );
EXCHG( ( (TEXTE_PCB*) aItem )->m_Pos, ( (TEXTE_PCB*) aImage )->m_Pos );
EXCHG( ( (TEXTE_PCB*) aItem )->m_Thickness, ( (TEXTE_PCB*) aImage )->m_Thickness );
EXCHG( ( (TEXTE_PCB*) aItem )->m_Orient, ( (TEXTE_PCB*) aImage )->m_Orient );
EXCHG( ( (TEXTE_PCB*) aItem )->m_Text, ( (TEXTE_PCB*) aImage )->m_Text );
EXCHG( ( (TEXTE_PCB*) aItem )->m_Italic, ( (TEXTE_PCB*) aImage )->m_Italic );
EXCHG( ( (TEXTE_PCB*) aItem )->m_Bold, ( (TEXTE_PCB*) aImage )->m_Bold );
EXCHG( ( (TEXTE_PCB*) aItem )->m_HJustify, ( (TEXTE_PCB*) aImage )->m_HJustify );
EXCHG( ( (TEXTE_PCB*) aItem )->m_VJustify, ( (TEXTE_PCB*) aImage )->m_VJustify );
std::swap( *((TEXTE_PCB*)aItem), *((TEXTE_PCB*)aImage) );
// EXCHG( ( (TEXTE_PCB*) aItem )->m_Mirror, ( (TEXTE_PCB*) aImage )->m_Mirror );
// EXCHG( ( (TEXTE_PCB*) aItem )->m_Size, ( (TEXTE_PCB*) aImage )->m_Size );
// EXCHG( ( (TEXTE_PCB*) aItem )->m_Pos, ( (TEXTE_PCB*) aImage )->m_Pos );
// EXCHG( ( (TEXTE_PCB*) aItem )->m_Thickness, ( (TEXTE_PCB*) aImage )->m_Thickness );
// EXCHG( ( (TEXTE_PCB*) aItem )->m_Orient, ( (TEXTE_PCB*) aImage )->m_Orient );
// EXCHG( ( (TEXTE_PCB*) aItem )->m_Text, ( (TEXTE_PCB*) aImage )->m_Text );
// EXCHG( ( (TEXTE_PCB*) aItem )->m_Italic, ( (TEXTE_PCB*) aImage )->m_Italic );
// EXCHG( ( (TEXTE_PCB*) aItem )->m_Bold, ( (TEXTE_PCB*) aImage )->m_Bold );
// EXCHG( ( (TEXTE_PCB*) aItem )->m_HJustify, ( (TEXTE_PCB*) aImage )->m_HJustify );
// EXCHG( ( (TEXTE_PCB*) aItem )->m_VJustify, ( (TEXTE_PCB*) aImage )->m_VJustify );
break;
case PCB_TARGET_T:
......@@ -295,16 +305,17 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
case PCB_DIMENSION_T:
{
wxString txt = ( (DIMENSION*) aItem )->GetText();
( (DIMENSION*) aItem )->SetText( ( (DIMENSION*) aImage )->GetText() );
( (DIMENSION*) aImage )->SetText( txt );
EXCHG( ( (DIMENSION*) aItem )->m_Width, ( (DIMENSION*) aImage )->m_Width );
EXCHG( ( (DIMENSION*) aItem )->m_Text.m_Size, ( (DIMENSION*) aImage )->m_Text.m_Size );
EXCHG( ( (DIMENSION*) aItem )->m_Text.m_Pos, ( (DIMENSION*) aImage )->m_Text.m_Pos );
EXCHG( ( (DIMENSION*) aItem )->m_Text.m_Thickness,
( (DIMENSION*) aImage )->m_Text.m_Thickness );
EXCHG( ( (DIMENSION*) aItem )->m_Text.m_Mirror,
( (DIMENSION*) aImage )->m_Text.m_Mirror );
std::swap( *((DIMENSION*)aItem), *((DIMENSION*)aImage) );
// wxString txt = ( (DIMENSION*) aItem )->GetText();
// ( (DIMENSION*) aItem )->SetText( ( (DIMENSION*) aImage )->GetText() );
// ( (DIMENSION*) aImage )->SetText( txt );
// EXCHG( ( (DIMENSION*) aItem )->m_Width, ( (DIMENSION*) aImage )->m_Width );
// EXCHG( ( (DIMENSION*) aItem )->m_Text.m_Size, ( (DIMENSION*) aImage )->m_Text.m_Size );
// EXCHG( ( (DIMENSION*) aItem )->m_Text.m_Pos, ( (DIMENSION*) aImage )->m_Text.m_Pos );
// EXCHG( ( (DIMENSION*) aItem )->m_Text.m_Thickness,
// ( (DIMENSION*) aImage )->m_Text.m_Thickness );
// EXCHG( ( (DIMENSION*) aItem )->m_Text.m_Mirror,
// ( (DIMENSION*) aImage )->m_Text.m_Mirror );
}
break;
......
......@@ -108,10 +108,11 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent )
for( iter = list.begin(); iter != list.end(); iter++ )
{
cmp* current = *iter;
if( (current->m_Val == Module->m_Value->m_Text) && (current->m_Pkg == Module->m_LibRef) )
if( (current->m_Val == Module->GetValue()) && (current->m_Pkg == Module->GetLibRef()) )
{
current->m_Ref.Append( wxT( ", " ), 1 );
current->m_Ref.Append( Module->m_Reference->m_Text );
current->m_Ref.Append( Module->GetReference() );
current->m_CmpCount++;
valExist = true;
......@@ -124,9 +125,9 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent )
{
comp = new cmp();
comp->m_Id = i++;
comp->m_Val = Module->m_Value->m_Text;
comp->m_Ref = Module->m_Reference->m_Text;
comp->m_Pkg = Module->m_LibRef;
comp->m_Val = Module->GetValue();
comp->m_Ref = Module->GetReference();
comp->m_Pkg = Module->GetLibRef();
comp->m_CmpCount = 1;
list.Append( comp );
}
......
......@@ -64,7 +64,7 @@ DIMENSION::~DIMENSION()
void DIMENSION::SetPosition( const wxPoint& aPos )
{
m_Text.SetPos( aPos );
m_Text.SetPosition( aPos );
}
......
......@@ -43,7 +43,6 @@ class MSG_PANEL_ITEM;
class DIMENSION : public BOARD_ITEM
{
public:
int m_Width;
int m_Shape; // / Currently always 0.
int m_Unit; // / 0 = inches, 1 = mm
......@@ -51,6 +50,8 @@ public:
TEXTE_PCB m_Text;
public:
// private: These member should be private. they are public only due to legacy code
wxPoint m_crossBarO, m_crossBarF;
wxPoint m_featureLineGO, m_featureLineGF;
......@@ -59,13 +60,17 @@ public:
wxPoint m_arrowD2O, m_arrowD2F;
wxPoint m_arrowG1O, m_arrowG1F;
wxPoint m_arrowG2O, m_arrowG2F;
public:
DIMENSION( BOARD_ITEM* aParent );
// Do not create a copy constructor. The one generated by the compiler is adequate.
~DIMENSION();
void SetValue( int aValue ) { m_Value = aValue; }
int GetValue() const { return m_Value; }
const wxPoint& GetPosition() const;
void SetPosition( const wxPoint& aPos ); // override, sets m_Text's position too
......@@ -93,6 +98,9 @@ public:
void SetText( const wxString& NewText );
const wxString GetText() const;
TEXTE_PCB& Text() { return m_Text; }
TEXTE_PCB& Text() const { return *(const_cast<TEXTE_PCB*> (&m_Text)); }
void Copy( DIMENSION* source );
void Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
......
......@@ -398,7 +398,7 @@ EDA_RECT DRAWSEGMENT::GetBoundingBox() const
if( module ) // Transform, if we belong to a module
{
RotatePoint( &pt, module->GetOrientation() );
pt += module->m_Pos;
pt += module->GetPosition();
}
if( ii == 0 )
......
......@@ -91,8 +91,8 @@ void EDGE_MODULE::SetDrawCoord()
RotatePoint( &m_Start.x, &m_Start.y, module->GetOrientation() );
RotatePoint( &m_End.x, &m_End.y, module->GetOrientation() );
m_Start += module->m_Pos;
m_End += module->m_Pos;
m_Start += module->GetPosition();
m_End += module->GetPosition();
}
}
......@@ -221,7 +221,7 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
wxPoint& pt = points[ii];
RotatePoint( &pt.x, &pt.y, module->GetOrientation() );
pt += module->m_Pos - offset;
pt += module->GetPosition() - offset;
}
GRPoly( panel->GetClipBox(), DC, points.size(), &points[0], true, m_Width, color, color );
......@@ -246,8 +246,8 @@ void EDGE_MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
return;
aList.push_back( MSG_PANEL_ITEM( _( "Graphic Item" ), wxEmptyString, DARKCYAN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Module" ), module->m_Reference->m_Text, DARKCYAN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Value" ), module->m_Value->m_Text, BLUE ) );
aList.push_back( MSG_PANEL_ITEM( _( "Module" ), module->GetReference(), DARKCYAN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Value" ), module->GetValue(), BLUE ) );
msg.Printf( wxT( "%8.8lX" ), module->GetTimeStamp() );
aList.push_back( MSG_PANEL_ITEM( _( "TimeStamp" ), msg, BROWN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Mod Layer" ), board->GetLayerName( module->GetLayer() ),
......
......@@ -63,7 +63,7 @@ MODULE::MODULE( BOARD* parent ) :
m_CntRot90 = m_CntRot180 = 0;
m_Surface = 0.0;
m_Link = 0;
m_LastEdit_Time = time( NULL );
m_LastEditTime = time( NULL );
m_LocalClearance = 0;
m_LocalSolderMaskMargin = 0;
m_LocalSolderPasteMargin = 0;
......@@ -91,10 +91,9 @@ MODULE::MODULE( const MODULE& aModule ) :
m_ModuleStatus = aModule.m_ModuleStatus;
m_Orient = aModule.m_Orient;
m_BoundaryBox = aModule.m_BoundaryBox;
m_PadNum = aModule.m_PadNum;
m_CntRot90 = aModule.m_CntRot90;
m_CntRot180 = aModule.m_CntRot180;
m_LastEdit_Time = aModule.m_LastEdit_Time;
m_LastEditTime = aModule.m_LastEditTime;
m_Link = aModule.m_Link;
m_Path = aModule.m_Path; //is this correct behavior?
......@@ -210,10 +209,9 @@ void MODULE::Copy( MODULE* aModule )
m_ModuleStatus = aModule->m_ModuleStatus;
m_Orient = aModule->m_Orient;
m_BoundaryBox = aModule->m_BoundaryBox;
m_PadNum = aModule->m_PadNum;
m_CntRot90 = aModule->m_CntRot90;
m_CntRot180 = aModule->m_CntRot180;
m_LastEdit_Time = aModule->m_LastEdit_Time;
m_LastEditTime = aModule->m_LastEditTime;
m_Link = aModule->m_Link;
m_Path = aModule->m_Path; //is this correct behavior?
SetTimeStamp( GetNewTimeStamp() );
......@@ -444,10 +442,10 @@ void MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
wxString msg;
BOARD* board = GetBoard();
aList.push_back( MSG_PANEL_ITEM( m_Reference->m_Text, m_Value->m_Text, DARKCYAN ) );
aList.push_back( MSG_PANEL_ITEM( m_Reference->GetText(), m_Value->GetText(), DARKCYAN ) );
// Display last date the component was edited (useful in Module Editor).
time_t edit_time = m_LastEdit_Time;
time_t edit_time = m_LastEditTime;
strcpy( Line, ctime( &edit_time ) );
strtok( Line, " \n\r" );
strcpy( bufcar, strtok( NULL, " \n\r" ) ); strcat( bufcar, " " );
......@@ -713,7 +711,6 @@ bool MODULE::IsLibNameValid( const wxString & aName )
}
/* Test for validity of the name of a footprint to be used in a footprint library
* ( no spaces, dir separators ... )
* param bool aUserReadable = false to get the list of invalid chars
......@@ -733,6 +730,242 @@ const wxChar* MODULE::ReturnStringLibNameInvalidChars( bool aUserReadable )
}
void MODULE::Move( const wxPoint& aMoveVector )
{
wxPoint newpos = m_Pos + aMoveVector;
SetPosition( newpos );
}
void MODULE::Rotate( const wxPoint& aRotCentre, double aAngle )
{
wxPoint newpos = m_Pos;
RotatePoint( &newpos, aRotCentre, aAngle );
SetPosition( newpos );
SetOrientation( GetOrientation() + aAngle );
}
void MODULE::Flip( const wxPoint& aCentre )
{
TEXTE_MODULE* text;
// Move module to its final position:
wxPoint finalPos = m_Pos;
finalPos.y = aCentre.y - ( finalPos.y - aCentre.y ); /// Mirror the Y position
SetPosition( finalPos );
// Flip layer
SetLayer( BOARD::ReturnFlippedLayerNumber( GetLayer() ) );
// Reverse mirror orientation.
NEGATE( m_Orient );
NORMALIZE_ANGLE_POS( m_Orient );
// Mirror pads to other side of board about the x axis, i.e. vertically.
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
pad->Flip( m_Pos.y );
// Mirror reference.
text = m_Reference;
text->m_Pos.y -= m_Pos.y;
text->m_Pos.y = -text->m_Pos.y;
text->m_Pos.y += m_Pos.y;
NEGATE(text->m_Pos0.y);
text->m_Mirror = false;
NEGATE_AND_NORMALIZE_ANGLE_POS( text->m_Orient );
text->SetLayer( GetLayer() );
text->SetLayer( BOARD::ReturnFlippedLayerNumber( text->GetLayer() ) );
if( GetLayer() == LAYER_N_BACK )
text->SetLayer( SILKSCREEN_N_BACK );
if( GetLayer() == LAYER_N_FRONT )
text->SetLayer( SILKSCREEN_N_FRONT );
if( (GetLayer() == SILKSCREEN_N_BACK)
|| (GetLayer() == ADHESIVE_N_BACK) || (GetLayer() == LAYER_N_BACK) )
text->m_Mirror = true;
// Mirror value.
text = m_Value;
text->m_Pos.y -= m_Pos.y;
NEGATE( text->m_Pos.y );
text->m_Pos.y += m_Pos.y;
NEGATE( text->m_Pos0.y );
text->m_Mirror = false;
NEGATE_AND_NORMALIZE_ANGLE_POS( text->m_Orient );
text->SetLayer( GetLayer() );
text->SetLayer( BOARD::ReturnFlippedLayerNumber( text->GetLayer() ) );
if( GetLayer() == LAYER_N_BACK )
text->SetLayer( SILKSCREEN_N_BACK );
if( GetLayer() == LAYER_N_FRONT )
text->SetLayer( SILKSCREEN_N_FRONT );
if( (GetLayer() == SILKSCREEN_N_BACK)
|| (GetLayer() == ADHESIVE_N_BACK) || (GetLayer() == LAYER_N_BACK) )
text->m_Mirror = true;
// Reverse mirror module graphics and texts.
for( EDA_ITEM* item = m_Drawings; item; item = item->Next() )
{
switch( item->Type() )
{
case PCB_MODULE_EDGE_T:
{
EDGE_MODULE* em = (EDGE_MODULE*) item;
wxPoint s = em->GetStart();
s.y -= m_Pos.y;
s.y = -s.y;
s.y += m_Pos.y;
em->SetStart( s );
wxPoint e = em->GetEnd();
e.y -= m_Pos.y;
e.y = -e.y;
e.y += m_Pos.y;
em->SetEnd( e );
NEGATE( em->m_Start0.y );
NEGATE( em->m_End0.y );
if( em->GetShape() == S_ARC )
{
em->SetAngle( -em->GetAngle() );
}
em->SetLayer( BOARD::ReturnFlippedLayerNumber( em->GetLayer() ) );
}
break;
case PCB_MODULE_TEXT_T:
// Reverse mirror position and mirror.
text = (TEXTE_MODULE*) item;
text->m_Pos.y -= m_Pos.y;
text->m_Pos.y = -text->m_Pos.y;
text->m_Pos.y += m_Pos.y;
NEGATE( text->m_Pos0.y );
text->m_Mirror = false;
NEGATE_AND_NORMALIZE_ANGLE_POS( text->m_Orient );
text->SetLayer( GetLayer() );
text->SetLayer( BOARD::ReturnFlippedLayerNumber( text->GetLayer() ) );
if( GetLayer() == LAYER_N_BACK )
text->SetLayer( SILKSCREEN_N_BACK );
if( GetLayer() == LAYER_N_FRONT )
text->SetLayer( SILKSCREEN_N_FRONT );
if( GetLayer() == SILKSCREEN_N_BACK
|| GetLayer() == ADHESIVE_N_BACK
|| GetLayer() == LAYER_N_BACK )
{
text->m_Mirror = true;
}
break;
default:
wxMessageBox( wxT( "MODULE::Flip() error: Unknown Draw Type" ) );
break;
}
}
CalculateBoundingBox();
}
void MODULE::SetPosition( const wxPoint& newpos )
{
wxPoint delta = newpos - m_Pos;
m_Pos += delta;
m_Reference->SetPosition( m_Reference->GetPosition() + delta );
m_Value->SetPosition( m_Value->GetPosition() + delta );
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{
pad->SetPosition( pad->GetPosition() + delta );
}
for( EDA_ITEM* item = m_Drawings; item; item = item->Next() )
{
switch( item->Type() )
{
case PCB_MODULE_EDGE_T:
{
EDGE_MODULE* pt_edgmod = (EDGE_MODULE*) item;
pt_edgmod->SetDrawCoord();
break;
}
case PCB_MODULE_TEXT_T:
{
TEXTE_MODULE* text = (TEXTE_MODULE*) item;
text->m_Pos += delta;
break;
}
default:
wxMessageBox( wxT( "Draw type undefined." ) );
break;
}
}
CalculateBoundingBox();
}
void MODULE::SetOrientation( double newangle )
{
double angleChange = newangle - m_Orient; // change in rotation
wxPoint pt;
NORMALIZE_ANGLE_POS( newangle );
m_Orient = newangle;
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{
pt = pad->GetPos0();
pad->SetOrientation( pad->GetOrientation() + angleChange );
RotatePoint( &pt, m_Orient );
pad->SetPosition( GetPosition() + pt );
}
// Update of the reference and value.
m_Reference->SetDrawCoord();
m_Value->SetDrawCoord();
// Displace contours and text of the footprint.
for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
{
if( item->Type() == PCB_MODULE_EDGE_T )
{
EDGE_MODULE* edge = (EDGE_MODULE*) item;
edge->SetDrawCoord();
}
else if( item->Type() == PCB_MODULE_TEXT_T )
{
TEXTE_MODULE* text = (TEXTE_MODULE*) item;
text->SetDrawCoord();
}
}
CalculateBoundingBox();
}
#if defined(DEBUG)
void MODULE::Show( int nestLevel, std::ostream& os ) const
......@@ -741,8 +974,8 @@ void MODULE::Show( int nestLevel, std::ostream& os ) const
// for now, make it look like XML, expand on this later.
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() <<
" ref=\"" << m_Reference->m_Text.mb_str() << '"' <<
" value=\"" << m_Value->m_Text.mb_str() << '"' <<
" ref=\"" << m_Reference->GetText().mb_str() << '"' <<
" value=\"" << m_Value->GetText().mb_str() << '"' <<
" layer=\"" << board->GetLayerName( m_Layer ).mb_str() << '"' <<
">\n";
......
......@@ -57,7 +57,7 @@ class MSG_PANEL_ITEM;
enum MODULE_ATTR_T
{
MOD_DEFAULT = 0, ///< default
MOD_CMS = 1, ///< Set for modules listed in the automatic insertion list
MOD_CMS = 1, ///< Set for modules listed in the automatic insertion list
///< (usually SMD footprints)
MOD_VIRTUAL = 2 ///< Virtual component: when created by copper shapes on
///< board (Like edge card connectors, mounting hole...)
......@@ -66,54 +66,16 @@ enum MODULE_ATTR_T
class MODULE : public BOARD_ITEM
{
public:
double m_Orient; // orientation in 0.1 degrees
wxPoint m_Pos; // Real coord on board
DLIST<D_PAD> m_Pads; /* Pad list (linked list) */
DLIST<BOARD_ITEM> m_Drawings; /* Graphic items list (linked list) */
DLIST<S3D_MASTER> m_3D_Drawings; /* First item of the 3D shapes (linked list)*/
TEXTE_MODULE* m_Reference; // Component reference (U34, R18..)
TEXTE_MODULE* m_Value; // Component value (74LS00, 22K..)
wxString m_LibRef; /* Name of the module in library (and
* the default value when loading a
* module from the library) */
int m_Attributs; ///< Flag bits ( see Mod_Attribut )
int flag; /* Use to trace ratsnest and auto routing. */
int m_ModuleStatus; ///< For autoplace: flags (LOCKED, AUTOPLACED)
// m_ModuleStatus bits:
#define MODULE_is_LOCKED 0x01 ///< module LOCKED: no autoplace allowed
#define MODULE_is_PLACED 0x02 ///< In autoplace: module automatically placed
#define MODULE_to_PLACE 0x04 ///< In autoplace: module waiting for autoplace
EDA_RECT m_BoundaryBox; // Bounding box : coordinates on board, real orientation.
int m_PadNum; // Pad count
int m_AltPadNum; /* Pad with netcode > 0 (active pads) count */
int m_CntRot90; ///< Automatic placement : cost ( 0..10 )
///< for 90 degrees rotation (Horiz<->Vertical)
int m_CntRot180; ///< Automatic placement : cost ( 0..10 )
///< for 180 degrees rotation (UP <->Down)
wxSize m_Ext; // Margin around the module, in automatic placement
double m_Surface; // Bounding box area
time_t m_Link; // Temporary logical link used in edition
time_t m_LastEdit_Time;
wxString m_Path;
wxString m_Doc; // Module Description (info for users)
wxString m_KeyWord; // Keywords to select the module in lib
// The final margin is the sum of these 2 values
ZoneConnection m_ZoneConnection;
int m_ThermalWidth, m_ThermalGap;
public:
MODULE( BOARD* parent );
......@@ -191,6 +153,10 @@ public:
int GetAttributes() const { return m_Attributs; }
void SetAttributes( int aAttributes ) { m_Attributs = aAttributes; }
void SetFlag( int aFlag ) { flag = aFlag; }
void IncrementFlag() { flag += 1; }
int GetFlag() const { return flag; }
void Move( const wxPoint& aMoveVector );
void Rotate( const wxPoint& aRotCentre, double aAngle );
......@@ -230,9 +196,18 @@ public:
m_ModuleStatus &= ~MODULE_is_PLACED;
}
void SetLastEditTime( time_t aTime ) { m_LastEdit_Time = aTime; }
void SetLastEditTime( ) { m_LastEdit_Time = time( NULL ); }
time_t GetLastEditTime() const { return m_LastEdit_Time; }
bool NeedsPlaced() const { return (m_ModuleStatus & MODULE_to_PLACE); }
void SetNeedsPlaced( bool needsPlaced )
{
if( needsPlaced )
m_ModuleStatus |= MODULE_to_PLACE;
else
m_ModuleStatus &= ~MODULE_to_PLACE;
}
void SetLastEditTime( time_t aTime ) { m_LastEditTime = aTime; }
void SetLastEditTime( ) { m_LastEditTime = time( NULL ); }
time_t GetLastEditTime() const { return m_LastEditTime; }
/* drawing functions */
......@@ -296,6 +271,10 @@ public:
TEXTE_MODULE& Value() { return *m_Value; }
TEXTE_MODULE& Reference() { return *m_Reference; }
/// The const versions to keep the compiler happy.
TEXTE_MODULE& Value() const { return *m_Value; }
TEXTE_MODULE& Reference() const { return *m_Reference; }
/**
* Function FindPadByName
......@@ -323,6 +302,17 @@ public:
*/
unsigned GetPadCount() const { return m_Pads.GetCount() ; }
double GetArea() const { return m_Surface; }
time_t GetLink() const { return m_Link; }
void SetLink( time_t aLink ) { m_Link = aLink; }
int GetPlacementCost180() const { return m_CntRot180; }
void SetPlacementCost180( int aCost ) { m_CntRot180 = aCost; }
int GetPlacementCost90() const { return m_CntRot90; }
void SetPlacementCost90( int aCost ) { m_CntRot90 = aCost; }
/**
* Function Add3DModel
* adds \a a3DModel definition to the end of the 3D model list.
......@@ -377,16 +367,38 @@ public:
#endif
private:
double m_Orient; ///< Orientation in tenths of a degree, 900=90.0 degrees.
wxPoint m_Pos; ///< Position of module on the board in internal units.
TEXTE_MODULE* m_Reference; ///< Component reference designator value (U34, R18..)
TEXTE_MODULE* m_Value; ///< Component value (74LS00, 22K..)
wxString m_LibRef; ///< Name of the module in the library.
int m_Attributs; ///< Flag bits ( see Mod_Attribut )
int m_ModuleStatus; ///< For autoplace: flags (LOCKED, AUTOPLACED)
EDA_RECT m_BoundaryBox; ///< Bounding box : coordinates on board, real orientation.
// The final margin is the sum of these 2 values
int m_ThermalWidth;
int m_ThermalGap;
wxString m_Doc; ///< File name and path for documentation file.
wxString m_KeyWord; ///< Search keywords to find module in library.
wxString m_Path;
ZoneConnection m_ZoneConnection;
time_t m_LastEditTime;
int flag; ///< Use to trace ratsnest and auto routing.
double m_Surface; ///< Bounding box area
time_t m_Link; ///< Temporary logical link used in edition
int m_CntRot90; ///< Horizontal automatic placement cost ( 0..10 ).
int m_CntRot180; ///< Vertical automatic placement cost ( 0..10 ).
// Local tolerances. When zero, this means the corresponding netclass value
// is used. Usually theses local tolerances zero, in deference to the
// corresponding netclass values.
int m_LocalClearance;
int m_LocalSolderMaskMargin; ///< Solder mask margin
int m_LocalSolderPasteMargin; ///< Solder paste margin
///< absolute value
int m_LocalClearance;
int m_LocalSolderMaskMargin; ///< Solder mask margin
int m_LocalSolderPasteMargin; ///< Solder paste margin absolute value
double m_LocalSolderPasteMarginRatio; ///< Solder mask margin ratio
///< value of pad size
double m_LocalSolderPasteMarginRatio; ///< Solder mask margin ratio
///< value of pad size
};
#endif // MODULE_H_
......@@ -128,239 +128,3 @@ int ChangeSideMaskLayer( int aMask )
return newMask;
}
void MODULE::Move( const wxPoint& aMoveVector )
{
wxPoint newpos = m_Pos + aMoveVector;
SetPosition( newpos );
}
void MODULE::Rotate( const wxPoint& aRotCentre, double aAngle )
{
wxPoint newpos = m_Pos;
RotatePoint( &newpos, aRotCentre, aAngle );
SetPosition( newpos );
SetOrientation( GetOrientation() + aAngle );
}
void MODULE::Flip( const wxPoint& aCentre )
{
TEXTE_MODULE* pt_texte;
// Move module to its final position:
wxPoint finalPos = m_Pos;
finalPos.y = aCentre.y - ( finalPos.y - aCentre.y ); /// Mirror the Y position
SetPosition( finalPos );
// Flip layer
SetLayer( BOARD::ReturnFlippedLayerNumber( GetLayer() ) );
// Reverse mirror orientation.
NEGATE( m_Orient );
NORMALIZE_ANGLE_POS( m_Orient );
// Mirror pads to other side of board about the x axis, i.e. vertically.
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
pad->Flip( m_Pos.y );
// Mirror reference.
pt_texte = m_Reference;
pt_texte->m_Pos.y -= m_Pos.y;
pt_texte->m_Pos.y = -pt_texte->m_Pos.y;
pt_texte->m_Pos.y += m_Pos.y;
NEGATE(pt_texte->m_Pos0.y);
pt_texte->m_Mirror = false;
NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient );
pt_texte->SetLayer( GetLayer() );
pt_texte->SetLayer( BOARD::ReturnFlippedLayerNumber( pt_texte->GetLayer() ) );
if( GetLayer() == LAYER_N_BACK )
pt_texte->SetLayer( SILKSCREEN_N_BACK );
if( GetLayer() == LAYER_N_FRONT )
pt_texte->SetLayer( SILKSCREEN_N_FRONT );
if( (GetLayer() == SILKSCREEN_N_BACK)
|| (GetLayer() == ADHESIVE_N_BACK) || (GetLayer() == LAYER_N_BACK) )
pt_texte->m_Mirror = true;
// Mirror value.
pt_texte = m_Value;
pt_texte->m_Pos.y -= m_Pos.y;
NEGATE( pt_texte->m_Pos.y );
pt_texte->m_Pos.y += m_Pos.y;
NEGATE( pt_texte->m_Pos0.y );
pt_texte->m_Mirror = false;
NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient );
pt_texte->SetLayer( GetLayer() );
pt_texte->SetLayer( BOARD::ReturnFlippedLayerNumber( pt_texte->GetLayer() ) );
if( GetLayer() == LAYER_N_BACK )
pt_texte->SetLayer( SILKSCREEN_N_BACK );
if( GetLayer() == LAYER_N_FRONT )
pt_texte->SetLayer( SILKSCREEN_N_FRONT );
if( (GetLayer() == SILKSCREEN_N_BACK)
|| (GetLayer() == ADHESIVE_N_BACK) || (GetLayer() == LAYER_N_BACK) )
pt_texte->m_Mirror = true;
// Reverse mirror module graphics and texts.
for( EDA_ITEM* item = m_Drawings; item; item = item->Next() )
{
switch( item->Type() )
{
case PCB_MODULE_EDGE_T:
{
EDGE_MODULE* em = (EDGE_MODULE*) item;
wxPoint s = em->GetStart();
s.y -= m_Pos.y;
s.y = -s.y;
s.y += m_Pos.y;
em->SetStart( s );
wxPoint e = em->GetEnd();
e.y -= m_Pos.y;
e.y = -e.y;
e.y += m_Pos.y;
em->SetEnd( e );
NEGATE( em->m_Start0.y );
NEGATE( em->m_End0.y );
if( em->GetShape() == S_ARC )
{
em->SetAngle( -em->GetAngle() );
}
em->SetLayer( BOARD::ReturnFlippedLayerNumber( em->GetLayer() ) );
}
break;
case PCB_MODULE_TEXT_T:
// Reverse mirror position and mirror.
pt_texte = (TEXTE_MODULE*) item;
pt_texte->m_Pos.y -= m_Pos.y;
pt_texte->m_Pos.y = -pt_texte->m_Pos.y;
pt_texte->m_Pos.y += m_Pos.y;
NEGATE( pt_texte->m_Pos0.y );
pt_texte->m_Mirror = false;
NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient );
pt_texte->SetLayer( GetLayer() );
pt_texte->SetLayer( BOARD::ReturnFlippedLayerNumber( pt_texte->GetLayer() ) );
if( GetLayer() == LAYER_N_BACK )
pt_texte->SetLayer( SILKSCREEN_N_BACK );
if( GetLayer() == LAYER_N_FRONT )
pt_texte->SetLayer( SILKSCREEN_N_FRONT );
if( GetLayer() == SILKSCREEN_N_BACK
|| GetLayer() == ADHESIVE_N_BACK
|| GetLayer() == LAYER_N_BACK )
{
pt_texte->m_Mirror = true;
}
break;
default:
wxMessageBox( wxT( "MODULE::Flip() error: Unknown Draw Type" ) );
break;
}
}
CalculateBoundingBox();
}
void MODULE::SetPosition( const wxPoint& newpos )
{
wxPoint delta = newpos - m_Pos;
m_Pos += delta;
m_Reference->SetPosition( m_Reference->GetPosition() + delta );
m_Value->SetPosition( m_Value->GetPosition() + delta );
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{
pad->SetPosition( pad->GetPosition() + delta );
}
for( EDA_ITEM* item = m_Drawings; item; item = item->Next() )
{
switch( item->Type() )
{
case PCB_MODULE_EDGE_T:
{
EDGE_MODULE* pt_edgmod = (EDGE_MODULE*) item;
pt_edgmod->SetDrawCoord();
break;
}
case PCB_MODULE_TEXT_T:
{
TEXTE_MODULE* pt_texte = (TEXTE_MODULE*) item;
pt_texte->m_Pos += delta;
break;
}
default:
wxMessageBox( wxT( "Draw type undefined." ) );
break;
}
}
CalculateBoundingBox();
}
void MODULE::SetOrientation( double newangle )
{
double angleChange = newangle - m_Orient; // change in rotation
wxPoint pt;
NORMALIZE_ANGLE_POS( newangle );
m_Orient = newangle;
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{
pt = pad->GetPos0();
pad->SetOrientation( pad->GetOrientation() + angleChange );
RotatePoint( &pt, m_Orient );
pad->SetPosition( GetPosition() + pt );
}
// Update of the reference and value.
m_Reference->SetDrawCoord();
m_Value->SetDrawCoord();
// Displace contours and text of the footprint.
for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
{
if( item->Type() == PCB_MODULE_EDGE_T )
{
EDGE_MODULE* pt_edgmod = (EDGE_MODULE*) item;
pt_edgmod->SetDrawCoord();
}
else if( item->Type() == PCB_MODULE_TEXT_T )
{
TEXTE_MODULE* pt_texte = (TEXTE_MODULE*) item;
pt_texte->SetDrawCoord();
}
}
CalculateBoundingBox();
}
......@@ -68,7 +68,7 @@ TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, int text_type ) :
if( module && ( module->Type() == PCB_MODULE_T ) )
{
m_Pos = module->m_Pos;
m_Pos = module->GetPosition();
int moduleLayer = module->GetLayer();
......@@ -149,9 +149,9 @@ void TEXTE_MODULE::SetLocalCoord()
return;
}
m_Pos0 = m_Pos - module->m_Pos;
m_Pos0 = m_Pos - module->GetPosition();
int angle = module->m_Orient;
int angle = module->GetOrientation();
RotatePoint( &m_Pos0.x, &m_Pos0.y, -angle );
}
......@@ -344,7 +344,7 @@ int TEXTE_MODULE::GetDrawRotation() const
rotation = m_Orient;
if( module )
rotation += module->m_Orient;
rotation += module->GetOrientation();
NORMALIZE_ANGLE_POS( rotation );
......@@ -372,7 +372,7 @@ void TEXTE_MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
_( "Ref." ), _( "Value" ), _( "Text" )
};
Line = module->m_Reference->m_Text;
Line = module->GetReference();
aList.push_back( MSG_PANEL_ITEM( _( "Module" ), Line, DARKCYAN ) );
Line = m_Text;
......
......@@ -196,7 +196,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, const void* testDa
{
TEXTE_MODULE* tm = (TEXTE_MODULE*) item;
if( tm->m_Text == wxT( "10uH" ) )
if( tm->GetText() == wxT( "10uH" ) )
{
breakhere++;
}
......@@ -290,10 +290,10 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, const void* testDa
if( m_Guide->IgnoreMTextsOnCmp() && module->GetLayer()==LAYER_N_FRONT )
goto exit;
if( m_Guide->IgnoreModulesVals() && item == module->m_Value )
if( m_Guide->IgnoreModulesVals() && item == &module->Value() )
goto exit;
if( m_Guide->IgnoreModulesRefs() && item == module->m_Reference )
if( m_Guide->IgnoreModulesRefs() && item == &module->Reference() )
goto exit;
}
break;
......
......@@ -72,8 +72,8 @@ static BOARD_ITEM* AllAreModulesAndReturnSmallestIfSo( GENERAL_COLLECTOR* aColle
{
MODULE* module = (MODULE*) (*aCollector)[i];
int lx = module->m_BoundaryBox.GetWidth();
int ly = module->m_BoundaryBox.GetHeight();
int lx = module->GetBoundingBox().GetWidth();
int ly = module->GetBoundingBox().GetHeight();
int lmin = std::min( lx, ly );
......
......@@ -158,7 +158,7 @@ void PCB_EDIT_FRAME::SendMessageToEESCHEMA( BOARD_ITEM* objectToSync )
{
case PCB_MODULE_T:
module = (MODULE*) objectToSync;
sprintf( cmd, "$PART: \"%s\"", TO_UTF8( module->m_Reference->m_Text ) );
sprintf( cmd, "$PART: \"%s\"", TO_UTF8( module->GetReference() ) );
break;
case PCB_PAD_T:
......@@ -166,7 +166,7 @@ void PCB_EDIT_FRAME::SendMessageToEESCHEMA( BOARD_ITEM* objectToSync )
pad = (D_PAD*) objectToSync;
msg = pad->GetPadName();
sprintf( cmd, "$PART: \"%s\" $PAD: \"%s\"",
TO_UTF8( module->m_Reference->m_Text ),
TO_UTF8( module->GetReference() ),
TO_UTF8( msg ) );
break;
......@@ -184,9 +184,9 @@ void PCB_EDIT_FRAME::SendMessageToEESCHEMA( BOARD_ITEM* objectToSync )
break;
sprintf( cmd, "$PART: \"%s\" %s \"%s\"",
TO_UTF8( module->m_Reference->m_Text ),
TO_UTF8( module->GetReference() ),
text_key,
TO_UTF8( text_mod->m_Text ) );
TO_UTF8( text_mod->GetText() ) );
break;
default:
......
......@@ -126,7 +126,7 @@ void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties()
}
wxString msg;
msg << m_CurrentModule->m_Orient;
msg << m_CurrentModule->GetOrientation();
m_OrientValue->SetValue( msg );
m_OrientValue->Enable( select );
......@@ -261,8 +261,8 @@ void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties()
m_ReferenceCopy = new TEXTE_MODULE( NULL );
m_ValueCopy = new TEXTE_MODULE( NULL );
m_ReferenceCopy->Copy( m_CurrentModule->m_Reference );
m_ValueCopy->Copy( m_CurrentModule->m_Value );
m_ReferenceCopy->Copy( &m_CurrentModule->Reference() );
m_ValueCopy->Copy( &m_CurrentModule->Value() );
m_ReferenceCtrl->SetValue( m_ReferenceCopy->m_Text );
m_ValueCtrl->SetValue( m_ValueCopy->m_Text );
......@@ -274,7 +274,7 @@ void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties()
_( "Use this attribute for \"virtual\" components drawn on board (like a old ISA PC bus connector)" ) );
/* Controls on right side of the dialog */
switch( m_CurrentModule->m_Attributs & 255 )
switch( m_CurrentModule->GetAttributes() & 255 )
{
case 0:
m_AttributsCtrl->SetSelection( 0 );
......@@ -293,17 +293,16 @@ void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties()
break;
}
m_AutoPlaceCtrl->SetSelection(
(m_CurrentModule->m_ModuleStatus & MODULE_is_LOCKED) ? 1 : 0 );
m_AutoPlaceCtrl->SetSelection( (m_CurrentModule->IsLocked()) ? 1 : 0 );
m_AutoPlaceCtrl->SetItemToolTip( 0,
_( "Enable hotkey move commands and Auto Placement" ) );
m_AutoPlaceCtrl->SetItemToolTip( 1,
_( "Disable hotkey move commands and Auto Placement" ) );
m_CostRot90Ctrl->SetValue( m_CurrentModule->m_CntRot90 );
m_CostRot90Ctrl->SetValue( m_CurrentModule->GetPlacementCost90() );
m_CostRot180Ctrl->SetValue( m_CurrentModule->m_CntRot180 );
m_CostRot180Ctrl->SetValue( m_CurrentModule->GetPlacementCost180() );
// Initialize 3D parameters
......@@ -507,8 +506,8 @@ void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event )
}
// Init Fields (should be first, because they can be moved or/and flipped later):
m_CurrentModule->m_Reference->Copy( m_ReferenceCopy );
m_CurrentModule->m_Value->Copy( m_ValueCopy );
m_CurrentModule->Reference().Copy( m_ReferenceCopy );
m_CurrentModule->Value().Copy( m_ValueCopy );
// Initialize masks clearances
m_CurrentModule->SetLocalClearance( ReturnValueFromTextCtrl( *m_NetClearanceValueCtrl ) );
......@@ -553,29 +552,25 @@ void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event )
modpos.x = ReturnValueFromTextCtrl( *m_ModPositionX );
modpos.y = ReturnValueFromTextCtrl( *m_ModPositionY );
m_CurrentModule->SetPosition( modpos );
if( m_AutoPlaceCtrl->GetSelection() == 1 )
m_CurrentModule->m_ModuleStatus |= MODULE_is_LOCKED;
else
m_CurrentModule->m_ModuleStatus &= ~MODULE_is_LOCKED;
m_CurrentModule->SetLocked( m_AutoPlaceCtrl->GetSelection() == 1 );
switch( m_AttributsCtrl->GetSelection() )
{
case 0:
m_CurrentModule->m_Attributs = 0;
m_CurrentModule->SetAttributes( 0 );
break;
case 1:
m_CurrentModule->m_Attributs = MOD_CMS;
m_CurrentModule->SetAttributes( MOD_CMS );
break;
case 2:
m_CurrentModule->m_Attributs = MOD_VIRTUAL;
m_CurrentModule->SetAttributes( MOD_VIRTUAL );
break;
}
m_CurrentModule->m_CntRot90 = m_CostRot90Ctrl->GetValue();
m_CurrentModule->m_CntRot180 = m_CostRot180Ctrl->GetValue();
m_CurrentModule->SetPlacementCost90( m_CostRot90Ctrl->GetValue() );
m_CurrentModule->SetPlacementCost180( m_CostRot180Ctrl->GetValue() );
/* Now, set orientation. must be made after others changes,
* because rotation changes fields positions on board according to the new orientation
......@@ -585,9 +580,9 @@ void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event )
msg = m_OrientValue->GetValue();
msg.ToLong( &orient );
if( m_CurrentModule->m_Orient != orient )
m_CurrentModule->Rotate( m_CurrentModule->m_Pos,
orient - m_CurrentModule->m_Orient );
if( m_CurrentModule->GetOrientation() != orient )
m_CurrentModule->Rotate( m_CurrentModule->GetPosition(),
orient - m_CurrentModule->GetOrientation() );
// Set component side, that also have effect on the fields positions on board
bool change_layer = false;
......@@ -600,7 +595,7 @@ void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event )
change_layer = true;
if( change_layer )
m_CurrentModule->Flip( m_CurrentModule->m_Pos );
m_CurrentModule->Flip( m_CurrentModule->GetPosition() );
/* Update 3D shape list */
int ii = m_3D_ShapeNameListBox->GetSelection();
......
......@@ -105,27 +105,25 @@ void DIALOG_MODULE_MODULE_EDITOR::initModeditProperties()
draw3D = (S3D_MASTER*) draw3D->Next();
}
m_DocCtrl->SetValue( m_currentModule->m_Doc );
m_KeywordCtrl->SetValue( m_currentModule->m_KeyWord);
m_DocCtrl->SetValue( m_currentModule->GetDescription() );
m_KeywordCtrl->SetValue( m_currentModule->GetKeywords() );
m_referenceCopy = new TEXTE_MODULE(NULL);
m_valueCopy = new TEXTE_MODULE(NULL);
m_referenceCopy->Copy(m_currentModule->m_Reference);
m_valueCopy->Copy(m_currentModule->m_Value);
m_referenceCopy->Copy( &m_currentModule->Reference() );
m_valueCopy->Copy( &m_currentModule->Value() );
m_ReferenceCtrl->SetValue( m_referenceCopy->m_Text );
m_ValueCtrl->SetValue( m_valueCopy->m_Text );
m_ValueCtrl->SetValue( m_valueCopy->m_Text );
m_FootprintNameCtrl->SetValue( m_currentModule->m_LibRef );
m_FootprintNameCtrl->SetValue( m_currentModule->GetLibRef() );
m_AttributsCtrl->SetItemToolTip( 0, _( "Use this attribute for most non smd components" ) );
m_AttributsCtrl->SetItemToolTip( 1,
_(
"Use this attribute for smd components.\nOnly components with this option are put in the footprint position list file" ) );
_( "Use this attribute for smd components.\nOnly components with this option are put in the footprint position list file" ) );
m_AttributsCtrl->SetItemToolTip( 2,
_(
"Use this attribute for \"virtual\" components drawn on board (like a old ISA PC bus connector)" ) );
_( "Use this attribute for \"virtual\" components drawn on board (like a old ISA PC bus connector)" ) );
// Controls on right side of the dialog
switch( m_currentModule->m_Attributs & 255 )
switch( m_currentModule->GetAttributes() & 255 )
{
case 0:
m_AttributsCtrl->SetSelection( 0 );
......@@ -144,14 +142,13 @@ void DIALOG_MODULE_MODULE_EDITOR::initModeditProperties()
break;
}
m_AutoPlaceCtrl->SetSelection(
(m_currentModule->m_ModuleStatus & MODULE_is_LOCKED) ? 1 : 0 );
m_AutoPlaceCtrl->SetSelection( (m_currentModule->IsLocked()) ? 1 : 0 );
m_AutoPlaceCtrl->SetItemToolTip( 0, _( "Enable hotkey move commands and Auto Placement" ) );
m_AutoPlaceCtrl->SetItemToolTip( 1, _( "Disable hotkey move commands and Auto Placement" ) );
m_CostRot90Ctrl->SetValue( m_currentModule->m_CntRot90 );
m_CostRot90Ctrl->SetValue( m_currentModule->GetPlacementCost90() );
m_CostRot180Ctrl->SetValue( m_currentModule->m_CntRot180 );
m_CostRot180Ctrl->SetValue( m_currentModule->GetPlacementCost180() );
// Initialize 3D parameters
......@@ -392,39 +389,35 @@ void DIALOG_MODULE_MODULE_EDITOR::OnOkClick( wxCommandEvent& event )
}
m_parent->SaveCopyInUndoList( m_currentModule, UR_MODEDIT );
if( m_AutoPlaceCtrl->GetSelection() == 1 )
m_currentModule->m_ModuleStatus |= MODULE_is_LOCKED;
else
m_currentModule->m_ModuleStatus &= ~MODULE_is_LOCKED;
m_currentModule->SetLocked( m_AutoPlaceCtrl->GetSelection() == 1 );
switch( m_AttributsCtrl->GetSelection() )
{
case 0:
m_currentModule->m_Attributs = 0;
m_currentModule->SetAttributes( 0 );
break;
case 1:
m_currentModule->m_Attributs = MOD_CMS;
m_currentModule->SetAttributes( MOD_CMS );
break;
case 2:
m_currentModule->m_Attributs = MOD_VIRTUAL;
m_currentModule->SetAttributes( MOD_VIRTUAL );
break;
}
m_currentModule->m_CntRot90 = m_CostRot90Ctrl->GetValue();
m_currentModule->m_CntRot180 = m_CostRot180Ctrl->GetValue();
m_currentModule->m_Doc = m_DocCtrl->GetValue();
m_currentModule->m_KeyWord = m_KeywordCtrl->GetValue();
m_currentModule->SetPlacementCost90( m_CostRot90Ctrl->GetValue() );
m_currentModule->SetPlacementCost180( m_CostRot180Ctrl->GetValue() );
m_currentModule->SetDescription( m_DocCtrl->GetValue() );
m_currentModule->SetKeywords( m_KeywordCtrl->GetValue() );
// Init footprint name in library
if( ! footprintName.IsEmpty() )
m_currentModule->m_LibRef = footprintName;
m_currentModule->SetLibRef( footprintName );
// Init Fields:
m_currentModule->m_Reference->Copy(m_referenceCopy );
m_currentModule->m_Value->Copy(m_valueCopy );
m_currentModule->Reference().Copy( m_referenceCopy );
m_currentModule->Value().Copy( m_valueCopy );
// Initialize masks clearances
m_currentModule->SetLocalClearance( ReturnValueFromTextCtrl( *m_NetClearanceValueCtrl ) );
......
......@@ -95,9 +95,9 @@ void DialogEditModuleText::initDlg( )
{
wxString format = m_ModuleInfoText->GetLabel();
msg.Printf( format,
GetChars( m_module->m_Reference->m_Text ),
GetChars( m_module->m_Value->m_Text ),
(float) m_module->m_Orient / 10 );
GetChars( m_module->GetReference() ),
GetChars( m_module->GetValue() ),
(float) m_module->GetOrientation() / 10 );
}
else
{
......
......@@ -119,14 +119,14 @@ void DIALOG_FIND::onButtonFindItemClick( wxCommandEvent& aEvent )
}
}
if( WildCompareString( searchString, module->m_Value->m_Text.GetData(), false ) )
if( WildCompareString( searchString, module->GetValue().GetData(), false ) )
{
count++;
if( count > itemCount )
{
foundItem = module;
pos = module->m_Pos;
pos = module->GetPosition();
itemCount++;
break;
}
......@@ -134,6 +134,7 @@ void DIALOG_FIND::onButtonFindItemClick( wxCommandEvent& aEvent )
}
wxString msg;
if( foundItem )
{
parent->SetCurItem( foundItem );
......
......@@ -163,7 +163,7 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( const wxString & aFilter, bool aRef,
if( aRef )
{
item = module->m_Reference;
item = &module->Reference();
if( item->GetSize() != GetDesignSettings().m_ModuleTextSize ||
item->GetThickness() != GetDesignSettings().m_ModuleTextWidth )
......@@ -174,7 +174,7 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( const wxString & aFilter, bool aRef,
if( aValue )
{
item = module->m_Value;
item = &module->Value();
if( item->GetSize() != GetDesignSettings().m_ModuleTextSize ||
item->GetThickness() != GetDesignSettings().m_ModuleTextWidth )
......@@ -215,14 +215,14 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( const wxString & aFilter, bool aRef,
if( aRef )
{
module->m_Reference->SetThickness( GetDesignSettings().m_ModuleTextWidth );
module->m_Reference->SetSize( GetDesignSettings().m_ModuleTextSize );
module->Reference().SetThickness( GetDesignSettings().m_ModuleTextWidth );
module->Reference().SetSize( GetDesignSettings().m_ModuleTextSize );
}
if( aValue )
{
module->m_Value->SetThickness( GetDesignSettings().m_ModuleTextWidth );
module->m_Value->SetSize( GetDesignSettings().m_ModuleTextSize );
module->Value().SetThickness( GetDesignSettings().m_ModuleTextWidth );
module->Value().SetSize( GetDesignSettings().m_ModuleTextSize );
}
if( aOthers )
......
......@@ -184,12 +184,12 @@ void DIALOG_NETLIST::OnTestFootprintsClick( wxCommandEvent& event )
{
MODULE* module = duplicate[ii];
if( module->m_Reference->m_Text.IsEmpty() )
if( module->GetReference().IsEmpty() )
list << wxT("<br>") << wxT("[noref)");
else
list << wxT("<br>") << module->m_Reference->m_Text;
list << wxT("<br>") << module->GetReference();
list << wxT(" (<i>") << module->m_Value->m_Text << wxT("</i>)");
list << wxT(" (<i>") << module->GetValue() << wxT("</i>)");
list << wxT(" @ ");
list << CoordinateToString( module->GetPosition().x ),
list << wxT(", ") << CoordinateToString( module->GetPosition().y ),
......@@ -230,11 +230,12 @@ void DIALOG_NETLIST::OnTestFootprintsClick( wxCommandEvent& event )
{
MODULE* module = notInNetlist[ii];
if( module->m_Reference->m_Text.IsEmpty() )
if( module->GetReference().IsEmpty() )
list << wxT("<br>") << wxT("[noref)");
else
list << wxT("<br>") << module->m_Reference->m_Text ;
list << wxT(" (<i>") << module->m_Value->m_Text << wxT("</i>)");
list << wxT("<br>") << module->GetReference() ;
list << wxT(" (<i>") << module->GetValue() << wxT("</i>)");
list << wxT(" @ ");
list << CoordinateToString( module->GetPosition().x ),
list << wxT(", ") << CoordinateToString( module->GetPosition().y ),
......
......@@ -136,7 +136,7 @@ bool PCB_EDIT_FRAME::ReOrientModules( const wxString& ModuleMask,
if( module->IsLocked() && !include_fixe )
continue;
if( WildCompareString( ModuleMask, module->m_Reference->m_Text, false ) )
if( WildCompareString( ModuleMask, module->GetReference(), false ) )
{
modified = true;
Rotate_Module( NULL, module, Orient, false );
......
......@@ -109,27 +109,27 @@ DIALOG_DIMENSION_EDITOR::DIALOG_DIMENSION_EDITOR( PCB_EDIT_FRAME* aParent,
CurrentDimension = aDimension;
if( aDimension->m_Text.m_Mirror )
if( aDimension->Text().IsMirrored() )
m_rbMirror->SetSelection( 1 );
else
m_rbMirror->SetSelection( 0 );
m_Name->SetValue( aDimension->m_Text.m_Text );
m_Name->SetValue( aDimension->Text().GetText() );
// Enter size value in dialog
PutValueInLocalUnits( *m_TxtSizeXCtrl, aDimension->m_Text.m_Size.x );
PutValueInLocalUnits( *m_TxtSizeXCtrl, aDimension->Text().GetSize().x );
AddUnitSymbol( *m_staticTextSizeX );
PutValueInLocalUnits( *m_TxtSizeYCtrl, aDimension->m_Text.m_Size.y );
PutValueInLocalUnits( *m_TxtSizeYCtrl, aDimension->Text().GetSize().y );
AddUnitSymbol( *m_staticTextSizeY );
// Enter lines thickness value in dialog
PutValueInLocalUnits( *m_TxtWidthCtrl, aDimension->m_Width );
PutValueInLocalUnits( *m_TxtWidthCtrl, aDimension->GetWidth() );
AddUnitSymbol( *m_staticTextWidth );
// Enter position value in dialog
PutValueInLocalUnits( *m_textCtrlPosX, aDimension->m_Text.m_Pos.x );
PutValueInLocalUnits( *m_textCtrlPosX, aDimension->Text().GetPosition().x );
AddUnitSymbol( *m_staticTextPosX );
PutValueInLocalUnits( *m_textCtrlPosY, aDimension->m_Text.m_Pos.y );
PutValueInLocalUnits( *m_textCtrlPosY, aDimension->Text().GetPosition().y );
AddUnitSymbol( *m_staticTextPosY );
for( int layer = FIRST_NO_COPPER_LAYER; layer<NB_LAYERS; layer++ )
......@@ -169,21 +169,23 @@ void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event )
// Get new size value:
msg = m_TxtSizeXCtrl->GetValue();
CurrentDimension->m_Text.m_Size.x = ReturnValueFromString( g_UserUnit, msg );
CurrentDimension->Text().SetWidth( ReturnValueFromString( g_UserUnit, msg ) );
msg = m_TxtSizeYCtrl->GetValue();
CurrentDimension->m_Text.m_Size.y = ReturnValueFromString( g_UserUnit, msg );
CurrentDimension->Text().SetHeight( ReturnValueFromString( g_UserUnit, msg ) );
// Get new position value:
// It will be copied later in dimension, because
msg = m_textCtrlPosX->GetValue();
CurrentDimension->m_Text.m_Pos.x = ReturnValueFromString( g_UserUnit, msg );
wxPoint pos;
pos.x = ReturnValueFromString( g_UserUnit, msg );
msg = m_textCtrlPosY->GetValue();
CurrentDimension->m_Text.m_Pos.y = ReturnValueFromString( g_UserUnit, msg );
pos.y = ReturnValueFromString( g_UserUnit, msg );
CurrentDimension->Text().SetPosition( pos );
// Get new line thickness value:
msg = m_TxtWidthCtrl->GetValue();
int width = ReturnValueFromString( g_UserUnit, msg );
int maxthickness = Clamp_Text_PenSize( width, CurrentDimension->m_Text.m_Size );
int maxthickness = Clamp_Text_PenSize( width, CurrentDimension->Text().GetSize() );
if( width > maxthickness )
{
......@@ -192,9 +194,10 @@ void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event )
width = maxthickness;
}
CurrentDimension->m_Text.m_Thickness = CurrentDimension->m_Width = width ;
CurrentDimension->SetWidth( width );
CurrentDimension->Text().SetThickness( width );
CurrentDimension->m_Text.m_Mirror = ( m_rbMirror->GetSelection() == 1 ) ? true : false;
CurrentDimension->Text().SetMirrored( ( m_rbMirror->GetSelection() == 1 ) ? true : false );
CurrentDimension->SetLayer( m_SelLayerBox->GetCurrentSelection() + FIRST_NO_COPPER_LAYER );
......@@ -252,18 +255,18 @@ DIMENSION* PCB_EDIT_FRAME::EditDimension( DIMENSION* aDimension, wxDC* aDC )
aDimension->m_arrowD1O = aDimension->m_arrowD1F = pos;
aDimension->m_arrowD2O = aDimension->m_arrowD2F = pos;
aDimension->m_Text.m_Size = GetBoard()->GetDesignSettings().m_PcbTextSize;
aDimension->Text().SetSize( GetBoard()->GetDesignSettings().m_PcbTextSize );
int width = GetBoard()->GetDesignSettings().m_PcbTextWidth;
int maxthickness = Clamp_Text_PenSize(width, aDimension->m_Text.m_Size );
int maxthickness = Clamp_Text_PenSize(width, aDimension->Text().GetSize() );
if( width > maxthickness )
{
width = maxthickness;
}
aDimension->m_Text.m_Thickness = aDimension->m_Width = width ;
aDimension->AdjustDimensionDetails( );
aDimension->Text().SetThickness( width );
aDimension->SetWidth( width );
aDimension->AdjustDimensionDetails();
aDimension->Draw( m_canvas, aDC, GR_XOR );
......@@ -377,13 +380,13 @@ void PCB_EDIT_FRAME::BeginMoveDimensionText( DIMENSION* aItem, wxDC* DC )
return;
// Store the initial position for undo/abort command
initialTextPosition = aItem->m_Text.m_Pos;
initialTextPosition = aItem->Text().GetPosition();
aItem->Draw( m_canvas, DC, GR_XOR );
aItem->SetFlags( IS_MOVED );
SetMsgPanel( aItem );
GetScreen()->SetCrossHairPosition( aItem->m_Text.m_Pos );
GetScreen()->SetCrossHairPosition( aItem->Text().GetPosition() );
m_canvas->MoveCursorToCrossHair();
m_canvas->SetMouseCapture( MoveDimensionText, AbortMoveDimensionText );
......@@ -404,7 +407,7 @@ static void MoveDimensionText( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
if( aErase )
dimension->Draw( aPanel, aDC, GR_XOR );
dimension->m_Text.m_Pos = aPanel->GetScreen()->GetCrossHairPosition();
dimension->Text().SetPosition( aPanel->GetScreen()->GetCrossHairPosition() );
dimension->Draw( aPanel, aDC, GR_XOR );
}
......@@ -425,7 +428,7 @@ void AbortMoveDimensionText( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
return;
dimension->Draw( aPanel, aDC, GR_XOR );
dimension->m_Text.m_Pos = initialTextPosition;
dimension->Text().SetPosition( initialTextPosition );
dimension->ClearFlags();
dimension->Draw( aPanel, aDC, GR_OR );
}
......@@ -444,9 +447,10 @@ void PCB_EDIT_FRAME::PlaceDimensionText( DIMENSION* aItem, wxDC* DC )
aItem->Draw( m_canvas, DC, GR_OR );
OnModify();
EXCHG( aItem->m_Text.m_Pos, initialTextPosition );
wxPoint tmp = aItem->Text().GetPosition();
aItem->Text().SetPosition( initialTextPosition );
SaveCopyInUndoList( aItem, UR_CHANGED );
EXCHG( aItem->m_Text.m_Pos, initialTextPosition );
aItem->Text().SetPosition( tmp );
aItem->ClearFlags();
}
......@@ -355,7 +355,7 @@ EDGE_MODULE* FOOTPRINT_EDIT_FRAME::Begin_Edge_Module( EDGE_MODULE* aEdge,
// Initialize the relative coordinates
aEdge->SetStart0( aEdge->GetStart() - module->GetPosition() );
RotatePoint( &aEdge->m_Start0, -module->m_Orient );
RotatePoint( &aEdge->m_Start0, -module->GetOrientation() );
aEdge->m_End0 = aEdge->m_Start0;
module->CalculateBoundingBox();
......
......@@ -638,13 +638,13 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
wxString msg;
msg.Printf( _( "Footprint %s found, but it is locked" ),
module->m_Reference->m_Text.GetData() );
module->GetReference().GetData() );
DisplayInfoMessage( this, msg );
break;
}
SendMessageToEESCHEMA( module );
GetScreen()->SetCrossHairPosition( module->m_Pos );
GetScreen()->SetCrossHairPosition( module->GetPosition() );
m_canvas->MoveCursorToCrossHair();
StartMoveModule( module, &dc, id == ID_POPUP_PCB_DRAG_MODULE_REQUEST );
break;
......@@ -660,7 +660,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
wxString msg;
msg.Printf( _( "Footprint %s found, but it is locked" ),
module->m_Reference->m_Text.GetData() );
module->GetReference().GetData() );
DisplayInfoMessage( this, msg );
break;
}
......@@ -686,7 +686,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
wxString msg;
msg.Printf( _( "Footprint %s found, but it is locked" ),
module->m_Reference->m_Text.GetData() );
module->GetReference().GetData() );
DisplayInfoMessage( this, msg );
break;
}
......@@ -714,14 +714,14 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
wxString msg;
msg.Printf( _( "Footprint %s found, but it is locked" ),
module->m_Reference->m_Text.GetData() );
module->GetReference().GetData() );
DisplayInfoMessage( this, msg );
break;
}
/* This is a simple rotation, no other editing in progress */
if( !GetCurItem()->IsMoving() )
SaveCopyInUndoList(GetCurItem(), UR_ROTATED, ((MODULE*)GetCurItem())->m_Pos);
SaveCopyInUndoList( GetCurItem(), UR_ROTATED, ((MODULE*)GetCurItem())->GetPosition() );
Rotate_Module( &dc, (MODULE*) GetCurItem(), g_RotationAngle, true );
break;
......@@ -742,7 +742,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
wxString msg;
msg.Printf( _( "Footprint %s found, but it is locked" ),
module->m_Reference->m_Text.GetData() );
module->GetReference().GetData() );
DisplayInfoMessage( this, msg );
break;
}
......@@ -750,7 +750,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
/* This is a simple rotation, no other editing in progress */
if( !GetCurItem()->IsMoving() )
SaveCopyInUndoList( GetCurItem(), UR_ROTATED_CLOCKWISE,
((MODULE*)GetCurItem())->m_Pos );
((MODULE*)GetCurItem())->GetPosition() );
Rotate_Module( &dc, (MODULE*) GetCurItem(), -g_RotationAngle, true );
break;
......@@ -771,14 +771,14 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
wxString msg;
msg.Printf( _( "Footprint %s found, but it is locked" ),
module->m_Reference->m_Text.GetData() );
module->GetReference().GetData() );
DisplayInfoMessage( this, msg );
break;
}
/* This is a simple flip, no other editing in progress */
if( !GetCurItem()->IsMoving() )
SaveCopyInUndoList(GetCurItem(), UR_FLIPPED, ((MODULE*)GetCurItem())->m_Pos);
SaveCopyInUndoList( GetCurItem(), UR_FLIPPED, ((MODULE*)GetCurItem())->GetPosition() );
Change_Side_Module( (MODULE*) GetCurItem(), &dc );
break;
......@@ -833,7 +833,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
wxString msg;
msg.Printf( _( "The parent (%s) of the pad is locked" ),
module->m_Reference->m_Text.GetData() );
module->GetReference().GetData() );
DisplayInfoMessage( this, msg );
break;
}
......@@ -852,7 +852,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
wxString msg;
msg.Printf( _( "The parent (%s) of the pad is locked" ),
module->m_Reference->m_Text.GetData() );
module->GetReference().GetData() );
DisplayInfoMessage( this, msg );
break;
}
......
......@@ -75,14 +75,14 @@ void FOOTPRINT_EDIT_FRAME::Place_Ancre( MODULE* aModule )
if( aModule == NULL )
return;
moveVector = aModule->m_Pos - GetScreen()->GetCrossHairPosition();
moveVector = aModule->GetPosition() - GetScreen()->GetCrossHairPosition();
aModule->m_Pos = GetScreen()->GetCrossHairPosition();
aModule->SetPosition( GetScreen()->GetCrossHairPosition() );
/* Update the relative coordinates:
* The coordinates are relative to the anchor point.
* Calculate deltaX and deltaY from the anchor. */
RotatePoint( &moveVector, -aModule->m_Orient );
RotatePoint( &moveVector, -aModule->GetOrientation() );
// Update the pad coordinates.
for( D_PAD* pad = (D_PAD*) aModule->m_Pads; pad; pad = pad->Next() )
......
......@@ -74,10 +74,10 @@ TEXTE_MODULE* PCB_BASE_FRAME::CreateTextModule( MODULE* Module, wxDC* DC )
Text->SetFlags( IS_NEW );
Text->m_Text = wxT( "text" );
Text->SetText( wxT( "text" ) );
GetDesignSettings().m_ModuleTextWidth = Clamp_Text_PenSize( GetDesignSettings().m_ModuleTextWidth,
std::min( GetDesignSettings().m_ModuleTextSize.x, GetDesignSettings().m_ModuleTextSize.y ), true );
std::min( GetDesignSettings().m_ModuleTextSize.x, GetDesignSettings().m_ModuleTextSize.y ), true );
Text->m_Size = GetDesignSettings().m_ModuleTextSize;
Text->m_Thickness = GetDesignSettings().m_ModuleTextWidth;
Text->m_Pos = GetScreen()->GetCrossHairPosition();
......@@ -247,8 +247,8 @@ void PCB_BASE_FRAME::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC )
// Set the new position for text.
Text->m_Pos = GetScreen()->GetCrossHairPosition();
wxPoint textRelPos = Text->m_Pos - Module->m_Pos;
RotatePoint( &textRelPos, -Module->m_Orient );
wxPoint textRelPos = Text->GetPosition() - Module->GetPosition();
RotatePoint( &textRelPos, -Module->GetOrientation() );
Text->SetPos0( textRelPos );
Text->ClearFlags();
Module->ClearFlags();
......
......@@ -163,12 +163,12 @@ void PCB_EDIT_FRAME::ExportToGenCAD( wxCommandEvent& aEvent )
for( module = pcb->m_Modules; module != NULL; module = module->Next() )
{
module->flag = 0;
module->SetFlag( 0 );
if( module->GetLayer() == LAYER_N_BACK )
{
module->Flip( module->m_Pos );
module->flag = 1;
module->Flip( module->GetPosition() );
module->SetFlag( 1 );
}
}
......@@ -200,10 +200,10 @@ void PCB_EDIT_FRAME::ExportToGenCAD( wxCommandEvent& aEvent )
// Undo the footprints modifications (flipped footprints)
for( module = pcb->m_Modules; module != NULL; module = module->Next() )
{
if( module->flag )
if( module->GetFlag() )
{
module->Flip( module->m_Pos );
module->flag = 0;
module->Flip( module->GetPosition() );
module->SetFlag( 0 );
}
}
}
......@@ -519,11 +519,11 @@ static void CreateShapesSection( FILE* aFile, BOARD* aPcb )
if( ( pad->GetLayerMask() & ALL_CU_LAYERS ) == LAYER_BACK )
{
layer = ( module->flag ) ? "TOP" : "BOTTOM";
layer = ( module->GetFlag() ) ? "TOP" : "BOTTOM";
}
else if( ( pad->GetLayerMask() & ALL_CU_LAYERS ) == LAYER_FRONT )
{
layer = ( module->flag ) ? "BOTTOM" : "TOP";
layer = ( module->GetFlag() ) ? "BOTTOM" : "TOP";
}
pad->ReturnStringPadName( pinname );
......@@ -535,7 +535,7 @@ static void CreateShapesSection( FILE* aFile, BOARD* aPcb )
NORMALIZE_ANGLE_POS( orient );
// Bottom side modules use the flipped padstack
fprintf( aFile, (module->flag) ?
fprintf( aFile, (module->GetFlag()) ?
"PIN %s PAD%dF %g %g %s %g %s\n" :
"PIN %s PAD%d %g %g %s %g %s\n",
TO_UTF8( pinname ), pad->GetSubRatsnest(),
......@@ -565,7 +565,7 @@ static void CreateComponentsSection( FILE* aFile, BOARD* aPcb )
const char* flip;
int orient = module->GetOrientation();
if( module->flag )
if( module->GetFlag() )
{
mirror = "0";
flip = "FLIP";
......@@ -578,52 +578,51 @@ static void CreateComponentsSection( FILE* aFile, BOARD* aPcb )
}
fprintf( aFile, "\nCOMPONENT %s\n",
TO_UTF8( module->m_Reference->m_Text ) );
TO_UTF8( module->GetReference() ) );
fprintf( aFile, "DEVICE %s_%s\n",
TO_UTF8( module->m_Reference->m_Text ),
TO_UTF8( module->m_Value->m_Text ) );
TO_UTF8( module->GetReference() ),
TO_UTF8( module->GetValue() ) );
fprintf( aFile, "PLACE %g %g\n",
MapXTo( module->m_Pos.x ),
MapYTo( module->m_Pos.y ) );
MapXTo( module->GetPosition().x ),
MapYTo( module->GetPosition().y ) );
fprintf( aFile, "LAYER %s\n",
(module->flag) ? "BOTTOM" : "TOP" );
(module->GetFlag()) ? "BOTTOM" : "TOP" );
fprintf( aFile, "ROTATION %g\n",
orient / 10.0 );
fprintf( aFile, "SHAPE %s %s %s\n",
TO_UTF8( module->m_Reference->m_Text ),
TO_UTF8( module->GetReference() ),
mirror, flip );
// Text on silk layer: RefDes and value (are they actually useful?)
textmod = module->m_Reference;
textmod = &module->Reference();
for( int ii = 0; ii < 2; ii++ )
{
int orient = textmod->GetOrientation();
wxString layer = GenCADLayerName[(module->flag) ?
wxString layer = GenCADLayerName[(module->GetFlag()) ?
SILKSCREEN_N_BACK : SILKSCREEN_N_FRONT];
fprintf( aFile, "TEXT %g %g %g %g %s %s \"%s\"",
textmod->GetPos0().x / SCALE_FACTOR,
textmod->GetPos0().x / SCALE_FACTOR,
-textmod->GetPos0().y / SCALE_FACTOR,
textmod->GetSize().x / SCALE_FACTOR,
orient / 10.0,
mirror,
TO_UTF8( layer ),
TO_UTF8( textmod->m_Text ) );
textmod->GetSize().x / SCALE_FACTOR,
orient / 10.0,
mirror,
TO_UTF8( layer ),
TO_UTF8( textmod->GetText() ) );
// Please note, the width is approx
fprintf( aFile, " 0 0 %g %g\n",
( textmod->GetSize().x * textmod->m_Text.Len() )
/ SCALE_FACTOR,
( textmod->GetSize().x * textmod->GetLength() ) / SCALE_FACTOR,
textmod->GetSize().y / SCALE_FACTOR );
textmod = module->m_Value; // Dirty trick for the second iteration
textmod = &module->Value(); // Dirty trick for the second iteration
}
// The SHEET is a 'generic description' for referencing the component
fprintf( aFile, "SHEET \"RefDes: %s, Value: %s\"\n",
TO_UTF8( module->m_Reference->m_Text ),
TO_UTF8( module->m_Value->m_Text ) );
TO_UTF8( module->GetReference() ),
TO_UTF8( module->GetValue() ) );
}
fputs( "$ENDCOMPONENTS\n\n", aFile );
......@@ -671,8 +670,8 @@ static void CreateSignalsSection( FILE* aFile, BOARD* aPcb )
pad->ReturnStringPadName( padname );
msg.Printf( wxT( "NODE %s %s" ),
GetChars( module->m_Reference->m_Text ),
GetChars( padname ) );
GetChars( module->GetReference() ),
GetChars( padname ) );
fputs( TO_UTF8( msg ), aFile );
fputs( "\n", aFile );
......@@ -861,15 +860,15 @@ static void CreateDevicesSection( FILE* aFile, BOARD* aPcb )
for( module = aPcb->m_Modules; module != NULL; module = module->Next() )
{
fprintf( aFile, "DEVICE \"%s\"\n", TO_UTF8( module->m_Reference->m_Text ) );
fprintf( aFile, "PART \"%s\"\n", TO_UTF8( module->m_Value->m_Text ) );
fprintf( aFile, "PACKAGE \"%s\"\n", TO_UTF8( module->m_LibRef ) );
fprintf( aFile, "DEVICE \"%s\"\n", TO_UTF8( module->GetReference() ) );
fprintf( aFile, "PART \"%s\"\n", TO_UTF8( module->GetValue() ) );
fprintf( aFile, "PACKAGE \"%s\"\n", TO_UTF8( module->GetLibRef() ) );
// The TYPE attribute is almost freeform
const char* ty = "TH";
if( module->m_Attributs & MOD_CMS )
if( module->GetAttributes() & MOD_CMS )
ty = "SMD";
if( module->m_Attributs & MOD_VIRTUAL )
if( module->GetAttributes() & MOD_VIRTUAL )
ty = "VIRTUAL";
fprintf( aFile, "TYPE %s\n", ty );
}
......@@ -990,19 +989,19 @@ static void FootprintWriteShape( FILE* aFile, MODULE* module )
int Yaxis_sign = -1;
// Flip for bottom side components
if( module->flag )
if( module->GetFlag() )
Yaxis_sign = 1;
/* creates header: */
fprintf( aFile, "\nSHAPE %s\n", TO_UTF8( module->m_Reference->m_Text ) );
fprintf( aFile, "\nSHAPE %s\n", TO_UTF8( module->GetReference() ) );
if( module->m_Attributs & MOD_VIRTUAL )
if( module->GetAttributes() & MOD_VIRTUAL )
{
fprintf( aFile, "INSERT SMD\n" );
}
else
{
if( module->m_Attributs & MOD_CMS )
if( module->GetAttributes() & MOD_CMS )
{
fprintf( aFile, "INSERT SMD\n" );
}
......
......@@ -264,6 +264,7 @@ static void write_triangle_bag( FILE* output_file, int color_index, //{{{
else
{
marker_found++;
switch( marker_found )
{
case 1: // Material marker
......@@ -309,6 +310,7 @@ static void write_triangle_bag( FILE* output_file, int color_index, //{{{
// Index marker
// OK, that's sick ...
int j = 0;
for( TRIANGLEBAG::const_iterator i = triangles.begin();
i != triangles.end();
i++ )
......@@ -323,6 +325,7 @@ static void write_triangle_bag( FILE* output_file, int color_index, //{{{
break;
}
}
lineno++;
}
}
......@@ -523,10 +526,13 @@ static void export_vrml_arc( int layer, double centerx, double centery,
double start_angle = atan2( arc_starty - centery, arc_startx - centerx );
int count = KiROUND( arc_angle / 360.0 * SEGM_COUNT_PER_360 );
if( count < 0 )
count = -count;
if( count == 0 )
count = 1;
double divisions = arc_angle*M_PI/180.0 / count;
double outer_radius = hypot( arc_starty - centery, arc_startx - centerx )
......@@ -561,13 +567,17 @@ static void export_vrml_varc( TRIANGLEBAG& triangles,
double radius = hypot( arc_starty - centery, arc_startx - centerx );
int count = KiROUND( arc_angle / 360.0 * SEGM_COUNT_PER_360 );
if( count < 0 )
count = -count;
if( count == 0 )
count = 1;
double divisions = arc_angle*M_PI/180.0 / count;
double alpha = 0;
for( int ii = 0; ii <= count; alpha += divisions, ii++ )
{
double angle_rot = start_angle + alpha;
......@@ -665,12 +675,13 @@ static void export_vrml_pcbtext( TEXTE_PCB* text )
if( text->m_MultilineAllowed )
{
wxPoint pos = text->m_Pos;
wxArrayString* list = wxStringSplit( text->m_Text, '\n' );
wxArrayString* list = wxStringSplit( text->GetText(), '\n' );
wxPoint offset;
offset.y = text->GetInterline();
RotatePoint( &offset, text->GetOrientation() );
for( unsigned i = 0; i<list->Count(); i++ )
{
wxString txt = list->Item( i );
......@@ -688,7 +699,7 @@ static void export_vrml_pcbtext( TEXTE_PCB* text )
else
{
DrawGraphicText( NULL, NULL, text->m_Pos, BLACK,
text->m_Text, text->GetOrientation(), size,
text->GetText(), text->GetOrientation(), size,
text->m_HJustify, text->m_VJustify,
text->m_Thickness, text->m_Italic,
true,
......@@ -804,9 +815,11 @@ static void export_vrml_zones( BOARD* pcb )
for( int ic = 1; ic <= imax; ic++ )
{
CPolyPt* endcorner = &zone->m_FilledPolysList[ic];
if( begincorner->utility == 0 ) // Draw only basic outlines, not extra segments
export_vrml_line( layer, begincorner->x, begincorner->y,
endcorner->x, endcorner->y, width, 1 );
if( (endcorner->end_contour) || (ic == imax) ) // the last corner of a filled area is found: draw it
{
if( endcorner->utility == 0 ) // Draw only basic outlines, not extra segments
......@@ -838,7 +851,7 @@ static void export_vrml_text_module( TEXTE_MODULE* module ) //{{{
s_text_layer = module->GetLayer();
s_text_width = module->m_Thickness;
DrawGraphicText( NULL, NULL, module->m_Pos, BLACK,
module->m_Text, module->GetDrawRotation(), size,
module->GetText(), module->GetDrawRotation(), size,
module->m_HJustify, module->m_VJustify,
module->m_Thickness, module->m_Italic,
true,
......@@ -1019,8 +1032,8 @@ static void export_vrml_module( BOARD* aPcb, MODULE* aModule,
double boardIU2WRML )
{
// Reference and value
export_vrml_text_module( aModule->m_Reference );
export_vrml_text_module( aModule->m_Value );
export_vrml_text_module( &aModule->Reference() );
export_vrml_text_module( &aModule->Value() );
// Export module edges
for( EDA_ITEM* item = aModule->m_Drawings; item != NULL; item = item->Next() )
......@@ -1084,11 +1097,11 @@ static void export_vrml_module( BOARD* aPcb, MODULE* aModule,
double roty = - vrmlm->m_MatRotation.y;
double rotz = - vrmlm->m_MatRotation.z;
if ( isFlipped )
if( isFlipped )
{
rotx += 180.0;
NEGATE(roty);
NEGATE(rotz);
NEGATE( roty );
NEGATE( rotz );
}
// Do some quaternion munching
......@@ -1098,6 +1111,7 @@ static void export_vrml_module( BOARD* aPcb, MODULE* aModule,
compose_quat( q1, q2, q1 );
build_quat( 0, 0, 1, rotz / 180.0 * M_PI, q2 );
compose_quat( q1, q2, q1 );
// Note here aModule->GetOrientation() is in 0.1 degrees,
// so module rotation is aModule->GetOrientation() / 1800.0
build_quat( 0, 0, 1, aModule->GetOrientation() / 1800.0 * M_PI, q2 );
......@@ -1105,6 +1119,7 @@ static void export_vrml_module( BOARD* aPcb, MODULE* aModule,
from_quat( q1, rot );
fprintf( aOutputFile, "Transform {\n" );
// A null rotation would fail the acos!
if( rot[3] != 0.0 )
{
......@@ -1117,7 +1132,7 @@ static void export_vrml_module( BOARD* aPcb, MODULE* aModule,
double offsety = vrmlm->m_MatPosition.y * IU_PER_MILS * 1000.0;
double offsetz = vrmlm->m_MatPosition.z * IU_PER_MILS * 1000.0;
if ( isFlipped )
if( isFlipped )
NEGATE(offsetz);
else // In normal mode, Y axis is reversed in Pcbnew.
NEGATE(offsety);
......@@ -1125,8 +1140,8 @@ static void export_vrml_module( BOARD* aPcb, MODULE* aModule,
RotatePoint(&offsetx, &offsety, aModule->GetOrientation());
fprintf( aOutputFile, " translation %g %g %g\n",
(offsetx + aModule->m_Pos.x) * boardIU2WRML,
- (offsety + aModule->m_Pos.y) * boardIU2WRML, // Y axis is reversed in Pcbnew
(offsetx + aModule->GetPosition().x) * boardIU2WRML,
- (offsety + aModule->GetPosition().y) * boardIU2WRML, // Y axis is reversed in Pcbnew
(offsetz + layer_z[aModule->GetLayer()]) * boardIU2WRML);
fprintf( aOutputFile, " scale %g %g %g\n",
......
......@@ -373,27 +373,27 @@ int PCB_EDIT_FRAME::DoGenFootprintsPositionFile( const wxString& aFullFileName,
continue;
}
if( module->m_Attributs & MOD_VIRTUAL )
if( module->GetAttributes() & MOD_VIRTUAL )
{
D( printf( "skipping module %s because it's virtual\n",
TO_UTF8( module->GetReference() ) );)
continue;
}
if( ( module->m_Attributs & MOD_CMS ) == 0 )
if( ( module->GetAttributes() & MOD_CMS ) == 0 )
{
if( aForceSmdItems ) // true to fix a bunch of mis-labeled modules:
{
if( !HasNonSMDPins( module ) )
{
// all module's pins are SMD, mark the part for pick and place
module->m_Attributs |= MOD_CMS;
module->SetAttributes( module->GetAttributes() | MOD_CMS );
OnModify();
}
else
{
D(printf( "skipping %s because its attribute is not CMS and it has non SMD pins\n",
TO_UTF8(module->GetReference()) ) );
TO_UTF8(module->GetReference()) ) );
continue;
}
}
......@@ -425,15 +425,16 @@ int PCB_EDIT_FRAME::DoGenFootprintsPositionFile( const wxString& aFullFileName,
continue;
}
if( module->m_Attributs & MOD_VIRTUAL )
if( module->GetAttributes() & MOD_VIRTUAL )
continue;
if( (module->m_Attributs & MOD_CMS) == 0 )
if( (module->GetAttributes() & MOD_CMS) == 0 )
continue;
LIST_MOD item;
item.m_Module = module;
item.m_Reference = module->m_Reference->m_Text;
item.m_Value = module->m_Value->m_Text;
item.m_Reference = module->GetReference();
item.m_Value = module->GetValue();
item.m_Layer = module->GetLayer();
list.push_back( item );
}
......@@ -470,11 +471,11 @@ int PCB_EDIT_FRAME::DoGenFootprintsPositionFile( const wxString& aFullFileName,
wxPoint module_pos;
const wxString& ref = list[ii].m_Reference;
const wxString& val = list[ii].m_Value;
const wxString& pkg = list[ii].m_Module->m_LibRef;
const wxString& pkg = list[ii].m_Module->GetLibRef();
sprintf( line, "%-8.8s %-16.16s %-16.16s",
TO_UTF8( ref ), TO_UTF8( val ), TO_UTF8( pkg ) );
TO_UTF8( ref ), TO_UTF8( val ), TO_UTF8( pkg ) );
module_pos = list[ii].m_Module->m_Pos;
module_pos = list[ii].m_Module->GetPosition();
module_pos -= File_Place_Offset;
char* text = line + strlen( line );
......@@ -483,7 +484,7 @@ int PCB_EDIT_FRAME::DoGenFootprintsPositionFile( const wxString& aFullFileName,
sprintf( text, " %9.4f %9.4f %8.1f ",
module_pos.x * conv_unit,
-module_pos.y * conv_unit,
double(list[ii].m_Module->m_Orient) / 10 );
double(list[ii].m_Module->GetOrientation()) / 10 );
int layer = list[ii].m_Module->GetLayer();
......@@ -605,31 +606,31 @@ bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool
for( MODULE* Module = GetBoard()->m_Modules; Module; Module = Module->Next() )
{
sprintf( line, "$MODULE %s\n", EscapedUTF8( Module->m_Reference->m_Text ).c_str() );
sprintf( line, "$MODULE %s\n", EscapedUTF8( Module->GetReference() ).c_str() );
fputs( line, rptfile );
sprintf( line, "reference %s\n", EscapedUTF8( Module->m_Reference->m_Text ).c_str() );
sprintf( line, "reference %s\n", EscapedUTF8( Module->GetReference() ).c_str() );
fputs( line, rptfile );
sprintf( line, "value %s\n", EscapedUTF8( Module->m_Value->m_Text ).c_str() );
sprintf( line, "value %s\n", EscapedUTF8( Module->GetValue() ).c_str() );
fputs( line, rptfile );
sprintf( line, "footprint %s\n", EscapedUTF8( Module->m_LibRef ).c_str() );
sprintf( line, "footprint %s\n", EscapedUTF8( Module->GetLibRef() ).c_str() );
fputs( line, rptfile );
msg = wxT( "attribut" );
if( Module->m_Attributs & MOD_VIRTUAL )
if( Module->GetAttributes() & MOD_VIRTUAL )
msg += wxT( " virtual" );
if( Module->m_Attributs & MOD_CMS )
if( Module->GetAttributes() & MOD_CMS )
msg += wxT( " smd" );
if( ( Module->m_Attributs & (MOD_VIRTUAL | MOD_CMS) ) == 0 )
if( ( Module->GetAttributes() & (MOD_VIRTUAL | MOD_CMS) ) == 0 )
msg += wxT( " none" );
msg += wxT( "\n" );
fputs( TO_UTF8( msg ), rptfile );
module_pos = Module->m_Pos;
module_pos = Module->GetPosition();
module_pos.x -= File_Place_Offset.x;
module_pos.y -= File_Place_Offset.y;
......@@ -638,7 +639,7 @@ bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool
module_pos.y * conv_unit );
fputs( line, rptfile );
sprintf( line, "orientation %.2f\n", (double) Module->m_Orient / 10 );
sprintf( line, "orientation %.2f\n", (double) Module->GetOrientation() / 10 );
if( Module->GetLayer() == LAYER_N_FRONT )
strcat( line, "layer component\n" );
......@@ -696,8 +697,7 @@ bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool
fprintf( rptfile, "$EndPAD\n" );
}
fprintf( rptfile, "$EndMODULE %s\n\n",
TO_UTF8(Module->m_Reference->m_Text ) );
fprintf( rptfile, "$EndMODULE %s\n\n", TO_UTF8 (Module->GetReference() ) );
}
}
catch( IO_ERROR ioe )
......
......@@ -241,7 +241,7 @@ void PCB_BASE_FRAME::GlobalChange_PadSettings( D_PAD* aPad,
if( !aSameFootprints && (module != Module_Ref) )
continue;
if( module->m_LibRef != Module_Ref->m_LibRef )
if( module->GetLibRef() != Module_Ref->GetLibRef() )
continue;
bool saveMe = false;
......@@ -280,7 +280,7 @@ void PCB_BASE_FRAME::GlobalChange_PadSettings( D_PAD* aPad,
if( !aSameFootprints && (module != Module_Ref) )
continue;
if( module->m_LibRef != Module_Ref->m_LibRef )
if( module->GetLibRef() != Module_Ref->GetLibRef() )
continue;
// Erase module on screen
......
......@@ -397,7 +397,7 @@ MODULE* GPCB_FPL_CACHE::parseMODULE( LINE_READER* aLineReader ) throw( IO_ERROR,
parseInt( parameters[7], conv_unit ) );
}
module->Reference().SetPos( textPos );
module->Reference().SetPosition( textPos );
module->Reference().SetPos0( textPos );
int orientation = parseInt( parameters[paramCnt-4] );
......@@ -415,7 +415,7 @@ MODULE* GPCB_FPL_CACHE::parseMODULE( LINE_READER* aLineReader ) throw( IO_ERROR,
module->Value().SetSize( module->Reference().GetSize() );
module->Value().SetThickness( module->Reference().GetThickness() );
textPos.y += tsize + thickness;
module->Value().SetPos( textPos );
module->Value().SetPosition( textPos );
module->Value().SetPos0( textPos );
while( aLineReader->ReadLine() )
......
......@@ -631,8 +631,8 @@ void PCB_IO::format( DIMENSION* aDimension, int aNestLevel ) const
throw( IO_ERROR )
{
m_out->Print( aNestLevel, "(dimension %s (width %s)",
FMT_IU( aDimension->m_Value ).c_str(),
FMT_IU( aDimension->m_Width ).c_str() );
FMT_IU( aDimension->GetValue() ).c_str(),
FMT_IU( aDimension->GetWidth() ).c_str() );
formatLayer( aDimension );
......@@ -641,7 +641,7 @@ void PCB_IO::format( DIMENSION* aDimension, int aNestLevel ) const
m_out->Print( 0, "\n" );
Format( (TEXTE_PCB*) &aDimension->m_Text, aNestLevel+1 );
Format( (TEXTE_PCB*) &aDimension->Text(), aNestLevel+1 );
m_out->Print( aNestLevel+1, "(feature1 (pts (xy %s %s) (xy %s %s)))\n",
FMT_IU( aDimension->m_featureLineDO.x ).c_str(),
......@@ -852,7 +852,7 @@ void PCB_IO::format( PCB_TARGET* aTarget, int aNestLevel ) const
void PCB_IO::format( MODULE* aModule, int aNestLevel ) const
throw( IO_ERROR )
{
m_out->Print( aNestLevel, "(module %s", m_out->Quotew( aModule->m_LibRef ).c_str() );
m_out->Print( aNestLevel, "(module %s", m_out->Quotew( aModule->GetLibRef() ).c_str() );
if( aModule->IsLocked() )
m_out->Print( aNestLevel, " locked" );
......@@ -870,30 +870,30 @@ void PCB_IO::format( MODULE* aModule, int aNestLevel ) const
else
m_out->Print( 0, "\n" );
m_out->Print( aNestLevel+1, "(at %s", FMT_IU( aModule->m_Pos ).c_str() );
m_out->Print( aNestLevel+1, "(at %s", FMT_IU( aModule->GetPosition() ).c_str() );
if( aModule->m_Orient != 0.0 )
m_out->Print( 0, " %s", FMT_ANGLE( aModule->m_Orient ).c_str() );
if( aModule->GetOrientation() != 0.0 )
m_out->Print( 0, " %s", FMT_ANGLE( aModule->GetOrientation() ).c_str() );
m_out->Print( 0, ")\n" );
if( !aModule->m_Doc.IsEmpty() )
if( !aModule->GetDescription().IsEmpty() )
m_out->Print( aNestLevel+1, "(descr %s)\n",
m_out->Quotew( aModule->m_Doc ).c_str() );
m_out->Quotew( aModule->GetDescription() ).c_str() );
if( !aModule->m_KeyWord.IsEmpty() )
if( !aModule->GetKeywords().IsEmpty() )
m_out->Print( aNestLevel+1, "(tags %s)\n",
m_out->Quotew( aModule->m_KeyWord ).c_str() );
m_out->Quotew( aModule->GetKeywords() ).c_str() );
if( !aModule->m_Path.IsEmpty() )
if( !aModule->GetPath().IsEmpty() )
m_out->Print( aNestLevel+1, "(path %s)\n",
m_out->Quotew( aModule->m_Path ).c_str() );
m_out->Quotew( aModule->GetPath() ).c_str() );
if( aModule->m_CntRot90 != 0 )
m_out->Print( aNestLevel+1, "(autoplace_cost90 %d)\n", aModule->m_CntRot90 );
if( aModule->GetPlacementCost90() != 0 )
m_out->Print( aNestLevel+1, "(autoplace_cost90 %d)\n", aModule->GetPlacementCost90() );
if( aModule->m_CntRot180 != 0 )
m_out->Print( aNestLevel+1, "(autoplace_cost180 %d)\n", aModule->m_CntRot180 );
if( aModule->GetPlacementCost180() != 0 )
m_out->Print( aNestLevel+1, "(autoplace_cost180 %d)\n", aModule->GetPlacementCost180() );
if( aModule->GetLocalSolderMaskMargin() != 0 )
m_out->Print( aNestLevel+1, "(solder_mask_margin %s)\n",
......@@ -911,33 +911,33 @@ void PCB_IO::format( MODULE* aModule, int aNestLevel ) const
m_out->Print( aNestLevel+1, "(clearance %s)\n",
FMT_IU( aModule->GetLocalClearance() ).c_str() );
if( aModule->m_ZoneConnection != UNDEFINED_CONNECTION )
m_out->Print( aNestLevel+1, "(zone_connect %d)\n", aModule->m_ZoneConnection );
if( aModule->GetZoneConnection() != UNDEFINED_CONNECTION )
m_out->Print( aNestLevel+1, "(zone_connect %d)\n", aModule->GetZoneConnection() );
if( aModule->m_ThermalWidth != 0 )
if( aModule->GetThermalWidth() != 0 )
m_out->Print( aNestLevel+1, "(thermal_width %s)\n",
FMT_IU( aModule->m_ThermalWidth ).c_str() );
FMT_IU( aModule->GetThermalWidth() ).c_str() );
if( aModule->m_ThermalGap != 0 )
if( aModule->GetThermalGap() != 0 )
m_out->Print( aNestLevel+1, "(thermal_gap %s)\n",
FMT_IU( aModule->m_ThermalGap ).c_str() );
FMT_IU( aModule->GetThermalGap() ).c_str() );
// Attributes
if( aModule->m_Attributs != MOD_DEFAULT )
if( aModule->GetAttributes() != MOD_DEFAULT )
{
m_out->Print( aNestLevel+1, "(attr" );
if( aModule->m_Attributs & MOD_CMS )
if( aModule->GetAttributes() & MOD_CMS )
m_out->Print( 0, " smd" );
if( aModule->m_Attributs & MOD_VIRTUAL )
if( aModule->GetAttributes() & MOD_VIRTUAL )
m_out->Print( 0, " virtual" );
m_out->Print( 0, ")\n" );
}
Format( (BOARD_ITEM*) aModule->m_Reference, aNestLevel+1 );
Format( (BOARD_ITEM*) aModule->m_Value, aNestLevel+1 );
Format( (BOARD_ITEM*) &aModule->Reference(), aNestLevel+1 );
Format( (BOARD_ITEM*) &aModule->Value(), aNestLevel+1 );
// Save drawing elements.
for( BOARD_ITEM* gr = aModule->m_Drawings; gr; gr = gr->Next() )
......
......@@ -948,15 +948,16 @@ MODULE* LEGACY_PLUGIN::LoadMODULE()
TEXTE_MODULE* textm;
if( tnum == TEXT_is_REFERENCE )
textm = module->m_Reference;
textm = &module->Reference();
else if( tnum == TEXT_is_VALUE )
textm = module->m_Value;
textm = &module->Value();
else
{
// text is a drawing
textm = new TEXTE_MODULE( module.get() );
module->m_Drawings.PushBack( textm );
}
loadMODULE_TEXT( textm );
}
......@@ -1013,7 +1014,7 @@ MODULE* LEGACY_PLUGIN::LoadMODULE()
if( cntRot180 > 10 )
cntRot180 = 10;
module->m_CntRot180 = cntRot180;
module->SetPlacementCost180( cntRot180 );
int cntRot90 = itmp1 & 0x0F;
if( cntRot90 > 10 )
......@@ -1023,7 +1024,7 @@ MODULE* LEGACY_PLUGIN::LoadMODULE()
if( itmp1 > 10 )
itmp1 = 0;
module->m_CntRot90 = (itmp1 << 4) | cntRot90;
module->SetPlacementCost90( (itmp1 << 4) | cntRot90 );
}
else if( TESTLINE( "At" ) ) // (At)tributes of module
......@@ -1056,12 +1057,12 @@ MODULE* LEGACY_PLUGIN::LoadMODULE()
else if( TESTLINE( "Cd" ) )
{
// e.g. "Cd Double rangee de contacts 2 x 4 pins\r\n"
module->m_Doc = FROM_UTF8( StrPurge( line + SZ( "Cd" ) ) );
module->SetDescription( FROM_UTF8( StrPurge( line + SZ( "Cd" ) ) ) );
}
else if( TESTLINE( "Kw" ) ) // Key words
{
module->m_KeyWord = FROM_UTF8( StrPurge( line + SZ( "Kw" ) ) );
module->SetKeywords( FROM_UTF8( StrPurge( line + SZ( "Kw" ) ) ) );
}
else if( TESTLINE( ".SolderPasteRatio" ) )
......@@ -2429,7 +2430,7 @@ void LEGACY_PLUGIN::loadDIMENSION()
else if( TESTLINE( "Va" ) )
{
BIU value = biuParse( line + SZ( "Va" ) );
dim->m_Value = value;
dim->SetValue( value );
}
else if( TESTLINE( "Ge" ) )
......@@ -2456,7 +2457,7 @@ void LEGACY_PLUGIN::loadDIMENSION()
char buf[2048];
ReadDelimitedText( buf, line + SZ( "Te" ), sizeof(buf) );
dim->m_Text.SetText( FROM_UTF8( buf ) );
dim->SetText( FROM_UTF8( buf ) );
}
else if( TESTLINE( "Po" ) )
......@@ -2477,10 +2478,9 @@ void LEGACY_PLUGIN::loadDIMENSION()
dim->SetPosition( wxPoint( pos_x, pos_y ) );
dim->SetTextSize( wxSize( width, height ) );
dim->m_Text.SetMirrored( mirror && *mirror == '0' );
dim->m_Text.SetThickness( thickn );
dim->m_Text.SetOrientation( orient );
dim->Text().SetMirrored( mirror && *mirror == '0' );
dim->Text().SetThickness( thickn );
dim->Text().SetOrientation( orient );
}
else if( TESTLINE( "Sb" ) )
......@@ -2498,7 +2498,7 @@ void LEGACY_PLUGIN::loadDIMENSION()
dim->m_crossBarO.y = crossBarOy;
dim->m_crossBarF.x = crossBarFx;
dim->m_crossBarF.y = crossBarFy;
dim->m_Width = width;
dim->SetWidth( width );
(void) ignore;
}
......@@ -3416,7 +3416,7 @@ void LEGACY_PLUGIN::SaveMODULE( const MODULE* me ) const
fprintf( m_fp, "Sc %lX\n", me->GetTimeStamp() );
fprintf( m_fp, "AR %s\n", TO_UTF8( me->GetPath() ) );
fprintf( m_fp, "Op %X %X 0\n", me->m_CntRot90, me->m_CntRot180 );
fprintf( m_fp, "Op %X %X 0\n", me->GetPlacementCost90(), me->GetPlacementCost180() );
if( me->GetLocalSolderMaskMargin() != 0 )
fprintf( m_fp, ".SolderMask %s\n", fmtBIU( me->GetLocalSolderMaskMargin() ).c_str() );
......@@ -3454,9 +3454,9 @@ void LEGACY_PLUGIN::SaveMODULE( const MODULE* me ) const
fprintf( m_fp, "\n" );
}
saveMODULE_TEXT( me->m_Reference );
saveMODULE_TEXT( &me->Reference() );
saveMODULE_TEXT( me->m_Value );
saveMODULE_TEXT( &me->Value() );
// save drawing elements
for( BOARD_ITEM* gr = me->m_Drawings; gr; gr = gr->Next() )
......@@ -3739,19 +3739,19 @@ void LEGACY_PLUGIN::saveDIMENTION( const DIMENSION* me ) const
fprintf( m_fp, "Ge %d %d %lX\n", me->GetShape(), me->GetLayer(), me->GetTimeStamp() );
fprintf( m_fp, "Va %s\n", fmtBIU( me->m_Value ).c_str() );
fprintf( m_fp, "Va %s\n", fmtBIU( me->GetValue() ).c_str() );
if( !me->m_Text.GetText().IsEmpty() )
fprintf( m_fp, "Te %s\n", EscapedUTF8( me->m_Text.GetText() ).c_str() );
if( !me->GetText().IsEmpty() )
fprintf( m_fp, "Te %s\n", EscapedUTF8( me->GetText() ).c_str() );
else
fprintf( m_fp, "Te \"?\"\n" );
fprintf( m_fp, "Po %s %s %s %s %d\n",
fmtBIUPoint( me->m_Text.GetPosition() ).c_str(),
fmtBIUSize( me->m_Text.GetSize() ).c_str(),
fmtBIU( me->m_Text.GetThickness() ).c_str(),
fmtDEG( me->m_Text.GetOrientation() ).c_str(),
me->m_Text.IsMirrored() ? 0 : 1 // strange but true
fmtBIUPoint( me->Text().GetPosition() ).c_str(),
fmtBIUSize( me->Text().GetSize() ).c_str(),
fmtBIU( me->Text().GetThickness() ).c_str(),
fmtDEG( me->Text().GetOrientation() ).c_str(),
me->Text().IsMirrored() ? 0 : 1 // strange but true
);
fprintf( m_fp, "Sb %d %s %s %s\n", S_SEGMENT,
......
......@@ -284,7 +284,7 @@ void FOOTPRINT_EDIT_FRAME::Export_Module( MODULE* aModule )
if( aModule == NULL )
return;
fn.SetName( aModule->m_LibRef );
fn.SetName( aModule->GetLibRef() );
wxString wildcard = wxGetTranslation( KiCadFootprintLibFileWildcard );
......@@ -728,17 +728,17 @@ MODULE* PCB_BASE_FRAME::Create_1_Module( const wxString& aModuleName )
module->SetLastEditTime();
// Update its name in lib
module->m_LibRef = moduleName;
module->SetLibRef( moduleName );
// Update reference:
module->m_Reference->m_Text = moduleName;
module->m_Reference->SetThickness( GetDesignSettings().m_ModuleTextWidth );
module->m_Reference->SetSize( GetDesignSettings().m_ModuleTextSize );
module->SetReference( moduleName );
module->Reference().SetThickness( GetDesignSettings().m_ModuleTextWidth );
module->Reference().SetSize( GetDesignSettings().m_ModuleTextSize );
// Set the value field to a default value
module->m_Value->m_Text = wxT( "VAL**" );
module->m_Value->SetThickness( GetDesignSettings().m_ModuleTextWidth );
module->m_Value->SetSize( GetDesignSettings().m_ModuleTextSize );
module->SetValue( wxT( "VAL**" ) );
module->Value().SetThickness( GetDesignSettings().m_ModuleTextWidth );
module->Value().SetSize( GetDesignSettings().m_ModuleTextSize );
module->SetPosition( wxPoint( 0, 0 ) );
SetMsgPanel( module );
......
......@@ -81,7 +81,7 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule )
GetBoard()->m_Status_Pcb = 0;
newModule = new MODULE( *aModule );
newModule->SetParent( GetBoard() );
newModule->m_Link = aModule->GetTimeStamp();
newModule->SetLink( aModule->GetTimeStamp() );
aModule = newModule;
......@@ -97,7 +97,7 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule )
// Put it on FRONT layer,
// because this is the default in ModEdit, and in libs
if( aModule->GetLayer() != LAYER_N_FRONT )
aModule->Flip( aModule->m_Pos );
aModule->Flip( aModule->GetPosition() );
// Put it in orientation 0,
// because this is the default orientation in ModEdit, and in libs
......@@ -231,7 +231,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
AddHistoryComponentName( HistoryList, moduleName );
module->SetFlags( IS_NEW );
module->m_Link = 0;
module->SetLink( 0 );
module->SetTimeStamp( GetNewTimeStamp() );
GetBoard()->m_Status_Pcb = 0;
......@@ -241,7 +241,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
// Put it on FRONT layer,
// (Can be stored flipped if the lib is an archive built from a board)
if( module->IsFlipped() )
module->Flip( module->m_Pos );
module->Flip( module->GetPosition() );
// Place it in orientation 0,
// even if it is not saved with orientation 0 in lib
......@@ -493,7 +493,7 @@ MODULE* FOOTPRINT_EDIT_FRAME::Select_1_Module_From_BOARD( BOARD* aPcb )
module = aPcb->m_Modules;
for( ; module != NULL; module = (MODULE*) module->Next() )
listnames.Add( module->m_Reference->m_Text );
listnames.Add( module->GetReference() );
msg.Printf( _( "Modules [%d items]" ), listnames.GetCount() );
......@@ -510,7 +510,7 @@ MODULE* FOOTPRINT_EDIT_FRAME::Select_1_Module_From_BOARD( BOARD* aPcb )
for( ; module != NULL; module = (MODULE*) module->Next() )
{
if( CmpName == module->m_Reference->m_Text )
if( CmpName == module->GetReference() )
break;
}
......
......@@ -348,13 +348,13 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
// Search the old module (source) if exists
// Because this source could be deleted when editing the main board...
if( module_in_edit->m_Link ) // this is not a new module ...
if( module_in_edit->GetLink() ) // this is not a new module ...
{
source_module = mainpcb->m_Modules;
for( ; source_module != NULL; source_module = (MODULE*) source_module->Next() )
{
if( module_in_edit->m_Link == source_module->GetTimeStamp() )
if( module_in_edit->GetLink() == source_module->GetTimeStamp() )
break;
}
}
......@@ -382,7 +382,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
// Create the "new" module
MODULE* newmodule = new MODULE( *module_in_edit );
newmodule->SetParent( mainpcb );
newmodule->m_Link = 0;
newmodule->SetLink( 0 );
// Put the footprint in the main pcb linked list.
mainpcb->Add( newmodule );
......@@ -395,7 +395,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
// and the source_module (old module) is deleted
PICKED_ITEMS_LIST pickList;
pcbframe->Exchange_Module( source_module, newmodule, &pickList );
newmodule->SetTimeStamp( module_in_edit->m_Link );
newmodule->SetTimeStamp( module_in_edit->GetLink() );
if( pickList.GetCount() )
pcbframe->SaveCopyInUndoList( pickList, UR_UNSPECIFIED );
......@@ -477,20 +477,20 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
// otherwise you cannot see what you are doing on board
if( GetBoard() && GetBoard()->m_Modules )
{
TEXTE_MODULE* ref = GetBoard()->m_Modules->m_Reference;
TEXTE_MODULE* val = GetBoard()->m_Modules->m_Value;
TEXTE_MODULE* ref = &GetBoard()->m_Modules->Reference();
TEXTE_MODULE* val = &GetBoard()->m_Modules->Value();
if( val && ref )
{
ref->SetType( TEXT_is_REFERENCE ); // just in case ...
if( ref->m_Text.Length() == 0 )
ref->m_Text = L"Ref**";
if( ref->GetLength() == 0 )
ref->SetText( wxT( "Ref**" ) );
val->SetType( TEXT_is_VALUE ); // just in case ...
if( val->m_Text.Length() == 0 )
val->m_Text = L"Val**";
if( val->GetLength() == 0 )
val->SetText( L"Val**" );
}
}
......@@ -769,29 +769,29 @@ void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform )
#define ROTATE( z ) RotatePoint( (&z), angle )
RotateMarkedItems( module, wxPoint(0,0), true );
pos = module->m_Reference->GetPosition();
pos = module->Reference().GetPosition();
ROTATE( pos );
module->m_Reference->SetPosition( pos );
module->m_Reference->SetPos0( module->m_Reference->GetPosition() );
module->m_Reference->m_Orient += angle;
module->Reference().SetPosition( pos );
module->Reference().SetPos0( module->Reference().GetPosition() );
module->Reference().m_Orient += angle;
if( module->m_Reference->m_Orient >= 1800 )
module->m_Reference->m_Orient -= 1800;
if( module->Reference().m_Orient >= 1800 )
module->Reference().m_Orient -= 1800;
pos = module->m_Value->GetPosition();
pos = module->Value().GetPosition();
ROTATE( pos );
module->m_Value->SetPosition( pos );
module->m_Value->SetPos0( module->m_Value->m_Pos );
module->m_Value->m_Orient += angle;
module->Value().SetPosition( pos );
module->Value().SetPos0( module->Value().m_Pos );
module->Value().m_Orient += angle;
if( module->m_Value->m_Orient >= 1800 )
module->m_Value->m_Orient -= 1800;
if( module->Value().m_Orient >= 1800 )
module->Value().m_Orient -= 1800;
break;
case ID_MODEDIT_MODULE_MIRROR:
// Mirror reference.
textmod = module->m_Reference;
textmod = &module->Reference();
NEGATE( textmod->m_Pos.x );
NEGATE( textmod->m_Pos0.x );
......@@ -799,7 +799,7 @@ void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform )
textmod->m_Orient = 3600 - textmod->m_Orient;
// Mirror value.
textmod = module->m_Value;
textmod = &module->Value();
NEGATE( textmod->m_Pos.x );
NEGATE( textmod->m_Pos0.x );
......
......@@ -408,10 +408,10 @@ void FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard( wxUpdateUIEvent& aEvent
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) GetParent();
MODULE* module_in_edit = GetBoard()->m_Modules;
bool canInsert = ( module_in_edit && !module_in_edit->m_Link );
bool canInsert = ( module_in_edit && !module_in_edit->GetLink() );
// If the source was deleted, the module can inserted but not updated in the board.
if( module_in_edit && module_in_edit->m_Link ) // this is not a new module
if( module_in_edit && module_in_edit->GetLink() ) // this is not a new module
{
BOARD* mainpcb = frame->GetBoard();
MODULE* source_module = mainpcb->m_Modules;
......@@ -419,7 +419,7 @@ void FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard( wxUpdateUIEvent& aEvent
// search if the source module was not deleted:
for( ; source_module != NULL; source_module = source_module->Next() )
{
if( module_in_edit->m_Link == source_module->GetTimeStamp() )
if( module_in_edit->GetLink() == source_module->GetTimeStamp() )
break;
}
......@@ -435,9 +435,9 @@ void FOOTPRINT_EDIT_FRAME::OnUpdateReplaceModuleInBoard( wxUpdateUIEvent& aEvent
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) GetParent();
MODULE* module_in_edit = GetBoard()->m_Modules;
bool canReplace = ( module_in_edit && module_in_edit->m_Link );
bool canReplace = ( module_in_edit && module_in_edit->GetLink() );
if( module_in_edit && module_in_edit->m_Link ) // this is not a new module
if( module_in_edit && module_in_edit->GetLink() ) // this is not a new module
{
BOARD* mainpcb = frame->GetBoard();
MODULE* source_module = mainpcb->m_Modules;
......@@ -445,7 +445,7 @@ void FOOTPRINT_EDIT_FRAME::OnUpdateReplaceModuleInBoard( wxUpdateUIEvent& aEvent
// search if the source module was not deleted:
for( ; source_module != NULL; source_module = source_module->Next() )
{
if( module_in_edit->m_Link == source_module->GetTimeStamp() )
if( module_in_edit->GetLink() == source_module->GetTimeStamp() )
break;
}
......
......@@ -80,7 +80,7 @@ MODULE* PCB_BASE_FRAME::GetModuleByName()
while( module )
{
if( module->m_Reference->m_Text.CmpNoCase( moduleName ) == 0 )
if( module->GetReference().CmpNoCase( moduleName ) == 0 )
break;
module = module->Next();
......@@ -200,8 +200,8 @@ void Abort_MoveOrCopyModule( EDA_DRAW_PANEL* Panel, wxDC* DC )
/* Redraw the module. */
if( module && s_ModuleInitialCopy )
{
if( s_ModuleInitialCopy->m_Orient != module->m_Orient )
pcbframe->Rotate_Module( NULL, module, s_ModuleInitialCopy->m_Orient, false );
if( s_ModuleInitialCopy->GetOrientation() != module->GetOrientation() )
pcbframe->Rotate_Module( NULL, module, s_ModuleInitialCopy->GetOrientation(), false );
if( s_ModuleInitialCopy->GetLayer() != module->GetLayer() )
pcbframe->Change_Side_Module( module, NULL );
......@@ -243,7 +243,7 @@ void MoveFootprint( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
}
/* Redraw the module at the new position. */
g_Offset_Module = module->m_Pos - aPanel->GetScreen()->GetCrossHairPosition();
g_Offset_Module = module->GetPosition() - aPanel->GetScreen()->GetCrossHairPosition();
DrawModuleOutlines( aPanel, aDC, module );
DrawSegmentWhileMovingFootprint( aPanel, aDC );
......@@ -263,8 +263,8 @@ bool PCB_EDIT_FRAME::Delete_Module( MODULE* aModule, wxDC* aDC, bool aAskBeforeD
if( aAskBeforeDeleting )
{
msg.Printf( _( "Delete Module %s (value %s) ?" ),
GetChars( aModule->m_Reference->m_Text ),
GetChars( aModule->m_Value->m_Text ) );
GetChars( aModule->GetReference() ),
GetChars( aModule->GetValue() ) );
if( !IsOK( this, msg ) )
{
......@@ -329,7 +329,7 @@ void PCB_EDIT_FRAME::Change_Side_Module( MODULE* Module, wxDC* DC )
}
/* Flip the module */
Module->Flip( Module->m_Pos );
Module->Flip( Module->GetPosition() );
SetMsgPanel( Module );
......@@ -464,7 +464,7 @@ void PCB_BASE_FRAME::Rotate_Module( wxDC* DC, MODULE* module, int angle, bool in
GetBoard()->m_Status_Pcb &= ~( LISTE_RATSNEST_ITEM_OK | CONNEXION_OK );
if( incremental )
module->SetOrientation( module->m_Orient + angle );
module->SetOrientation( module->GetOrientation() + angle );
else
module->SetOrientation( angle );
......
......@@ -235,10 +235,10 @@ MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC )
return NULL;
// here the module is already in the BOARD, Create_1_Module() does that.
module->m_LibRef = wxT( "MuSelf" );
module->m_Attributs = MOD_VIRTUAL | MOD_CMS;
module->SetLibRef( wxT( "MuSelf" ) );
module->SetAttributes( MOD_VIRTUAL | MOD_CMS );
module->ClearFlags();
module->m_Pos = Mself.m_End;
module->SetPosition( Mself.m_End );
// Generate segments
for( unsigned jj = 1; jj < buffer.size(); jj++ )
......@@ -281,15 +281,15 @@ MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC )
// Modify text positions.
SetMsgPanel( module );
module->m_Value->m_Pos.x = module->m_Reference->m_Pos.x =
( Mself.m_Start.x + Mself.m_End.x ) / 2;
module->m_Value->m_Pos.y = module->m_Reference->m_Pos.y =
( Mself.m_Start.y + Mself.m_End.y ) / 2;
module->Value().m_Pos.x = module->Reference().m_Pos.x =
( Mself.m_Start.x + Mself.m_End.x ) / 2;
module->Value().m_Pos.y = module->Reference().m_Pos.y =
( Mself.m_Start.y + Mself.m_End.y ) / 2;
module->m_Reference->m_Pos.y -= module->m_Reference->m_Size.y;
module->m_Value->m_Pos.y += module->m_Value->m_Size.y;
module->m_Reference->SetPos0( module->m_Reference->m_Pos - module->m_Pos );
module->m_Value->SetPos0( module->m_Value->m_Pos - module->m_Pos );
module->Reference().m_Pos.y -= module->Reference().m_Size.y;
module->Value().m_Pos.y += module->Value().m_Size.y;
module->Reference().SetPos0( module->Reference().m_Pos - module->GetPosition() );
module->Value().SetPos0( module->Value().m_Pos - module->GetPosition() );
module->CalculateBoundingBox();
module->Draw( m_canvas, DC, GR_OR );
......@@ -535,21 +535,21 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveBasicShape( const wxString& name, int pad_c
#define DEFAULT_SIZE 30
module->SetTimeStamp( GetNewTimeStamp() );
module->m_Value->m_Size = wxSize( DEFAULT_SIZE, DEFAULT_SIZE );
module->Value().m_Size = wxSize( DEFAULT_SIZE, DEFAULT_SIZE );
module->m_Value->SetPos0( wxPoint( 0, -DEFAULT_SIZE ) );
module->Value().SetPos0( wxPoint( 0, -DEFAULT_SIZE ) );
module->m_Value->m_Pos.y += module->m_Value->GetPos0().y;
module->Value().m_Pos.y += module->Value().GetPos0().y;
module->m_Value->m_Thickness = DEFAULT_SIZE / 4;
module->Value().m_Thickness = DEFAULT_SIZE / 4;
module->m_Reference->m_Size = wxSize( DEFAULT_SIZE, DEFAULT_SIZE );
module->Reference().m_Size = wxSize( DEFAULT_SIZE, DEFAULT_SIZE );
module->m_Reference->SetPos0( wxPoint( 0, DEFAULT_SIZE ) );
module->Reference().SetPos0( wxPoint( 0, DEFAULT_SIZE ) );
module->m_Reference->m_Pos.y += module->m_Reference->GetPos0().y;
module->Reference().m_Pos.y += module->Reference().GetPos0().y;
module->m_Reference->m_Thickness = DEFAULT_SIZE / 4;
module->Reference().m_Thickness = DEFAULT_SIZE / 4;
// Create 2 pads used in gaps and stubs. The gap is between these 2 pads
// the stub is the pad 2
......@@ -1063,7 +1063,7 @@ void PCB_EDIT_FRAME::Edit_Gap( wxDC* DC, MODULE* aModule )
return;
// Test if module is a gap type (name begins with GAP, and has 2 pads).
msg = aModule->m_Reference->m_Text.Left( 3 );
msg = aModule->GetReference().Left( 3 );
if( msg != wxT( "GAP" ) )
return;
......@@ -1110,7 +1110,7 @@ void PCB_EDIT_FRAME::Edit_Gap( wxDC* DC, MODULE* aModule )
wxPoint padpos = pad->GetPos0() + aModule->GetPosition();
RotatePoint( &padpos.x, &padpos.y,
aModule->m_Pos.x, aModule->m_Pos.y, aModule->GetOrientation() );
aModule->GetPosition().x, aModule->GetPosition().y, aModule->GetOrientation() );
pad->SetPosition( padpos );
......@@ -1123,7 +1123,7 @@ void PCB_EDIT_FRAME::Edit_Gap( wxDC* DC, MODULE* aModule )
padpos = next_pad->GetPos0() + aModule->GetPosition();
RotatePoint( &padpos.x, &padpos.y,
aModule->m_Pos.x, aModule->m_Pos.y, aModule->GetOrientation() );
aModule->GetPosition().x, aModule->GetPosition().y, aModule->GetOrientation() );
next_pad->SetPosition( padpos );
......
......@@ -215,7 +215,7 @@ MODULE* PCB_EDIT_FRAME::ListAndSelectModuleName( void )
Module = (MODULE*) GetBoard()->m_Modules;
for( ; Module != NULL; Module = (MODULE*) Module->Next() )
listnames.Add( Module->m_Reference->m_Text );
listnames.Add( Module->GetReference() );
EDA_LIST_DIALOG dlg( this, _( "Components" ), listnames, wxEmptyString );
......@@ -227,7 +227,7 @@ MODULE* PCB_EDIT_FRAME::ListAndSelectModuleName( void )
for( ; Module != NULL; Module = Module->Next() )
{
if( Module->m_Reference->m_Text == ref )
if( Module->GetReference() == ref )
break;
}
......@@ -271,13 +271,14 @@ bool PCB_EDIT_FRAME::Test_Duplicate_Missing_And_Extra_Footprints(
// Search for duplicate footprints.
MODULE* module = GetBoard()->m_Modules;
for( ; module != NULL; module = module->Next() )
{
MODULE* altmodule = module->Next();
for( ; altmodule != NULL; altmodule = altmodule->Next() )
{
if( module->m_Reference->m_Text.CmpNoCase( altmodule->m_Reference->m_Text ) == 0 )
if( module->GetReference().CmpNoCase( altmodule->GetReference() ) == 0 )
{
aDuplicate.push_back( module );
break;
......@@ -305,7 +306,7 @@ bool PCB_EDIT_FRAME::Test_Duplicate_Missing_And_Extra_Footprints(
for( ii = 0; ii < moduleInfoList.size(); ii++ )
{
COMPONENT_INFO* cmp_info = moduleInfoList[ii];
if( module->m_Reference->m_Text.CmpNoCase( cmp_info->m_Reference ) == 0 )
if( module->GetReference().CmpNoCase( cmp_info->m_Reference ) == 0 )
break; // Module is in net list.
}
......
......@@ -335,19 +335,20 @@ int NETLIST_READER::SetPadsNetName( const wxString & aModule, const wxString & a
void NETLIST_READER::RemoveExtraFootprints()
{
MODULE* nextModule;
MODULE* module = m_pcbframe->GetBoard()->m_Modules;
for( ; module != NULL; module = nextModule )
{
unsigned ii;
nextModule = module->Next();
if( module->m_ModuleStatus & MODULE_is_LOCKED )
if( module->IsLocked() )
continue;
for( ii = 0; ii < m_componentsInNetlist.size(); ii++ )
{
COMPONENT_INFO* cmp_info = m_componentsInNetlist[ii];
if( module->GetReference().CmpNoCase( cmp_info->m_Reference ) == 0 )
break; // Module is found in net list.
}
......@@ -370,7 +371,7 @@ MODULE* NETLIST_READER::FindModule( const wxString& aId )
{
if( m_UseTimeStamp ) // identification by time stamp
{
if( aId.CmpNoCase( module->m_Path ) == 0 )
if( aId.CmpNoCase( module->GetPath() ) == 0 )
return module;
}
else // identification by Reference
......
......@@ -335,7 +335,7 @@ bool NETLIST_READER::SetPadNetName( char* aText )
{
wxString msg;
msg.Printf( _( "Module [%s]: Pad [%s] not found" ),
GetChars( m_currModule->m_Reference->m_Text ),
GetChars( m_currModule->GetReference() ),
GetChars( pinName ) );
m_messageWindow->AppendText( msg + wxT( "\n" ) );
}
......
......@@ -198,8 +198,8 @@ void PCB_BASE_FRAME::DeletePad( D_PAD* aPad, bool aQuery )
{
wxString msg;
msg.Printf( _( "Delete Pad (module %s %s) " ),
GetChars( module->m_Reference->m_Text ),
GetChars( module->m_Value->m_Text ) );
GetChars( module->GetReference() ),
GetChars( module->GetValue() ) );
if( !IsOK( this, msg ) )
return;
......
......@@ -516,7 +516,7 @@ void PCB_MODULE::AddToBoard()
module->SetAttributes( MOD_DEFAULT | MOD_CMS );
// reference text
TEXTE_MODULE* ref_text = module->m_Reference;
TEXTE_MODULE* ref_text = &module->Reference();
ref_text->SetText( m_name.text );
ref_text->SetType( TEXT_is_REFERENCE );
......@@ -537,7 +537,7 @@ void PCB_MODULE::AddToBoard()
ref_text->SetDrawCoord();
// value text
TEXTE_MODULE* val_text = module->m_Value;
TEXTE_MODULE* val_text = &module->Value();
val_text->SetText( m_value.text );
val_text->SetType( TEXT_is_REFERENCE );
......
......@@ -1373,7 +1373,7 @@ DIMENSION* PCB_PARSER::parseDIMENSION() throw( IO_ERROR, PARSE_ERROR )
auto_ptr< DIMENSION > dimension( new DIMENSION( NULL ) );
dimension->m_Value = parseBoardUnits( "dimension value" );
dimension->SetValue( parseBoardUnits( "dimension value" ) );
NeedLEFT();
token = NextTok();
......@@ -1405,7 +1405,7 @@ DIMENSION* PCB_PARSER::parseDIMENSION() throw( IO_ERROR, PARSE_ERROR )
case T_gr_text:
{
TEXTE_PCB* text = parseTEXTE_PCB();
dimension->m_Text = *text;
dimension->Text() = *text;
dimension->SetPosition( text->GetPosition() );
delete text;
break;
......@@ -1593,12 +1593,12 @@ MODULE* PCB_PARSER::parseMODULE() throw( IO_ERROR, PARSE_ERROR )
break;
case T_autoplace_cost90:
module->m_CntRot90 = parseInt( "auto place cost at 90 degrees" );
module->SetPlacementCost90( parseInt( "auto place cost at 90 degrees" ) );
NeedRIGHT();
break;
case T_autoplace_cost180:
module->m_CntRot180 = parseInt( "auto place cost at 180 degrees" );
module->SetPlacementCost180( parseInt( "auto place cost at 180 degrees" ) );
NeedRIGHT();
break;
......
......@@ -123,7 +123,7 @@ bool BRDITEMS_PLOTTER::PlotAllTextsModule( MODULE* aModule )
bool trace_val = GetPlotValue();
bool trace_ref = GetPlotReference();
TEXTE_MODULE* textModule = aModule->m_Reference;
TEXTE_MODULE* textModule = &aModule->Reference();
unsigned textLayer = textModule->GetLayer();
if( textLayer >= LAYER_COUNT )
......@@ -135,7 +135,7 @@ bool BRDITEMS_PLOTTER::PlotAllTextsModule( MODULE* aModule )
if( !textModule->IsVisible() && !GetPlotInvisibleText() )
trace_ref = false;
textModule = aModule->m_Value;
textModule = &aModule->Value();
textLayer = textModule->GetLayer();
if( textLayer > LAYER_COUNT )
......@@ -151,17 +151,17 @@ bool BRDITEMS_PLOTTER::PlotAllTextsModule( MODULE* aModule )
if( trace_ref )
{
if( GetReferenceColor() == UNSPECIFIED_COLOR )
PlotTextModule( aModule->m_Reference, getColor( textLayer ) );
PlotTextModule( &aModule->Reference(), getColor( textLayer ) );
else
PlotTextModule( aModule->m_Reference, GetReferenceColor() );
PlotTextModule( &aModule->Reference(), GetReferenceColor() );
}
if( trace_val )
{
if( GetValueColor() == UNSPECIFIED_COLOR )
PlotTextModule( aModule->m_Value, getColor( textLayer ) );
PlotTextModule( &aModule->Value(), getColor( textLayer ) );
else
PlotTextModule( aModule->m_Value, GetValueColor() );
PlotTextModule( &aModule->Value(), GetValueColor() );
}
for( textModule = (TEXTE_MODULE*) aModule->m_Drawings.GetFirst();
......@@ -253,10 +253,10 @@ void BRDITEMS_PLOTTER::PlotTextModule( TEXTE_MODULE* pt_texte,
bool allow_bold = pt_texte->m_Bold || thickness;
m_plotter->Text( pos, aColor,
pt_texte->m_Text,
orient, size,
pt_texte->m_HJustify, pt_texte->m_VJustify,
thickness, pt_texte->m_Italic, allow_bold );
pt_texte->GetText(),
orient, size,
pt_texte->m_HJustify, pt_texte->m_VJustify,
thickness, pt_texte->m_Italic, allow_bold );
}
......@@ -275,7 +275,7 @@ void BRDITEMS_PLOTTER::PlotDimension( DIMENSION* aDim )
// the white items are not seen on a white paper or screen
m_plotter->SetColor( color != WHITE ? color : LIGHTGRAY);
PlotTextePcb( &aDim->m_Text );
PlotTextePcb( &aDim->Text() );
draw.SetStart( aDim->m_crossBarO );
draw.SetEnd( aDim->m_crossBarF );
......@@ -470,7 +470,7 @@ void BRDITEMS_PLOTTER::PlotTextePcb( TEXTE_PCB* pt_texte )
wxPoint pos;
wxSize size;
if( pt_texte->m_Text.IsEmpty() )
if( pt_texte->GetText().IsEmpty() )
return;
if( ( GetLayerMask( pt_texte->GetLayer() ) & m_layerMask ) == 0 )
......@@ -494,7 +494,7 @@ void BRDITEMS_PLOTTER::PlotTextePcb( TEXTE_PCB* pt_texte )
if( pt_texte->m_MultilineAllowed )
{
wxArrayString* list = wxStringSplit( pt_texte->m_Text, '\n' );
wxArrayString* list = wxStringSplit( pt_texte->GetText(), '\n' );
wxPoint offset;
offset.y = pt_texte->GetInterline();
......@@ -514,9 +514,9 @@ void BRDITEMS_PLOTTER::PlotTextePcb( TEXTE_PCB* pt_texte )
}
else
{
m_plotter->Text( pos, UNSPECIFIED_COLOR, pt_texte->m_Text, orient, size,
pt_texte->m_HJustify, pt_texte->m_VJustify,
thickness, pt_texte->m_Italic, allow_bold );
m_plotter->Text( pos, UNSPECIFIED_COLOR, pt_texte->GetText(), orient, size,
pt_texte->m_HJustify, pt_texte->m_VJustify,
thickness, pt_texte->m_Italic, allow_bold );
}
}
......
......@@ -377,11 +377,11 @@ static void Print_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, MODULE* aModule,
if( mlayer & aMasklayer )
{
if( aModule->m_Reference->IsVisible() )
aModule->m_Reference->Draw( aPanel, aDC, aDraw_mode );
if( aModule->Reference().IsVisible() )
aModule->Reference().Draw( aPanel, aDC, aDraw_mode );
if( aModule->m_Value->IsVisible() )
aModule->m_Value->Draw( aPanel, aDC, aDraw_mode );
if( aModule->Value().IsVisible() )
aModule->Value().Draw( aPanel, aDC, aDraw_mode );
}
for( EDA_ITEM* item = aModule->m_Drawings; item; item = item->Next() )
......
......@@ -555,7 +555,7 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, MODULE* aModule )
IMAGE* image = new IMAGE(0);
image->image_id = TO_UTF8( aModule->m_LibRef );
image->image_id = TO_UTF8( aModule->GetLibRef() );
// from the pads, and make an IMAGE using collated padstacks.
for( int p=0; p<moduleItems.GetCount(); ++p )
......@@ -1365,12 +1365,12 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IO_ERROR )
comp->places.push_back( place );
place->SetRotation( module->GetOrientation()/10.0 );
place->SetVertex( mapPt( module->m_Pos ) );
place->SetVertex( mapPt( module->GetPosition() ) );
place->component_id = componentId;
place->part_number = TO_UTF8( module->GetValue() );
// module is flipped from bottom side, set side to T_back
if( module->flag )
if( module->GetFlag() )
{
int angle = 1800 - module->GetOrientation();
NORMALIZE_ANGLE_POS(angle);
......@@ -1679,11 +1679,12 @@ void SPECCTRA_DB::FlipMODULEs( BOARD* aBoard )
{
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
{
module->flag = 0;
module->SetFlag( 0 );
if( module->GetLayer() == LAYER_N_BACK )
{
module->Flip( module->m_Pos );
module->flag = 1;
module->Flip( module->GetPosition() );
module->SetFlag( 1 );
}
}
......@@ -1700,10 +1701,10 @@ void SPECCTRA_DB::RevertMODULEs( BOARD* aBoard )
// top view. Restore those that were flipped.
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
{
if( module->flag )
if( module->GetFlag() )
{
module->Flip( module->m_Pos );
module->flag = 0;
module->Flip( module->GetPosition() );
module->SetFlag( 0 );
}
}
......
......@@ -440,21 +440,25 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IO_ERROR )
{
// convert from degrees to tenths of degrees used in KiCad.
int orientation = (int) (place->rotation * 10.0);
if( module->GetLayer() != LAYER_N_FRONT )
{
// module is on copper layer (back)
module->Flip( module->m_Pos );
module->Flip( module->GetPosition() );
}
module->SetOrientation( orientation );
}
else if( place->side == T_back )
{
int orientation = (int) ((place->rotation + 180.0) * 10.0);
if( module->GetLayer() != LAYER_N_BACK )
{
// module is on component layer (front)
module->Flip( module->m_Pos );
module->Flip( module->GetPosition() );
}
module->SetOrientation( orientation );
}
else
......
......@@ -106,9 +106,9 @@ void DIALOG_EXCHANGE_MODULE::Init()
{
SetFocus();
m_OldModule->AppendText( m_CurrentModule->m_LibRef );
m_NewModule->AppendText( m_CurrentModule->m_LibRef );
m_OldValue->AppendText( m_CurrentModule->m_Value->m_Text );
m_OldModule->AppendText( m_CurrentModule->GetLibRef() );
m_NewModule->AppendText( m_CurrentModule->GetLibRef() );
m_OldValue->AppendText( m_CurrentModule->GetValue() );
m_Selection->SetSelection( s_SelectionMode );
// Enable/disable widgets:
......@@ -317,16 +317,16 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue )
if( newmodulename == wxEmptyString )
return;
lib_reference = m_CurrentModule->m_LibRef;
lib_reference = m_CurrentModule->GetLibRef();
if( aUseValue )
{
check_module_value = true;
value = m_CurrentModule->m_Value->m_Text;
value = m_CurrentModule->GetValue();
msg.Printf( _( "Change modules <%s> -> <%s> (val = %s)?" ),
GetChars( m_CurrentModule->m_LibRef ),
GetChars( m_CurrentModule->GetLibRef() ),
GetChars( newmodulename ),
GetChars( m_CurrentModule->m_Value->m_Text ) );
GetChars( m_CurrentModule->GetValue() ) );
}
else
{
......@@ -351,12 +351,12 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue )
{
PtBack = Module->Back();
if( lib_reference.CmpNoCase( Module->m_LibRef ) != 0 )
if( lib_reference.CmpNoCase( Module->GetLibRef() ) != 0 )
continue;
if( check_module_value )
{
if( value.CmpNoCase( Module->m_Value->m_Text ) != 0 )
if( value.CmpNoCase( Module->GetValue() ) != 0 )
continue;
}
......@@ -413,7 +413,7 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleAll()
{
PtBack = Module->Back();
if( Change_1_Module( Module, Module->m_LibRef, &pickList, ShowErr ) )
if( Change_1_Module( Module, Module->GetLibRef(), &pickList, ShowErr ) )
change = true;
else if( ShowErr )
ShowErr--;
......@@ -458,12 +458,12 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* Module,
wxBusyCursor dummy;
/* Copy parameters from the old module. */
oldnamecmp = Module->m_LibRef;
oldnamecmp = Module->GetLibRef();
namecmp = new_module;
/* Load module. */
line.Printf( _( "Change module %s (%s) " ),
GetChars( Module->m_Reference->m_Text ),
GetChars( Module->GetReference() ),
GetChars( oldnamecmp ) );
m_WinMessages->AppendText( line );
......@@ -484,7 +484,7 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* Module,
m_Parent->Exchange_Module( Module, NewModule, aUndoPickList );
Maj_ListeCmp( NewModule->m_Reference->m_Text, oldnamecmp, namecmp, ShowError );
Maj_ListeCmp( NewModule->GetReference(), oldnamecmp, namecmp, ShowError );
return true;
}
......@@ -517,7 +517,7 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aOldModule,
GetBoard()->m_Status_Pcb = 0;
oldpos = GetScreen()->GetCrossHairPosition();
GetScreen()->SetCrossHairPosition( aOldModule->m_Pos, false );
GetScreen()->SetCrossHairPosition( aOldModule->GetPosition(), false );
/* place module without ratsnest refresh: this will be made later
* when all modules are on board
......@@ -528,22 +528,22 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aOldModule,
/* Flip footprint if needed */
if( aOldModule->GetLayer() != aNewModule->GetLayer() )
{
aNewModule->Flip( aNewModule->m_Pos );
aNewModule->Flip( aNewModule->GetPosition() );
}
/* Rotate footprint if needed */
if( aOldModule->m_Orient != aNewModule->m_Orient )
if( aOldModule->GetOrientation() != aNewModule->GetOrientation() )
{
Rotate_Module( NULL, aNewModule, aOldModule->m_Orient, false );
Rotate_Module( NULL, aNewModule, aOldModule->GetOrientation(), false );
}
/* Update reference and value */
aNewModule->m_Reference->m_Text = aOldModule->m_Reference->m_Text;
aNewModule->m_Value->m_Text = aOldModule->m_Value->m_Text;
aNewModule->SetReference( aOldModule->GetReference() );
aNewModule->SetValue( aOldModule->GetValue() );
/* Updating other parameters */
aNewModule->SetTimeStamp( aOldModule->GetTimeStamp() );
aNewModule->m_Path = aOldModule->m_Path;
aNewModule->SetPath( aOldModule->GetPath() );
/* Update pad netnames ( when possible) */
pad = aNewModule->m_Pads;
......@@ -650,14 +650,14 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent )
{
fprintf( FichCmp, "\nBeginCmp\n" );
fprintf( FichCmp, "TimeStamp = %8.8lX\n", Module->GetTimeStamp() );
fprintf( FichCmp, "Path = %s\n", TO_UTF8( Module->m_Path ) );
fprintf( FichCmp, "Path = %s\n", TO_UTF8( Module->GetPath() ) );
fprintf( FichCmp, "Reference = %s;\n",
!Module->m_Reference->m_Text.IsEmpty() ?
TO_UTF8( Module->m_Reference->m_Text ) : "[NoRef]" );
!Module->GetReference().IsEmpty() ?
TO_UTF8( Module->GetReference() ) : "[NoRef]" );
fprintf( FichCmp, "ValeurCmp = %s;\n",
!Module->m_Value->m_Text.IsEmpty() ?
TO_UTF8( Module->m_Value->m_Text ) : "[NoVal]" );
fprintf( FichCmp, "IdModule = %s;\n", TO_UTF8( Module->m_LibRef ) );
!Module->GetValue().IsEmpty() ?
TO_UTF8( Module->GetValue() ) : "[NoVal]" );
fprintf( FichCmp, "IdModule = %s;\n", TO_UTF8( Module->GetLibRef() ) );
fprintf( FichCmp, "EndCmp\n" );
}
......
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