Edit worksheet properties when no other selection is available.
Fixes https://gitlab.com/kicad/code/kicad/issues/4044
This commit is contained in:
parent
60cad7d526
commit
f113370e1e
|
@ -136,25 +136,33 @@ bool SCH_EDIT_TOOL::Init()
|
||||||
|
|
||||||
wxASSERT_MSG( drawingTools, "eeshema.InteractiveDrawing tool is not available" );
|
wxASSERT_MSG( drawingTools, "eeshema.InteractiveDrawing tool is not available" );
|
||||||
|
|
||||||
auto sheetTool = [ this ] ( const SELECTION& aSel ) {
|
auto sheetTool =
|
||||||
|
[ this ] ( const SELECTION& aSel )
|
||||||
|
{
|
||||||
return ( m_frame->IsCurrentTool( EE_ACTIONS::drawSheet ) );
|
return ( m_frame->IsCurrentTool( EE_ACTIONS::drawSheet ) );
|
||||||
};
|
};
|
||||||
|
|
||||||
auto anyTextTool = [ this ] ( const SELECTION& aSel ) {
|
auto anyTextTool =
|
||||||
|
[ this ] ( const SELECTION& aSel )
|
||||||
|
{
|
||||||
return ( m_frame->IsCurrentTool( EE_ACTIONS::placeLabel )
|
return ( m_frame->IsCurrentTool( EE_ACTIONS::placeLabel )
|
||||||
|| m_frame->IsCurrentTool( EE_ACTIONS::placeGlobalLabel )
|
|| m_frame->IsCurrentTool( EE_ACTIONS::placeGlobalLabel )
|
||||||
|| m_frame->IsCurrentTool( EE_ACTIONS::placeHierLabel )
|
|| m_frame->IsCurrentTool( EE_ACTIONS::placeHierLabel )
|
||||||
|| m_frame->IsCurrentTool( EE_ACTIONS::placeSchematicText ) );
|
|| m_frame->IsCurrentTool( EE_ACTIONS::placeSchematicText ) );
|
||||||
};
|
};
|
||||||
|
|
||||||
auto duplicateCondition = [] ( const SELECTION& aSel ) {
|
auto duplicateCondition =
|
||||||
|
[] ( const SELECTION& aSel )
|
||||||
|
{
|
||||||
if( SCH_LINE_WIRE_BUS_TOOL::IsDrawingLineWireOrBus( aSel ) )
|
if( SCH_LINE_WIRE_BUS_TOOL::IsDrawingLineWireOrBus( aSel ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto orientCondition = [] ( const SELECTION& aSel ) {
|
auto orientCondition =
|
||||||
|
[] ( const SELECTION& aSel )
|
||||||
|
{
|
||||||
if( aSel.Empty() )
|
if( aSel.Empty() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -179,47 +187,42 @@ bool SCH_EDIT_TOOL::Init()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
auto propertiesCondition = []( const SELECTION& aSel ) {
|
auto propertiesCondition =
|
||||||
|
[]( const SELECTION& aSel )
|
||||||
|
{
|
||||||
|
if( aSel.GetSize() == 0 )
|
||||||
|
return true; // Show worksheet properties
|
||||||
|
|
||||||
if( aSel.GetSize() != 1
|
if( aSel.GetSize() != 1
|
||||||
&& !( aSel.GetSize() >= 1 && aSel.Front()->Type() == SCH_LINE_T
|
&& !( aSel.GetSize() >= 1 && aSel.Front()->Type() == SCH_LINE_T
|
||||||
&& aSel.AreAllItemsIdentical() ) )
|
&& aSel.AreAllItemsIdentical() ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto item = static_cast<EDA_ITEM*>( aSel.Front() );
|
EDA_ITEM* item = static_cast<EDA_ITEM*>( aSel.Front() );
|
||||||
|
|
||||||
switch( item->Type() )
|
switch( item->Type() )
|
||||||
{
|
{
|
||||||
case SCH_MARKER_T:
|
case SCH_COMPONENT_T:
|
||||||
case SCH_JUNCTION_T:
|
case SCH_SHEET_T:
|
||||||
case SCH_NO_CONNECT_T:
|
|
||||||
case SCH_BUS_WIRE_ENTRY_T:
|
|
||||||
case SCH_BUS_BUS_ENTRY_T:
|
|
||||||
case SCH_SHEET_PIN_T:
|
case SCH_SHEET_PIN_T:
|
||||||
case SCH_PIN_T:
|
case SCH_TEXT_T:
|
||||||
return false;
|
case SCH_LABEL_T:
|
||||||
case SCH_LINE_T:
|
case SCH_GLOBAL_LABEL_T:
|
||||||
{
|
case SCH_HIER_LABEL_T:
|
||||||
const std::deque<EDA_ITEM*> items = aSel.GetItems();
|
case SCH_FIELD_T:
|
||||||
if( !std::all_of( items.begin(), items.end(),
|
case SCH_BITMAP_T:
|
||||||
[&]( const EDA_ITEM* selItem )
|
return aSel.GetSize() == 1;
|
||||||
{
|
|
||||||
const SCH_LINE* line = dynamic_cast<const SCH_LINE*>( selItem );
|
case SCH_LINE_T:
|
||||||
if ( line == nullptr )
|
return std::all_of( aSel.GetItems().begin(), aSel.GetItems().end(),
|
||||||
{
|
[&]( EDA_ITEM* selItem )
|
||||||
wxLogWarning(
|
{
|
||||||
"Non-line object encountered in selection, this shouldn't have bypassed the preceeding check" );
|
SCH_LINE* line = dynamic_cast<SCH_LINE*>( selItem );
|
||||||
return false;
|
return line && line->IsGraphicLine();
|
||||||
}
|
} );
|
||||||
return line->IsGraphicLine();
|
|
||||||
} ) )
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only graphic lines support properties in the file format
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1231,7 +1234,10 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
|
||||||
EE_SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::EditableItems );
|
EE_SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::EditableItems );
|
||||||
|
|
||||||
if( selection.Empty() )
|
if( selection.Empty() )
|
||||||
|
{
|
||||||
|
m_toolMgr->RunAction( ACTIONS::pageSettings );
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
SCH_ITEM* item = (SCH_ITEM*) selection.Front();
|
SCH_ITEM* item = (SCH_ITEM*) selection.Front();
|
||||||
|
|
||||||
|
|
|
@ -123,14 +123,18 @@ bool EDIT_TOOL::Init()
|
||||||
m_selectionTool = static_cast<SELECTION_TOOL*>( m_toolMgr->FindTool( "pcbnew.InteractiveSelection" ) );
|
m_selectionTool = static_cast<SELECTION_TOOL*>( m_toolMgr->FindTool( "pcbnew.InteractiveSelection" ) );
|
||||||
wxASSERT_MSG( m_selectionTool, "pcbnew.InteractiveSelection tool is not available" );
|
wxASSERT_MSG( m_selectionTool, "pcbnew.InteractiveSelection tool is not available" );
|
||||||
|
|
||||||
auto editingModuleCondition = [ this ] ( const SELECTION& aSelection ) {
|
auto editingModuleCondition =
|
||||||
|
[ this ] ( const SELECTION& aSelection )
|
||||||
|
{
|
||||||
return m_editModules;
|
return m_editModules;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto singleModuleCondition = SELECTION_CONDITIONS::OnlyType( PCB_MODULE_T )
|
auto singleModuleCondition = SELECTION_CONDITIONS::OnlyType( PCB_MODULE_T )
|
||||||
&& SELECTION_CONDITIONS::Count( 1 );
|
&& SELECTION_CONDITIONS::Count( 1 );
|
||||||
|
|
||||||
auto noActiveToolCondition = [ this ] ( const SELECTION& aSelection ) {
|
auto noActiveToolCondition =
|
||||||
|
[ this ] ( const SELECTION& aSelection )
|
||||||
|
{
|
||||||
return frame()->ToolStackIsEmpty();
|
return frame()->ToolStackIsEmpty();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -146,7 +150,7 @@ bool EDIT_TOOL::Init()
|
||||||
menu.AddItem( PCB_ACTIONS::rotateCw, SELECTION_CONDITIONS::NotEmpty );
|
menu.AddItem( PCB_ACTIONS::rotateCw, SELECTION_CONDITIONS::NotEmpty );
|
||||||
menu.AddItem( PCB_ACTIONS::flip, SELECTION_CONDITIONS::NotEmpty );
|
menu.AddItem( PCB_ACTIONS::flip, SELECTION_CONDITIONS::NotEmpty );
|
||||||
menu.AddItem( ACTIONS::doDelete, SELECTION_CONDITIONS::NotEmpty );
|
menu.AddItem( ACTIONS::doDelete, SELECTION_CONDITIONS::NotEmpty );
|
||||||
menu.AddItem( PCB_ACTIONS::properties, SELECTION_CONDITIONS::Count( 1 )
|
menu.AddItem( PCB_ACTIONS::properties, SELECTION_CONDITIONS::LessThan( 2 )
|
||||||
|| SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) );
|
|| SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) );
|
||||||
|
|
||||||
menu.AddItem( PCB_ACTIONS::moveExact, SELECTION_CONDITIONS::NotEmpty );
|
menu.AddItem( PCB_ACTIONS::moveExact, SELECTION_CONDITIONS::NotEmpty );
|
||||||
|
@ -586,7 +590,11 @@ int EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
|
||||||
DIALOG_TRACK_VIA_PROPERTIES dlg( editFrame, selection, *m_commit );
|
DIALOG_TRACK_VIA_PROPERTIES dlg( editFrame, selection, *m_commit );
|
||||||
dlg.ShowQuasiModal(); // QuasiModal required for NET_SELECTOR
|
dlg.ShowQuasiModal(); // QuasiModal required for NET_SELECTOR
|
||||||
}
|
}
|
||||||
else if( selection.Size() == 1 ) // Properties are displayed when there is only one item selected
|
else if( selection.Size() == 0 )
|
||||||
|
{
|
||||||
|
m_toolMgr->RunAction( ACTIONS::pageSettings );
|
||||||
|
}
|
||||||
|
else if( selection.Size() == 1 )
|
||||||
{
|
{
|
||||||
// Display properties dialog
|
// Display properties dialog
|
||||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.Front() );
|
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.Front() );
|
||||||
|
|
Loading…
Reference in New Issue