浏览代码

add to config window in progress

/main
Mohsen Kamalzadeh 4 年前
当前提交
8785414f
共有 9 个文件被更改,包括 139 次插入49 次删除
  1. 85
      com.unity.perception/Editor/GroundTruth/AddToConfigWindow.cs
  2. 2
      com.unity.perception/Editor/GroundTruth/LabelingEditor.cs
  3. 32
      com.unity.perception/Editor/GroundTruth/Uss/Styles.uss
  4. 15
      com.unity.perception/Editor/GroundTruth/Uxml/AddedLabelElement.uxml
  5. 5
      com.unity.perception/Editor/GroundTruth/Uxml/ConfigElementLabelNotPresent.uxml
  6. 8
      com.unity.perception/Editor/GroundTruth/Uxml/ConfigElementLabelPresent.uxml
  7. 6
      com.unity.perception/Editor/GroundTruth/Uxml/Labeling_Main.uxml
  8. 28
      com.unity.perception/Runtime/GroundTruth/Labeling/IdLabelConfig.cs
  9. 7
      com.unity.perception/Runtime/GroundTruth/Labeling/LabelConfig.cs

85
com.unity.perception/Editor/GroundTruth/AddToConfigWindow.cs


private static string m_LabelValue;
private static Label m_TitleLabel;
private List<string> m_ConfigsContainingLabel = new List<string>();
private List<string> m_ConfigsNotContainingLabel = new List<string>();
private List<ScriptableObject> m_ConfigsContainingLabel = new List<ScriptableObject>();
private List<ScriptableObject> m_ConfigsNotContainingLabel = new List<ScriptableObject>();
private ListView m_PresentConfigsListview;
private ListView m_NonPresentConfigsListview;

var window = GetWindow<AddToConfigWindow>();
window.minSize = new Vector2(400, 500);
window.Init();
window.Show();
}

if(m_TitleLabel != null)
m_TitleLabel.text = "Add " + m_LabelValue + "to Label Configurations";
Refresh();
}
void Refresh()
{
var types = FindAllRelevant();
AssetDatabase.Refresh();

CheckInclusionInConfigs(labelConfigGuids, types, m_LabelValue, this);
Func<VisualElement> makeItem = () => new Label();
Action<VisualElement, int> bindItem = (e, i) => (e as Label).text = m_ConfigsContainingLabel[i];
Func<VisualElement> makeItem = () => new ConfigElementLabelPresent(m_LabelValue);
void BindItem(VisualElement e, int i)
{
if (e is ConfigElementLabelPresent element)
{
element.m_Label.text = m_ConfigsContainingLabel[i].name;
element.m_LabelConfig = m_ConfigsContainingLabel[i];
}
}
m_PresentConfigsListview.bindItem = bindItem;
m_PresentConfigsListview.bindItem = BindItem;
Func<VisualElement> makeItem1 = () => new Label();
Action<VisualElement, int> bindItem1 = (e, i) => (e as Label).text = m_ConfigsNotContainingLabel[i];
m_NonPresentConfigsListview.itemHeight = 30;
m_NonPresentConfigsListview.itemsSource = m_ConfigsNotContainingLabel;
m_NonPresentConfigsListview.bindItem = bindItem1;
m_NonPresentConfigsListview.makeItem = makeItem1;
// Func<VisualElement> makeItem1 = () => new Label();
// Action<VisualElement, int> bindItem1 = (e, i) => (e as Label).text = m_ConfigsNotContainingLabel[i];
//
// m_NonPresentConfigsListview.itemHeight = 30;
// m_NonPresentConfigsListview.itemsSource = m_ConfigsNotContainingLabel;
//
// m_NonPresentConfigsListview.bindItem = bindItem1;
// m_NonPresentConfigsListview.makeItem = makeItem1;
}
void OnEnable()

