Commit 7c7d675c authored by stambaughw's avatar stambaughw

Component library object improvements.

* Library component objects can now draw themselves without external drawing code.
* Fix all the library drawing and field objects to support component drawing code.
* Provide proper file dialog wild card for symbol libraries and us wxFileDialog.
* Update component library editing code to reflect component drawing changes.
parent d4a5e5ac
This diff is collapsed.
......@@ -42,7 +42,8 @@ bool LibDrawText::Save( FILE* ExportFile ) const
fprintf( ExportFile, "T %d %d %d %d %d %d %d %s ", m_Orient,
m_Pos.x, m_Pos.y, m_Size.x, m_Attributs, m_Unit, m_Convert,
CONV_TO_UTF8( text ) );
fprintf( ExportFile, " %s %d", m_Italic ? "Italic" : "Normal", (m_Bold>0) ? 1 : 0 );
fprintf( ExportFile, " %s %d", m_Italic ? "Italic" : "Normal",
( m_Bold>0 ) ? 1 : 0 );
char hjustify = 'C';
if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT )
......@@ -76,7 +77,8 @@ bool LibDrawText::Load( char* line, wxString& errorMsg )
cnt = sscanf( &line[2], "%d %d %d %d %d %d %d %s %s %d %c %c",
&m_Orient, &m_Pos.x, &m_Pos.y, &m_Size.x, &m_Attributs,
&m_Unit, &m_Convert, buf, tmp, &thickness, &hjustify, &vjustify );
&m_Unit, &m_Convert, buf, tmp, &thickness, &hjustify,
&vjustify );
if( cnt < 8 )
{
......@@ -149,7 +151,8 @@ bool LibDrawText::HitTest( const wxPoint& refPos )
* @param aThreshold = unused here (TextHitTest calculates its threshold )
* @param aTransMat = the transform matrix
*/
bool LibDrawText::HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] )
bool LibDrawText::HitTest( wxPoint aPosRef, int aThreshold,
const int aTransMat[2][2] )
{
wxPoint physicalpos = TransformCoordinate( aTransMat, m_Pos );
wxPoint tmp = m_Pos;
......@@ -229,6 +232,8 @@ void LibDrawText::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
* transformation matrix causes xy axes to be flipped. */
int t1 = ( aTransformMatrix[0][0] != 0 ) ^ ( m_Orient != 0 );
GRSetDrawMode( aDC, aDrawMode );
DrawGraphicText( aPanel, aDC, pos1, (EDA_Colors) color, m_Text,
t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT,
m_Size, m_HJustify, m_VJustify,
......
......@@ -6,15 +6,14 @@
#include "common.h"
#include "kicad_string.h"
#include "confirm.h"
#include "class_drawpanel.h"
#include "gr_basic.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "protos.h"
#include <wx/tokenzr.h>
#include <wx/txtstrm.h>
int SortItemsFct(const void* ref, const void* item)
{
......@@ -260,6 +259,136 @@ EDA_LibComponentStruct::~EDA_LibComponentStruct()
}
void EDA_LibComponentStruct::Draw( WinEDA_DrawPanel* panel, wxDC* dc,
const wxPoint& offset, int multi,
int convert, int drawMode, int color,
const int transformMatrix[2][2],
bool showPinText, bool drawFields,
bool onlySelected )
{
wxString fieldText;
LibDrawField* Field;
LibEDA_BaseStruct* drawItem;
BASE_SCREEN* screen = panel->GetScreen();
GRSetDrawMode( dc, drawMode );
for( drawItem = m_Drawings; drawItem != NULL; drawItem = drawItem->Next() )
{
if( onlySelected && drawItem->m_Selected == 0 )
continue;
// Do not draw an item while moving (the cursor handler does that)
if( drawItem->m_Flags & IS_MOVED )
continue;
/* Do not draw items not attached to the current part */
if( multi && drawItem->m_Unit && ( drawItem->m_Unit != multi ) )
continue;
if( convert && drawItem->m_Convert && ( drawItem->m_Convert != convert ) )
continue;
if( drawItem->Type() == COMPONENT_PIN_DRAW_TYPE )
{
drawItem->Draw( panel, dc, offset, color, drawMode, &showPinText,
transformMatrix );
}
else
{
bool force_nofill =
( screen->m_IsPrinting
&& drawItem->m_Fill == FILLED_WITH_BG_BODYCOLOR
&& GetGRForceBlackPenState() );
drawItem->Draw( panel, dc, offset, color, drawMode,
(void*) force_nofill, transformMatrix );
}
}
if( drawFields )
{
/* The reference designator field is a special case for naming
* convention.
*
* FIXME: This should be handled by the LibDrawField class.
*/
if( m_UnitCount > 1 )
{
#if defined(KICAD_GOST)
fieldText.Printf( wxT( "%s?.%c" ), (const wxChar*) m_Prefix.m_Text,
multi + '1' - 1 );
#else
fieldText.Printf( wxT( "%s?%c" ), (const wxChar*) m_Prefix.m_Text,
multi + 'A' - 1 );
#endif
}
else
{
fieldText = m_Prefix.m_Text + wxT( "?" );
}
m_Prefix.Draw( panel, dc, offset, color, drawMode, &fieldText,
transformMatrix );
m_Name.Draw( panel, dc, offset, color, drawMode, NULL, transformMatrix );
for( Field = m_Fields; Field != NULL; Field = Field->Next() )
{
Field->Draw( panel, dc, offset, color, drawMode, NULL,
transformMatrix );
}
}
int len = panel->GetScreen()->Unscale( 3 );
GRLine( &panel->m_ClipBox, dc, offset.x, offset.y - len, offset.x,
offset.y + len, 0, color );
GRLine( &panel->m_ClipBox, dc, offset.x - len, offset.y, offset.x + len,
offset.y, 0, color );
/* Enable this to draw the bounding box around the component to validate
* the bounding box calculations. */
#if 0
EDA_Rect bBox = LibEntry->GetBoundaryBox( Multi, convert );
GRRect( &panel->m_ClipBox, dc, bBox.GetOrigin().x, bBox.GetOrigin().y,
bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA );
#endif
}
void EDA_LibComponentStruct::RemoveDrawItem( LibEDA_BaseStruct* item,
WinEDA_DrawPanel* panel,
wxDC* dc )
{
wxASSERT( item != NULL );
LibEDA_BaseStruct* prevItem = m_Drawings;
if( dc != NULL )
item->Draw( panel, dc, wxPoint( 0, 0 ), -1, g_XorMode, NULL,
DefaultTransformMatrix );
if( m_Drawings == item )
{
m_Drawings = item->Next();
SAFE_DELETE( item );
return;
}
while( prevItem )
{
if( prevItem->Next() == item )
{
prevItem->SetNext( item->Next() );
SAFE_DELETE( item );
break;
}
prevItem = prevItem->Next();
}
}
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
......
......@@ -165,6 +165,40 @@ public:
* @param aFields - a std::vector <LibDrawField> to import.
*/
void SetFields( const std::vector <LibDrawField> aFields );
/**
* Draw component.
*
* @param panel - Window to draw on.
* @param dc - Device context to draw on.
* @param offset - Position to component.
* @param multi - Component unit if multiple parts per component.
* @param convert - Component conversion (DeMorgan) if available.
* @param drawMode - Device context drawing mode, see wxDC.
* @param color - Color to draw component.
* @param transformMatrix - Cooridinate adjustment settings.
* @param showPinText - Show pin text if true.
* @param drawFields - Draw field text if true otherwise just draw
* body items.
* @param onlySelected - Draws only the body items that are selected.
* Used for block move redraws.
*/
void Draw( WinEDA_DrawPanel* panel, wxDC* dc, const wxPoint& offset,
int multi, int convert, int drawMode, int color = -1,
const int transformMatrix[2][2] = DefaultTransformMatrix,
bool showPinText = true, bool drawFields = true,
bool onlySelected = false );
/**
* Remove draw item from list.
*
* @param item - Draw item to remove from list.
* @param panel - Panel to remove part from.
* @param dc - Device context to remove part from.
*/
void RemoveDrawItem( LibEDA_BaseStruct* item,
WinEDA_DrawPanel* panel = NULL,
wxDC* dc = NULL );
};
......
......@@ -234,10 +234,9 @@ parameter <%c> is not valid" ),
/** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
int LibDrawField::GetPenSize( )
int LibDrawField::GetPenSize()
{
int pensize = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;
return pensize;
return ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width;
}
......@@ -249,20 +248,24 @@ void LibDrawField::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
const wxPoint& aOffset, int aColor, int aDrawMode,
void* aData, const int aTransformMatrix[2][2] )
{
wxPoint text_pos;
wxPoint text_pos;
int color;
int linewidth = GetPenSize();
int color = aColor;
int linewidth = GetPenSize( );
linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold );
if( aColor < 0 ) // Used normal color or selected color
if( ( m_Attributs & TEXT_NO_VISIBLE ) && ( aColor < 0 ) )
{
color = g_InvisibleItemColor;
}
else if( ( m_Selected & IS_SELECTED ) && ( aColor < 0 ) )
{
if( (m_Selected & IS_SELECTED) )
color = g_ItemSelectetColor;
color = g_ItemSelectetColor;
}
else
{
color = aColor;
}
if( color < 0 )
{
......@@ -281,13 +284,14 @@ void LibDrawField::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
break;
}
}
text_pos = TransformCoordinate( aTransformMatrix, m_Pos ) + aOffset;
wxString* text = aData ? (wxString*) aData : &m_Text;
text_pos = TransformCoordinate( aTransformMatrix, m_Pos ) + aOffset;
wxString* text = aData ? (wxString*)aData : &m_Text;
GRSetDrawMode( aDC, aDrawMode );
DrawGraphicText( aPanel, aDC, text_pos, (EDA_Colors) color, text->GetData(),
DrawGraphicText( aPanel, aDC, text_pos, (EDA_Colors) color, *text,
m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
m_Size, m_HJustify, m_VJustify, linewidth, m_Italic, m_Bold );
m_Size, m_HJustify, m_VJustify, linewidth, m_Italic,
m_Bold );
}
......
......@@ -189,8 +189,8 @@ void LibraryStruct::RemoveEntry( LibCmpEntry* entry )
/* Remove alias name from the root component alias list */
if( Root == NULL )
{
wxLogWarning( wxT( "No root component found for alias <%s> in " \
"library <%s>." ),
wxLogWarning( wxT( "No root component found for alias <%s> in \
library <%s>." ),
( const wxChar* ) entry->m_Name.m_Text,
( const wxChar* ) m_Name );
}
......
......@@ -38,7 +38,7 @@ LibDrawPin::LibDrawPin(EDA_LibComponentStruct * aParent) :
m_PinShape = NONE; /* Bit a bit: Pin shape (voir enum prec) */
m_PinType = PIN_UNSPECIFIED; /* electrical type of pin */
m_Attributs = 0; /* bit 0 != 0: pin invisible */
m_PinNum = 0; /*pin number ( i.e. 4 codes Ascii ) */
m_PinNum = 0; /*pin number ( i.e. 4 codes ASCII ) */
m_PinNumSize = 50;
m_PinNameSize = 50; /* Default size for pin name and num */
m_Width = 0;
......@@ -236,7 +236,7 @@ bool LibDrawPin::Load( char* line, wxString& errorMsg )
return false;
}
if( i == 12 ) /* Special Symbole defined */
if( i == 12 ) /* Special Symbol defined */
{
for( j = strlen( pinAttrs ); j > 0; )
{
......@@ -280,10 +280,9 @@ bool LibDrawPin::Load( char* line, wxString& errorMsg )
/** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
int LibDrawPin::GetPenSize( )
int LibDrawPin::GetPenSize()
{
int pensize = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;
return pensize;
return ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width;
}
......@@ -308,11 +307,14 @@ void LibDrawPin::Draw( WinEDA_DrawPanel* aPanel,
return;
}
EDA_LibComponentStruct* Entry = ( (DrawPinPrms*) aData )->m_Entry;
bool DrawPinText = ( (DrawPinPrms*) aData )->m_DrawPinText;
EDA_LibComponentStruct* Entry = GetParent();
bool DrawPinText = true;
if( ( aData != NULL ) && ( (bool*) aData == false ) )
DrawPinText = false;
/* Calculate pin orient taking in account the component orientation. */
int orient = ReturnPinDrawOrient( aTransformMatrix );
int orient = ReturnPinDrawOrient( aTransformMatrix );
/* Calculate the pin position */
wxPoint pos1 = TransformCoordinate( aTransformMatrix, m_Pos ) + aOffset;
......@@ -322,8 +324,7 @@ void LibDrawPin::Draw( WinEDA_DrawPanel* aPanel,
if( DrawPinText )
{
DrawPinTexts( aPanel, aDC, pos1, orient,
Entry->m_TextInside,
DrawPinTexts( aPanel, aDC, pos1, orient, Entry->m_TextInside,
Entry->m_DrawPinNum, Entry->m_DrawPinName,
aColor, aDrawMode );
}
......@@ -943,7 +944,7 @@ int LibDrawPin::ReturnPinDrawOrient( const int TransMat[2][2] )
end.x = 1; break;
}
end = TransformCoordinate( TransMat, end ); // = pos of end point, accordint to the component orientation
end = TransformCoordinate( TransMat, end ); // = pos of end point, according to the component orientation
orient = PIN_UP;
if( end.x == 0 )
{
......@@ -1044,7 +1045,7 @@ LibEDA_BaseStruct* LibDrawPin::DoGenCopy()
/** Function LibDrawPin::DisplayInfo
* Displays info (pin num and name, otientation ...
* Displays info (pin num and name, orientation ...
* on the Info window
*/
void LibDrawPin::DisplayInfo( WinEDA_DrawFrame* frame )
......
......@@ -64,54 +64,8 @@ void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC,
int Multi, int convert, int DrawMode,
int Color, bool DrawPinText )
{
wxPoint pos1, pos2;
bool force_nofill;
LibEDA_BaseStruct* DEntry;
BASE_SCREEN* screen = panel->GetScreen();
if( Entry->m_Drawings == NULL )
return;
GRSetDrawMode( DC, DrawMode );
for( DEntry = Entry->m_Drawings; DEntry != NULL; DEntry = DEntry->Next() )
{
/* Do not draw items not attached to the current part */
if( Multi && DEntry->m_Unit && (DEntry->m_Unit != Multi) )
continue;
if( convert && DEntry->m_Convert && (DEntry->m_Convert != convert) )
continue;
// Do not draw an item while moving (the cursor handler does that)
if( DEntry->m_Flags & IS_MOVED )
continue;
force_nofill = false;
switch( DEntry->Type() )
{
case COMPONENT_PIN_DRAW_TYPE:
{
DrawPinPrms prms( Entry, DrawPinText );
DEntry->Draw( panel, DC, Pos, Color, DrawMode, &prms, TransMat );
}
break;
case COMPONENT_ARC_DRAW_TYPE:
case COMPONENT_CIRCLE_DRAW_TYPE:
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
case COMPONENT_RECT_DRAW_TYPE:
case COMPONENT_POLYLINE_DRAW_TYPE:
default:
if( screen->m_IsPrinting
&& DEntry->m_Fill == FILLED_WITH_BG_BODYCOLOR
&& GetGRForceBlackPenState() )
force_nofill = true;
DEntry->Draw( panel, DC, Pos, Color, DrawMode, (void*) force_nofill,
TransMat );
break;
}
}
Entry->Draw( panel, DC, Pos, Multi, convert, DrawMode, Color, TransMat,
DrawPinText, false );
if( g_DebugLevel > 4 ) /* Draw the component boundary box */
{
......
This diff is collapsed.
......@@ -77,19 +77,6 @@ enum DrawPinOrient {
PIN_DOWN = 'D',
};
// Struct to pass parameters for drawing pins, in function Draw
class DrawPinPrms
{
public:
EDA_LibComponentStruct* m_Entry; // Pointer to the component in lib
bool m_DrawPinText; // Are pin texts drawn ?
DrawPinPrms( EDA_LibComponentStruct* entry, bool drawpintext = true )
{
m_Entry = entry;
m_DrawPinText = drawpintext;
}
};
/****************************************************************************/
/* Classes for handle the body items of a component: pins add graphic items */
......@@ -103,11 +90,11 @@ public:
class LibEDA_BaseStruct : public EDA_BaseStruct
{
public:
int m_Unit; /* Unit identification (for multi part per package)
int m_Unit; /* Unit identification (for multi part per package)
* 0 if the item is common to all units */
int m_Convert; /* Shape identification (for parts which have a convert
int m_Convert; /* Shape identification (for parts which have a convert
* shape) 0 if the item is common to all shapes */
FILL_T m_Fill; /* NO_FILL, FILLED_SHAPE or FILLED_WITH_BG_BODYCOLOR.
FILL_T m_Fill; /* NO_FILL, FILLED_SHAPE or FILLED_WITH_BG_BODYCOLOR.
* has meaning only for some items */
wxString m_typeName; /* Name of object displayed in the message panel. */
......@@ -227,11 +214,11 @@ public:
/* (Currently Unused) Pin num and Pin name text options: italic/normal
* /bold, 0 = default */
char m_PinNumShapeOpt;
char m_PinNameShapeOpt;
char m_PinNumShapeOpt;
char m_PinNameShapeOpt;
// (Currently Unused) Pin num and Pin name text opt position, 0 = default:
char m_PinNumPositionOpt;
char m_PinNamePositionOpt;
char m_PinNumPositionOpt;
char m_PinNamePositionOpt;
wxPoint m_Pos; /* Position or centre (Arc and Circle) or start
* point (segments) */
......
This diff is collapsed.
/**************************************************************/
/* librairy editor: edition of component general properties */
/* librairy editor: edition of component general properties */
/**************************************************************/
#include "fctsys.h"
......@@ -434,8 +434,8 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::ChangeNbUnitsPerPackage( int MaxUnit )
return FALSE;
}
}
DeleteOneLibraryDrawStruct( m_Parent->DrawPanel, NULL, CurrentLibEntry,
DrawItem, 0 );
CurrentLibEntry->RemoveDrawItem( DrawItem );
}
}
......@@ -529,12 +529,9 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert()
return FALSE;
}
}
m_Parent->GetScreen()->SetModify();
DeleteOneLibraryDrawStruct( m_Parent->DrawPanel,
NULL,
CurrentLibEntry,
DrawItem,
0 );
CurrentLibEntry->RemoveDrawItem( DrawItem );
}
}
}
......
This diff is collapsed.
......@@ -6,11 +6,9 @@
#include "gr_basic.h"
#include "common.h"
#include "class_drawpanel.h"
#include "drawtxt.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "trigo.h"
#include "protos.h"
//#define DRAW_ARC_WITH_ANGLE // Used to select function to draw arcs
......@@ -42,117 +40,6 @@ wxPoint TransformCoordinate( const int aTransformMatrix[2][2],
}
/**************************************************************/
/* Routine de dessin d'un composant d'une librairie
* LibEntry = pointeur sur la description en librairie
* posX, posY = position du composant
* DrawMode = GrOR ..
* Color = 0 : dessin en vraies couleurs, sinon couleur = Color
*
* Une croix symbolise le point d'accrochage (ref position) du composant
*
* Le composant est toujours trace avec orientation 0
*/
/*************************************************************/
void DrawLibEntry( WinEDA_DrawPanel* panel, wxDC* DC,
EDA_LibComponentStruct* LibEntry,
const wxPoint& aOffset,
int Multi, int convert,
int DrawMode, int Color )
{
int color;
wxString Prefix;
LibDrawField* Field;
wxPoint text_pos;
DrawLibPartAux( panel, DC, NULL, LibEntry, aOffset,
DefaultTransformMatrix, Multi,
convert, DrawMode, Color );
/* Trace des 2 champs ref et value (Attention aux coord: la matrice
* de transformation change de signe les coord Y */
GRSetDrawMode( DC, DrawMode );
if( LibEntry->m_Prefix.m_Attributs & TEXT_NO_VISIBLE )
{
if( Color >= 0 )
color = Color;
else
color = g_InvisibleItemColor;
}
else
color = Color;
if( LibEntry->m_UnitCount > 1 )
#if defined(KICAD_GOST)
Prefix.Printf( wxT( "%s?.%c" ),
LibEntry->m_Prefix.m_Text.GetData(), Multi + '1' - 1 );
#else
Prefix.Printf( wxT( "%s?%c" ),
LibEntry->m_Prefix.m_Text.GetData(), Multi + 'A' - 1 );
#endif
else
Prefix = LibEntry->m_Prefix.m_Text + wxT( "?" );
if( (LibEntry->m_Prefix.m_Flags & IS_MOVED) == 0 )
LibEntry->m_Prefix.Draw( panel, DC, aOffset, color, DrawMode,
&Prefix, DefaultTransformMatrix );
if( LibEntry->m_Name.m_Attributs & TEXT_NO_VISIBLE )
{
if( Color >= 0 )
color = Color;
else
color = g_InvisibleItemColor;
}
else
color = Color;
if( (LibEntry->m_Name.m_Flags & IS_MOVED) == 0 )
LibEntry->m_Name.Draw( panel, DC, aOffset, color, DrawMode, NULL,
DefaultTransformMatrix );
for( Field = LibEntry->m_Fields; Field != NULL; Field = Field->Next() )
{
if( Field->m_Text.IsEmpty() )
return;
if( (Field->m_Flags & IS_MOVED) != 0 )
continue;
if( Field->m_Attributs & TEXT_NO_VISIBLE )
{
if( Color >= 0 )
color = Color;
else
color = g_InvisibleItemColor;
}
else
color = Color;
Field->Draw( panel, DC, aOffset, color, DrawMode, NULL,
DefaultTransformMatrix );
}
// Trace de l'ancre
int len = panel->GetScreen()->Unscale( 3 );
GRLine( &panel->m_ClipBox, DC, aOffset.x, aOffset.y - len, aOffset.x,
aOffset.y + len, 0, color );
GRLine( &panel->m_ClipBox, DC, aOffset.x - len, aOffset.y, aOffset.x + len,
aOffset.y, 0, color );
/* Enable this to draw the bounding box around the component to validate
* the bounding box calculations. */
#if 0
EDA_Rect bBox = LibEntry->GetBoundaryBox( Multi, convert );
GRRect( &panel->m_ClipBox, DC, bBox.GetOrigin().x, bBox.GetOrigin().y,
bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA );
#endif
}
/*****************************************************************************/
/*
* Routine to find a part in one of the libraries given its name.
......@@ -282,53 +169,3 @@ void DrawingLibInGhost( WinEDA_DrawPanel* panel, wxDC* DC,
DrawLibItem->m_Transform, multi, convert, DrawMode, Color,
DrawPinText );
}
/************************************************************/
/* Routine to draw One LibraryDrawStruct at given position, */
/* matrice de transformation 1 0 0 -1 (normale) */
/* DrawMode = GrXOR, GrOR .. */
/************************************************************/
/* Utilise en LibEdit et Lib Browse */
void DrawLibraryDrawStruct( WinEDA_DrawPanel* aPanel, wxDC* aDC,
EDA_LibComponentStruct* aLibEntry,
wxPoint aPosition, LibEDA_BaseStruct* aDrawItem,
int aDrawMode, int aColor )
{
int TransMat[2][2];
bool no_fill;
BASE_SCREEN* screen = aPanel->GetScreen();
GRSetDrawMode( aDC, aDrawMode );
TransMat[0][0] = 1;
TransMat[0][1] = TransMat[1][0] = 0;
TransMat[1][1] = -1;
no_fill = false;
switch( aDrawItem->Type() )
{
case COMPONENT_PIN_DRAW_TYPE: /* Trace des Pins */
{
DrawPinPrms prms( aLibEntry, true );
aDrawItem->Draw( aPanel, aDC, aPosition, aColor, aDrawMode, &prms,
TransMat );
}
break;
case COMPONENT_ARC_DRAW_TYPE:
case COMPONENT_CIRCLE_DRAW_TYPE:
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
case COMPONENT_RECT_DRAW_TYPE:
case COMPONENT_POLYLINE_DRAW_TYPE:
default:
if( screen->m_IsPrinting
&& aDrawItem->m_Fill == FILLED_WITH_BG_BODYCOLOR
&& GetGRForceBlackPenState() )
no_fill = true;
aDrawItem->Draw( aPanel, aDC, aPosition, aColor, aDrawMode,
(void*) no_fill, TransMat );
break;
}
}
......@@ -70,10 +70,11 @@ DrawSheetStruct* g_RootSheet = NULL;
SCH_SCREEN* g_ScreenLib = NULL;
wxString g_NetCmpExtBuffer( wxT( "cmp" ) );
wxString g_SymbolExtBuffer( wxT( "sym" ) );
const wxString SymbolFileExtension( wxT( "sym" ) );
const wxString CompLibFileExtension( wxT( "lib" ) );
const wxString SymbolFileWildcard( wxT( "Kicad drawing symbol file (*.sym)|*.sym" ) );
const wxString CompLibFileWildcard( wxT( "Kicad component library file (*.lib)|*.lib" ) );
wxString g_SimulatorCommandLine; // ligne de commande pour l'appel au simulateur (gnucap, spice..)
......
......@@ -173,7 +173,9 @@ extern SCH_SCREEN* g_ScreenLib;
/* Gestion des librairies schematiques */
extern wxString g_NetCmpExtBuffer;
extern wxString g_SymbolExtBuffer;
extern const wxString SymbolFileExtension;
extern const wxString SymbolFileWildcard;
extern const wxString CompLibFileExtension;
extern const wxString CompLibFileWildcard;
......
......@@ -237,8 +237,8 @@ void WinEDA_LibeditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
DrawPanel->DrawBackGround( DC );
if( CurrentLibEntry )
DrawLibEntry( DrawPanel, DC, CurrentLibEntry, wxPoint( 0, 0 ),
CurrentUnit, CurrentConvert, GR_DEFAULT_DRAWMODE );
CurrentLibEntry->Draw( DrawPanel, DC, wxPoint( 0, 0 ), CurrentUnit,
CurrentConvert, GR_DEFAULT_DRAWMODE );
DrawPanel->CursorOn( DC ); // redraw cursor
......
This diff is collapsed.
This diff is collapsed.
......@@ -118,7 +118,7 @@ WinEDA_LibeditFrame::WinEDA_LibeditFrame( wxWindow* father,
// Give an icon
SetIcon( wxIcon( libedit_xpm ) );
SetBaseScreen( g_ScreenLib );
GetScreen()->m_Center = true; // set to true to have the coordinates origine -0,0) centered on screen
GetScreen()->m_Center = true;
LoadSettings();
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
if( DrawPanel )
......@@ -181,9 +181,7 @@ void WinEDA_LibeditFrame::SaveSettings()
}
/***********************************************************/
void WinEDA_LibeditFrame::OnCloseWindow( wxCloseEvent& Event )
/***********************************************************/
{
LibraryStruct* Lib;
......@@ -218,13 +216,14 @@ void WinEDA_LibeditFrame::OnCloseWindow( wxCloseEvent& Event )
}
/******************************************/
void WinEDA_LibeditFrame::SetToolbars()
/******************************************/
/* Enable or disable tools of the differents toolbars,
* according to the current conditions or options
/*
* Enable or disable tools of the differents toolbars, according to the
* current conditions or options.
*
* FIXME: Get rid of this function and use WX_UPDATE_UI to handle enabling of
* menu and toolbar items.
*/
void WinEDA_LibeditFrame::SetToolbars()
{
if( m_HToolBar == NULL )
return;
......@@ -282,7 +281,8 @@ void WinEDA_LibeditFrame::SetToolbars()
else
m_HToolBar->EnableTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, false );
m_HToolBar->ToggleTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, g_EditPinByPinIsOn );
m_HToolBar->ToggleTool( ID_LIBEDIT_EDIT_PIN_BY_PIN,
g_EditPinByPinIsOn );
m_HToolBar->EnableTool( ID_DE_MORGAN_CONVERT_BUTT, g_AsDeMorgan );
m_HToolBar->EnableTool( ID_DE_MORGAN_NORMAL_BUTT, g_AsDeMorgan );
......@@ -290,7 +290,8 @@ void WinEDA_LibeditFrame::SetToolbars()
bool enable_dtool = false;
if( !CurrentAliasName.IsEmpty() )
{
int AliasLocation = LocateAlias( CurrentLibEntry->m_AliasList, CurrentAliasName );
int AliasLocation = LocateAlias( CurrentLibEntry->m_AliasList,
CurrentAliasName );
if( AliasLocation >= 0 )
if( !CurrentLibEntry->m_AliasList[AliasLocation +
ALIAS_DOC_FILENAME].IsEmpty() )
......@@ -307,8 +308,10 @@ void WinEDA_LibeditFrame::SetToolbars()
if( GetScreen() )
{
m_HToolBar->EnableTool( ID_LIBEDIT_UNDO, GetScreen()->GetUndoCommandCount() );
m_HToolBar->EnableTool( ID_LIBEDIT_REDO, GetScreen()->GetRedoCommandCount() );
m_HToolBar->EnableTool( ID_LIBEDIT_UNDO,
GetScreen()->GetUndoCommandCount() );
m_HToolBar->EnableTool( ID_LIBEDIT_REDO,
GetScreen()->GetRedoCommandCount() );
}
}
......@@ -330,9 +333,7 @@ void WinEDA_LibeditFrame::SetToolbars()
}
/**************************************/
int WinEDA_LibeditFrame::BestZoom()
/**************************************/
{
int dx, dy, ii, jj;
int bestzoom;
......@@ -341,7 +342,8 @@ int WinEDA_LibeditFrame::BestZoom()
if( CurrentLibEntry )
{
BoundaryBox = CurrentLibEntry->GetBoundaryBox( CurrentUnit, CurrentConvert );
BoundaryBox = CurrentLibEntry->GetBoundaryBox( CurrentUnit,
CurrentConvert );
dx = BoundaryBox.GetWidth();
dy = BoundaryBox.GetHeight();
}
......@@ -383,9 +385,7 @@ void WinEDA_LibeditFrame::OnUpdateNotEditingPart( wxUpdateUIEvent& event )
}
/*************************************************************************/
void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
/*************************************************************************/
{
int id = event.GetId();
wxPoint pos;
......@@ -514,15 +514,18 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
wxString docfilename;
if( !CurrentAliasName.IsEmpty() )
{
int AliasLocation = LocateAlias( CurrentLibEntry->m_AliasList, CurrentAliasName );
int AliasLocation = LocateAlias( CurrentLibEntry->m_AliasList,
CurrentAliasName );
if( AliasLocation >= 0 )
docfilename = CurrentLibEntry->m_AliasList[AliasLocation + ALIAS_DOC_FILENAME];
docfilename =
CurrentLibEntry->m_AliasList[AliasLocation + ALIAS_DOC_FILENAME];
}
else
docfilename = CurrentLibEntry->m_DocFile;
if( !docfilename.IsEmpty() )
GetAssociatedDocument( this, docfilename, & wxGetApp().GetLibraryPathList() );
GetAssociatedDocument( this, docfilename,
&wxGetApp().GetLibraryPathList() );
}
break;
......@@ -667,7 +670,6 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT:
// Delete the last created segment, while creating a polyline draw item
if( CurrentDrawItem == NULL )
break;
......@@ -690,7 +692,8 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
else
DeleteOneLibraryDrawStruct( DrawPanel, &dc, CurrentLibEntry, CurrentDrawItem, true );
CurrentLibEntry->RemoveDrawItem( CurrentDrawItem, DrawPanel,
&dc );
}
CurrentDrawItem = NULL;
......@@ -798,7 +801,8 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
break;
default:
DisplayError( this, wxT( "WinEDA_LibeditFrame::Process_Special_Functions error" ) );
DisplayError( this,
wxT( "WinEDA_LibeditFrame::Process_Special_Functions error" ) );
break;
}
......
......@@ -20,24 +20,29 @@
////@begin XPM images
////@end XPM images
/*****************************************************************************************/
void InstallPineditFrame(WinEDA_LibeditFrame * parent, wxDC * DC, const wxPoint & pos)
/*****************************************************************************************/
void InstallPineditFrame( WinEDA_LibeditFrame* parent, wxDC* DC,
const wxPoint & pos )
{
wxPoint MousePos = parent->GetScreen()->m_Curseur;
int accept = TRUE;
if ( (CurrentDrawItem == NULL) || (CurrentDrawItem->Type() == COMPONENT_PIN_DRAW_TYPE) )
wxPoint MousePos = parent->GetScreen()->m_Curseur;
int accept = TRUE;
if ( ( CurrentDrawItem == NULL )
|| ( CurrentDrawItem->Type() == COMPONENT_PIN_DRAW_TYPE ) )
{
LibDrawPin * Pin = (LibDrawPin *) CurrentDrawItem;
WinEDA_PinPropertiesFrame * frame = new WinEDA_PinPropertiesFrame(parent);
accept = frame->ShowModal(); frame->Destroy();
if ( !accept && Pin && ( Pin->m_Flags & IS_NEW ) ) // Abord create new pin
WinEDA_PinPropertiesFrame dlg( parent );
accept = dlg.ShowModal();
if ( !accept && Pin && ( Pin->m_Flags & IS_NEW ) )
{
if ( parent->DrawPanel->ForceCloseManageCurseur && DC)
parent->DrawPanel->ForceCloseManageCurseur(parent->DrawPanel, DC);
if ( parent->DrawPanel->ForceCloseManageCurseur && DC )
parent->DrawPanel->ForceCloseManageCurseur( parent->DrawPanel,
DC );
}
}
else DisplayError(parent, wxT("Error: Not a Pin!") );
else
DisplayError( parent, wxT( "Error: Not a Pin!" ) );
parent->GetScreen()->m_Curseur = MousePos;
parent->DrawPanel->MouseToCursorSchema();
}
......
......@@ -25,7 +25,8 @@ static wxString shape_list[NBSHAPES] =
int CodeShape[NBSHAPES] =
{
NONE, INVERT, CLOCK, CLOCK | INVERT, LOWLEVEL_IN, LOWLEVEL_IN | CLOCK, LOWLEVEL_OUT
NONE, INVERT, CLOCK, CLOCK | INVERT, LOWLEVEL_IN, LOWLEVEL_IN | CLOCK,
LOWLEVEL_OUT
};
......@@ -38,9 +39,9 @@ static void DrawMovePin( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
/* Variables locales */
static wxPoint OldPos, PinPreviousPos;
static int LastPinType = PIN_INPUT,
LastPinOrient = PIN_RIGHT,
LastPinShape = NONE,
static int LastPinType = PIN_INPUT,
LastPinOrient = PIN_RIGHT,
LastPinShape = NONE,
LastPinSize = 300,
LastPinNameSize = 50,
LastPinNumSize = 50,
......@@ -97,7 +98,6 @@ void WinEDA_PinPropertiesFrame::PinPropertiesAccept( wxCommandEvent& event )
CurrentDrawItem->DisplayInfo( m_Parent );
}
Close();
m_Parent->DrawPanel->Refresh();
}
......@@ -154,8 +154,7 @@ static void AbortPinMove( WinEDA_DrawPanel* Panel, wxDC* DC )
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem;
if( CurrentPin && ( CurrentPin->m_Flags & IS_NEW ) )
DeleteOneLibraryDrawStruct( Panel, DC, CurrentLibEntry,
CurrentPin, true );
CurrentLibEntry->RemoveDrawItem( CurrentPin, Panel, DC );
/* clear edit flags */
LibEDA_BaseStruct* item = CurrentLibEntry->m_Drawings;
......@@ -240,8 +239,9 @@ void WinEDA_LibeditFrame::PlacePin( wxDC* DC )
}
DrawPanel->CursorOff( DC );
DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, wxPoint( 0, 0 ),
CurrentPin, GR_DEFAULT_DRAWMODE );
bool showPinText = true;
CurrentPin->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, GR_DEFAULT_DRAWMODE,
&showPinText, DefaultTransformMatrix );
DrawPanel->CursorOn( DC );
CurrentDrawItem = NULL;
......@@ -330,20 +330,21 @@ static void DrawMovePin( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
{
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem;
wxPoint pinpos = CurrentPin->m_Pos;
bool showPinText = true;
/* Erase pin in old position */
if( erase || ( CurrentPin->m_Flags & IS_NEW ) )
{
CurrentPin->m_Pos = PinPreviousPos;
DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, wxPoint(0, 0),
CurrentPin, g_XorMode );
CurrentPin->Draw( panel, DC, wxPoint( 0, 0 ), -1, g_XorMode,
&showPinText, DefaultTransformMatrix );
}
/* Redraw pin in new position */
CurrentPin->m_Pos.x = panel->GetScreen()->m_Curseur.x;
CurrentPin->m_Pos.y = -panel->GetScreen()->m_Curseur.y;
DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, wxPoint( 0, 0 ),
CurrentPin, g_XorMode );
CurrentPin->Draw( panel, DC, wxPoint( 0, 0 ), -1, g_XorMode,
&showPinText, DefaultTransformMatrix );
PinPreviousPos = CurrentPin->m_Pos;
......@@ -514,13 +515,11 @@ void WinEDA_LibeditFrame::DeletePin( wxDC* DC,
LibEDA_BaseStruct* DrawItem;
wxPoint PinPos;
if( LibEntry == NULL )
return;
if( Pin == NULL )
if( LibEntry == NULL || Pin == NULL )
return;
PinPos = Pin->m_Pos;
DeleteOneLibraryDrawStruct( DrawPanel, DC, LibEntry, Pin, true );
LibEntry->RemoveDrawItem( (LibEDA_BaseStruct*) Pin, DrawPanel, DC );
/* Effacement des autres pins de meme coordonnees */
if( g_EditPinByPinIsOn == false )
......@@ -537,7 +536,7 @@ void WinEDA_LibeditFrame::DeletePin( wxDC* DC,
DrawItem = DrawItem->Next();
if( Pin->m_Pos != PinPos )
continue;
DeleteOneLibraryDrawStruct( DrawPanel, DC, LibEntry, Pin, 0 );
LibEntry->RemoveDrawItem( (LibEDA_BaseStruct*) Pin );
}
}
GetScreen()->SetModify();
......@@ -551,6 +550,7 @@ void WinEDA_LibeditFrame::CreatePin( wxDC* DC )
{
LibEDA_BaseStruct* DrawItem;
LibDrawPin* CurrentPin;
bool showPinText = true;
if( CurrentLibEntry == NULL )
return;
......@@ -599,8 +599,8 @@ void WinEDA_LibeditFrame::CreatePin( wxDC* DC )
CurrentLibEntry->SortDrawItems();
if( DC )
DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry,
wxPoint(0, 0), CurrentPin, g_XorMode );
CurrentPin->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode,
&showPinText, DefaultTransformMatrix );
DrawPanel->m_IgnoreMouseEvents = true;
InstallPineditFrame( this, DC, wxPoint( -1, -1 ) );
......@@ -673,8 +673,8 @@ void WinEDA_PinPropertiesFrame::SetAttributsPin( bool draw,
continue;
if( Pin->m_Orient != CurrentPin->m_Orient )
continue;
DeleteOneLibraryDrawStruct( m_Parent->DrawPanel, NULL,
CurrentLibEntry, Pin, 0 );
CurrentLibEntry->RemoveDrawItem( (LibEDA_BaseStruct*) Pin );
}
}
} // end if unit
......@@ -705,8 +705,8 @@ void WinEDA_PinPropertiesFrame::SetAttributsPin( bool draw,
continue;
if( Pin->m_Orient != CurrentPin->m_Orient )
continue;
DeleteOneLibraryDrawStruct( m_Parent->DrawPanel, NULL,
CurrentLibEntry, Pin, 0 );
CurrentLibEntry->RemoveDrawItem( (LibEDA_BaseStruct*) Pin );
}
}
} // end if convert
......@@ -848,8 +848,9 @@ void WinEDA_LibeditFrame::GlobalSetPins( wxDC* DC,
{
LibDrawPin* Pin;
bool selected = ( MasterPin->m_Selected & IS_SELECTED ) != 0;
bool showPinText = true;
if( (CurrentLibEntry == NULL) || (MasterPin == NULL) )
if( ( CurrentLibEntry == NULL ) || ( MasterPin == NULL ) )
return;
if( MasterPin->Type() != COMPONENT_PIN_DRAW_TYPE )
return;
......@@ -868,8 +869,8 @@ void WinEDA_LibeditFrame::GlobalSetPins( wxDC* DC,
if( selected && (Pin->m_Selected & IS_SELECTED) == 0 )
continue;
DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry,
wxPoint( 0, 0 ), Pin, g_XorMode );
Pin->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode,
&showPinText, DefaultTransformMatrix );
switch( id )
{
......@@ -886,7 +887,8 @@ void WinEDA_LibeditFrame::GlobalSetPins( wxDC* DC,
break;
}
DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, wxPoint(0, 0), Pin, GR_DEFAULT_DRAWMODE );
Pin->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, GR_DEFAULT_DRAWMODE,
&showPinText, DefaultTransformMatrix );
}
}
......@@ -1006,9 +1008,9 @@ bool WinEDA_LibeditFrame::TestPins( EDA_LibComponentStruct* LibEntry )
error++;
curr_pin->ReturnPinStringNum( StringPinNum );
msg.Printf( _( "Duplicate Pin %4.4s (Pin %s loc %d, %d, and Pin %s loc %d, %d)" ),
StringPinNum.GetData(),
curr_pin->m_PinName.GetData(), curr_pin->m_Pos.x, -curr_pin->m_Pos.y,
Pin->m_PinName.GetData(), Pin->m_Pos.x, -Pin->m_Pos.y );
StringPinNum.GetData(), curr_pin->m_PinName.GetData(),
curr_pin->m_Pos.x, -curr_pin->m_Pos.y,
Pin->m_PinName.GetData(), Pin->m_Pos.x, -Pin->m_Pos.y );
if( CurrentLibEntry->m_UnitCount > 1 )
{
......
......@@ -57,23 +57,6 @@ void DrawingLibInGhost( WinEDA_DrawPanel* panel,
int Color,
bool DrawPinText );
void DrawLibEntry( WinEDA_DrawPanel* panel,
wxDC* DC,
EDA_LibComponentStruct* LibEntry,
const wxPoint& aOffset,
int Multi,
int convert,
int DrawMode,
int Color = -1 );
void DrawLibraryDrawStruct( WinEDA_DrawPanel* aPanel,
wxDC* aDC,
EDA_LibComponentStruct* aLibEntry,
wxPoint aPosition,
LibEDA_BaseStruct* aDrawItem,
int aDrawMode,
int aColor = -1 );
bool MapAngles( int* Angle1,
int* Angle2,
const int TransMat[2][2] );
......@@ -283,21 +266,6 @@ bool LocateAndDeleteItem( WinEDA_SchematicFrame* frame, wxDC* DC );
void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Window );
void DeleteAllMarkers( int type );
/* Effacement des marqueurs du type "type" */
void DeleteOneLibraryDrawStruct( WinEDA_DrawPanel* panel,
wxDC* DC, EDA_LibComponentStruct* LibEntry,
LibEDA_BaseStruct* DrawItem, int Affiche );
/* Routine d'effacement d'un "LibraryDrawStruct"
* (d'un element de dessin d'un composant )
* Parametres d'entree
* Pointeur sur le composant comportant la structure
* (Si NULL la structure a effacer est supposee non rattachee
* a un composant)
* Pointeur sur la structure a effacer
* Affiche (si != 0 Efface le graphique correspondant de l'ecran) */
/**************/
/* GETPART.CPP */
......
/*********************************************************************/
/* EESchema - symbdraw.cpp */
/* EESchema - symbdraw.cpp */
/* Create, move .. graphic shapes used to build and draw a component */
/* (lines, arcs .. */
/* (lines, arcs .. */
/*********************************************************************/
#include "fctsys.h"
......@@ -60,12 +60,8 @@ void WinEDA_bodygraphics_PropertiesFrame::bodygraphics_PropertiesAccept( wxComma
m_Parent->DrawPanel->PrepareGraphicContext( &dc );
DrawLibraryDrawStruct( m_Parent->DrawPanel,
&dc,
CurrentLibEntry,
wxPoint( 0, 0 ),
CurrentDrawItem,
g_XorMode );
CurrentDrawItem->Draw( m_Parent->DrawPanel, &dc, wxPoint( 0, 0 ), -1,
g_XorMode, NULL, DefaultTransformMatrix );
if( g_FlDrawSpecificUnit )
CurrentDrawItem->m_Unit = CurrentUnit;
......@@ -113,12 +109,8 @@ void WinEDA_bodygraphics_PropertiesFrame::bodygraphics_PropertiesAccept( wxComma
m_Parent->GetScreen()->SetModify();
DrawLibraryDrawStruct( m_Parent->DrawPanel,
&dc,
CurrentLibEntry,
wxPoint( 0, 0 ),
CurrentDrawItem,
g_XorMode );
CurrentDrawItem->Draw( m_Parent->DrawPanel, &dc, wxPoint( 0, 0 ),
-1, g_XorMode, NULL, DefaultTransformMatrix );
}
Close();
......@@ -164,8 +156,11 @@ static void AbortSymbolTraceOn( WinEDA_DrawPanel* Panel, wxDC* DC )
Panel->m_Parent->RedrawActiveWindow( DC, TRUE );
}
else
DrawLibraryDrawStruct( Panel, DC, CurrentLibEntry, wxPoint( 0, 0 ),
CurrentDrawItem, g_XorMode );
{
CurrentDrawItem->Draw( Panel, DC, wxPoint( 0, 0 ), -1, g_XorMode,
NULL, DefaultTransformMatrix );
}
SAFE_DELETE( CurrentDrawItem );
}
else
......@@ -175,9 +170,9 @@ static void AbortSymbolTraceOn( WinEDA_DrawPanel* Panel, wxDC* DC )
Panel->GetScreen()->m_Curseur = StartCursor;
RedrawWhileMovingCursor( Panel, DC, TRUE );
Panel->GetScreen()->m_Curseur = curpos;
DrawLibraryDrawStruct( Panel, DC, CurrentLibEntry, wxPoint( 0, 0 ),
CurrentDrawItem, GR_DEFAULT_DRAWMODE );
CurrentDrawItem->Draw( Panel, DC, wxPoint( 0, 0 ), -1,
GR_DEFAULT_DRAWMODE, NULL,
DefaultTransformMatrix );
CurrentDrawItem->m_Flags = 0;
}
}
......@@ -311,9 +306,8 @@ LibEDA_BaseStruct* WinEDA_LibeditFrame::CreateGraphicItem( EDA_LibComponentStruc
else
{
StartMoveDrawSymbol( DC );
DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry,
wxPoint( 0, 0 ),
Text, g_XorMode );
Text->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, NULL,
DefaultTransformMatrix );
}
}
break;
......@@ -400,15 +394,15 @@ static void RedrawWhileMovingCursor( WinEDA_DrawPanel* panel,
/* Erase shape in the old positon*/
if( erase )
{
pos = ItemPreviousPos - StartCursor,
DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, pos,
CurrentDrawItem, g_XorMode );
pos = ItemPreviousPos - StartCursor;
CurrentDrawItem->Draw( panel, DC, pos, -1, g_XorMode, NULL,
DefaultTransformMatrix );
}
/* Redraw moved shape */
pos = Screen->m_Curseur - StartCursor,
DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, pos,
CurrentDrawItem, g_XorMode );
pos = Screen->m_Curseur - StartCursor;
CurrentDrawItem->Draw( panel, DC, pos, -1, g_XorMode, NULL,
DefaultTransformMatrix );
ItemPreviousPos = Screen->m_Curseur;
}
......@@ -514,7 +508,7 @@ void WinEDA_LibeditFrame::StartMoveDrawSymbol( wxDC* DC )
/****************************************************************/
/* Routine de Gestion des evenements souris lors de la creation */
/* d'un nouvel element type LibraryDrawStruct */
/* d'un nouvel element type LibraryDrawStruct */
/****************************************************************/
static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
{
......@@ -543,8 +537,8 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
}
else
{
DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, wxPoint( 0, 0 ),
CurrentDrawItem, DrawMode );
CurrentDrawItem->Draw( panel, DC, wxPoint( 0, 0 ), -1, DrawMode,
NULL, DefaultTransformMatrix );
if( CurrentDrawItem->Type() == COMPONENT_ARC_DRAW_TYPE )
{
int Color = ReturnLayerColor( LAYER_DEVICE );
......@@ -621,8 +615,8 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
}
else
{
DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, wxPoint( 0, 0 ),
CurrentDrawItem, DrawMode );
CurrentDrawItem->Draw( panel, DC, wxPoint( 0, 0 ), -1, DrawMode,
NULL, DefaultTransformMatrix );
if( CurrentDrawItem->Type() == COMPONENT_ARC_DRAW_TYPE )
{
int Color = ReturnLayerColor( LAYER_DEVICE );
......@@ -719,8 +713,8 @@ void WinEDA_LibeditFrame::EndDrawGraphicItem( wxDC* DC )
MoveLibDrawItemAt( CurrentDrawItem, pos );
}
DrawLibEntry( DrawPanel, DC, CurrentLibEntry, wxPoint( 0, 0 ), CurrentUnit,
CurrentConvert, GR_DEFAULT_DRAWMODE );
CurrentLibEntry->Draw( DrawPanel, DC, wxPoint( 0, 0 ), CurrentUnit,
CurrentConvert, GR_DEFAULT_DRAWMODE );
CurrentDrawItem->m_Flags = 0;
CurrentDrawItem = NULL;
......@@ -824,15 +818,14 @@ void WinEDA_LibeditFrame::DeleteDrawPoly( wxDC* DC )
/* Used for deleting last entered segment while creating a Polyline
*/
{
if( CurrentDrawItem == NULL )
return;
if( CurrentDrawItem->Type() != COMPONENT_POLYLINE_DRAW_TYPE )
if( CurrentDrawItem == NULL
|| CurrentDrawItem->Type() != COMPONENT_POLYLINE_DRAW_TYPE )
return;
LibDrawPolyline* Poly = (LibDrawPolyline*) CurrentDrawItem;
DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, wxPoint( 0, 0 ),
CurrentDrawItem, g_XorMode );
CurrentDrawItem->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode,
NULL, DefaultTransformMatrix );
while( Poly->GetCornerCount() > 2 ) // First segment is kept, only its end point is changed
{
......@@ -847,6 +840,6 @@ void WinEDA_LibeditFrame::DeleteDrawPoly( wxDC* DC )
}
}
DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, wxPoint( 0, 0 ),
CurrentDrawItem, g_XorMode );
CurrentDrawItem->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode,
NULL, DefaultTransformMatrix );
}
......@@ -8,7 +8,6 @@
/* fichier symbedit.cpp */
#include "fctsys.h"
#include "gr_basic.h"
#include "appl_wxstruct.h"
#include "common.h"
#include "class_drawpanel.h"
......@@ -22,12 +21,9 @@
#include "protos.h"
/* Routines locales */
static bool CompareSymbols( LibEDA_BaseStruct* DEntryRef,
LibEDA_BaseStruct* DEntryCompare );
/* Variables locales */
/*
* Read a component shape file (a symbol file *.sym )and add data (graphic
......@@ -40,10 +36,9 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void )
{
EDA_LibComponentStruct* Component;
LibEDA_BaseStruct* DrawEntry;
wxString FullFileName, mask;
FILE* ImportFile;
wxString msg, err;
LibraryStruct* Lib;
FILE* ImportFile;
wxString msg, err;
LibraryStruct* Lib;
/* Exit if no library entry is selected or a command is in progress. */
if( CurrentLibEntry == NULL
......@@ -52,36 +47,29 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void )
DrawPanel->m_IgnoreMouseEvents = TRUE;
mask = wxT( "*" ) + g_SymbolExtBuffer;
wxString default_lib_path = wxGetApp().ReturnLastVisitedLibraryPath();
wxString default_path = wxGetApp().ReturnLastVisitedLibraryPath();
wxFileDialog dlg( this, _( "Import Symbol Drawings" ), default_path,
wxEmptyString, SymbolFileWildcard,
wxFD_OPEN | wxFD_FILE_MUST_EXIST );
FullFileName = EDA_FileSelector( _( "Import symbol drawings:" ),
default_lib_path, /* Chemin par defaut */
wxEmptyString, /* nom fichier par defaut */
g_SymbolExtBuffer, /* extension par defaut */
mask, /* Masque d'affichage */
this,
0,
TRUE
);
if( dlg.ShowModal() == wxID_CANCEL )
return;
GetScreen()->m_Curseur = wxPoint( 0, 0 );
DrawPanel->MouseToCursorSchema();
DrawPanel->m_IgnoreMouseEvents = FALSE;
if( FullFileName.IsEmpty() )
return;
wxFileName fn = FullFileName;
wxFileName fn = dlg.GetPath();
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
/* Load data */
ImportFile = wxFopen( FullFileName, wxT( "rt" ) );
ImportFile = wxFopen( fn.GetFullPath(), wxT( "rt" ) );
if( ImportFile == NULL )
{
msg.Printf( _( "Failed to open Symbol File <%s>" ),
(const wxChar*) FullFileName );
(const wxChar*) fn.GetFullPath() );
DisplayError( this, msg );
return;
}
......@@ -164,43 +152,43 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void )
*/
void WinEDA_LibeditFrame::SaveOneSymbol()
{
EDA_LibComponentStruct* LibEntry = CurrentLibEntry;
int Unit = CurrentUnit, convert = CurrentConvert;
LibEDA_BaseStruct* DrawEntry;
wxString FullFileName, mask;
wxString msg;
FILE* ExportFile;
LibEDA_BaseStruct* DrawEntry;
wxString msg;
FILE* ExportFile;
if( LibEntry->m_Drawings == NULL )
if( CurrentLibEntry->m_Drawings == NULL )
return;
/* Creation du fichier symbole */
wxString default_lib_path = wxGetApp().ReturnLastVisitedLibraryPath();
mask = wxT( "*" ) + g_SymbolExtBuffer;
FullFileName = EDA_FileSelector( _( "Export symbol drawings:" ),
default_lib_path, /* Chemin par defaut */
wxEmptyString, /* nom fichier par defaut */
g_SymbolExtBuffer, /* extension par defaut */
mask, /* Masque d'affichage */
this,
wxFD_SAVE,
TRUE
);
if( FullFileName.IsEmpty() )
wxString default_path = wxGetApp().ReturnLastVisitedLibraryPath();
wxFileDialog dlg( this, _( "Export Symbol Drawings" ), default_path,
CurrentLibEntry->m_Name.m_Text, SymbolFileWildcard,
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() == wxID_CANCEL )
return;
wxFileName fn = FullFileName;
wxFileName fn = dlg.GetPath();
/* The GTK file chooser doesn't return the file extension added to
* file name so add it here. */
if( fn.GetExt().IsEmpty() )
fn.SetExt( SymbolFileExtension );
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
ExportFile = wxFopen( FullFileName, wxT( "wt" ) );
ExportFile = wxFopen( fn.GetFullPath(), wxT( "wt" ) );
if( ExportFile == NULL )
{
msg.Printf( _( "Unable to create <%s>" ), FullFileName.GetData() );
msg.Printf( _( "Unable to create <%s>" ),
(const wxChar*) fn.GetFullPath() );
DisplayError( this, msg );
return;
}
msg.Printf( _( "Save Symbol in [%s]" ), FullFileName.GetData() );
msg.Printf( _( "Save Symbol in [%s]" ), (const wxChar*) fn.GetPath() );
Affiche_Message( msg );
/* Creation de l'entete de la librairie */
......@@ -211,39 +199,40 @@ void WinEDA_LibeditFrame::SaveOneSymbol()
/* Creation du commentaire donnant le nom du composant */
fprintf( ExportFile, "# SYMBOL %s\n#\n",
(const char*) LibEntry->m_Name.m_Text.GetData() );
CONV_TO_UTF8( CurrentLibEntry->m_Name.m_Text ) );
/* Generation des lignes utiles */
fprintf( ExportFile, "DEF %s",
(const char*) LibEntry->m_Name.m_Text.GetData() );
if( !LibEntry->m_Prefix.m_Text.IsEmpty() )
CONV_TO_UTF8( CurrentLibEntry->m_Name.m_Text ) );
if( !CurrentLibEntry->m_Prefix.m_Text.IsEmpty() )
fprintf( ExportFile, " %s",
(const char*) LibEntry->m_Prefix.m_Text.GetData() );
CONV_TO_UTF8( CurrentLibEntry->m_Prefix.m_Text ) );
else
fprintf( ExportFile, " ~" );
fprintf( ExportFile, " %d %d %c %c %d %d %c\n",
0, /* unused */
LibEntry->m_TextInside,
LibEntry->m_DrawPinNum ? 'Y' : 'N',
LibEntry->m_DrawPinName ? 'Y' : 'N',
CurrentLibEntry->m_TextInside,
CurrentLibEntry->m_DrawPinNum ? 'Y' : 'N',
CurrentLibEntry->m_DrawPinName ? 'Y' : 'N',
1, 0 /* unused */, 'N' );
/* Position / orientation / visibilite des champs */
LibEntry->m_Prefix.Save( ExportFile );
LibEntry->m_Name.Save( ExportFile );
CurrentLibEntry->m_Prefix.Save( ExportFile );
CurrentLibEntry->m_Name.Save( ExportFile );
DrawEntry = CurrentLibEntry->m_Drawings;
DrawEntry = LibEntry->m_Drawings;
if( DrawEntry )
{
fprintf( ExportFile, "DRAW\n" );
for( ; DrawEntry != NULL; DrawEntry = DrawEntry->Next() )
{
/* Elimination des elements non relatifs a l'unite */
if( Unit && DrawEntry->m_Unit && ( DrawEntry->m_Unit != Unit ) )
if( CurrentUnit && DrawEntry->m_Unit
&& ( DrawEntry->m_Unit != CurrentUnit ) )
continue;
if( convert && DrawEntry->m_Convert
&& ( DrawEntry->m_Convert != convert ) )
if( CurrentConvert && DrawEntry->m_Convert
&& ( DrawEntry->m_Convert != CurrentConvert ) )
continue;
DrawEntry->Save( ExportFile );
......@@ -251,6 +240,7 @@ void WinEDA_LibeditFrame::SaveOneSymbol()
fprintf( ExportFile, "ENDDRAW\n" );
}
fprintf( ExportFile, "ENDDEF\n" );
fclose( ExportFile );
}
......@@ -281,7 +271,7 @@ void SuppressDuplicateDrawItem( EDA_LibComponentStruct* LibEntry )
{
if( CompareSymbols( DEntryRef, DEntryCompare ) == TRUE )
{
DeleteOneLibraryDrawStruct( NULL, DC, LibEntry, DEntryRef, 1 );
LibEntry->RemoveDrawItem( DEntryRef, NULL, DC );
deleted = TRUE;
break;
}
......@@ -474,7 +464,7 @@ void WinEDA_LibeditFrame::PlaceAncre()
break;
default:
;
break;
}
DrawEntry = DrawEntry->Next();
}
......
......@@ -310,8 +310,8 @@ void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
g_ViewUnit = 1;
if( g_ViewConvert < 1 )
g_ViewConvert = 1;
DrawLibEntry( DrawPanel, DC, LibEntry, wxPoint( 0, 0 ),
g_ViewUnit, g_ViewConvert, GR_DEFAULT_DRAWMODE );
LibEntry->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_ViewUnit,
g_ViewConvert, GR_DEFAULT_DRAWMODE );
LibEntry->m_Name.m_Text = RealName;
}
}
......@@ -319,8 +319,8 @@ void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{
Msg.Printf( _( "Current Part: <%s>" ),
ViewCmpEntry->m_Name.m_Text.GetData() );
DrawLibEntry( DrawPanel, DC, LibEntry, wxPoint( 0, 0 ),
g_ViewUnit, g_ViewConvert, GR_DEFAULT_DRAWMODE );
LibEntry->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_ViewUnit,
g_ViewConvert, GR_DEFAULT_DRAWMODE );
}
AfficheDoc( this, ViewCmpEntry->m_Doc, ViewCmpEntry->m_KeyWord );
}
......
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