Move Circle, Arc, Rectangle and PolyLine tools to modern toolset.

This commit is contained in:
Jeff Young 2019-05-08 00:51:37 +01:00
parent a3483f44d2
commit 40f41133b3
29 changed files with 301 additions and 492 deletions

View File

@ -106,7 +106,6 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( int aType )
*/
void SCH_EDIT_FRAME::ConvertTextType( SCH_TEXT* aText, KICAD_T aType )
{
SCH_SCREEN* screen = GetScreen();
bool selected = aText->IsSelected();
wxCHECK_RET( aText->CanIncrementLabel(), "Cannot convert text type." );

View File

@ -230,7 +230,6 @@ enum id_eeschema_frm
ID_POPUP_LIBEDIT_BODY_EDIT_ITEM,
ID_POPUP_LIBEDIT_DELETE_ITEM,
ID_POPUP_LIBEDIT_MODIFY_ITEM,
ID_POPUP_LIBEDIT_END_CREATE_ITEM,
ID_POPUP_LIBEDIT_CANCEL_EDITING,
ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST,
ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM,

View File

@ -473,8 +473,7 @@ BITMAP_DEF LIB_ARC::GetMenuImage() const
void LIB_ARC::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
{
wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0,
wxT( "Invalid edit mode for LIB_ARC object." ) );
LIB_ITEM::BeginEdit( aEditMode, aPosition );
if( aEditMode == IS_NEW )
{
@ -516,17 +515,12 @@ void LIB_ARC::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
m_editState = 0;
}
m_Flags = aEditMode;
}
bool LIB_ARC::ContinueEdit( const wxPoint aPosition )
{
wxCHECK_MSG( ( m_Flags & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0, false,
wxT( "Bad call to ContinueEdit(). LIB_ARC is not being edited." ) );
if( m_Flags == IS_NEW )
if( IsNew() )
{
if( m_editState == 1 ) // Second position yields the arc segment length.
{
@ -540,20 +534,18 @@ bool LIB_ARC::ContinueEdit( const wxPoint aPosition )
}
void LIB_ARC::EndEdit( const wxPoint& aPosition, bool aAbort )
void LIB_ARC::EndEdit( const wxPoint& aPosition )
{
wxCHECK_RET( ( m_Flags & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0,
wxT( "Bad call to EndEdit(). LIB_ARC is not being edited." ) );
LIB_ITEM::EndEdit( aPosition );
m_lastEditState = 0;
m_editState = 0;
m_Flags = 0;
}
void LIB_ARC::CalcEdit( const wxPoint& aPosition )
{
if( m_Flags == IS_RESIZED )
if( IsResized() )
{
wxPoint newCenterPoint, startPos, endPos;
@ -627,7 +619,7 @@ void LIB_ARC::CalcEdit( const wxPoint& aPosition )
m_Pos = newCenterPoint;
CalcRadiusAngles();
}
else if( m_Flags == IS_NEW )
else if( IsNew() )
{
if( m_editState == 1 )
{
@ -664,7 +656,7 @@ void LIB_ARC::CalcEdit( const wxPoint& aPosition )
CalcRadiusAngles();
}
else if( m_Flags == IS_MOVED )
else if( IsMoving() )
{
Move( m_initialPos + aPosition - m_initialCursorPos );
}

View File

@ -63,16 +63,6 @@ class LIB_ARC : public LIB_ITEM
void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData,
const TRANSFORM& aTransform ) override;
/**
* Calculates the center, radius, and angles at \a aPosition when the arc is being edited.
*
* Note: The center may not necessarily be on the grid.
*
* @param aPosition - The current mouse position in drawing coordinates.
*/
void CalcEdit( const wxPoint& aPosition ) override;
public:
LIB_ARC( LIB_PART * aParent );
@ -99,9 +89,10 @@ public:
int GetPenSize() const override;
void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) ) override;
void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint ) override;
void CalcEdit( const wxPoint& aPosition ) override;
bool ContinueEdit( const wxPoint aNextPoint ) override;
void EndEdit( const wxPoint& aPosition, bool aAbort = false ) override;
void EndEdit( const wxPoint& aPosition ) override;
void SetOffset( const wxPoint& aOffset ) override;

View File

@ -255,8 +255,7 @@ BITMAP_DEF LIB_CIRCLE::GetMenuImage() const
void LIB_CIRCLE::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
{
wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0,
wxT( "Invalid edit mode for LIB_CIRCLE object." ) );
LIB_ITEM::BeginEdit( aEditMode, aPosition );
if( aEditMode == IS_NEW )
{
@ -267,32 +266,12 @@ void LIB_CIRCLE::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
m_initialPos = m_Pos;
m_initialCursorPos = aPosition;
}
m_Flags = aEditMode;
}
bool LIB_CIRCLE::ContinueEdit( const wxPoint aPosition )
{
wxCHECK_MSG( ( m_Flags & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0, false,
wxT( "Bad call to ContinueEdit(). LIB_CIRCLE is not being edited." ) );
return false;
}
void LIB_CIRCLE::EndEdit( const wxPoint& aPosition, bool aAbort )
{
wxCHECK_RET( ( m_Flags & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0,
wxT( "Bad call to EndEdit(). LIB_CIRCLE is not being edited." ) );
m_Flags = 0;
}
void LIB_CIRCLE::CalcEdit( const wxPoint& aPosition )
{
if( m_Flags == IS_NEW || m_Flags == IS_RESIZED )
if( IsNew() || IsResized() )
{
m_Radius = KiROUND( GetLineLength( m_Pos, aPosition ) );
}

View File

@ -41,8 +41,6 @@ class LIB_CIRCLE : public LIB_ITEM
void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData,
const TRANSFORM& aTransform ) override;
void CalcEdit( const wxPoint& aPosition ) override;
public:
LIB_CIRCLE( LIB_PART * aParent );
@ -69,9 +67,8 @@ public:
void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override;
void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) ) override;
bool ContinueEdit( const wxPoint aNextPoint ) override;
void EndEdit( const wxPoint& aPosition, bool aAbort = false ) override;
void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint ) override;
void CalcEdit( const wxPoint& aPosition ) override;
void SetOffset( const wxPoint& aOffset ) override;

View File

@ -144,7 +144,10 @@ public:
* started. This may or may not be required depending on the item
* being edited and the edit mode.
*/
virtual void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition = wxPoint( 0, 0 ) ) {}
virtual void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
{
SetFlags( aEditMode );
}
/**
* Continue an edit in progress at \a aPosition.
@ -156,7 +159,10 @@ public:
* @param aPosition The position of the mouse left click in drawing coordinates.
* @return True if additional mouse clicks are required to complete the edit in progress.
*/
virtual bool ContinueEdit( const wxPoint aPosition ) { return false; }
virtual bool ContinueEdit( const wxPoint aPosition )
{
return false;
}
/**
* End an object editing action.
@ -164,9 +170,11 @@ public:
* This is used to end or abort an edit action in progress initiated by BeginEdit().
*
* @param aPosition The position of the last edit event in drawing coordinates.
* @param aAbort Set to true to abort the current edit in progress.
*/
virtual void EndEdit( const wxPoint& aPosition, bool aAbort = false ) { m_Flags = 0; }
virtual void EndEdit( const wxPoint& aPosition )
{
ClearFlags( GetEditFlags() );
}
/**
* Calculates the attributes of an item at \a aPosition when it is being edited.
@ -219,7 +227,7 @@ public:
/**
* @return the boundary box for this, in library coordinates
*/
virtual const EDA_RECT GetBoundingBox() const override { return EDA_ITEM::GetBoundingBox(); }
const EDA_RECT GetBoundingBox() const override { return EDA_ITEM::GetBoundingBox(); }
/**
* Display basic info (type, part and convert) about the current item in message panel.
@ -230,8 +238,7 @@ public:
* </p>
* @param aList is the list to populate.
*/
virtual void GetMsgPanelInfo( EDA_UNITS_T aUnits,
std::vector< MSG_PANEL_ITEM >& aList ) override;
void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override;
/**
* Test LIB_ITEM objects for equivalence.

View File

@ -504,8 +504,7 @@ wxString LIB_FIELD::GetSelectMenuText( EDA_UNITS_T aUnits ) const
void LIB_FIELD::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
{
wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED ) ) != 0,
wxT( "Invalid edit mode for LIB_FIELD object." ) );
LIB_ITEM::BeginEdit( aEditMode, aPosition );
if( aEditMode == IS_MOVED )
{
@ -516,26 +515,13 @@ void LIB_FIELD::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
{
SetTextPos( aPosition );
}
m_Flags = aEditMode;
}
bool LIB_FIELD::ContinueEdit( const wxPoint aPosition )
void LIB_FIELD::EndEdit( const wxPoint& aPosition )
{
wxCHECK_MSG( ( m_Flags & ( IS_NEW | IS_MOVED ) ) != 0, false,
wxT( "Bad call to ContinueEdit(). Text is not being edited." ) );
LIB_ITEM::EndEdit( aPosition );
return false;
}
void LIB_FIELD::EndEdit( const wxPoint& aPosition, bool aAbort )
{
wxCHECK_RET( ( m_Flags & ( IS_NEW | IS_MOVED ) ) != 0,
wxT( "Bad call to EndEdit(). Text is not being edited." ) );
m_Flags = 0;
m_rotate = false;
m_updateText = false;
}
@ -555,11 +541,11 @@ void LIB_FIELD::CalcEdit( const wxPoint& aPosition )
m_updateText = false;
}
if( m_Flags == IS_NEW )
if( IsNew() )
{
SetTextPos( aPosition );
}
else if( m_Flags == IS_MOVED )
else if( IsMoving() )
{
Move( m_initialPos + aPosition - m_initialCursorPos );
}

View File

@ -188,9 +188,8 @@ public:
COLOR4D GetDefaultColor() override;
void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) ) override;
bool ContinueEdit( const wxPoint aNextPoint ) override;
void EndEdit( const wxPoint& aPosition, bool aAbort = false ) override;
void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint ) override;
void EndEdit( const wxPoint& aPosition ) override;
void Rotate() override;

View File

@ -1714,11 +1714,11 @@ void LIB_PIN::CalcEdit( const wxPoint& aPosition )
{
DBG(printf("m_Flags %x\n", m_Flags );)
if( m_Flags == IS_NEW )
if( IsNew() )
{
SetPosition( aPosition );
}
else if( m_Flags == IS_MOVED )
else if( IsMoving() )
{
DBG(printf("MOVEPIN\n");)
Move( aPosition );

View File

@ -327,8 +327,7 @@ BITMAP_DEF LIB_POLYLINE::GetMenuImage() const
void LIB_POLYLINE::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
{
wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0,
wxT( "Invalid edit mode for LIB_POLYLINE object." ) );
LIB_ITEM::BeginEdit( aEditMode, aPosition );
if( aEditMode == IS_NEW )
{
@ -387,17 +386,12 @@ void LIB_POLYLINE::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
m_initialCursorPos = aPosition;
m_initialPos = m_PolyPoints[0];
}
m_Flags = aEditMode;
}
bool LIB_POLYLINE::ContinueEdit( const wxPoint aPosition )
{
wxCHECK_MSG( ( m_Flags & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0, false,
wxT( "Bad call to ContinueEdit(). LIB_POLYLINE is not being edited." ) );
if( m_Flags == IS_NEW )
if( IsNew() )
{
// do not add zero length segments
if( m_PolyPoints[m_PolyPoints.size() - 2] != m_PolyPoints.back() )
@ -410,10 +404,9 @@ bool LIB_POLYLINE::ContinueEdit( const wxPoint aPosition )
}
void LIB_POLYLINE::EndEdit( const wxPoint& aPosition, bool aAbort )
void LIB_POLYLINE::EndEdit( const wxPoint& aPosition )
{
wxCHECK_RET( ( m_Flags & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0,
wxT( "Bad call to EndEdit(). LIB_POLYLINE is not being edited." ) );
LIB_ITEM::EndEdit( aPosition );
// do not include last point twice
if( m_Flags == IS_NEW && 2 < m_PolyPoints.size() )
@ -432,18 +425,16 @@ void LIB_POLYLINE::EndEdit( const wxPoint& aPosition, bool aAbort )
m_PolyPoints.erase( m_PolyPoints.begin() + m_ModifyIndex ); // delete a point on this
}
}
m_Flags = 0;
}
void LIB_POLYLINE::CalcEdit( const wxPoint& aPosition )
{
if( m_Flags == IS_NEW )
if( IsNew() )
{
m_PolyPoints[ GetCornerCount() - 1 ] = aPosition;
}
else if( m_Flags == IS_RESIZED )
else if( IsResized() )
{
if( m_ModifyIndex < 0 ) // negative indicates new vertex is to be inserted
{
@ -453,7 +444,7 @@ void LIB_POLYLINE::CalcEdit( const wxPoint& aPosition )
m_PolyPoints[ m_ModifyIndex ] = aPosition;
}
else if( m_Flags == IS_MOVED )
else if( IsMoving() )
{
Move( m_initialPos + aPosition - m_initialCursorPos );
}

View File

@ -42,8 +42,6 @@ class LIB_POLYLINE : public LIB_ITEM
void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData,
const TRANSFORM& aTransform ) override;
void CalcEdit( const wxPoint& aPosition ) override;
public:
LIB_POLYLINE( LIB_PART * aParent );
@ -85,9 +83,10 @@ public:
void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override;
void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) ) override;
void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint ) override;
void CalcEdit( const wxPoint& aPosition ) override;
bool ContinueEdit( const wxPoint aNextPoint ) override;
void EndEdit( const wxPoint& aPosition, bool aAbort = false ) override;
void EndEdit( const wxPoint& aPosition ) override;
void SetOffset( const wxPoint& aOffset ) override;

View File

@ -279,8 +279,7 @@ BITMAP_DEF LIB_RECTANGLE::GetMenuImage() const
void LIB_RECTANGLE::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
{
wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0,
wxT( "Invalid edit mode for LIB_RECTANGLE object." ) );
LIB_ITEM::BeginEdit( aEditMode, aPosition );
if( aEditMode == IS_NEW )
{
@ -308,26 +307,13 @@ void LIB_RECTANGLE::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
m_initialPos = m_Pos;
m_initialCursorPos = aPosition;
}
m_Flags = aEditMode;
}
bool LIB_RECTANGLE::ContinueEdit( const wxPoint aPosition )
void LIB_RECTANGLE::EndEdit( const wxPoint& aPosition )
{
wxCHECK_MSG( ( m_Flags & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0, false,
wxT( "Bad call to ContinueEdit(). LIB_RECTANGLE is not being edited." ) );
LIB_ITEM::EndEdit( aPosition );
return false;
}
void LIB_RECTANGLE::EndEdit( const wxPoint& aPosition, bool aAbort )
{
wxCHECK_RET( ( m_Flags & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0,
wxT( "Bad call to EndEdit(). LIB_RECTANGLE is not being edited." ) );
m_Flags = 0;
m_isHeightLocked = false;
m_isWidthLocked = false;
}
@ -335,11 +321,11 @@ void LIB_RECTANGLE::EndEdit( const wxPoint& aPosition, bool aAbort )
void LIB_RECTANGLE::CalcEdit( const wxPoint& aPosition )
{
if( m_Flags == IS_NEW )
if( IsNew() )
{
m_End = aPosition;
}
else if( m_Flags == IS_RESIZED )
else if( IsResized() )
{
if( m_isHeightLocked )
{
@ -363,7 +349,7 @@ void LIB_RECTANGLE::CalcEdit( const wxPoint& aPosition )
m_End = aPosition;
}
}
else if( m_Flags == IS_MOVED )
else if( IsMoving() )
{
Move( m_initialPos + aPosition - m_initialCursorPos );
}

View File

@ -44,8 +44,6 @@ class LIB_RECTANGLE : public LIB_ITEM
void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData,
const TRANSFORM& aTransform ) override;
void CalcEdit( const wxPoint& aPosition ) override;
public:
LIB_RECTANGLE( LIB_PART * aParent );
@ -73,9 +71,9 @@ public:
void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override;
void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) ) override;
bool ContinueEdit( const wxPoint aNextPoint ) override;
void EndEdit( const wxPoint& aPosition, bool aAbort = false ) override;
void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint ) override;
void CalcEdit( const wxPoint& aPosition ) override;
void EndEdit( const wxPoint& aPosition ) override;
void SetOffset( const wxPoint& aOffset ) override;

View File

@ -341,8 +341,8 @@ BITMAP_DEF LIB_TEXT::GetMenuImage() const
void LIB_TEXT::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
{
wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED ) ) != 0,
wxT( "Invalid edit mode for LIB_TEXT object." ) );
// JEY TODO: this should all move to modern toolset....
LIB_ITEM::BeginEdit( aEditMode, aPosition );
if( aEditMode == IS_MOVED )
{
@ -353,26 +353,14 @@ void LIB_TEXT::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
{
SetTextPos( aPosition );
}
m_Flags = aEditMode;
}
bool LIB_TEXT::ContinueEdit( const wxPoint aPosition )
void LIB_TEXT::EndEdit( const wxPoint& aPosition )
{
wxCHECK_MSG( ( m_Flags & ( IS_NEW | IS_MOVED ) ) != 0, false,
wxT( "Bad call to ContinueEdit(). Text is not being edited." ) );
// JEY TODO: this should all move to modern toolset....
LIB_ITEM::EndEdit( aPosition );
return false;
}
void LIB_TEXT::EndEdit( const wxPoint& aPosition, bool aAbort )
{
wxCHECK_RET( ( m_Flags & ( IS_NEW | IS_MOVED ) ) != 0,
wxT( "Bad call to EndEdit(). Text is not being edited." ) );
m_Flags = 0;
m_rotate = false;
m_updateText = false;
}
@ -380,6 +368,7 @@ void LIB_TEXT::EndEdit( const wxPoint& aPosition, bool aAbort )
void LIB_TEXT::CalcEdit( const wxPoint& aPosition )
{
// JEY TODO: this should all move to modern toolset....
DBG(printf("textCalcEdit %d %d\n", aPosition.x, aPosition.y );)
if( m_rotate )
@ -394,11 +383,11 @@ void LIB_TEXT::CalcEdit( const wxPoint& aPosition )
m_updateText = false;
}
if( m_Flags == IS_NEW )
if( IsNew() )
{
SetTextPos( aPosition );
}
else if( m_Flags == IS_MOVED )
else if( IsMoving() )
{
Move( m_initialPos + aPosition - m_initialCursorPos );
DBG(printf("%p: move %d %d\n", this, GetPosition().x, GetPosition().y );)

View File

@ -50,8 +50,6 @@ class LIB_TEXT : public LIB_ITEM, public EDA_TEXT
void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData,
const TRANSFORM& aTransform ) override;
void CalcEdit( const wxPoint& aPosition ) override;
public:
LIB_TEXT( LIB_PART * aParent );
@ -99,11 +97,9 @@ public:
void Rotate() override;
void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) ) override;
bool ContinueEdit( const wxPoint aNextPoint ) override;
void EndEdit( const wxPoint& aPosition, bool aAbort = false ) override;
void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint ) override;
void CalcEdit( const wxPoint& aPosition ) override;
void EndEdit( const wxPoint& aPosition ) override;
void SetOffset( const wxPoint& aOffset ) override;

View File

@ -74,21 +74,19 @@
#include <sch_view.h>
#include <sch_painter.h>
int LIB_EDIT_FRAME:: m_unit = 1;
int LIB_EDIT_FRAME:: m_convert = 1;
LIB_ITEM* LIB_EDIT_FRAME:: m_lastDrawItem = NULL;
bool LIB_EDIT_FRAME:: m_showDeMorgan = false;
int LIB_EDIT_FRAME:: g_LastTextSize = -1;
double LIB_EDIT_FRAME:: g_LastTextAngle = TEXT_ANGLE_HORIZ;
int LIB_EDIT_FRAME:: m_drawLineWidth = 0;
int LIB_EDIT_FRAME:: g_LastLineWidth = 0;
// these values are overridden when reading the config
int LIB_EDIT_FRAME:: m_textPinNumDefaultSize = DEFAULTPINNUMSIZE;
int LIB_EDIT_FRAME:: m_textPinNameDefaultSize = DEFAULTPINNAMESIZE;
int LIB_EDIT_FRAME:: m_defaultPinLength = DEFAULTPINLENGTH;
FILL_T LIB_EDIT_FRAME:: m_drawFillStyle = NO_FILL;
FILL_T LIB_EDIT_FRAME:: g_LastFillStyle = NO_FILL;
BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
@ -218,6 +216,8 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
m_tempCopyComponent = NULL;
m_treePane = nullptr;
m_libMgr = nullptr;
m_unit = 1;
m_convert = 1;
// Delayed initialization
if( g_LastTextSize == -1 )
@ -681,7 +681,6 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_COPY_BLOCK:
case wxID_CUT:
case ID_POPUP_CUT_BLOCK:
case ID_POPUP_LIBEDIT_END_CREATE_ITEM:
case ID_LIBEDIT_EDIT_PIN:
case ID_POPUP_LIBEDIT_BODY_EDIT_ITEM:
case ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM:
@ -725,14 +724,6 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
m_syncPinEdit = m_mainToolBar->GetToolToggled( ID_LIBEDIT_SYNC_PIN_EDIT );
break;
case ID_POPUP_LIBEDIT_END_CREATE_ITEM:
m_canvas->MoveCursorToCrossHair();
if( item )
EndDrawGraphicItem( nullptr );
break;
case ID_POPUP_LIBEDIT_BODY_EDIT_ITEM:
if( item )
{
@ -1099,6 +1090,10 @@ void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
case ID_LIBEDIT_PIN_BUTT:
case ID_LIBEDIT_BODY_TEXT_BUTT:
case ID_LIBEDIT_ANCHOR_ITEM_BUTT:
case ID_LIBEDIT_BODY_RECT_BUTT:
case ID_LIBEDIT_BODY_CIRCLE_BUTT:
case ID_LIBEDIT_BODY_ARC_BUTT:
case ID_LIBEDIT_BODY_LINE_BUTT:
// moved to modern toolset
return;
default:
@ -1109,22 +1104,6 @@ void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
switch( id )
{
case ID_LIBEDIT_BODY_RECT_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add rectangle" ) );
break;
case ID_LIBEDIT_BODY_CIRCLE_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add circle" ) );
break;
case ID_LIBEDIT_BODY_ARC_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add arc" ) );
break;
case ID_LIBEDIT_BODY_LINE_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add line" ) );
break;
case ID_LIBEDIT_IMPORT_BODY_BUTT:
SetToolID( id, GetGalCanvas()->GetDefaultCursor(), _( "Import" ) );
LoadOneSymbol();

View File

@ -83,20 +83,14 @@ class LIB_EDIT_FRAME : public SCH_BASE_FRAME
*/
bool m_showPinElectricalTypeName;
/** The current draw or edit graphic item fill style. */
static FILL_T m_drawFillStyle;
/** Default line width for drawing or editing graphic items. */
static int m_drawLineWidth;
static LIB_ITEM* m_lastDrawItem;
// The unit number to edit and show
static int m_unit;
int m_unit;
// Show the normal shape ( m_convert <= 1 ) or the converted shape
// ( m_convert > 1 )
static int m_convert;
int m_convert;
// true to force DeMorgan/normal tools selection enabled.
// They are enabled when the loaded component has
@ -133,6 +127,8 @@ public:
static int g_LastTextSize;
static double g_LastTextAngle;
static FILL_T g_LastFillStyle;
static int g_LastLineWidth;
public:
LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent );
@ -407,7 +403,7 @@ public:
bool GetShowElectricalType() { return m_showPinElectricalTypeName; }
void SetShowElectricalType( bool aShow ) { m_showPinElectricalTypeName = aShow; }
FILL_T GetFillStyle() { return m_drawFillStyle; }
FILL_T GetFillStyle() { return g_LastFillStyle; }
/**
* Create a temporary copy of the current edited component.
@ -539,9 +535,6 @@ private:
void GetComponentFromUndoList( wxCommandEvent& event );
void GetComponentFromRedoList( wxCommandEvent& event );
// Editing pins
void CreatePin( wxDC* DC );
/**
* Prepare the displacement of a pin
*
@ -556,20 +549,9 @@ private:
*/
void CreateImagePins( LIB_PIN* aPin );
/**
* Places an anchor reference coordinate for the current component.
* <p>
* All object coordinates are offset to the current cursor position.
* </p>
*/
void PlaceAnchor();
// Editing graphic items
LIB_ITEM* CreateGraphicItem( LIB_PART* LibEntry, wxDC* DC );
void GraphicItemBeginDraw( wxDC* DC );
void StartMoveDrawSymbol( wxDC* DC, LIB_ITEM* aItem );
void StartModifyDrawSymbol( wxDC* DC, LIB_ITEM* aItem ); //<! Modify the item, adjust size etc.
void EndDrawGraphicItem( wxDC* DC );
/**
* Read a component symbol file (*.sym ) and add graphic items to the current component.

View File

@ -58,35 +58,6 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
break;
case ID_NO_TOOL_SELECTED:
// If an item is currently in edit, finish edit
if( item_in_edit )
{
switch( item->Type() )
{
case LIB_PIN_T:
PlacePin();
break;
default:
EndDrawGraphicItem( DC );
break;
}
}
break;
case ID_LIBEDIT_BODY_LINE_BUTT:
case ID_LIBEDIT_BODY_ARC_BUTT:
case ID_LIBEDIT_BODY_CIRCLE_BUTT:
case ID_LIBEDIT_BODY_RECT_BUTT:
if( no_item_edited )
SetDrawItem( CreateGraphicItem( part, DC ) );
else if( item )
{
if( item->IsNew() )
GraphicItemBeginDraw( DC );
else
EndDrawGraphicItem( DC );
}
break;
case ID_LIBEDIT_DELETE_ITEM_BUTT:
@ -99,6 +70,10 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
case ID_LIBEDIT_BODY_TEXT_BUTT:
case ID_LIBEDIT_ANCHOR_ITEM_BUTT:
case ID_LIBEDIT_PIN_BUTT:
case ID_LIBEDIT_BODY_LINE_BUTT:
case ID_LIBEDIT_BODY_ARC_BUTT:
case ID_LIBEDIT_BODY_CIRCLE_BUTT:
case ID_LIBEDIT_BODY_RECT_BUTT:
// Moved to modern toolset
break;
@ -167,15 +142,9 @@ void LIB_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& aPosition )
case LIB_ARC_T:
case LIB_CIRCLE_T:
case LIB_RECTANGLE_T:
if( not_edited )
EditGraphicSymbol( DC, item );
break;
case LIB_POLYLINE_T:
if( not_edited )
EditGraphicSymbol( DC, item );
else if( item->IsNew() )
EndDrawGraphicItem( DC );
break;
case LIB_TEXT_T:

View File

@ -225,8 +225,8 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
if( item->IsNew() )
{
AddMenuItem( PopMenu, ID_POPUP_LIBEDIT_END_CREATE_ITEM, _( "Line End" ),
KiBitmap( checked_ok_xpm ) );
// AddMenuItem( PopMenu, ID_POPUP_LIBEDIT_END_CREATE_ITEM, _( "Line End" ),
// KiBitmap( checked_ok_xpm ) );
}
msg = AddHotkeyName( _( "Edit Line Options..." ), g_Libedit_Hotkeys_Descr, HK_EDIT );

View File

@ -62,20 +62,10 @@ void LIB_EDIT_FRAME::EditGraphicSymbol( wxDC* DC, LIB_ITEM* DrawItem )
return;
// Init default values (used to create a new draw item)
m_drawLineWidth = dialog.GetWidth();
g_LastLineWidth = dialog.GetWidth();
m_DrawSpecificConvert = !dialog.GetApplyToAllConversions();
m_DrawSpecificUnit = !dialog.GetApplyToAllUnits();
#if 0
/* TODO: see if m_drawFillStyle must retain the last fill option or not.
* if the last is Filled, having next new graphic items created
* with filled body is often bad.
* currently m_drawFillStyle is left with the default value (not filled)
*/
if( DrawItem->IsFillable() )
m_drawFillStyle = (FILL_T) dialog.GetFillStyle();
#endif
// Save copy for undo if not in edit (edit command already handle the save copy)
if( !DrawItem->InEditMode() )
SaveCopyInUndoList( DrawItem->GetParent() );
@ -93,7 +83,7 @@ void LIB_EDIT_FRAME::EditGraphicSymbol( wxDC* DC, LIB_ITEM* DrawItem )
if( DrawItem->IsFillable() )
DrawItem->SetFillMode( (FILL_T) dialog.GetFillStyle() );
DrawItem->SetWidth( m_drawLineWidth );
DrawItem->SetWidth( g_LastLineWidth );
GetCanvas()->GetView()->Update( DrawItem );
GetCanvas()->Refresh();
@ -114,7 +104,7 @@ static void AbortSymbolTraceOn( EDA_DRAW_PANEL* aPanel, wxDC* DC )
return;
bool newItem = item->IsNew();
item->EndEdit( parent->GetCrossHairPosition( true ), true );
item->EndEdit( parent->GetCrossHairPosition( true ) );
if( newItem )
delete item;
@ -131,98 +121,6 @@ static void AbortSymbolTraceOn( EDA_DRAW_PANEL* aPanel, wxDC* DC )
}
LIB_ITEM* LIB_EDIT_FRAME::CreateGraphicItem( LIB_PART* LibEntry, wxDC* DC )
{
LIB_ITEM* item = GetDrawItem();
m_canvas->SetMouseCapture( RedrawWhileMovingCursor, AbortSymbolTraceOn );
wxPoint drawPos = GetCrossHairPosition( true );
// no temp copy -> the current version of symbol will be used for Undo
// This is normal when adding new items to the current symbol
ClearTempCopyComponent();
auto view = static_cast<SCH_DRAW_PANEL*>(m_canvas)->GetView();
view->ShowPreview( true );
switch( GetToolId() )
{
case ID_LIBEDIT_BODY_ARC_BUTT:
item = new LIB_ARC( LibEntry );
break;
case ID_LIBEDIT_BODY_CIRCLE_BUTT:
item = new LIB_CIRCLE( LibEntry );
break;
case ID_LIBEDIT_BODY_RECT_BUTT:
item = new LIB_RECTANGLE( LibEntry );
break;
case ID_LIBEDIT_BODY_LINE_BUTT:
item = new LIB_POLYLINE( LibEntry );
break;
case ID_LIBEDIT_BODY_TEXT_BUTT:
// Moved to modern toolset
break;
default:
DisplayError( this, wxT( "LIB_EDIT_FRAME::CreateGraphicItem() error" ) );
return NULL;
}
if( item )
{
item->BeginEdit( IS_NEW, drawPos );
// Don't set line parameters for text objects.
if( item->Type() != LIB_TEXT_T )
{
item->SetWidth( m_drawLineWidth );
item->SetFillMode( m_drawFillStyle );
}
if( m_DrawSpecificUnit )
item->SetUnit( m_unit );
if( m_DrawSpecificConvert )
item->SetConvert( m_convert );
// Draw initial symbol:
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
}
else
{
m_canvas->EndMouseCapture();
return NULL;
}
m_canvas->MoveCursorToCrossHair();
m_canvas->SetIgnoreMouseEvents( false );
SetDrawItem( item );
return item;
}
void LIB_EDIT_FRAME::GraphicItemBeginDraw( wxDC* DC )
{
if( GetDrawItem() == NULL )
return;
wxPoint pos = GetCrossHairPosition( true );
auto view = static_cast<SCH_DRAW_PANEL*>(m_canvas)->GetView();
view->ShowPreview( true );
if( GetDrawItem()->ContinueEdit( pos ) )
return;
EndDrawGraphicItem( DC );
}
/*
* Redraw the graphic shape while moving
*/
@ -280,50 +178,3 @@ void LIB_EDIT_FRAME::StartModifyDrawSymbol( wxDC* DC, LIB_ITEM* aItem )
m_canvas->SetMouseCapture( RedrawWhileMovingCursor, AbortSymbolTraceOn );
m_canvas->CallMouseCapture( DC, wxDefaultPosition, true );
}
void LIB_EDIT_FRAME::EndDrawGraphicItem( wxDC* DC )
{
LIB_ITEM* item = GetDrawItem();
if( item == NULL )
return;
if( LIB_PART* part = GetCurPart() )
{
if( GetToolId() != ID_NO_TOOL_SELECTED )
SetCursor( wxCURSOR_PENCIL );
else
SetCursor( (wxStockCursor) GetGalCanvas()->GetDefaultCursor() );
if( GetTempCopyComponent() ) // used when editing an existing item
SaveCopyInUndoList( GetTempCopyComponent() );
else
{
// When creating a new item, there is still no change for the
// current symbol. So save it.
SaveCopyInUndoList( part );
}
if( item->IsNew() )
part->AddDrawItem( item );
item->EndEdit( GetCrossHairPosition( true ) );
SetDrawItem( NULL );
m_canvas->SetMouseCapture( NULL, NULL );
auto view = static_cast<SCH_DRAW_PANEL*>(m_canvas)->GetView();
DBG(printf("end: pos %d %d\n", item->GetPosition().x, item->GetPosition().y );)
view->ClearHiddenFlags();
view->ClearPreview();
OnModify();
}
RebuildView();
GetCanvas()->Refresh();
}

