Pick up current rule values when editing meanders.
This commit is contained in:
parent
61bdee027b
commit
5f5113c80a
|
@ -1563,7 +1563,7 @@ void VIEW::SetVisible( VIEW_ITEM* aItem, bool aIsVisible )
|
|||
}
|
||||
|
||||
|
||||
void VIEW::Hide( VIEW_ITEM* aItem, bool aHide )
|
||||
void VIEW::Hide( VIEW_ITEM* aItem, bool aHide, bool aHideOveraly )
|
||||
{
|
||||
VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
|
||||
|
||||
|
@ -1573,10 +1573,13 @@ void VIEW::Hide( VIEW_ITEM* aItem, bool aHide )
|
|||
if( !( viewData->m_flags & VISIBLE ) )
|
||||
return;
|
||||
|
||||
if( aHideOveraly )
|
||||
viewData->m_flags |= OVERLAY_HIDDEN;
|
||||
|
||||
if( aHide )
|
||||
viewData->m_flags |= HIDDEN;
|
||||
else
|
||||
viewData->m_flags &= ~HIDDEN;
|
||||
viewData->m_flags &= ~( HIDDEN | OVERLAY_HIDDEN );
|
||||
|
||||
Update( aItem, APPEARANCE );
|
||||
}
|
||||
|
@ -1590,6 +1593,14 @@ bool VIEW::IsVisible( const VIEW_ITEM* aItem ) const
|
|||
}
|
||||
|
||||
|
||||
bool VIEW::IsHiddenOnOverlay( const VIEW_ITEM* aItem ) const
|
||||
{
|
||||
const VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
|
||||
|
||||
return viewData && ( viewData->m_flags & OVERLAY_HIDDEN );
|
||||
}
|
||||
|
||||
|
||||
bool VIEW::HasItem( const VIEW_ITEM* aItem ) const
|
||||
{
|
||||
const VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
|
||||
|
|
|
@ -119,6 +119,9 @@ void VIEW_GROUP::ViewDraw( int aLayer, VIEW* aView ) const
|
|||
// Build a list of layers used by the items in the group
|
||||
for( VIEW_ITEM* item : drawList )
|
||||
{
|
||||
if( aView->IsHiddenOnOverlay( item ) )
|
||||
continue;
|
||||
|
||||
int item_layers[VIEW::VIEW_MAX_LAYERS], item_layers_count;
|
||||
item->ViewGetLayers( item_layers, item_layers_count );
|
||||
|
||||
|
|
|
@ -128,9 +128,10 @@ public:
|
|||
* Temporarily hide the item in the view (e.g. for overlaying).
|
||||
*
|
||||
* @param aItem: the item to modify.
|
||||
* @param aHide: whether the item is hidden (on all layers), or not.
|
||||
* @param aHide: whether the item is hidden, or not.
|
||||
* @param aHideOveraly: whether the item should also be hidden on overlays.
|
||||
*/
|
||||
void Hide( VIEW_ITEM* aItem, bool aHide = true );
|
||||
void Hide( VIEW_ITEM* aItem, bool aHide = true, bool aHideOveraly = false );
|
||||
|
||||
/**
|
||||
* Return information if the item is visible (or not).
|
||||
|
@ -141,6 +142,8 @@ public:
|
|||
*/
|
||||
bool IsVisible( const VIEW_ITEM* aItem ) const;
|
||||
|
||||
bool IsHiddenOnOverlay( const VIEW_ITEM* aItem ) const;
|
||||
|
||||
/**
|
||||
* Indicates whether or not the given item has been added to the view.
|
||||
*/
|
||||
|
|
|
@ -62,9 +62,11 @@ enum VIEW_UPDATE_FLAGS {
|
|||
* Define the visibility of the item (temporarily hidden, invisible, etc).
|
||||
*/
|
||||
enum VIEW_VISIBILITY_FLAGS {
|
||||
VISIBLE = 0x01, ///< Item is visible (in general)
|
||||
HIDDEN = 0x02 ///< Item is temporarily hidden (e.g. being used by a tool).
|
||||
///< Overrides VISIBLE flag.
|
||||
VISIBLE = 0x01, ///< Item is visible (in general)
|
||||
HIDDEN = 0x02, ///< Item is temporarily hidden (usually in favor of a being drawn
|
||||
///< from an overlay, such as a SELECTION).
|
||||
///< Overrides VISIBLE flag.
|
||||
OVERLAY_HIDDEN = 0x04 ///< Item is temporarily hidden from being drawn on an overlay.
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -166,6 +166,14 @@ static std::string SideToString( const PNS::MEANDER_SIDE aValue )
|
|||
}
|
||||
|
||||
|
||||
static NETINFO_ITEM* getCoupledNet( PNS::ROUTER* aRouter, NETINFO_ITEM* aNet )
|
||||
{
|
||||
PNS::RULE_RESOLVER* resolver = aRouter->GetRuleResolver();
|
||||
|
||||
return static_cast<NETINFO_ITEM*>( resolver->DpCoupledNet( aNet ) );
|
||||
}
|
||||
|
||||
|
||||
class PCB_GENERATOR_MEANDERS : public PCB_GENERATOR
|
||||
{
|
||||
public:
|
||||
|
@ -195,15 +203,15 @@ public:
|
|||
|
||||
wxString GetGeneratorType() const override { return wxS( "meanders" ); }
|
||||
|
||||
int snapToNearestTrackPoint( VECTOR2I& aP, BOARD* aBoard, int aNet )
|
||||
NETINFO_ITEM* snapToNearestTrackPoint( VECTOR2I& aP, BOARD* aBoard, NETINFO_ITEM* aNet )
|
||||
{
|
||||
SEG::ecoord minDistSq = VECTOR2I::ECOORD_MAX;
|
||||
VECTOR2I closestPt = aP;
|
||||
int closestNet = -1;
|
||||
SEG::ecoord minDistSq = VECTOR2I::ECOORD_MAX;
|
||||
VECTOR2I closestPt = aP;
|
||||
NETINFO_ITEM* closestNet = nullptr;
|
||||
|
||||
for( PCB_TRACK *track : aBoard->Tracks() )
|
||||
{
|
||||
if( aNet >= 0 && track->GetNetCode() != aNet )
|
||||
if( aNet && track->GetNet() != aNet )
|
||||
continue;
|
||||
|
||||
SEG seg ( track->GetStart(), track->GetEnd() );
|
||||
|
@ -215,7 +223,7 @@ public:
|
|||
{
|
||||
minDistSq = distSq;
|
||||
closestPt = nearest;
|
||||
closestNet = track->GetNetCode();
|
||||
closestNet = track->GetNet();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -225,7 +233,7 @@ public:
|
|||
return closestNet;
|
||||
}
|
||||
|
||||
return -1;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool baselineValid()
|
||||
|
@ -249,9 +257,8 @@ public:
|
|||
std::shared_ptr<DRC_ENGINE>& drcEngine = board->GetDesignSettings().m_DRCEngine;
|
||||
DRC_CONSTRAINT constraint;
|
||||
PCB_LAYER_ID layer = aStartItem->GetLayer();
|
||||
PNS::RULE_RESOLVER* resolver = aTool->Router()->GetRuleResolver();
|
||||
|
||||
if( aMode == SINGLE && resolver->DpCoupledNet( aStartItem->GetNet() ) )
|
||||
if( aMode == SINGLE && getCoupledNet( aTool->Router(), aStartItem->GetNet() ) )
|
||||
aMode = DIFF_PAIR;
|
||||
|
||||
PCB_GENERATOR_MEANDERS* meander = new PCB_GENERATOR_MEANDERS( board, layer, aMode );
|
||||
|
@ -314,11 +321,6 @@ public:
|
|||
aCommit->Modify( this );
|
||||
}
|
||||
|
||||
// Remove ourselves from the selection so that we don't redraw our existing children as
|
||||
// part of the selection VIEW_GROUP (which ignores the HIDDEN flags).
|
||||
PCB_SELECTION_TOOL*selectionTool = aFrame->GetToolManager()->GetTool<PCB_SELECTION_TOOL>();
|
||||
selectionTool->RemoveItemFromSel( this, true );
|
||||
|
||||
int layer = GetLayer();
|
||||
PNS::ROUTER* router = aTool->Router();
|
||||
|
||||
|
@ -326,8 +328,49 @@ public:
|
|||
router->SyncWorld();
|
||||
|
||||
if( !baselineValid() )
|
||||
{
|
||||
InitBaseLine( router, layer, aBoard );
|
||||
|
||||
if( baselineValid() && !m_overrideCustomRules )
|
||||
{
|
||||
PNS::CONSTRAINT constraint;
|
||||
PNS::RULE_RESOLVER* resolver = router->GetRuleResolver();
|
||||
|
||||
NETINFO_ITEM* net = snapToNearestTrackPoint( m_origin, aBoard, nullptr );
|
||||
PNS::SEGMENT pnsItem( m_baseLine->CSegment( 0 ), net );
|
||||
|
||||
if( m_tuningMode == SINGLE )
|
||||
{
|
||||
if( resolver->QueryConstraint( PNS::CONSTRAINT_TYPE::CT_LENGTH,
|
||||
&pnsItem, nullptr, layer, &constraint ) )
|
||||
{
|
||||
m_targetLength = constraint.m_Value.Opt();
|
||||
aFrame->GetToolManager()->PostEvent( EVENTS::SelectedItemsModified );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NETINFO_ITEM* coupledNet = static_cast<NETINFO_ITEM*>( resolver->DpCoupledNet( net ) );
|
||||
PNS::SEGMENT coupledItem( m_baseLineCoupled->CSegment( 0 ), coupledNet );
|
||||
|
||||
if( m_tuningMode == DIFF_PAIR )
|
||||
{
|
||||
if( resolver->QueryConstraint( PNS::CONSTRAINT_TYPE::CT_LENGTH,
|
||||
&pnsItem, &coupledItem, layer, &constraint ) )
|
||||
{
|
||||
m_targetLength = constraint.m_Value.Opt();
|
||||
aFrame->GetToolManager()->PostEvent( EVENTS::SelectedItemsModified );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( resolver->QueryConstraint( PNS::CONSTRAINT_TYPE::CT_DIFF_PAIR_SKEW,
|
||||
&pnsItem, &coupledItem, layer, &constraint ) )
|
||||
{
|
||||
m_targetSkew = constraint.m_Value.Opt();
|
||||
aFrame->GetToolManager()->PostEvent( EVENTS::SelectedItemsModified );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -431,12 +474,13 @@ public:
|
|||
}
|
||||
|
||||
bool initBaseLine( PNS::ROUTER* router, int layer, BOARD* aBoard, VECTOR2I& aStart,
|
||||
VECTOR2I& aEnd, int aNetCode, std::optional<SHAPE_LINE_CHAIN>& aBaseLine )
|
||||
VECTOR2I& aEnd, NETINFO_ITEM* aNet,
|
||||
std::optional<SHAPE_LINE_CHAIN>& aBaseLine )
|
||||
{
|
||||
PNS::NODE* world = router->GetWorld();
|
||||
|
||||
snapToNearestTrackPoint( aStart, aBoard, aNetCode );
|
||||
snapToNearestTrackPoint( aEnd, aBoard, aNetCode );
|
||||
snapToNearestTrackPoint( aStart, aBoard, aNet );
|
||||
snapToNearestTrackPoint( aEnd, aBoard, aNet );
|
||||
|
||||
VECTOR2I startSnapPoint, endSnapPoint;
|
||||
|
||||
|
@ -472,18 +516,15 @@ public:
|
|||
{
|
||||
m_baseLineCoupled.reset();
|
||||
|
||||
int netCode = snapToNearestTrackPoint( m_origin, aBoard, -1 );
|
||||
NETINFO_ITEM* net = snapToNearestTrackPoint( m_origin, aBoard, nullptr );
|
||||
|
||||
if( !initBaseLine( router, layer, aBoard, m_origin, m_end, netCode, m_baseLine ) )
|
||||
if( !initBaseLine( router, layer, aBoard, m_origin, m_end, net, m_baseLine ) )
|
||||
return false;
|
||||
|
||||
if( m_tuningMode == DIFF_PAIR )
|
||||
if( m_tuningMode == DIFF_PAIR || m_tuningMode == DIFF_PAIR_SKEW )
|
||||
{
|
||||
PNS::RULE_RESOLVER* resolver = router->GetRuleResolver();
|
||||
|
||||
if( PNS::NET_HANDLE handle = resolver->DpCoupledNet( aBoard->FindNet( netCode ) ) )
|
||||
if( NETINFO_ITEM* coupledNet = getCoupledNet( router, net ) )
|
||||
{
|
||||
int coupledNet = static_cast<NETINFO_ITEM*>( handle )->GetNetCode();
|
||||
VECTOR2I coupledStart = m_origin;
|
||||
VECTOR2I coupledEnd = m_end;
|
||||
|
||||
|
@ -680,12 +721,12 @@ public:
|
|||
}
|
||||
|
||||
// LINE does not have a separate remover, as LINEs are never truly a member of the tree
|
||||
for( PNS::LINKED_ITEM* li : line->Links() )
|
||||
for( PNS::LINKED_ITEM* pnsItem : line->Links() )
|
||||
{
|
||||
if( li->Parent() )
|
||||
if( BOARD_ITEM* item = pnsItem->Parent() )
|
||||
{
|
||||
aFrame->GetCanvas()->GetView()->Hide( li->Parent() );
|
||||
m_removedItems.insert( li->Parent() );
|
||||
aFrame->GetCanvas()->GetView()->Hide( item, true, true );
|
||||
m_removedItems.insert( item );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1070,7 +1111,7 @@ public:
|
|||
|
||||
void ViewDraw( int aLayer, KIGFX::VIEW* aView ) const override final
|
||||
{
|
||||
if( !IsSelected() && !IsNew() )
|
||||
if( !IsSelected() )
|
||||
return;
|
||||
|
||||
KIGFX::PREVIEW::DRAW_CONTEXT ctx( *aView );
|
||||
|
@ -1561,7 +1602,7 @@ static struct PCB_GENERATOR_MEANDERS_DESC
|
|||
{
|
||||
ENUM_MAP<LENGTH_TUNING_MODE>::Instance()
|
||||
.Map( LENGTH_TUNING_MODE::SINGLE, _HKI( "Single track" ) )
|
||||
/*.Map( LENGTH_TUNING_MODE::DIFF_PAIR, _HKI( "Diff. pair" ) )*/ // Not supported
|
||||
.Map( LENGTH_TUNING_MODE::DIFF_PAIR, _HKI( "Diff. pair" ) )
|
||||
.Map( LENGTH_TUNING_MODE::DIFF_PAIR_SKEW, _HKI( "Diff. pair Skew" ) );
|
||||
|
||||
ENUM_MAP<PNS::MEANDER_SIDE>::Instance()
|
||||
|
|
|
@ -340,6 +340,7 @@ bool PNS_PCBNEW_RULE_RESOLVER::QueryConstraint( PNS::CONSTRAINT_TYPE aType,
|
|||
case PNS::CONSTRAINT_TYPE::CT_WIDTH: hostType = TRACK_WIDTH_CONSTRAINT; break;
|
||||
case PNS::CONSTRAINT_TYPE::CT_DIFF_PAIR_GAP: hostType = DIFF_PAIR_GAP_CONSTRAINT; break;
|
||||
case PNS::CONSTRAINT_TYPE::CT_LENGTH: hostType = LENGTH_CONSTRAINT; break;
|
||||
case PNS::CONSTRAINT_TYPE::CT_DIFF_PAIR_SKEW: hostType = SKEW_CONSTRAINT; break;
|
||||
case PNS::CONSTRAINT_TYPE::CT_VIA_DIAMETER: hostType = VIA_DIAMETER_CONSTRAINT; break;
|
||||
case PNS::CONSTRAINT_TYPE::CT_VIA_HOLE: hostType = HOLE_SIZE_CONSTRAINT; break;
|
||||
case PNS::CONSTRAINT_TYPE::CT_HOLE_CLEARANCE: hostType = HOLE_CLEARANCE_CONSTRAINT; break;
|
||||
|
@ -445,6 +446,8 @@ bool PNS_PCBNEW_RULE_RESOLVER::QueryConstraint( PNS::CONSTRAINT_TYPE aType,
|
|||
case PNS::CONSTRAINT_TYPE::CT_HOLE_CLEARANCE:
|
||||
case PNS::CONSTRAINT_TYPE::CT_EDGE_CLEARANCE:
|
||||
case PNS::CONSTRAINT_TYPE::CT_HOLE_TO_HOLE:
|
||||
case PNS::CONSTRAINT_TYPE::CT_LENGTH:
|
||||
case PNS::CONSTRAINT_TYPE::CT_DIFF_PAIR_SKEW:
|
||||
aConstraint->m_Value = hostConstraint.GetValue();
|
||||
aConstraint->m_RuleName = hostConstraint.GetName();
|
||||
aConstraint->m_Type = aType;
|
||||
|
|
|
@ -58,7 +58,8 @@ enum class CONSTRAINT_TYPE
|
|||
CT_VIA_HOLE = 6,
|
||||
CT_HOLE_CLEARANCE = 7,
|
||||
CT_EDGE_CLEARANCE = 8,
|
||||
CT_HOLE_TO_HOLE = 9
|
||||
CT_HOLE_TO_HOLE = 9,
|
||||
CT_DIFF_PAIR_SKEW = 10
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue