Commit 9861941d authored by stambaughw's avatar stambaughw

Component library editor and viewer improvements and library draw object changes.

* Component library viewer restores state between uses.
* Fixed automatic zoom calculations in library viewer.
* Make library entry list dialog restore previous selection.
* Fix bounding box calculation for vertical field and text draw objects.
* Changed library draw object comparison to test for greater and less than.
* Initial preparation for merging separate library component draw item lists.
parent afb6898f
......@@ -20,8 +20,6 @@
#include "protos.h"
LibDrawText::LibDrawText(LIB_COMPONENT * aParent) :
LIB_DRAW_ITEM( COMPONENT_GRAPHIC_TEXT_DRAW_TYPE, aParent ),
EDA_TextStruct()
......@@ -176,7 +174,7 @@ LIB_DRAW_ITEM* LibDrawText::DoGenCopy()
{
LibDrawText* newitem = new LibDrawText(NULL);
newitem->m_Pos = m_Pos;
newitem->m_Pos = m_Pos;
newitem->m_Orient = m_Orient;
newitem->m_Size = m_Size;
newitem->m_Attributs = m_Attributs;
......@@ -193,14 +191,30 @@ LIB_DRAW_ITEM* LibDrawText::DoGenCopy()
}
bool LibDrawText::DoCompare( const LIB_DRAW_ITEM& other ) const
int LibDrawText::DoCompare( const LIB_DRAW_ITEM& other ) const
{
wxASSERT( other.Type() == COMPONENT_GRAPHIC_TEXT_DRAW_TYPE );
const LibDrawText* tmp = ( LibDrawText* ) &other;
return ( ( m_Pos == tmp->m_Pos ) && ( m_Size == tmp->m_Size )
&& ( m_Text == tmp->m_Text ) );
int result = m_Text.CmpNoCase( tmp->m_Text );
if( result != 0 )
return result;
if( m_Pos.x != tmp->m_Pos.x )
return m_Pos.x - tmp->m_Pos.x;
if( m_Pos.y != tmp->m_Pos.y )
return m_Pos.y - tmp->m_Pos.y;
if( m_Size.x != tmp->m_Size.x )
return m_Size.x - tmp->m_Size.x;
if( m_Size.y != tmp->m_Size.y )
return m_Size.y - tmp->m_Size.y;
return 0;
}
......@@ -259,7 +273,8 @@ void LibDrawText::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
{
wxPoint pos1, pos2;
int color = ReturnLayerColor( LAYER_DEVICE );
int color = ReturnLayerColor( LAYER_DEVICE );
if( aColor < 0 ) // Used normal color or selected color
{
if( ( m_Selected & IS_SELECTED ) )
......@@ -270,16 +285,18 @@ void LibDrawText::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
pos1 = TransformCoordinate( aTransformMatrix, m_Pos ) + aOffset;
/* The text orientation may need to be flipped if the
* 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,
m_Orient, m_Size, m_HJustify, m_VJustify,
GetPenSize( ), m_Italic, m_Bold );
#if 0
EDA_Rect bBox = GetBoundingBox();
bBox.Inflate( 1, 1 );
GRRect( &aPanel->m_ClipBox, aDC, bBox.GetOrigin().x, bBox.GetOrigin().y,
bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA );
#endif
}
......@@ -294,3 +311,22 @@ void LibDrawText::DisplayInfo( WinEDA_DrawFrame* frame )
frame->MsgPanel->Affiche_1_Parametre( 20, _( "Line width" ), msg, BLUE );
}
EDA_Rect LibDrawText::GetBoundingBox()
{
EDA_Rect rect = GetTextBox();
rect.m_Pos.y *= -1;
rect.m_Pos.y -= rect.GetHeight();
wxPoint orig = rect.GetOrigin();
wxPoint end = rect.GetEnd();
wxPoint center = rect.Centre();
RotatePoint( &orig, center, m_Orient );
RotatePoint( &end, center, m_Orient );
rect.SetOrigin( orig );
rect.SetEnd( end );
return rect;
}
......@@ -486,7 +486,7 @@ void LIB_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* dc,
/* 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 );
EDA_Rect bBox = GetBoundaryBox( multi, convert );
GRRect( &panel->m_ClipBox, dc, bBox.GetOrigin().x, bBox.GetOrigin().y,
bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA );
#endif
......
......@@ -8,6 +8,8 @@
#include "base_struct.h"
#include "drawtxt.h"
#include "kicad_string.h"
#include "class_drawpanel.h"
#include "trigo.h"
#include "program.h"
#include "general.h"
......@@ -309,9 +311,20 @@ void LibDrawField::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
wxString* text = aData ? (wxString*)aData : &m_Text;
GRSetDrawMode( aDC, aDrawMode );
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_Orient, m_Size, m_HJustify, m_VJustify, linewidth,
m_Italic, m_Bold );
/* Set to one (1) to draw bounding box around field text to validate
* bounding box calculation. */
#if 0
wxString tmp = m_Text;
m_Text = *text;
EDA_Rect bBox = GetBoundingBox();
m_Text = tmp;
bBox.Inflate( 1, 1 );
GRRect( &aPanel->m_ClipBox, aDC, bBox.GetOrigin().x, bBox.GetOrigin().y,
bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA );
#endif
}
......@@ -404,14 +417,33 @@ void LibDrawField::Copy( LibDrawField* Target ) const
}
bool LibDrawField::DoCompare( const LIB_DRAW_ITEM& other ) const
int LibDrawField::DoCompare( const LIB_DRAW_ITEM& other ) const
{
wxASSERT( other.Type() == COMPONENT_FIELD_DRAW_TYPE );
const LibDrawField* tmp = ( LibDrawField* ) &other;
return ( ( m_FieldId == tmp->m_FieldId ) && ( m_Text == tmp->m_Text )
&& ( m_Pos == tmp->m_Pos ) && ( m_Size == tmp->m_Size ) );
if( m_FieldId == tmp->m_FieldId )
return m_FieldId - tmp->m_FieldId;
int result = m_Text.CmpNoCase( tmp->m_Text );
if( result != 0 )
return result;
if( m_Pos.x != tmp->m_Pos.x )
return m_Pos.x - tmp->m_Pos.x;
if( m_Pos.y != tmp->m_Pos.y )
return m_Pos.y - tmp->m_Pos.y;
if( m_Size.x != tmp->m_Size.x )
return m_Size.x - tmp->m_Size.x;
if( m_Size.y != tmp->m_Size.y )
return m_Size.y - tmp->m_Size.y;
return 0;
}
......@@ -476,6 +508,25 @@ wxString LibDrawField::GetFullText( int unit )
}
EDA_Rect LibDrawField::GetBoundingBox()
{
EDA_Rect rect = GetTextBox();
rect.m_Pos.y *= -1;
rect.m_Pos.y -= rect.GetHeight();
wxPoint orig = rect.GetOrigin();
wxPoint end = rect.GetEnd();
wxPoint center = rect.Centre();
RotatePoint( &orig, center, m_Orient );
RotatePoint( &end, center, m_Orient );
rect.SetOrigin( orig );
rect.SetEnd( end );
return rect;
}
/**
* Function ReturnDefaultFieldName
* Return the default field name from its index (REFERENCE, VALUE ..)
......
......@@ -79,7 +79,7 @@ public:
*
* @return EDA_Rect - Bounding rectangle.
*/
virtual EDA_Rect GetBoundingBox() { return GetTextBox(); }
virtual EDA_Rect GetBoundingBox();
/**
* Function HitTest
......@@ -132,7 +132,7 @@ public:
protected:
virtual LIB_DRAW_ITEM* DoGenCopy();
virtual bool DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual int DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
......
......@@ -368,6 +368,15 @@ void LibDrawPin::Draw( WinEDA_DrawPanel* aPanel,
Entry->m_DrawPinNum, Entry->m_DrawPinName,
aColor, aDrawMode );
}
/* Set to one (1) to draw bounding box around pin to validate bounding
* box calculation. */
#if 0
EDA_Rect bBox = GetBoundingBox();
bBox.Inflate( 5, 5 );
GRRect( &aPanel->m_ClipBox, aDC, bBox.GetOrigin().x, bBox.GetOrigin().y,
bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA );
#endif
}
......@@ -1083,13 +1092,27 @@ LIB_DRAW_ITEM* LibDrawPin::DoGenCopy()
}
bool LibDrawPin::DoCompare( const LIB_DRAW_ITEM& other ) const
int LibDrawPin::DoCompare( const LIB_DRAW_ITEM& other ) const
{
wxASSERT( other.Type() == COMPONENT_PIN_DRAW_TYPE );
const LibDrawPin* tmp = ( LibDrawPin* ) &other;
return ( m_Pos == tmp->m_Pos );
if( m_PinNum != tmp->m_PinNum )
return m_PinNum - tmp->m_PinNum;
int result = m_PinName.CmpNoCase( tmp->m_PinName );
if( result != 0 )
return result;
if( m_Pos.x != tmp->m_Pos.x )
return m_Pos.x - tmp->m_Pos.x;
if( m_Pos.y != tmp->m_Pos.y )
return m_Pos.y - tmp->m_Pos.y;
return 0;
}
......
......@@ -85,7 +85,28 @@ bool LIB_DRAW_ITEM::operator==( const LIB_DRAW_ITEM& other ) const
return ( ( Type() == other.Type() )
&& ( m_Unit == other.m_Unit )
&& ( m_Convert == other.m_Convert )
&& DoCompare( other ) );
&& DoCompare( other ) == 0 );
}
bool LIB_DRAW_ITEM::operator<( const LIB_DRAW_ITEM& other ) const
{
int result = Type() - other.Type();
if( result < 0 )
return true;
result = m_Unit - other.m_Unit;
if( result < 0 )
return true;
result = m_Convert - other.m_Convert;
if( result < 0 )
return true;
return DoCompare( other ) < 0;
}
......@@ -276,14 +297,25 @@ LIB_DRAW_ITEM* LibDrawArc::DoGenCopy()
}
bool LibDrawArc::DoCompare( const LIB_DRAW_ITEM& other ) const
int LibDrawArc::DoCompare( const LIB_DRAW_ITEM& other ) const
{
wxASSERT( other.Type() == COMPONENT_ARC_DRAW_TYPE );
const LibDrawArc* tmp = ( LibDrawArc* ) &other;
return ( ( m_Pos == tmp->m_Pos ) && ( m_t1 == tmp->m_t1 )
&& ( m_t2 == tmp->m_t2 ) );
if( m_Pos.x != tmp->m_Pos.x )
return m_Pos.x - tmp->m_Pos.x;
if( m_Pos.y != tmp->m_Pos.y )
return m_Pos.y - tmp->m_Pos.y;
if( m_t1 != tmp->m_t1 )
return m_t1 - tmp->m_t1;
if( m_t2 != tmp->m_t2 )
return m_t2 - tmp->m_t2;
return 0;
}
......@@ -591,13 +623,22 @@ LIB_DRAW_ITEM* LibDrawCircle::DoGenCopy()
}
bool LibDrawCircle::DoCompare( const LIB_DRAW_ITEM& other ) const
int LibDrawCircle::DoCompare( const LIB_DRAW_ITEM& other ) const
{
wxASSERT( other.Type() == COMPONENT_CIRCLE_DRAW_TYPE );
const LibDrawCircle* tmp = ( LibDrawCircle* ) &other;
return ( ( m_Pos == tmp->m_Pos ) && ( m_Radius == tmp->m_Radius ) );
if( m_Pos.x != tmp->m_Pos.x )
return m_Pos.x - tmp->m_Pos.x;
if( m_Pos.y != tmp->m_Pos.y )
return m_Pos.y - tmp->m_Pos.y;
if( m_Radius != tmp->m_Radius )
return m_Radius - tmp->m_Radius;
return 0;
}
......@@ -673,6 +714,14 @@ void LibDrawCircle::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
else
GRCircle( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y,
m_Radius, GetPenSize( ), color );
/* Set to one (1) to draw bounding box around circle to validate bounding
* box calculation. */
#if 0
EDA_Rect bBox = GetBoundingBox();
GRRect( &aPanel->m_ClipBox, aDC, bBox.GetOrigin().x, bBox.GetOrigin().y,
bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA );
#endif
}
......@@ -785,13 +834,25 @@ LIB_DRAW_ITEM* LibDrawSquare::DoGenCopy()
}
bool LibDrawSquare::DoCompare( const LIB_DRAW_ITEM& other ) const
int LibDrawSquare::DoCompare( const LIB_DRAW_ITEM& other ) const
{
wxASSERT( other.Type() == COMPONENT_RECT_DRAW_TYPE );
const LibDrawSquare* tmp = ( LibDrawSquare* ) &other;
return ( ( m_Pos == tmp->m_Pos ) && ( m_End == tmp->m_End ) );
if( m_Pos.x != tmp->m_Pos.x )
return m_Pos.x - tmp->m_Pos.x;
if( m_Pos.y != tmp->m_Pos.y )
return m_Pos.y - tmp->m_Pos.y;
if( m_End.x != tmp->m_End.x )
return m_End.x - tmp->m_End.x;
if( m_End.y != tmp->m_End.y )
return m_End.y - tmp->m_End.y;
return 0;
}
......@@ -870,6 +931,15 @@ void LibDrawSquare::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
else
GRRect( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, pos2.x, pos2.y,
GetPenSize( ), color );
/* Set to one (1) to draw bounding box around rectangle to validate
* bounding box calculation. */
#if 0
EDA_Rect bBox = GetBoundingBox();
bBox.Inflate( m_Width + 1, m_Width + 1 );
GRRect( &aPanel->m_ClipBox, aDC, bBox.GetOrigin().x, bBox.GetOrigin().y,
bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA );
#endif
}
......@@ -1009,13 +1079,25 @@ LIB_DRAW_ITEM* LibDrawSegment::DoGenCopy()
}
bool LibDrawSegment::DoCompare( const LIB_DRAW_ITEM& other ) const
int LibDrawSegment::DoCompare( const LIB_DRAW_ITEM& other ) const
{
wxASSERT( other.Type() == COMPONENT_LINE_DRAW_TYPE );
const LibDrawSegment* tmp = ( LibDrawSegment* ) &other;
return ( ( m_Pos == tmp->m_Pos ) && ( m_End == tmp->m_End ) );
if( m_Pos.x != tmp->m_Pos.x )
return m_Pos.x - tmp->m_Pos.x;
if( m_Pos.y != tmp->m_Pos.y )
return m_Pos.y - tmp->m_Pos.y;
if( m_End.x != tmp->m_End.x )
return m_End.x - tmp->m_End.x;
if( m_End.y != tmp->m_End.y )
return m_End.y - tmp->m_End.y;
return 0;
}
......@@ -1082,6 +1164,15 @@ void LibDrawSegment::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
GRLine( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, pos2.x, pos2.y,
GetPenSize( ), color );
/* Set to one (1) to draw bounding box around line segment to validate
* bounding box calculation. */
#if 0
EDA_Rect bBox = GetBoundingBox();
bBox.Inflate( m_Width + 2, m_Width + 2 );
GRRect( &aPanel->m_ClipBox, aDC, bBox.GetOrigin().x, bBox.GetOrigin().y,
bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA );
#endif
}
......@@ -1257,21 +1348,24 @@ LIB_DRAW_ITEM* LibDrawPolyline::DoGenCopy()
}
bool LibDrawPolyline::DoCompare( const LIB_DRAW_ITEM& other ) const
int LibDrawPolyline::DoCompare( const LIB_DRAW_ITEM& other ) const
{
wxASSERT( other.Type() == COMPONENT_POLYLINE_DRAW_TYPE );
const LibDrawPolyline* tmp = ( LibDrawPolyline* ) &other;
if( m_PolyPoints.size() != tmp->m_PolyPoints.size() )
return false;
return m_PolyPoints.size() - tmp->m_PolyPoints.size();
for( size_t i = 0; i < m_PolyPoints.size(); i++ )
{
if( m_PolyPoints[i] != tmp->m_PolyPoints[i] )
return false;
if( m_PolyPoints[i].x != tmp->m_PolyPoints[i].x )
return m_PolyPoints[i].x - tmp->m_PolyPoints[i].x;
if( m_PolyPoints[i].y != tmp->m_PolyPoints[i].y )
return m_PolyPoints[i].y - tmp->m_PolyPoints[i].y;
}
return true;
return 0;
}
......@@ -1383,6 +1477,15 @@ void LibDrawPolyline::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
else
GRPoly( &aPanel->m_ClipBox, aDC, m_PolyPoints.size(),
Buf_Poly_Drawings, 0, GetPenSize( ), color, color );
/* Set to one (1) to draw bounding box around polyline to validate
* bounding box calculation. */
#if 0
EDA_Rect bBox = GetBoundingBox();
bBox.Inflate( m_Width + 1, m_Width + 1 );
GRRect( &aPanel->m_ClipBox, aDC, bBox.GetOrigin().x, bBox.GetOrigin().y,
bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA );
#endif
}
......@@ -1589,22 +1692,24 @@ LIB_DRAW_ITEM* LibDrawBezier::DoGenCopy()
}
bool LibDrawBezier::DoCompare( const LIB_DRAW_ITEM& other ) const
int LibDrawBezier::DoCompare( const LIB_DRAW_ITEM& other ) const
{
wxASSERT( other.Type() == COMPONENT_BEZIER_DRAW_TYPE );
const LibDrawBezier* tmp = ( LibDrawBezier* ) &other;
if( m_BezierPoints.size() != tmp->m_BezierPoints.size() )
return false;
return m_BezierPoints.size() - tmp->m_BezierPoints.size();
for( size_t i = 0; i < m_BezierPoints.size(); i++ )
{
if( m_BezierPoints[i] != tmp->m_BezierPoints[i] )
return false;
if( m_BezierPoints[i].x != tmp->m_BezierPoints[i].x )
return m_BezierPoints[i].x - tmp->m_BezierPoints[i].x;
if( m_BezierPoints[i].y != tmp->m_BezierPoints[i].y )
return m_BezierPoints[i].y - tmp->m_BezierPoints[i].y;
}
return true;
return 0;
}
......@@ -1712,6 +1817,14 @@ void LibDrawBezier::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
GRPoly( &aPanel->m_ClipBox, aDC, m_PolyPoints.size(),
&PolyPointsTraslated[0], 0, GetPenSize(), color, color );
/* Set to one (1) to draw bounding box around bezier curve to validate
* bounding box calculation. */
#if 0
EDA_Rect bBox = GetBoundingBox();
bBox.Inflate( m_Width + 1, m_Width + 1 );
GRRect( &aPanel->m_ClipBox, aDC, bBox.GetOrigin().x, bBox.GetOrigin().y,
bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA );
#endif
}
......
......@@ -10,6 +10,7 @@
class LIB_COMPONENT;
class PLOTTER;
class LIB_DRAW_ITEM;
#define TARGET_PIN_DIAM 12 /* Circle diameter drawn at the active end of
......@@ -36,7 +37,8 @@ class PLOTTER;
* Enum ElectricPinType
* is the set of schematic pin types, used in ERC tests.
*/
enum ElectricPinType {
enum ElectricPinType
{
PIN_INPUT,
PIN_OUTPUT,
PIN_BIDI,
......@@ -62,10 +64,11 @@ extern const wxChar* MsgPinElectricType[];
* Enum DrawPinShape
* is the set of shapes allowed for pins.
*/
enum DrawPinShape {
NONE = 0,
INVERT = 1,
CLOCK = 2,
enum DrawPinShape
{
NONE = 0,
INVERT = 1,
CLOCK = 2,
LOWLEVEL_IN = 4,
LOWLEVEL_OUT = 8
};
......@@ -75,10 +78,11 @@ enum DrawPinShape {
* Enum DrawPinOrient
* is the set of orientations allowed for pins.
*/
enum DrawPinOrient {
enum DrawPinOrient
{
PIN_RIGHT = 'R',
PIN_LEFT = 'L',
PIN_UP = 'U',
PIN_UP = 'U',
PIN_DOWN = 'D',
};
......@@ -200,7 +204,7 @@ public:
/**
* Test LIB_DRAW_ITEM objects for equivalence.
*
* @param tst - Object to test against.
* @param other - Object to test against.
*
* @return bool - True if object is identical to this object.
*/
......@@ -210,6 +214,15 @@ public:
return *this == *other;
}
/**
* Test if another draw item is less than this draw object.
*
* @param other - Draw item to compare against.
*
* @return bool - True if object is less than this object.
*/
bool operator<( const LIB_DRAW_ITEM& other) const;
/**
* Set drawing object offset from the current position.
*
......@@ -261,7 +274,7 @@ protected:
*
* This is called by the == operator.
*/
virtual bool DoCompare( const LIB_DRAW_ITEM& other ) const = 0;
virtual int DoCompare( const LIB_DRAW_ITEM& other ) const = 0;
virtual void DoOffset( const wxPoint& offset ) = 0;
virtual bool DoTestInside( EDA_Rect& rect ) = 0;
virtual void DoMove( const wxPoint& newPosition ) = 0;
......@@ -270,6 +283,12 @@ protected:
};
/**
* Helper for defining a list of library draw object pointers.
*/
typedef boost::ptr_vector< LIB_DRAW_ITEM > LIB_DRAW_ITEM_LIST;
/********/
/* Pins */
/********/
......@@ -395,7 +414,7 @@ public:
protected:
virtual LIB_DRAW_ITEM* DoGenCopy();
virtual bool DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual int DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
......@@ -471,7 +490,7 @@ public:
protected:
virtual LIB_DRAW_ITEM* DoGenCopy();
virtual bool DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual int DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
......@@ -543,7 +562,7 @@ public:
protected:
virtual LIB_DRAW_ITEM* DoGenCopy();
virtual bool DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual int DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
......@@ -586,7 +605,7 @@ public:
* @param refPos A wxPoint to test
* @return bool - true if a hit, else false
*/
virtual bool HitTest( const wxPoint& refPos );
virtual bool HitTest( const wxPoint& refPos );
/** Function HitTest
* @return true if the point aPosRef is near a segment
......@@ -604,7 +623,7 @@ public:
* @param refArea : the given EDA_Rect
* @return bool - true if a hit, else false
*/
virtual bool HitTest( EDA_Rect& refArea )
virtual bool HitTest( EDA_Rect& refArea )
{
return TextHitTest( refArea );
}
......@@ -620,9 +639,11 @@ public:
virtual void DisplayInfo( WinEDA_DrawFrame* frame );
virtual EDA_Rect GetBoundingBox();
protected:
virtual LIB_DRAW_ITEM* DoGenCopy();
virtual bool DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual int DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
......@@ -693,7 +714,7 @@ public:
protected:
virtual LIB_DRAW_ITEM* DoGenCopy();
virtual bool DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual int DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
......@@ -763,7 +784,7 @@ public:
protected:
virtual LIB_DRAW_ITEM* DoGenCopy();
virtual bool DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual int DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
......@@ -844,7 +865,7 @@ public:
protected:
virtual LIB_DRAW_ITEM* DoGenCopy();
virtual bool DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual int DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
......@@ -925,7 +946,7 @@ public:
protected:
virtual LIB_DRAW_ITEM* DoGenCopy();
virtual bool DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual int DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
......
......@@ -44,12 +44,6 @@ bool g_HVLines = true; // Bool: force H or V directions (Wires, Bus ..)
struct EESchemaVariables g_EESchemaVar;
/* Variables globales pour Libview */
wxString g_CurrentViewLibraryName; /* nom de la librairie en cours d'examen */
wxString g_CurrentViewComponentName; /* nom du le composant en cours d'examen */
int g_ViewConvert; /* Vue normal / convert */
int g_ViewUnit; /* part a afficher (A, B ..) */
/* Variables globales pour Schematic Edit */
int g_DefaultTextLabelSize = DEFAULT_SIZE_TEXT;
......
......@@ -125,11 +125,6 @@ struct EESchemaVariables
extern struct EESchemaVariables g_EESchemaVar;
/* Variables globales pour Libview */
extern wxString g_CurrentViewLibraryName; /* nom de la librairie en cours d'examen */
extern wxString g_CurrentViewComponentName; /* nom du le composant en cours d'examen */
extern int g_ViewConvert; /* Vue normal / convert */
extern int g_ViewUnit; /* part a afficher (A, B ..) */
/* Variables globales pour Schematic Edit */
extern int g_DefaultTextLabelSize;
......
......@@ -31,7 +31,6 @@ static wxPoint OldPos;
wxString SelectFromLibBrowser( WinEDA_DrawFrame* parent )
{
wxString name;
WinEDA_ViewlibFrame* Viewer;
wxSemaphore semaphore( 0, 1 );
WinEDA_SchematicFrame* frame;
......@@ -39,23 +38,23 @@ wxString SelectFromLibBrowser( WinEDA_DrawFrame* parent )
frame = (WinEDA_SchematicFrame*) wxGetApp().GetTopWindow();
Viewer = frame->m_ViewlibFrame;
/* Close the current Lib browser, if open, and open a new one, in "modal" mode */
/* Close the current Lib browser, if open, and open a new one, in
* "modal" mode */
if( Viewer )
Viewer->Destroy();
Viewer = frame->m_ViewlibFrame =
new WinEDA_ViewlibFrame( frame, NULL, &semaphore );
Viewer = frame->m_ViewlibFrame = new WinEDA_ViewlibFrame( frame, NULL,
&semaphore );
Viewer->AdjustScrollBars();
// Show the library viewer frame until it is closed
while( semaphore.TryWait() == wxSEMA_BUSY ) // Wait for viewer closing event
while( semaphore.TryWait() == wxSEMA_BUSY ) // Wait for viewer closing event
{
wxYield();
wxMilliSleep( 50 );
}
name = g_CurrentViewComponentName;
return name;
return Viewer->GetEntryName();
}
......
......@@ -248,7 +248,7 @@ void WinEDA_LibeditFrame::RotateField( wxDC* DC, LibDrawField* Field )
if( Field->m_Orient )
Field->m_Orient = 0;
else
Field->m_Orient = 1;
Field->m_Orient = 900;
int drawMode = g_XorMode;
......@@ -264,24 +264,20 @@ void WinEDA_LibeditFrame::RotateField( wxDC* DC, LibDrawField* Field )
LIB_DRAW_ITEM* WinEDA_LibeditFrame::LocateItemUsingCursor()
{
LIB_DRAW_ITEM* DrawEntry = m_drawItem;
if( m_component == NULL )
return NULL;
if( ( DrawEntry == NULL ) || ( DrawEntry->m_Flags == 0 ) )
if( ( m_drawItem == NULL ) || ( m_drawItem->m_Flags == 0 ) )
{
DrawEntry = m_drawItem =
m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT,
GetScreen()->m_MousePosition );
if( DrawEntry == NULL )
{
DrawEntry = m_drawItem =
m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT,
GetScreen()->m_Curseur );
}
m_drawItem = m_component->LocateDrawItem( m_unit, m_convert,
TYPE_NOT_INIT,
GetScreen()->m_MousePosition );
if( m_drawItem == NULL )
m_drawItem = m_component->LocateDrawItem( m_unit, m_convert,
TYPE_NOT_INIT,
GetScreen()->m_Curseur );
}
return DrawEntry;
return m_drawItem;
}
......@@ -58,6 +58,8 @@ public:
void LoadSettings();
void SaveSettings();
wxString& GetEntryName( void ) const { return m_entryName; }
private:
void SelectCurrentLibrary();
void SelectAndViewLibraryPart( int option );
......@@ -65,6 +67,13 @@ private:
void ViewOneLibraryContent( CMP_LIBRARY* Lib, int Flag );
bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
protected:
static wxString m_libraryName;
static wxString m_entryName;
static int m_unit;
static int m_convert;
static wxSize m_clientSize;
DECLARE_EVENT_TABLE()
};
......
......@@ -75,6 +75,9 @@ int DisplayComponentsNamesInLib( WinEDA_DrawFrame* frame,
WinEDAListBox dlg( frame, _( "Select Component" ), ListNames, OldName,
DisplayCmpDoc, wxColour( 255, 255, 255 ) );
if( !OldName.IsEmpty() )
dlg.m_List->SetStringSelection( OldName );
dlg.MoveMouseToOrigin();
int rsp = dlg.ShowModal();
......
......@@ -102,27 +102,27 @@ void WinEDA_ViewlibFrame::ReCreateHToolbar()
m_HToolBar->Realize();
}
if( (g_CurrentViewLibraryName != wxEmptyString)
&& (g_CurrentViewComponentName != wxEmptyString) )
if( (m_libraryName != wxEmptyString)
&& (m_entryName != wxEmptyString) )
{
lib = CMP_LIBRARY::FindLibrary( g_CurrentViewLibraryName );
lib = CMP_LIBRARY::FindLibrary( m_libraryName );
if( lib != NULL )
{
component = lib->FindComponent( g_CurrentViewComponentName );
component = lib->FindComponent( m_entryName );
if( component && component->HasConversion() )
asdeMorgan = true;
entry = lib->FindEntry( g_CurrentViewComponentName );
entry = lib->FindEntry( m_entryName );
}
}
// Must be AFTER Realize():
m_HToolBar->ToggleTool( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT,
(g_ViewConvert <= 1) ? TRUE : FALSE );
(m_convert <= 1) ? TRUE : FALSE );
m_HToolBar->ToggleTool( ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT,
(g_ViewConvert >= 2) ? TRUE : FALSE );
(m_convert >= 2) ? TRUE : FALSE );
m_HToolBar->EnableTool( ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, asdeMorgan );
m_HToolBar->EnableTool( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, asdeMorgan );
......@@ -137,7 +137,7 @@ void WinEDA_ViewlibFrame::ReCreateHToolbar()
SelpartBox->Append( msg );
}
SelpartBox->SetSelection( 0 );
SelpartBox->SetSelection( m_unit - 1 );
SelpartBox->Enable( component && component->HasConversion() );
m_HToolBar->EnableTool( ID_LIBVIEW_VIEWDOC,
......
......@@ -16,6 +16,16 @@
#include "class_library.h"
/**
* Save previous component library viewer state.
*/
wxString WinEDA_ViewlibFrame::m_libraryName;
wxString WinEDA_ViewlibFrame::m_entryName;
int WinEDA_ViewlibFrame::m_unit = 1;
int WinEDA_ViewlibFrame::m_convert = 1;
wxSize WinEDA_ViewlibFrame::m_clientSize = wxSize( -1, -1 );
/*****************************/
/* class WinEDA_ViewlibFrame */
/*****************************/
......@@ -122,7 +132,10 @@ WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father,
}
else
{
g_CurrentViewLibraryName = Library->GetName();
m_libraryName = Library->GetName();
m_entryName.Clear();
m_unit = 1;
m_convert = 1;
m_LibListSize.x = 0;
}
......@@ -149,7 +162,7 @@ WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father,
DisplayLibInfos();
if( DrawPanel )
DrawPanel->SetAcceleratorTable( table );
BestZoom();
Zoom_Automatique( false );
Show( TRUE );
}
......@@ -162,9 +175,7 @@ WinEDA_ViewlibFrame::~WinEDA_ViewlibFrame()
}
/*****************************************************************/
void WinEDA_ViewlibFrame::OnCloseWindow( wxCloseEvent& Event )
/*****************************************************************/
{
SaveSettings();
if( m_Semaphore )
......@@ -173,12 +184,10 @@ void WinEDA_ViewlibFrame::OnCloseWindow( wxCloseEvent& Event )
}
/****************************************************/
void WinEDA_ViewlibFrame::OnSashDrag( wxSashEvent& event )
/****************************************************/
/* Resize sub windows when dragging a sash window border
/*
* Resize sub windows when dragging a sash window border
*/
void WinEDA_ViewlibFrame::OnSashDrag( wxSashEvent& event )
{
if( event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE )
return;
......@@ -212,9 +221,7 @@ void WinEDA_ViewlibFrame::OnSashDrag( wxSashEvent& event )
}
/*****************************************************/
void WinEDA_ViewlibFrame::OnSize( wxSizeEvent& SizeEv )
/*****************************************************/
{
wxSize clientsize;
wxSize maintoolbar_size;
......@@ -270,12 +277,10 @@ void WinEDA_ViewlibFrame::OnSize( wxSizeEvent& SizeEv )
}
/***********************************/
int WinEDA_ViewlibFrame::BestZoom()
/***********************************/
{
int bestzoom, ii, jj;
wxSize size, itemsize;
wxSize size;
LIB_COMPONENT* component;
CMP_LIBRARY* lib;
......@@ -283,33 +288,51 @@ int WinEDA_ViewlibFrame::BestZoom()
GetScreen()->m_Curseur.y = 0;
bestzoom = 16;
lib = CMP_LIBRARY::FindLibrary( g_CurrentViewLibraryName );
lib = CMP_LIBRARY::FindLibrary( m_libraryName );
if( lib == NULL )
return bestzoom;
component = lib->FindComponent( g_CurrentViewComponentName );
component = lib->FindComponent( m_entryName );
if( component == NULL )
{
bestzoom = 16;
GetScreen()->m_Curseur.x = 0;
GetScreen()->m_Curseur.y = 0;
return bestzoom;
/*
* This fixes a bug where the client size of the drawing area is not
* correctly reported until after the window is shown. This is most
* likely due to the unmanaged windows ( vertical tool bars and message
* panel ) that are drawn in the main window which wxWidgets knows
* nothing about. When the library editor is reopened with a component
* already loading, the zoom will be calculated correctly.
*/
if( !IsShownOnScreen() )
{
if( m_clientSize != wxSize( -1, -1 ) )
size = m_clientSize;
else
size = DrawPanel->GetClientSize();
}
else
{
if( m_clientSize == wxSize( -1, -1 ) )
m_clientSize = DrawPanel->GetClientSize();
size = m_clientSize;
}
EDA_Rect BoundaryBox = component->GetBoundaryBox( g_ViewUnit,
g_ViewConvert );
itemsize = BoundaryBox.GetSize();
size = DrawPanel->GetClientSize();
size -= wxSize( 25, 25 ); // reserve a 25 mils margin.
ii = wxRound( double( itemsize.x ) / double( size.x ) );
jj = wxRound( double( itemsize.y ) / double( size.y ) );
EDA_Rect BoundaryBox = component->GetBoundaryBox( m_unit, m_convert );
// Reserve a 25 mils margin around component bounding box.
size -= wxSize( 25, 25 );
ii = wxRound( ( (double) BoundaryBox.GetWidth() / double( size.x ) ) *
(double) GetScreen()->m_ZoomScalar );
jj = wxRound( ( (double) BoundaryBox.GetHeight() / (double) size.y ) *
(double) GetScreen()->m_ZoomScalar );
bestzoom = MAX( ii, jj ) + 1;
GetScreen()->m_Curseur = BoundaryBox.Centre();
return bestzoom * GetScreen()->m_ZoomScalar;
return bestzoom;
}
......@@ -321,34 +344,27 @@ int WinEDA_ViewlibFrame::BestZoom()
*/
void WinEDA_ViewlibFrame::ReCreateListLib()
{
wxArrayString libNamesList;
bool found = false;
if( m_LibList == NULL )
return;
m_LibList->Clear();
libNamesList = CMP_LIBRARY::GetLibraryNames();
m_LibList->Append( libNamesList );
m_LibList->Append( CMP_LIBRARY::GetLibraryNames() );
// Search for a previous selection:
for ( unsigned ii = 0; ii < m_LibList->GetCount(); ii++ )
int index = m_LibList->FindString( m_libraryName );
if( index != wxNOT_FOUND )
{
if( g_CurrentViewLibraryName.Cmp( m_LibList->GetString( ii ) ) == 0 )
{
m_LibList->SetSelection( ii, TRUE );
found = TRUE;
break;
}
m_LibList->SetSelection( index, true );
}
/* If not found, clear current library selection because it can be
* deleted after a config change.
*/
if( !found )
else
{
g_CurrentViewLibraryName.Empty();
g_CurrentViewComponentName.Empty();
/* If not found, clear current library selection because it can be
* deleted after a config change. */
m_libraryName = wxEmptyString;
m_entryName = wxEmptyString;
m_unit = 1;
m_convert = 1;
}
ReCreateListCmp();
......@@ -363,17 +379,35 @@ void WinEDA_ViewlibFrame::ReCreateListCmp()
if( m_CmpList == NULL )
return;
CMP_LIBRARY* Library = CMP_LIBRARY::FindLibrary( g_CurrentViewLibraryName );
wxArrayString nameList;
m_CmpList->Clear();
g_CurrentViewComponentName.Empty();
g_ViewConvert = 1; /* Select normal/"de morgan" shape */
g_ViewUnit = 1; /* Select unit to display for multiple
* parts per package */
if( Library )
Library->GetEntryNames( nameList );
CMP_LIBRARY* Library = CMP_LIBRARY::FindLibrary( m_libraryName );
if( Library == NULL )
{
m_libraryName = wxEmptyString;
m_entryName = wxEmptyString;
m_convert = 1;
m_unit = 1;
return;
}
wxArrayString nameList;
Library->GetEntryNames( nameList );
m_CmpList->Append( nameList );
int index = m_CmpList->FindString( m_entryName );
if( index == wxNOT_FOUND )
{
m_entryName = wxEmptyString;
m_convert = 1;
m_unit = 1;
}
else
{
m_CmpList->SetSelection( index, true );
}
}
......@@ -385,9 +419,9 @@ void WinEDA_ViewlibFrame::ClickOnLibList( wxCommandEvent& event )
return;
wxString name = m_LibList->GetString( ii );
if( g_CurrentViewLibraryName == name )
if( m_libraryName == name )
return;
g_CurrentViewLibraryName = name;
m_libraryName = name;
ReCreateListCmp();
DrawPanel->Refresh();
DisplayLibInfos();
......@@ -403,13 +437,17 @@ void WinEDA_ViewlibFrame::ClickOnCmpList( wxCommandEvent& event )
return;
wxString name = m_CmpList->GetString( ii );
g_CurrentViewComponentName = name;
DisplayLibInfos();
g_ViewUnit = 1;
g_ViewConvert = 1;
Zoom_Automatique( FALSE );
ReCreateHToolbar();
DrawPanel->Refresh();
if( m_entryName.CmpNoCase( name ) != 0 )
{
m_entryName = name;
DisplayLibInfos();
m_unit = 1;
m_convert = 1;
Zoom_Automatique( false );
ReCreateHToolbar();
DrawPanel->Refresh();
}
}
......@@ -422,9 +460,9 @@ void WinEDA_ViewlibFrame::ExportToSchematicLibraryPart( wxCommandEvent& event )
int ii = m_CmpList->GetSelection();
if( ii >= 0 )
g_CurrentViewComponentName = m_CmpList->GetString( ii );
m_entryName = m_CmpList->GetString( ii );
else
g_CurrentViewComponentName.Empty();
m_entryName.Empty();
Close( TRUE );
}
......
......@@ -48,8 +48,8 @@ void WinEDA_ViewlibFrame::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_LIBVIEW_VIEWDOC:
LibEntry = CMP_LIBRARY::FindLibraryEntry( g_CurrentViewComponentName,
g_CurrentViewLibraryName );
LibEntry = CMP_LIBRARY::FindLibraryEntry( m_entryName,
m_libraryName );
if( LibEntry && ( !LibEntry->m_DocFile.IsEmpty() ) )
GetAssociatedDocument( this, LibEntry->m_DocFile,
......@@ -59,14 +59,14 @@ void WinEDA_ViewlibFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT:
m_HToolBar->ToggleTool( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, TRUE );
m_HToolBar->ToggleTool( ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, FALSE );
g_ViewConvert = 1;
m_convert = 1;
DrawPanel->Refresh();
break;
case ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT:
m_HToolBar->ToggleTool( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, FALSE );
m_HToolBar->ToggleTool( ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, TRUE );
g_ViewConvert = 2;
m_convert = 2;
DrawPanel->Refresh();
break;
......@@ -74,7 +74,7 @@ void WinEDA_ViewlibFrame::Process_Special_Functions( wxCommandEvent& event )
ii = SelpartBox->GetChoice();
if( ii < 0 )
return;
g_ViewUnit = ii + 1;
m_unit = ii + 1;
DrawPanel->Refresh();
break;
......@@ -104,15 +104,15 @@ void WinEDA_ViewlibFrame::DisplayLibInfos()
wxString msg;
CMP_LIBRARY* Lib;
Lib = CMP_LIBRARY::FindLibrary( g_CurrentViewLibraryName );
msg = _( "Library browser" );
Lib = CMP_LIBRARY::FindLibrary( m_libraryName );
msg = _( "Library Browser" );
msg << wxT( " [" );
if( Lib )
msg << Lib->GetFullFileName();
else
msg += _( "none selected" );
msg += _( "no library selected" );
msg << wxT( "]" );
SetTitle( msg );
......@@ -129,8 +129,8 @@ void WinEDA_ViewlibFrame::SelectCurrentLibrary()
Lib = SelectLibraryFromList( this );
if( Lib )
{
g_CurrentViewComponentName.Empty();
g_CurrentViewLibraryName = Lib->GetName();
m_entryName.Empty();
m_libraryName = Lib->GetName();
DisplayLibInfos();
if( m_LibList )
{
......@@ -138,7 +138,7 @@ void WinEDA_ViewlibFrame::SelectCurrentLibrary()
DrawPanel->Refresh();
DisplayLibInfos();
ReCreateHToolbar();
int id = m_LibList->FindString( g_CurrentViewLibraryName.GetData() );
int id = m_LibList->FindString( m_libraryName.GetData() );
if( id >= 0 )
m_LibList->SetSelection( id );
}
......@@ -153,22 +153,22 @@ void WinEDA_ViewlibFrame::SelectAndViewLibraryPart( int option )
{
CMP_LIBRARY* Lib;
if( g_CurrentViewLibraryName.IsEmpty() )
if( m_libraryName.IsEmpty() )
SelectCurrentLibrary();
if( g_CurrentViewLibraryName.IsEmpty() )
if( m_libraryName.IsEmpty() )
return;
Lib = CMP_LIBRARY::FindLibrary( g_CurrentViewLibraryName );
Lib = CMP_LIBRARY::FindLibrary( m_libraryName );
if( Lib == NULL )
return;
if( ( g_CurrentViewComponentName.IsEmpty() ) || ( option == NEW_PART ) )
if( ( m_entryName.IsEmpty() ) || ( option == NEW_PART ) )
{
ViewOneLibraryContent( Lib, NEW_PART );
return;
}
CMP_LIB_ENTRY* LibEntry = Lib->FindEntry( g_CurrentViewComponentName );
CMP_LIB_ENTRY* LibEntry = Lib->FindEntry( m_entryName );
if( LibEntry == NULL )
return;
......@@ -208,12 +208,12 @@ void WinEDA_ViewlibFrame::ViewOneLibraryContent( CMP_LIBRARY* Lib, int Flag )
if( Flag == NEW_PART )
{
DisplayComponentsNamesInLib( this, Lib, CmpName,
g_CurrentViewComponentName );
m_entryName );
}
if( Flag == NEXT_PART )
{
LibEntry = Lib->GetNextEntry( g_CurrentViewComponentName );
LibEntry = Lib->GetNextEntry( m_entryName );
if( LibEntry )
CmpName = LibEntry->m_Name.m_Text;
......@@ -221,24 +221,24 @@ void WinEDA_ViewlibFrame::ViewOneLibraryContent( CMP_LIBRARY* Lib, int Flag )
if( Flag == PREVIOUS_PART )
{
LibEntry = Lib->GetPreviousEntry( g_CurrentViewComponentName );
LibEntry = Lib->GetPreviousEntry( m_entryName );
if( LibEntry )
CmpName = LibEntry->m_Name.m_Text;
}
g_ViewUnit = 1;
g_ViewConvert = 1;
m_unit = 1;
m_convert = 1;
LibEntry = Lib->FindEntry( CmpName );
g_CurrentViewComponentName = CmpName;
m_entryName = CmpName;
DisplayLibInfos();
Zoom_Automatique( FALSE );
RedrawActiveWindow( &dc, TRUE );
Zoom_Automatique( false );
RedrawActiveWindow( &dc, true );
if( m_CmpList )
{
int id = m_CmpList->FindString( g_CurrentViewComponentName.GetData() );
int id = m_CmpList->FindString( m_entryName.GetData() );
if( id >= 0 )
m_CmpList->SetSelection( id );
}
......@@ -260,12 +260,12 @@ void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
ActiveScreen = GetScreen();
lib = CMP_LIBRARY::FindLibrary( g_CurrentViewLibraryName );
lib = CMP_LIBRARY::FindLibrary( m_libraryName );
if( lib == NULL )
return;
entry = lib->FindEntry( g_CurrentViewComponentName );
entry = lib->FindEntry( m_entryName );
if( entry == NULL )
return;
......@@ -292,10 +292,10 @@ void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
/* Temporarily change the name field text to reflect the alias name. */
tmp = component->GetName();
component->m_Name.m_Text = alias->GetName();
if( g_ViewUnit < 1 )
g_ViewUnit = 1;
if( g_ViewConvert < 1 )
g_ViewConvert = 1;
if( m_unit < 1 )
m_unit = 1;
if( m_convert < 1 )
m_convert = 1;
component->m_Name.m_Text = tmp;
}
else
......@@ -304,8 +304,8 @@ void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
msg = _( "None" );
}
component->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_ViewUnit,
g_ViewConvert, GR_DEFAULT_DRAWMODE );
component->Draw( DrawPanel, DC, wxPoint( 0, 0 ), m_unit, m_convert,
GR_DEFAULT_DRAWMODE );
if( !tmp.IsEmpty() )
component->m_Name.m_Text = tmp;
......
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