Fix expansion of clsuter arrays
This commit is contained in:
parent
c708f4da9e
commit
1a1919fb8e
@ -313,64 +313,54 @@ namespace NanoBrain {
|
|||||||
|
|
||||||
// Draw selected Nucleus
|
// Draw selected Nucleus
|
||||||
if (expandArray) {
|
if (expandArray) {
|
||||||
// if (this.currentNucleus is IReceptor receptor1) {
|
|
||||||
// float maxValue = 0;
|
|
||||||
// foreach (Nucleus nucleus in receptor1.nucleiArray) {
|
|
||||||
// if (nucleus is Neuron neuron) {
|
|
||||||
// float value = neuron.outputMagnitude;
|
|
||||||
// if (value > maxValue)
|
|
||||||
// maxValue = value;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// float spacing = 400f / receptor1.nucleiArray.Count();
|
|
||||||
// float margin = 10 + spacing / 2;
|
|
||||||
// float xMin = 150 - size;
|
|
||||||
// float xMax = 150 + size;
|
|
||||||
// float yMin = 10 + margin - size / 2;
|
|
||||||
// float yMax = 400 - margin + size;
|
|
||||||
// Vector3[] verts = new Vector3[4] {
|
|
||||||
// new(xMin, yMin, 0),
|
|
||||||
// new(xMax, yMin, 0),
|
|
||||||
// new(xMax, yMax, 0),
|
|
||||||
// new(xMin, yMax, 0)
|
|
||||||
// };
|
|
||||||
// Handles.color = Color.black;
|
|
||||||
// Handles.DrawAAConvexPolygon(verts);
|
|
||||||
// int row = 0;
|
|
||||||
// foreach (Nucleus nucleus in receptor1.nucleiArray) {
|
|
||||||
// Vector3 pos = new(150, margin + row * spacing, 0.0f);
|
|
||||||
// Handles.color = Color.white;
|
|
||||||
// // The selected nucleus highlight ring
|
|
||||||
// Handles.DrawSolidDisc(pos, Vector3.forward, size + 2);
|
|
||||||
// DrawNucleus(nucleus, pos, maxValue, size);
|
|
||||||
// row++;
|
|
||||||
// }
|
|
||||||
// GUIStyle style = new(EditorStyles.label) {
|
|
||||||
// alignment = TextAnchor.UpperCenter,
|
|
||||||
// normal = { textColor = Color.white },
|
|
||||||
// fontStyle = FontStyle.Bold,
|
|
||||||
// };
|
|
||||||
// Vector3 labelPos = new(150, yMax + size + 5, 0);
|
|
||||||
// string receptorName = receptor1.GetName();
|
|
||||||
// int colonPos = receptorName.IndexOf(":");
|
|
||||||
// if (colonPos > 0) {
|
|
||||||
// string baseName = receptorName[..colonPos];
|
|
||||||
// Handles.Label(labelPos, baseName, style);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// Handles.Label(labelPos, receptorName, style);
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
float maxValue = 1;
|
float maxValue = 1;
|
||||||
if (this.currentNucleus is Neuron neuron)
|
|
||||||
maxValue = neuron.outputMagnitude;
|
|
||||||
else if (this.currentNucleus is Cluster cluster)
|
|
||||||
maxValue = cluster.defaultOutput.outputMagnitude;
|
|
||||||
|
|
||||||
DrawNucleus(this.currentNucleus, position, maxValue, 20);
|
if (this.currentNucleus is Cluster cluster) {
|
||||||
|
float spacing = 400f / cluster.siblingClusters.Length;
|
||||||
|
float margin = 10 + spacing / 2;
|
||||||
|
float xMin = 150 - size;
|
||||||
|
float xMax = 150 + size;
|
||||||
|
float yMin = 10 + margin - size / 2;
|
||||||
|
float yMax = 400 - margin + size;
|
||||||
|
Vector3[] verts = new Vector3[4] {
|
||||||
|
new(xMin, yMin, 0),
|
||||||
|
new(xMax, yMin, 0),
|
||||||
|
new(xMax, yMax, 0),
|
||||||
|
new(xMin, yMax, 0)
|
||||||
|
};
|
||||||
|
Handles.color = Color.black;
|
||||||
|
Handles.DrawAAConvexPolygon(verts);
|
||||||
|
int row = 0;
|
||||||
|
foreach (Cluster sibling in cluster.siblingClusters) {
|
||||||
|
Vector3 pos = new(150, margin + row * spacing, 0.0f);
|
||||||
|
Handles.color = Color.white;
|
||||||
|
// The selected sibling highlight ring
|
||||||
|
Handles.DrawSolidDisc(pos, Vector3.forward, size + 2);
|
||||||
|
DrawNucleus(sibling, pos, maxValue, size);
|
||||||
|
row++;
|
||||||
|
}
|
||||||
|
GUIStyle style = new(EditorStyles.label) {
|
||||||
|
alignment = TextAnchor.UpperCenter,
|
||||||
|
normal = { textColor = Color.white },
|
||||||
|
fontStyle = FontStyle.Bold,
|
||||||
|
};
|
||||||
|
Vector3 labelPos = new(150, yMax + size + 5, 0);
|
||||||
|
string clusterName = cluster.name;
|
||||||
|
int colonPos = clusterName.IndexOf(":");
|
||||||
|
if (colonPos > 0) {
|
||||||
|
string baseName = clusterName[..colonPos];
|
||||||
|
Handles.Label(labelPos, baseName, style);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Handles.Label(labelPos, clusterName, style);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (this.currentNucleus is Neuron neuron)
|
||||||
|
maxValue = neuron.outputMagnitude;
|
||||||
|
|
||||||
// }
|
DrawNucleus(this.currentNucleus, position, maxValue, 20);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
float maxValue = 1;
|
float maxValue = 1;
|
||||||
@ -473,7 +463,7 @@ namespace NanoBrain {
|
|||||||
if (synapse.neuron is null)
|
if (synapse.neuron is null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (synapse.neuron.parent is Cluster cluster &&
|
if (synapse.neuron.parent is Cluster cluster &&
|
||||||
//cluster.siblingClusters != null &&
|
//cluster.siblingClusters != null &&
|
||||||
synapse.neuron.parent != nucleus.parent) {
|
synapse.neuron.parent != nucleus.parent) {
|
||||||
|
|
||||||
@ -558,6 +548,8 @@ namespace NanoBrain {
|
|||||||
string extName = nucleus.name[(colonPos1 + 2)..];
|
string extName = nucleus.name[(colonPos1 + 2)..];
|
||||||
Handles.Label(labelPos1, extName, style);
|
Handles.Label(labelPos1, extName, style);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
Handles.Label(labelPos1, "0", style);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (parentCluster.siblingClusters != null && parentCluster.siblingClusters.Length > 1) {
|
if (parentCluster.siblingClusters != null && parentCluster.siblingClusters.Length > 1) {
|
||||||
@ -581,6 +573,8 @@ namespace NanoBrain {
|
|||||||
string extName = nucleus.name[(colonPos1 + 2)..];
|
string extName = nucleus.name[(colonPos1 + 2)..];
|
||||||
Handles.Label(labelPos1, extName, style);
|
Handles.Label(labelPos1, extName, style);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
Handles.Label(labelPos1, "0", style);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (cluster.siblingClusters != null && cluster.siblingClusters.Length > 1) {
|
if (cluster.siblingClusters != null && cluster.siblingClusters.Length > 1) {
|
||||||
@ -595,7 +589,7 @@ namespace NanoBrain {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expandArray == false) {
|
if (expandArray == false || nucleus != currentNucleus) {
|
||||||
// put name below nucleus
|
// put name below nucleus
|
||||||
Vector3 labelPos = position - Vector3.down * (size + 5); // below neuron
|
Vector3 labelPos = position - Vector3.down * (size + 5); // below neuron
|
||||||
style.alignment = TextAnchor.UpperCenter;
|
style.alignment = TextAnchor.UpperCenter;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user