if (labelExistsInConfig)
{
m_ConfigsContainingLabel.Add(asset.name);
m_ConfigsContainingLabel.Add(asset);
m_ConfigsNotContainingLabel.Add(asset.name);
m_ConfigsNotContainingLabel.Add(asset);
}
}
}

}
return false;
}
}
class ConfigElementLabelPresent : VisualElement
{
private string m_UxmlDir = "Packages/com.unity.perception/Editor/GroundTruth/Uxml/";
private string m_UxmlPath;
private VisualElement m_Root;
private Button m_RemoveButton;
private ObjectField m_ConfigObjectField;
public Label m_Label;
public ScriptableObject m_LabelConfig;
public ConfigElementLabelPresent(string targetLabel)
{
m_UxmlPath = m_UxmlDir + "ConfigElementLabelPresent.uxml";
AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(m_UxmlPath).CloneTree(this);
m_Label = this.Q<Label>("config-name");
m_RemoveButton = this.Q<Button>("remove-from-config-button");
m_ConfigObjectField = this.Q<ObjectField>("config-object");
m_ConfigObjectField.value = m_LabelConfig;
m_ConfigObjectField.objectType = typeof(ScriptableObject);
this.MarkDirtyRepaint();
m_RemoveButton.clicked += () =>
{
//var methodInfo = m_LabelConfig.GetType().GetMethod("DoesLabelMatchAnyEntries");
if (m_LabelConfig is IdLabelConfig idLabelConfig)
{
idLabelConfig.RemoveLabel(targetLabel);
}
};
}
}
class ConfigElementLabelNotPresent : VisualElement
{
}
}

2
com.unity.perception/Editor/GroundTruth/LabelingEditor.cs


