Refactoring. Push editing code to toolset.
This commit is contained in:
parent
7e7ef82f55
commit
0d8789935d
|
@ -736,21 +736,6 @@ public:
|
||||||
bool LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy,
|
bool LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy,
|
||||||
const wxString& aFileName );
|
const wxString& aFileName );
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new SCH_SHEET_PIN object and add it to \a aSheet at the current cursor position.
|
|
||||||
*
|
|
||||||
* @param aSheet The sheet to add the new sheet pin to.
|
|
||||||
* @return The new sheet pin object created or NULL if the task was aborted by the user.
|
|
||||||
*/
|
|
||||||
SCH_SHEET_PIN* CreateSheetPin( SCH_SHEET* aSheet, SCH_HIERLABEL* aLabel );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Import a hierarchical label with no attached sheet pin.
|
|
||||||
*
|
|
||||||
* @param aSheet The sheet to import the new sheet pin to.
|
|
||||||
*/
|
|
||||||
SCH_HIERLABEL* ImportHierLabel( SCH_SHEET* aSheet );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a given junction and heals any wire segments under the junction
|
* Removes a given junction and heals any wire segments under the junction
|
||||||
*
|
*
|
||||||
|
|
|
@ -38,7 +38,6 @@
|
||||||
#include <schematic.h>
|
#include <schematic.h>
|
||||||
#include <symbol_lib_table.h>
|
#include <symbol_lib_table.h>
|
||||||
#include <dialogs/dialog_sheet_properties.h>
|
#include <dialogs/dialog_sheet_properties.h>
|
||||||
#include <dialogs/dialog_sheet_pin_properties.h>
|
|
||||||
#include <tool/actions.h>
|
#include <tool/actions.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -476,63 +475,6 @@ bool SCH_EDIT_FRAME::EditSheetProperties( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PINSHEETLABEL_SHAPE SCH_EDIT_FRAME::m_lastSheetPinType = PINSHEETLABEL_SHAPE::PS_INPUT;
|
|
||||||
|
|
||||||
|
|
||||||
SCH_SHEET_PIN* SCH_EDIT_FRAME::CreateSheetPin( SCH_SHEET* aSheet, SCH_HIERLABEL* aLabel )
|
|
||||||
{
|
|
||||||
SCHEMATIC_SETTINGS& settings = aSheet->Schematic()->Settings();
|
|
||||||
wxString text;
|
|
||||||
SCH_SHEET_PIN* sheetPin;
|
|
||||||
|
|
||||||
if( aLabel )
|
|
||||||
{
|
|
||||||
text = aLabel->GetText();
|
|
||||||
m_lastSheetPinType = aLabel->GetShape();
|
|
||||||
}
|
|
||||||
|
|
||||||
sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), text );
|
|
||||||
sheetPin->SetFlags( IS_NEW );
|
|
||||||
sheetPin->SetTextSize( wxSize( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) );
|
|
||||||
sheetPin->SetShape( m_lastSheetPinType );
|
|
||||||
|
|
||||||
if( !aLabel )
|
|
||||||
{
|
|
||||||
DIALOG_SHEET_PIN_PROPERTIES dlg( this, sheetPin );
|
|
||||||
|
|
||||||
if( dlg.ShowModal() != wxID_OK || sheetPin->GetText().IsEmpty() )
|
|
||||||
{
|
|
||||||
delete sheetPin;
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_lastSheetPinType = sheetPin->GetShape();
|
|
||||||
|
|
||||||
sheetPin->SetPosition( (wxPoint) GetCanvas()->GetViewControls()->GetCursorPosition() );
|
|
||||||
|
|
||||||
return sheetPin;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SCH_HIERLABEL* SCH_EDIT_FRAME::ImportHierLabel( SCH_SHEET* aSheet )
|
|
||||||
{
|
|
||||||
if( !aSheet->GetScreen() )
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
for( auto item : aSheet->GetScreen()->Items().OfType( SCH_HIER_LABEL_T ) )
|
|
||||||
{
|
|
||||||
auto label = static_cast<SCH_HIERLABEL*>( item );
|
|
||||||
|
|
||||||
/* A global label has been found: check if there a corresponding sheet label. */
|
|
||||||
if( !aSheet->HasPin( label->GetText() ) )
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SCH_EDIT_FRAME::DrawCurrentSheetToClipboard()
|
void SCH_EDIT_FRAME::DrawCurrentSheetToClipboard()
|
||||||
{
|
{
|
||||||
wxRect DrawArea;
|
wxRect DrawArea;
|
||||||
|
|
|
@ -47,9 +47,11 @@
|
||||||
#include <dialogs/dialog_edit_label.h>
|
#include <dialogs/dialog_edit_label.h>
|
||||||
#include <dialogs/dialog_edit_line_style.h>
|
#include <dialogs/dialog_edit_line_style.h>
|
||||||
#include <dialogs/dialog_junction_props.h>
|
#include <dialogs/dialog_junction_props.h>
|
||||||
|
#include <dialogs/dialog_sheet_pin_properties.h>
|
||||||
|
|
||||||
SCH_DRAWING_TOOLS::SCH_DRAWING_TOOLS() :
|
SCH_DRAWING_TOOLS::SCH_DRAWING_TOOLS() :
|
||||||
EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveDrawing" ),
|
EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveDrawing" ),
|
||||||
|
m_lastSheetPinType( PINSHEETLABEL_SHAPE::PS_INPUT ),
|
||||||
m_lastGlobalLabelShape( PINSHEETLABEL_SHAPE::PS_INPUT ),
|
m_lastGlobalLabelShape( PINSHEETLABEL_SHAPE::PS_INPUT ),
|
||||||
m_lastTextOrientation( LABEL_SPIN_STYLE::LEFT ),
|
m_lastTextOrientation( LABEL_SPIN_STYLE::LEFT ),
|
||||||
m_lastTextBold( false ),
|
m_lastTextBold( false ),
|
||||||
|
@ -722,6 +724,60 @@ SCH_TEXT* SCH_DRAWING_TOOLS::createNewText( const VECTOR2I& aPosition, int aType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SCH_HIERLABEL* SCH_DRAWING_TOOLS::importHierLabel( SCH_SHEET* aSheet )
|
||||||
|
{
|
||||||
|
if( !aSheet->GetScreen() )
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
for( EDA_ITEM* item : aSheet->GetScreen()->Items().OfType( SCH_HIER_LABEL_T ) )
|
||||||
|
{
|
||||||
|
SCH_HIERLABEL* label = static_cast<SCH_HIERLABEL*>( item );
|
||||||
|
|
||||||
|
/* A global label has been found: check if there a corresponding sheet label. */
|
||||||
|
if( !aSheet->HasPin( label->GetText() ) )
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SCH_SHEET_PIN* SCH_DRAWING_TOOLS::createSheetPin( SCH_SHEET* aSheet, SCH_HIERLABEL* aLabel )
|
||||||
|
{
|
||||||
|
SCHEMATIC_SETTINGS& settings = aSheet->Schematic()->Settings();
|
||||||
|
wxString text;
|
||||||
|
SCH_SHEET_PIN* sheetPin;
|
||||||
|
|
||||||
|
if( aLabel )
|
||||||
|
{
|
||||||
|
text = aLabel->GetText();
|
||||||
|
m_lastSheetPinType = aLabel->GetShape();
|
||||||
|
}
|
||||||
|
|
||||||
|
sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), text );
|
||||||
|
sheetPin->SetFlags( IS_NEW );
|
||||||
|
sheetPin->SetTextSize( wxSize( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) );
|
||||||
|
sheetPin->SetShape( m_lastSheetPinType );
|
||||||
|
|
||||||
|
if( !aLabel )
|
||||||
|
{
|
||||||
|
DIALOG_SHEET_PIN_PROPERTIES dlg( m_frame, sheetPin );
|
||||||
|
|
||||||
|
if( dlg.ShowModal() != wxID_OK || sheetPin->GetText().IsEmpty() )
|
||||||
|
{
|
||||||
|
delete sheetPin;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_lastSheetPinType = sheetPin->GetShape();
|
||||||
|
|
||||||
|
sheetPin->SetPosition( (wxPoint) getViewControls()->GetCursorPosition() );
|
||||||
|
|
||||||
|
return sheetPin;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
EDA_ITEM* item = nullptr;
|
EDA_ITEM* item = nullptr;
|
||||||
|
@ -849,7 +905,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
if( isImportMode )
|
if( isImportMode )
|
||||||
{
|
{
|
||||||
label = m_frame->ImportHierLabel( sheet );
|
label = importHierLabel( sheet );
|
||||||
|
|
||||||
if( !label )
|
if( !label )
|
||||||
{
|
{
|
||||||
|
@ -861,7 +917,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
item = m_frame->CreateSheetPin( sheet, label );
|
item = createSheetPin( sheet, label );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -65,6 +65,10 @@ private:
|
||||||
*/
|
*/
|
||||||
SCH_TEXT* createNewText( const VECTOR2I& aPosition, int aType );
|
SCH_TEXT* createNewText( const VECTOR2I& aPosition, int aType );
|
||||||
|
|
||||||
|
SCH_HIERLABEL* importHierLabel( SCH_SHEET* aSheet );
|
||||||
|
|
||||||
|
SCH_SHEET_PIN* createSheetPin( SCH_SHEET* aSheet, SCH_HIERLABEL* aLabel );
|
||||||
|
|
||||||
void sizeSheet( SCH_SHEET* aSheet, VECTOR2I aPos );
|
void sizeSheet( SCH_SHEET* aSheet, VECTOR2I aPos );
|
||||||
|
|
||||||
///> Sets up handlers for various events.
|
///> Sets up handlers for various events.
|
||||||
|
@ -75,6 +79,7 @@ private:
|
||||||
std::vector<COMPONENT_SELECTION> m_symbolHistoryList;
|
std::vector<COMPONENT_SELECTION> m_symbolHistoryList;
|
||||||
std::vector<COMPONENT_SELECTION> m_powerHistoryList;
|
std::vector<COMPONENT_SELECTION> m_powerHistoryList;
|
||||||
|
|
||||||
|
PINSHEETLABEL_SHAPE m_lastSheetPinType;
|
||||||
PINSHEETLABEL_SHAPE m_lastGlobalLabelShape;
|
PINSHEETLABEL_SHAPE m_lastGlobalLabelShape;
|
||||||
LABEL_SPIN_STYLE m_lastTextOrientation;
|
LABEL_SPIN_STYLE m_lastTextOrientation;
|
||||||
bool m_lastTextBold;
|
bool m_lastTextBold;
|
||||||
|
|
Loading…
Reference in New Issue