View File

@ -41,6 +41,10 @@
#include <bitmaps.h>
#include <lib_text.h>
#include <dialogs/dialog_lib_edit_text.h>
#include <lib_arc.h>
#include <lib_circle.h>
#include <lib_polyline.h>
#include <lib_rectangle.h>
// Drawing tool actions
TOOL_ACTION SCH_ACTIONS::placeSymbolPin( "libedit.InteractiveDrawing.placeSymbolPin",
@ -78,6 +82,10 @@ TOOL_ACTION SCH_ACTIONS::placeSymbolAnchor( "libedit.InteractiveDrawing.placeSym
_( "Move Symbol Anchor" ), _( "Specify a new location for the symbol anchor" ),
anchor_xpm, AF_ACTIVATE );
TOOL_ACTION SCH_ACTIONS::finishDrawing( "libedit.InteractiveDrawing.finishDrawing",
AS_GLOBAL, 0, _( "Finish Drawing" ), _( "Finish drawing shape" ),
checked_ok_xpm, AF_NONE );
LIB_DRAWING_TOOLS::LIB_DRAWING_TOOLS() :
TOOL_INTERACTIVE( "libedit.InteractiveDrawing" ),
@ -100,8 +108,9 @@ bool LIB_DRAWING_TOOLS::Init()
m_frame = getEditFrame<LIB_EDIT_FRAME>();
m_selectionTool = m_toolMgr->GetTool<SCH_SELECTION_TOOL>();
auto activeTool = [ this ] ( const SELECTION& aSel ) {
return ( m_frame->GetToolId() != ID_NO_TOOL_SELECTED );
auto isDrawingCondition = [] ( const SELECTION& aSel ) {
LIB_ITEM* item = (LIB_ITEM*) aSel.Front();
return item && item->IsNew();
};
auto& ctxMenu = m_menu.GetMenu();
@ -109,9 +118,10 @@ bool LIB_DRAWING_TOOLS::Init()
//
// Build the drawing tool menu
//
ctxMenu.AddItem( ACTIONS::cancelInteractive, activeTool, 1 );
ctxMenu.AddItem( ACTIONS::cancelInteractive, SCH_CONDITIONS::ShowAlways, 1 );
ctxMenu.AddItem( SCH_ACTIONS::finishDrawing, isDrawingCondition, 2 );
ctxMenu.AddSeparator( activeTool, 1000 );
ctxMenu.AddSeparator( SCH_CONDITIONS::ShowAlways, 1000 );
m_menu.AddStandardSubMenus( m_frame );
return true;
@ -171,6 +181,7 @@ int LIB_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType )
break;
}
else if( evt->IsClick( BUT_LEFT ) )
{
LIB_PART* part = m_frame->GetCurPart();
@ -253,20 +264,7 @@ int LIB_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType )
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
}
else if( TOOL_EVT_UTILS::IsSelectionEvent( evt.get() ) )
{
// This happens if our text was replaced out from under us by ConvertTextType()
SELECTION& selection = m_selectionTool->GetSelection();
if( selection.GetSize() == 1 )
{
item = (LIB_ITEM*) selection.Front();
m_view->ClearPreview();
m_view->AddToPreview( item->Clone() );
}
else
item = nullptr;
}
else if( item && ( evt->IsAction( &SCH_ACTIONS::refreshPreview ) || evt->IsMotion() ) )
{
static_cast<LIB_ITEM*>( item )->SetPosition( wxPoint( cursorPos.x, -cursorPos.y) );
@ -285,6 +283,129 @@ int LIB_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType )
}
int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
{
if( aEvent.IsAction( &SCH_ACTIONS::drawSymbolArc ) )
m_frame->SetToolID( ID_LIBEDIT_BODY_ARC_BUTT, wxCURSOR_PENCIL, _( "Draw Arc" ) );
else if( aEvent.IsAction( &SCH_ACTIONS::drawSymbolCircle ) )
m_frame->SetToolID( ID_LIBEDIT_BODY_CIRCLE_BUTT, wxCURSOR_PENCIL, _( "Draw Circle" ) );
else if( aEvent.IsAction( &SCH_ACTIONS::drawSymbolLines ) )
m_frame->SetToolID( ID_LIBEDIT_BODY_LINE_BUTT, wxCURSOR_PENCIL, _( "Draw Lines" ) );
else if( aEvent.IsAction( &SCH_ACTIONS::drawSymbolRectangle ) )
m_frame->SetToolID( ID_LIBEDIT_BODY_RECT_BUTT, wxCURSOR_PENCIL, _( "Draw Rectangle" ) );
m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true );
m_controls->ShowCursor( true );
Activate();
LIB_PART* part = m_frame->GetCurPart();
LIB_ITEM* item = nullptr;
// Main loop: keep receiving events
while( auto evt = Wait() )
{
VECTOR2I cursorPos = m_controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) )
{
m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true );
m_view->ClearPreview();
if( item )
{
delete item;
item = nullptr;
if( !evt->IsActivate() )
continue;
}
break;
}
else if( evt->IsClick( BUT_LEFT ) && !item )
{
if( !part )
continue;
switch( m_frame->GetToolId() )
{
case ID_LIBEDIT_BODY_ARC_BUTT: item = new LIB_ARC( part ); break;
case ID_LIBEDIT_BODY_CIRCLE_BUTT: item = new LIB_CIRCLE( part ); break;
case ID_LIBEDIT_BODY_LINE_BUTT: item = new LIB_POLYLINE( part ); break;
case ID_LIBEDIT_BODY_RECT_BUTT: item = new LIB_RECTANGLE( part ); break;
default: wxFAIL_MSG( "LIB_DRAWING_TOOLS:DrawShape(): unknown tool" );
}
item->SetWidth( LIB_EDIT_FRAME::g_LastLineWidth );
item->SetFillMode( LIB_EDIT_FRAME::g_LastFillStyle );
item->BeginEdit( IS_NEW, wxPoint( cursorPos.x, -cursorPos.y ) );
if( m_frame->m_DrawSpecificUnit )
item->SetUnit( m_frame->GetUnit() );
if( m_frame->m_DrawSpecificConvert )
item->SetConvert( m_frame->GetConvert() );
m_selectionTool->AddItemToSel( item );
}
else if( item && ( evt->IsClick( BUT_LEFT )
|| evt->IsDblClick( BUT_LEFT )
|| evt->IsAction( &SCH_ACTIONS::finishDrawing ) ) )
{
if( evt->IsDblClick()
|| evt->IsAction( &SCH_ACTIONS::finishDrawing )
|| !item->ContinueEdit( wxPoint( cursorPos.x, -cursorPos.y ) ) )
{
item->EndEdit( wxPoint( cursorPos.x, -cursorPos.y ) );
m_view->ClearPreview();
m_frame->SaveCopyInUndoList( part );
part->AddDrawItem( item );
item = nullptr;
m_frame->RebuildView();
m_frame->OnModify();
}
}
else if( item && ( evt->IsAction( &SCH_ACTIONS::refreshPreview )
|| evt->IsMotion() ) )
{
item->CalcEdit( wxPoint( cursorPos.x, -cursorPos.y) );
m_view->ClearPreview();
m_view->AddToPreview( item->Clone() );
}
else if( evt->IsDblClick( BUT_LEFT ) && !item )
{
// JEY TODO: handle edit action...
// This will need to be a RunAction() as the user might have double-clicked
// a text or pin or something
}
else if( evt->IsClick( BUT_RIGHT ) )
{
// Warp after context menu only if dragging...
if( !item )
m_toolMgr->VetoContextMenuMouseWarp();
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
}
// Enable autopanning and cursor capture only when there is a shape being drawn
m_controls->SetAutoPan( !!item );
m_controls->CaptureCursor( !!item );
}
m_frame->SetNoToolSelected();
return 0;
}
int LIB_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent )
{
m_frame->SetToolID( ID_LIBEDIT_ANCHOR_ITEM_BUTT, wxCURSOR_PENCIL, _( "Move symbol anchor" ) );
@ -339,9 +460,9 @@ void LIB_DRAWING_TOOLS::setTransitions()
{
Go( &LIB_DRAWING_TOOLS::PlacePin, SCH_ACTIONS::placeSymbolPin.MakeEvent() );
Go( &LIB_DRAWING_TOOLS::PlaceText, SCH_ACTIONS::placeSymbolText.MakeEvent() );
// Go( &LIB_DRAWING_TOOLS::DrawRectangle, SCH_ACTIONS::drawSymbolRectangle.MakeEvent() );
// Go( &LIB_DRAWING_TOOLS::DrawCircle, SCH_ACTIONS::drawSymbolCircle.MakeEvent() );
// Go( &LIB_DRAWING_TOOLS::DrawArc, SCH_ACTIONS::drawSymbolArc.MakeEvent() );
// Go( &LIB_DRAWING_TOOLS::DrawLines, SCH_ACTIONS::drawSymbolLines.MakeEvent() );
Go( &LIB_DRAWING_TOOLS::DrawShape, SCH_ACTIONS::drawSymbolRectangle.MakeEvent() );
Go( &LIB_DRAWING_TOOLS::DrawShape, SCH_ACTIONS::drawSymbolCircle.MakeEvent() );
Go( &LIB_DRAWING_TOOLS::DrawShape, SCH_ACTIONS::drawSymbolArc.MakeEvent() );
Go( &LIB_DRAWING_TOOLS::DrawShape, SCH_ACTIONS::drawSymbolLines.MakeEvent() );
Go( &LIB_DRAWING_TOOLS::PlaceAnchor, SCH_ACTIONS::placeSymbolAnchor.MakeEvent() );
}

View File

@ -57,20 +57,13 @@ public:
int PlacePin( const TOOL_EVENT& aEvent );
int PlaceText( const TOOL_EVENT& aEvent );
int DrawRectangle( const TOOL_EVENT& aEvent );
int DrawCircle( const TOOL_EVENT& aEvent );
int DrawArc( const TOOL_EVENT& aEvent );
int DrawLines( const TOOL_EVENT& aEvent );
int DrawShape( const TOOL_EVENT& aEvent );
int PlaceAnchor( const TOOL_EVENT& aEvent );
private:
void createPin();
int doTwoClickPlace( KICAD_T aType );
int doSingleClickPlace( KICAD_T aType );
///> Sets up handlers for various events.
void setTransitions() override;

View File

@ -222,6 +222,18 @@ OPT<TOOL_EVENT> SCH_ACTIONS::TranslateLegacyId( int aId )
case ID_LIBEDIT_ANCHOR_ITEM_BUTT:
return SCH_ACTIONS::placeSymbolAnchor.MakeEvent();
case ID_LIBEDIT_BODY_ARC_BUTT:
return SCH_ACTIONS::drawSymbolArc.MakeEvent();
case ID_LIBEDIT_BODY_CIRCLE_BUTT:
return SCH_ACTIONS::drawSymbolCircle.MakeEvent();
case ID_LIBEDIT_BODY_LINE_BUTT:
return SCH_ACTIONS::drawSymbolLines.MakeEvent();
case ID_LIBEDIT_BODY_RECT_BUTT:
return SCH_ACTIONS::drawSymbolRectangle.MakeEvent();
}
return OPT<TOOL_EVENT>();

