I have a viewport3d control in a WPF window, in this I draw some elements essentially GeometryModel3D type, with a method "CreateTextLabelModel3D" of the class "TextCreator" I visualize characteristics of the elements such as: length, order number, name of the elements, etc. . With some bool type variables, it is indicated which ones are displayed and which ones are not, all the previous steps are carried out correctly, the problem occurs when I try to hide some characteristic and visualize another, the new one is superimposed on the other that I should hide. below the code snippet.
public void TransferirChequeoPropiedades(bool _chkNum, bool _chkDime, bool _chkLong, bool _chkLoad, bool _chkPesoPropio,
bool _chknumArea, bool _chknumHueco, bool _chkLadoRec, bool _chkAlturaRec, bool _chkArea, bool _chkCargaLosa, bool
_chkCargasapli, bool _chkProp)
{
chkNum = _chkNum;
chkDime = _chkDime;
chkLong = _chkLong;
chkLoad = _chkLoad;
chkPesoPropio = _chkPesoPropio;
chknumArea = _chknumArea;
chknumHueco = _chknumHueco;
chkLadoRec = _chkLadoRec;
chkAlturaRec = _chkAlturaRec;
chkArea = _chkArea;
chkCargaLosa = _chkCargaLosa;
chkCargasapli = _chkCargasapli;
chkProp = _chkProp;
MostrarPropiedadesDimension(MainModel3Dgroup);
}
void MostrarPropiedadesDimension(Model3DGroup modelg)
{
Brush colorTexto = colortextos;
GeometryModel3D textLong = null;
modelg.Children.Remove(textLong); // modelg is a Model3DGroup Element
model_visual.Content = modelg; // model_visual is a ModelVisual3D Element
if (chkLong) // bool variable from a checkbox
{
for (int i = 0; i < Shapes3D.Count; i++)
{
double x = Shapes3D[i].Pt13D.X; // Start point X of line elements
double x2 = Shapes3D[i].Pt23D.X; // End point X of line elements
double y = Shapes3D[i].Pt13D.Y; // Start point Y of line elements
double y2 = Shapes3D[i].Pt23D.Y; // End point Y of line elements
double z = Shapes3D[i].Pt13D.Z; // Z coordinate of the points of line elements
if (Shapes3D[i].Pt13D.Y.Equals(Shapes3D[i].Pt23D.Y))
{
// CreateTextLabelModel3D is a static method of the TextCreator static Class
textLong = TextCreator.CreateTextLabelModel3D((x2 - x).ToString(), colorTexto,
false, .3, new Point3D(x + (x2 - x) / 2 - 0.1, y + 0.25, z), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
}
else if (Shapes3D[i].Pt13D.X.Equals(Shapes3D[i].Pt23D.X))
{
textLong = TextCreator.CreateTextLabelModel3D((Math.Abs(y2 - y)).ToString(), colorTexto,
false, .3, new Point3D(x - 0.25, y + (y2 - y) / 2 - 0.1, z), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
}
modelg.Children.Add(textLong);
}
}
if (chkNum) // bool variable from a checkbox
{
for (int i = 0; i < Shapes3D.Count; i++)
{
double x = Shapes3D[i].Pt13D.X;
double x2 = Shapes3D[i].Pt23D.X;
double y = Shapes3D[i].Pt13D.Y;
double y2 = Shapes3D[i].Pt23D.Y;
double z = Shapes3D[i].Pt13D.Z;
if (Shapes3D[i].Pt13D.Y.Equals(Shapes3D[i].Pt23D.Y))
{
textLong = TextCreator.CreateTextLabelModel3D((i + 1).ToString(), colorTexto,
false, .3, new Point3D(x + (x2 - x) / 2 - 0.1, y + 0.25, z), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
}
else if (Shapes3D[i].Pt13D.X.Equals(Shapes3D[i].Pt23D.X))
{
textLong = TextCreator.CreateTextLabelModel3D((i + 1).ToString(), colorTexto,
false, .3, new Point3D(x - 0.25, y + (y2 - y) / 2 - 0.1, z), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
}
modelg.Children.Add(textLong);
}
}
}