Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
366e28f22This file is pinned to the selected release. Download the original to open it in your design tool.
using IDE.Core.Interfaces;
using IDE.Core.Storage;
using IDE.Core.Wizards;
using System.Collections.Generic;
namespace IDE.Core.Designers
{
/*This rule creates the following problem, and for this reason is temporarily removed:
* - when you define a pad on a footprint you specify the mask and paste expansions
* - on the board, you specify this kind of rule
* - different manufacturers have different preferences: Eurocircuits prefer not to specify an expansion but creates this adjustments according to their manuf capabilities; others (from China) don't adjust and take gerbers as is
*
* - we could use this rule to enforce the geometry to be expanded or contracted by some expansion value, but this will affect the geometry generated by pads (and maybe the others?) (will modify the geometry and will override it)
*
*
*/
public class MaskExpansionRuleModel : AbstractBoardRule
{
public MaskExpansionRuleModel()
{
Expansion = 0.1;
}
public override string RuleType
{
get
{
return "Mask expansion";
}
}
double expansion;
public double Expansion
{
get
{
return expansion;
}
set
{
expansion = value;
OnPropertyChanged(nameof(Expansion));
}
}
MaskExpansionRuleType maskRuleType = MaskExpansionRuleType.SolderMask;
public MaskExpansionRuleType MaskRuleType
{
get
{
return maskRuleType;
}
set
{
maskRuleType = value;
OnPropertyChanged(nameof(MaskRuleType));
}
}
IList<OptionViewModel<MaskExpansionRuleType>> maskRuleTypes;
public IList<OptionViewModel<MaskExpansionRuleType>> MaskRuleTypes
{
get
{
if (maskRuleTypes == null)
{
var list = new List<OptionViewModel<MaskExpansionRuleType>>()
{
new OptionViewModel<MaskExpansionRuleType>(MaskExpansionRuleType.SolderMask, 0, null, "Solder mask"),
new OptionViewModel<MaskExpansionRuleType>(MaskExpansionRuleType.PasteMask, 0, null, "Paste mask"),
};
maskRuleTypes = list.AsReadOnly();
}
return maskRuleTypes;
}
}
public override void Load(ILayeredViewModel doc)
{
}
public override BoardRule SaveToBoardRule()
{
return new MaskExpansionRule
{
//abstract
Id = Id,
Name = Name,
Comment = Comment,
IsEnabled = IsEnabled,
Priority = Priority,
Expansion = Expansion,
MaskRuleType = MaskRuleType
};
}
public override bool RuleAppliesToItem(ISelectableItem item)
{
return item is IPadCanvasItem;
}
public override bool RuleAppliesToItemsPair(ISelectableItem item1, ISelectableItem item2)
{
return false;
}
public override bool IsPairedRule()
{
return false;
}
public override bool CheckItem(ISelectableItem item1, RuleCheckResult result)
{
//if(item1 is IPadCanvasItem)
//{
// var g1 = GeometryHelper.GetGeometry(item1);
// switch(maskRuleType)
// {
// case MaskExpansionRuleType.SolderMask:
// break;
// case MaskExpansionRuleType.PasteMask:
// break;
// }
//}
return true;
}
public override void LoadFromData(IBoardRuleData rule)
{
var r = rule as MaskExpansionRule;
Id = r.Id;
Name = r.Name;
Comment = r.Comment;
IsEnabled = r.IsEnabled;
Priority = r.Priority;
Expansion = r.Expansion;
MaskRuleType = r.MaskRuleType;
}
}
}