View File

@ -111,6 +111,7 @@ public:
static TOOL_ACTION drawSymbolArc;
static TOOL_ACTION drawSymbolLines;
static TOOL_ACTION placeSymbolAnchor;
static TOOL_ACTION finishDrawing;
// Editing
static TOOL_ACTION move;

View File

@ -161,10 +161,6 @@ bool SCH_DRAWING_TOOLS::Init()
m_frame = getEditFrame<SCH_EDIT_FRAME>();
m_selectionTool = m_toolMgr->GetTool<SCH_SELECTION_TOOL>();
auto activeTool = [ this ] ( const SELECTION& aSel ) {
return ( m_frame->GetToolId() != ID_NO_TOOL_SELECTED );
};
auto belowRootSheetCondition = [] ( const SELECTION& aSel ) {
return g_CurrentSheet->Last() != g_RootSheet;
};
@ -174,10 +170,10 @@ bool SCH_DRAWING_TOOLS::Init()
//
// Build the drawing tool menu
//
ctxMenu.AddItem( ACTIONS::cancelInteractive, activeTool, 1 );
ctxMenu.AddItem( SCH_ACTIONS::leaveSheet, belowRootSheetCondition, 1 );
ctxMenu.AddItem( ACTIONS::cancelInteractive, SCH_CONDITIONS::ShowAlways, 1 );
ctxMenu.AddItem( SCH_ACTIONS::leaveSheet, belowRootSheetCondition, 2 );
ctxMenu.AddSeparator( activeTool, 1000 );
ctxMenu.AddSeparator( SCH_CONDITIONS::ShowAlways, 1000 );
m_menu.AddStandardSubMenus( m_frame );
return true;
@ -359,7 +355,8 @@ int SCH_DRAWING_TOOLS::doPlaceComponent( SCH_COMPONENT* aComponent, SCHLIB_FILTE
}
}
}
else if( aComponent && ( evt->IsAction( &SCH_ACTIONS::refreshPreview ) || evt->IsMotion() ) )
else if( aComponent && ( evt->IsAction( &SCH_ACTIONS::refreshPreview )
|| evt->IsMotion() ) )
{
aComponent->SetPosition( (wxPoint)cursorPos );
m_view->ClearPreview();
@ -476,7 +473,8 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
}
else if( image && ( evt->IsAction( &SCH_ACTIONS::refreshPreview ) || evt->IsMotion() ) )
else if( image && ( evt->IsAction( &SCH_ACTIONS::refreshPreview )
|| evt->IsMotion() ) )
{
image->SetPosition( (wxPoint)cursorPos );
m_view->ClearPreview();
@ -747,7 +745,8 @@ int SCH_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType )
else
item = nullptr;
}
else if( item && ( evt->IsAction( &SCH_ACTIONS::refreshPreview ) || evt->IsMotion() ) )
else if( item && ( evt->IsAction( &SCH_ACTIONS::refreshPreview )
|| evt->IsMotion() ) )
{
static_cast<SCH_ITEM*>( item )->SetPosition( (wxPoint)cursorPos );
m_view->ClearPreview();
@ -834,9 +833,8 @@ int SCH_DRAWING_TOOLS::doDrawSheet( SCH_SHEET *aSheet )
break;
}
else if( evt->IsClick( BUT_LEFT ) || evt->IsAction( &SCH_ACTIONS::finishSheet ) )
{
if( !aSheet && !evt->IsAction( &SCH_ACTIONS::finishSheet ) )
else if( evt->IsClick( BUT_LEFT ) && !aSheet )
{
aSheet = new SCH_SHEET( (wxPoint) cursorPos );
aSheet->SetFlags( IS_NEW | IS_RESIZED );
@ -851,7 +849,9 @@ int SCH_DRAWING_TOOLS::doDrawSheet( SCH_SHEET *aSheet )
m_view->ClearPreview();
m_view->AddToPreview( aSheet->Clone() );
}
else if( aSheet )
else if( aSheet && ( evt->IsClick( BUT_LEFT )
|| evt->IsAction( &SCH_ACTIONS::finishSheet ) ) )
{
m_view->ClearPreview();
@ -874,17 +874,15 @@ int SCH_DRAWING_TOOLS::doDrawSheet( SCH_SHEET *aSheet )
if( m_frame->GetToolId() == ID_SCH_RESIZE_SHEET )
break; // resize sheet is a single-shot command; when we're done we're done
}
}
else if( evt->IsMotion() )
{
m_view->ClearPreview();
if( aSheet )
else if( aSheet && ( evt->IsAction( &SCH_ACTIONS::refreshPreview )
|| evt->IsMotion() ) )
{
sizeSheet( aSheet, cursorPos );
m_view->ClearPreview();
m_view->AddToPreview( aSheet->Clone() );
}
}
else if( evt->IsClick( BUT_RIGHT ) )
{
// Warp after context menu only if dragging...

View File

@ -137,10 +137,9 @@ bool SCH_EDITOR_CONTROL::Init()
auto& ctxMenu = m_menu.GetMenu();
// "Cancel" goes at the top of the context menu when a tool is active
ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1000 );
ctxMenu.AddSeparator( activeToolCondition, 1000 );
ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1 );
// Finally, add the standard zoom & grid items
ctxMenu.AddSeparator( activeToolCondition, 1000 );
m_menu.AddStandardSubMenus( m_frame );
return true;