{
private string m_UxmlDir = "Packages/com.unity.perception/Editor/GroundTruth/Uxml/";
private string m_UxmlPath;
private VisualElement m_Root;
private Button m_RemoveButton;
private Button m_AddToConfigButton;
public TextField m_LabelTextField;

{
private string m_UxmlDir = "Packages/com.unity.perception/Editor/GroundTruth/Uxml/";
private string m_UxmlPath;
private VisualElement m_Root;
private Button m_AddButton;
public Label m_Label;

32
com.unity.perception/Editor/GroundTruth/Uss/Styles.uss


background-color: #505050;
align-self: center;
}

padding: 2px;
padding-left: 5px;
border-radius: 4px;
background-color: #272727;
background-color: #313131;
color: black
color: black;
.labeling__added-label-value > .unity-base-field__label {
color:black;
.labeling__added-label-value > .unity-text-field__input {
color: rgb(195, 195, 195);
background-color: #313131;
border-width: 0px;
}
.labeling__suggested-label-value {

color: #999999;
color: rgb(180, 180, 180);
}
.labeling__label-listview {

padding: 6px;
padding-top: 6px;
border-bottom-right-radius: 0;
background-color: #191919;
background-color: #272727;
}
.labeling__configs-listview {

border-width: 0;
border-top-right-radius: 0;
border-top-left-radius: 0;
background-color: #191919;
background-color: rgb(25, 25, 25);
color: #CACACA;
}
.outer-container {

border-radius: 10px;
border-width: 1px;
padding: 10px;
background-color: #272727;
background-color: rgb(75, 75, 75);
background-color: #505050;
border-width: 0px;
color: #EEEEEE;
}
.labeling__add-to-config-button {

background-color: #505050;
border-width: 0px;
color: #EEEEEE;
color: #CACACA;
}
.subtitle-label {
color: #CACACA;
}

15
com.unity.perception/Editor/GroundTruth/Uxml/AddedLabelElement.uxml


<UXML xmlns="UnityEngine.UIElements">
<VisualElement class="added-label">
<Style src="../Uss/Styles.uss"/>
<Button name="remove-button" class="labeling__remove-item-button"/>
<TextField name="label-value" class="labeling__added-label-value"/>
<Button name="add-to-config-button" class="labeling__add-to-config-button" text="Add to Label Config..."/>
</VisualElement>
</UXML>
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xmlns="UnityEngine.UIElements" editor-extension-mode="False">
<ui:VisualElement class="added-label">
<ui:Button name="remove-button" class="labeling__remove-item-button" />
<ui:TextField name="label-value" class="labeling__added-label-value" />
<ui:Button name="add-to-config-button" text="Add to Label Config..." class="labeling__add-to-config-button" />
</ui:VisualElement>
</ui:UXML>

5
com.unity.perception/Editor/GroundTruth/Uxml/ConfigElementLabelNotPresent.uxml


<UXML xmlns="UnityEngine.UIElements">
<VisualElement class="added-label">
<Style src="../Uss/Styles.uss"/>
<Button name="remove-button" class="labeling__remove-item-button"/>
<TextField name="label-value" class="labeling__added-label-value"/>
<Button name="add-to-config-button" class="labeling__add-to-config-button" text="Add to Label Config..."/>
<Label name="config-name" class="labeling__config-name-label"/>
<Button name="add-to-config-button" class="labeling__addremove-config-button"/>
</VisualElement>
</UXML>

8
com.unity.perception/Editor/GroundTruth/Uxml/ConfigElementLabelPresent.uxml


<UXML xmlns="UnityEngine.UIElements">
<UXML xmlns="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements">
<Button name="remove-button" class="labeling__remove-item-button"/>
<TextField name="label-value" class="labeling__added-label-value"/>
<Button name="add-to-config-button" class="labeling__add-to-config-button" text="Add to Label Config..."/>
<editor:ObjectField name="config-object"/>
<Label name="config-name" class="labeling__config-name-label"/>
<Button name="remove-from-config-button" class="labeling__addremove-config-button"/>
</VisualElement>
</UXML>

6
com.unity.perception/Editor/GroundTruth/Uxml/Labeling_Main.uxml


<VisualElement name="suggested-labels" class="inner-container">
<Label text="Suggested Labels" class="title-label"/>
<VisualElement name="suggested-labels-from-name" style="padding-top: 10px;">
<Label text="Based on asset name"/>
<Label text="Based on asset name" class="subtitle-label"/>
<Label text="Based on asset path"/>
<Label text="Based on asset path" class="subtitle-label"/>
<Label text="From Perception asset database" style="padding-top: 10px;"/>
<Label text="From Perception asset database" class="subtitle-label" style="padding-top: 10px;"/>
<ListView name="suggested-labels-db-listview" class="labeling__label-listview" style="min-height: 97px;"/>
</VisualElement><VisualElement/>
</VisualElement>

28
com.unity.perception/Runtime/GroundTruth/Labeling/IdLabelConfig.cs


return TryGetLabelEntryFromInstanceId(instanceId, out labelEntry, out var _);
}
public override void RemoveLabel(string label)
{
base.RemoveLabel(label);
if (autoAssignIds)
{
}
}
void AutoAssignIds()
{
var size = base.labelEntries.Count;
if (size == 0)
return;
var nextId = startingLabelId == StartingLabelId.One ? 1 : 0;
for (int i = 0; i < size; i++)
{
//m_LabelEntries[i].id = nextId;
nextId++;
}
}
/// <summary>
/// Attempts to find the label id for the given instance id.
/// </summary>

{
m_LabelEntryMatchCache?.Dispose();
m_LabelEntryMatchCache = null;
}
public void ClearLabelEntryMatchCache()
{
m_LabelEntryMatchCache?.ClearCache();
}
[SuppressMessage("ReSharper", "InconsistentNaming")]

7
com.unity.perception/Runtime/GroundTruth/Labeling/LabelConfig.cs


[FormerlySerializedAs("LabelEntries")]
[FormerlySerializedAs("LabelingConfigurations")]
[SerializeField]
List<T> m_LabelEntries = new List<T>();
protected List<T> m_LabelEntries = new List<T>();
/// <summary>
/// A sequence of <see cref="ILabelEntry"/> which defines the labels relevant for this configuration and their values.

return m_LabelEntries.Any(entry => string.Equals(entry.label, label));
}
public virtual void RemoveLabel(string label)
{
m_LabelEntries.RemoveAll(entry => String.Equals(entry.label, label));
}
/// <summary>
/// Initialize the list of LabelEntries on this LabelingConfiguration. Should only be called immediately after instantiation.

正在加载...
取消
保存