View File

@ -78,10 +78,6 @@ bool SCH_MOVE_TOOL::Init()
wxASSERT_MSG( m_selectionTool, "eeshema.InteractiveSelection tool is not available" );
auto activeTool = [ this ] ( const SELECTION& aSel ) {
return ( m_frame->GetToolId() != ID_NO_TOOL_SELECTED );
};
auto moveCondition = [] ( const SELECTION& aSel ) {
if( aSel.Empty() )
return false;
@ -97,9 +93,9 @@ bool SCH_MOVE_TOOL::Init()
//
CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu();
ctxMenu.AddItem( ACTIONS::cancelInteractive, activeTool, 1 );
ctxMenu.AddItem( ACTIONS::cancelInteractive, SCH_CONDITIONS::ShowAlways, 1 );
ctxMenu.AddSeparator( SELECTION_CONDITIONS::NotEmpty, 1000 );
ctxMenu.AddSeparator( SCH_CONDITIONS::ShowAlways, 1000 );
m_menu.AddStandardSubMenus( m_frame );
//

View File

@ -233,7 +233,7 @@ bool SCH_WIRE_BUS_TOOL::Init()
// Build the tool menu
//
ctxMenu.AddItem( ACTIONS::cancelInteractive, SCH_CONDITIONS::ShowAlways, 1 );
ctxMenu.AddItem( SCH_ACTIONS::leaveSheet, belowRootSheetCondition, 1 );
ctxMenu.AddItem( SCH_ACTIONS::leaveSheet, belowRootSheetCondition, 2 );
ctxMenu.AddSeparator( SCH_CONDITIONS::ShowAlways, 10 );
ctxMenu.AddItem( SCH_ACTIONS::startWire, wireOrBusTool && SCH_CONDITIONS::Idle, 10 );