private void Display3D() { int[] ListPos = new int[3]; ListPos[0] = 0; ListPos[1] = 0; ListPos[2] = 0; if (CurrentWorld == null) { CurrentWorld = new c3DWorld(Parent.NewWorld.Dimensions, new cPoint3D(1,1,1), this.renderWindowControlFor3D, ListPos, CompleteScreening); } CurrentWorld.ren1.RemoveAllViewProps(); foreach (var CurrentCell in Parent.NewWorld.ListCells) { c3DSphere CurrentSphere = CurrentCell.Get3DObj(); if (Parent.ListClusteringAlgo.GetListParams("3D").GetListValuesParam().ListCheckValues.Get("checkBoxDisplayText").Value) CurrentSphere.AddText(CurrentCell.Type.Name,CurrentWorld,2,CurrentCell.Type.TypeColor); if (Parent.ListClusteringAlgo.GetListParams("3D").GetListValuesParam().ListCheckValues.Get("checkBoxDisplayCellPath").Value) { for (int Memory = 0; Memory < CurrentCell.PreviousStates.Count-1; Memory++) { c3DLine NewLineForMemory = new c3DLine(CurrentCell.PreviousStates[Memory].CentroidPosition,CurrentCell.PreviousStates[Memory + 1].CentroidPosition); NewLineForMemory.Colour = CurrentCell.Type.TypeColor; CurrentWorld.AddGeometric3DObject(NewLineForMemory); } c3DLine NewLineForMemoryFinal = new c3DLine(CurrentCell.PreviousStates[CurrentCell.PreviousStates.Count - 1].CentroidPosition, CurrentCell.CentroidPosition); NewLineForMemoryFinal.Colour = CurrentCell.Type.TypeColor; CurrentWorld.AddGeometric3DObject(NewLineForMemoryFinal); } CurrentWorld.AddGeometric3DObject(CurrentSphere); // CurrentSphere.Colour = CurrentCell.Type.TypeColor; } CurrentWorld.DisplayBottom(Color.White); CurrentWorld.Render(); }
public void AddText(String Text, c3DWorld CurrentWorld, double scale) { if (TextActor == null) { TextActor = vtkFollower.New(); TextMapper = vtkPolyDataMapper.New(); TextVTK = vtkVectorText.New(); TextVTK.SetText(Text); TextMapper.SetInputConnection(TextVTK.GetOutputPort()); TextActor.SetMapper(TextMapper); //TextActor.SetPosition(this.GetActor().GetCenter()[0]-1, this.GetActor().GetCenter()[1]-1, this.GetActor().GetCenter()[2]-2); TextActor.SetPosition(Position.X , Position.Y , Position.Z - 1); TextActor.SetPickable(0); CurrentWorld.ren1.AddActor(TextActor); TextActor.SetCamera(CurrentWorld.ren1.GetActiveCamera()); } else { TextVTK.SetText(Text); } TextActor.SetScale(scale); }
// private cPoint3D Point2; //private void CreateLine(cPoint3D Point1, cPoint3D Point2, Color Colour) //{ // Position = new cPoint3D(Point1.X, Point1.Y, Point1.Z); // Position = new cPoint3D(0, 0, 0); // this.Colour = Colour; // Line = vtkLineSource.New(); // this.Point1 = new cPoint3D(Point1.X, Point1.Y, Point1.Z); // this.Point2 = new cPoint3D(Point2.X, Point2.Y, Point2.Z); // Line.SetPoint1(Point1.X, Point1.Y, Point1.Z); // Line.SetPoint2(Point2.X, Point2.Y, Point2.Z); // vtk_PolyDataMapper = vtkPolyDataMapper.New(); // vtk_PolyDataMapper.SetInputConnection(Line.GetOutputPort()); // CreateVTK3DObject(0); //} public c3DText(c3DWorld CurrentWorld, string TextToDisplay, cPoint3D Position, Color Colour, double Scale) { // CreateLine(Point1, Point2, Colour); vtkFollower TextActor = vtkFollower.New(); vtkPolyDataMapper TextMapper = vtkPolyDataMapper.New(); vtkVectorText TextVTK = vtkVectorText.New(); // double Dist = Point1.DistTo(Point2); TextVTK.SetText(TextToDisplay); TextMapper.SetInputConnection(TextVTK.GetOutputPort()); TextActor.SetMapper(TextMapper); TextActor.SetPosition(Position.X, Position.Y, Position.Z); TextActor.SetPickable(0); TextActor.SetScale(Scale); CurrentWorld.ren1.AddActor(TextActor); TextActor.SetCamera(CurrentWorld.ren1.GetActiveCamera()); }
public void DisplayLenght(c3DWorld CurrentWorld, double scale) { vtkFollower TextActor = vtkFollower.New(); vtkPolyDataMapper TextMapper = vtkPolyDataMapper.New(); vtkVectorText TextVTK = vtkVectorText.New(); double Dist = Point1.DistTo(Point2); TextVTK.SetText(Dist.ToString("N2")); TextMapper.SetInputConnection(TextVTK.GetOutputPort()); TextActor.SetMapper(TextMapper); TextActor.SetPosition(this.GetActor().GetCenter()[0], this.GetActor().GetCenter()[1], this.GetActor().GetCenter()[2]); TextActor.SetPickable(0); TextActor.SetScale(scale); CurrentWorld.ren1.AddActor(TextActor); TextActor.SetCamera(CurrentWorld.ren1.GetActiveCamera()); }
public void DisplayXYZ() { if (CompleteScreening == null) return; int DescX = this.comboBoxDescriptorX.SelectedIndex; int DescY = this.comboBoxDescriptorY.SelectedIndex; int DescZ = this.comboBoxDescriptorZ.SelectedIndex; if (DescX < 0) DescX = 0; if (DescY < 0) DescY = 0; if (DescZ < 0) DescZ = 0; int[] Pos = new int[2]; Pos[0] = 0; Pos[1] = 0; if (CurrentWorld == null) { CurrentWorld = new c3DWorld(new cPoint3D(1000, 1000, 1000), new cPoint3D(ListScales[DescX], ListScales[DescY], ListScales[DescZ]), this.renderWindowControl1, Pos, CompleteScreening); } CurrentWorld.SetBackgroundColor(Color.Black); CurrentWorld.ren1.RemoveAllViewProps(); // if (widget != null) widget.SetEnabled(0); Series CurrentSeries = new Series("ScatterPoints"); double MinX = double.MaxValue; double MinY = double.MaxValue; double MinZ = double.MaxValue; double MaxZ = double.MinValue; double MaxX = double.MinValue; double MaxY = double.MinValue; double TempX, TempY, TempZ; int Idx = 0; cExtendPlateList ListPlate = new cExtendPlateList(); cMetaBiologicalObjectList ListMeta = new cMetaBiologicalObjectList("Test"); cBiologicalSpot CurrentSpot1 = new cBiologicalSpot(Color.White, new cPoint3D(0, 0, 0), 1, 4); cMetaBiologicalObject Plate3D = new cMetaBiologicalObject("Data", ListMeta, CurrentSpot1); if (!IsFullScreen) ListPlate.Add(CompleteScreening.GetCurrentDisplayPlate()); else ListPlate = CompleteScreening.ListPlatesActive; vtkUnsignedCharArray colors = vtkUnsignedCharArray.New(); colors.SetName("colors"); colors.SetNumberOfComponents(3); vtkPoints Allpoints = vtkPoints.New(); cExtendedList ListPtX = new cExtendedList(); cExtendedList ListPtY = new cExtendedList(); cExtendedList ListPtZ = new cExtendedList(); for (int i = 0; i < ListPlate.Count; i++) { cPlate CurrentPlate = ListPlate[i]; for (int IdxValue = 0; IdxValue < CompleteScreening.Columns; IdxValue++) for (int IdxValue0 = 0; IdxValue0 < CompleteScreening.Rows; IdxValue0++) { cWell TmpWell = CurrentPlate.GetWell(IdxValue, IdxValue0, true); if (TmpWell != null) { TempX = TmpWell.ListDescriptors[DescX].GetValue(); if (TempX < MinX) MinX = TempX; if (TempX > MaxX) MaxX = TempX; TempY = TmpWell.ListDescriptors[DescY].GetValue(); if (TempY < MinY) MinY = TempY; if (TempY > MaxY) MaxY = TempY; TempZ = TmpWell.ListDescriptors[DescZ].GetValue(); if (TempZ < MinZ) MinZ = TempZ; if (TempZ > MaxZ) MaxZ = TempZ; // cBiologicalSpot CurrentSpot = new cBiologicalSpot(TmpWell.GetColor(), new cPoint3D(TempX, TempY, TempZ), 1, 4); List<char> Col = new List<char>(); Col.Add((char)(TmpWell.GetColor().R)); Col.Add((char)(TmpWell.GetColor().G)); Col.Add((char)(TmpWell.GetColor().B)); // IntPtr unmanagedPointer = Marshal.UnsafeAddrOfPinnedArrayElement(Col.ToArray(), 0); //colors.InsertNextTupleValue(unmanagedPointer); colors.InsertNextTuple3(Col[0], Col[1], Col[2]); ListPtX.Add(TempX); ListPtY.Add(TempY); ListPtZ.Add(TempZ); // CurrentSpot.Name = TmpWell.AssociatedPlate.Name + " - " + TmpWell.GetPosX() + "x" + TmpWell.GetPosY() + " :" + TmpWell.Name; // CurrentSpot.ObjectType = TmpWell.AssociatedPlate.Name + " - " + TmpWell.GetPosX() + "x" + TmpWell.GetPosY() + " :" + TmpWell.Name; // Plate3D.AddObject(CurrentSpot); // CurrentWorld.AddBiological3DObject(CurrentSpot); //CurrentSeries.Points.Add(TempX, TempY); // if (IsFullScreen) // CurrentSeries.Points[Idx].ToolTip = TmpWell.AssociatedPlate.Name + "\n" + TmpWell.GetPosX() + "x" + TmpWell.GetPosY() + " :" + TmpWell.Name; // else // CurrentSeries.Points[Idx].ToolTip = TmpWell.GetPosX() + "x" + TmpWell.GetPosY() + " :" + TmpWell.Name; Idx++; } } } double MinValueX = ListPtX.Min(); double MaxValueX = ListPtX.Max(); cExtendedList NormX = ListPtX.Normalize(MinValueX, MaxValueX); double MinValueY = ListPtY.Min(); double MaxValueY = ListPtY.Max(); cExtendedList NormY = ListPtY.Normalize(MinValueY, MaxValueY); double MinValueZ = ListPtZ.Min(); double MaxValueZ = ListPtZ.Max(); cExtendedList NormZ = ListPtZ.Normalize(MinValueZ, MaxValueZ); for (int IdxPt = 0; IdxPt < ListPtX.Count; IdxPt++) Allpoints.InsertNextPoint(NormX[IdxPt], NormY[IdxPt], NormZ[IdxPt]); vtkPolyData polydata = vtkPolyData.New(); polydata.SetPoints(Allpoints); polydata.GetPointData().SetScalars(colors); vtkSphereSource SphereSource = vtkSphereSource.New(); SphereSource.SetRadius(RadiusSphere); vtkGlyph3D glyph3D = vtkGlyph3D.New(); glyph3D.SetColorModeToColorByScalar(); glyph3D.SetSourceConnection(SphereSource.GetOutputPort()); glyph3D.SetInput(polydata); glyph3D.ScalingOff(); glyph3D.Update(); vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection(glyph3D.GetOutputPort()); vtkActor actor = vtkActor.New(); actor.SetMapper(mapper); CurrentWorld.ren1.AddActor(actor); if ((CompleteScreening.GetCurrentDisplayPlate().ListDRCRegions != null) && (CompleteScreening.GlobalInfo.OptionsWindow.checkBoxConnectDRCPts.Checked)) { foreach (cDRC_Region TmpRegion in CompleteScreening.GetCurrentDisplayPlate().ListDRCRegions) { int cpt = 0; cWell[][] ListWells = TmpRegion.GetListWells(); foreach (cWell[] item in ListWells) { for (int IdxWell = 0; IdxWell < item.Length - 1; IdxWell++) { //cWell TmpWell0 = CompleteScreening.GetCurrentDisplayPlate().GetWell(item[IdxWell], IdxValue0, true); if ((item[IdxWell] != null) && (item[IdxWell + 1] != null) && (item[IdxWell].GetClass() >= -1)) { double StartX = (item[IdxWell].ListDescriptors[DescX].GetValue() - MinValueX) / (MaxValueX - MinValueX); double StartY = (item[IdxWell].ListDescriptors[DescY].GetValue() - MinValueY) / (MaxValueY - MinValueY); double StartZ = (item[IdxWell].ListDescriptors[DescZ].GetValue() - MinValueZ) / (MaxValueZ - MinValueZ); double EndX = (item[IdxWell + 1].ListDescriptors[DescX].GetValue() - MinValueX) / (MaxValueX - MinValueX); double EndY = (item[IdxWell + 1].ListDescriptors[DescY].GetValue() - MinValueY) / (MaxValueY - MinValueY); double EndZ = (item[IdxWell + 1].ListDescriptors[DescZ].GetValue() - MinValueZ) / (MaxValueZ - MinValueZ); cPoint3D StartPt = new cPoint3D(StartX, StartY, StartZ); cPoint3D EndPt = new cPoint3D(EndX, EndY, EndZ); c3DLine NewLine = new c3DLine(StartPt, EndPt); CurrentWorld.AddGeometric3DObject(NewLine); } } } /*List<cDRC> ListDRC = new List<cDRC>(); for (int i = 0; i < CompleteScreening.ListDescriptors.Count; i++) { if (CompleteScreening.ListDescriptors[i].IsActive()) { cDRC CurrentDRC = new cDRC(TmpRegion, CompleteScreening.ListDescriptors[i]); ListDRC.Add(CurrentDRC); cpt++; } } */ //cDRCDisplay DRCDisplay = new cDRCDisplay(ListDRC, GlobalInfo); //if (DRCDisplay.CurrentChart.Series.Count == 0) continue; //DRCDisplay.CurrentChart.Location = new Point((DRCDisplay.CurrentChart.Width + 50) * 0, (DRCDisplay.CurrentChart.Height + 10 + DRCDisplay.CurrentRichTextBox.Height) * h++); //DRCDisplay.CurrentRichTextBox.Location = new Point(DRCDisplay.CurrentChart.Location.X, DRCDisplay.CurrentChart.Location.Y + DRCDisplay.CurrentChart.Height + 5); //WindowforDRCsDisplay.LChart.Add(DRCDisplay.CurrentChart); //WindowforDRCsDisplay.LRichTextBox.Add(DRCDisplay.CurrentRichTextBox); } } // vtkAxesActor axis = vtkAxesActor.New(); vtkAxisActor axisX = vtkAxisActor.New(); axisX.SetPoint1(0, 0, 0); axisX.SetPoint2(1, 0, 0); axisX.SetTickLocationToBoth(); axisX.SetDeltaMajor(0.1); axisX.SetMajorTickSize(0); axisX.MinorTicksVisibleOff(); //axisX.Maj CurrentWorld.ren1.AddActor(axisX); vtkAxisActor axisY = vtkAxisActor.New(); axisY.SetPoint1(0, 0, 0); axisY.SetPoint2(0, 1, 0); axisY.SetTickLocationToBoth(); axisY.SetDeltaMajor(0.1); axisY.SetMajorTickSize(0.05); axisY.MinorTicksVisibleOff(); CurrentWorld.ren1.AddActor(axisY); vtkAxisActor axisZ = vtkAxisActor.New(); axisZ.SetPoint1(0, 0, 0); axisZ.SetPoint2(0, 0, 1); axisZ.SetTickLocationToBoth(); axisZ.SetDeltaMajor(0.1); axisZ.SetMajorTickSize(0.05); axisZ.MinorTicksVisibleOff(); CurrentWorld.ren1.AddActor(axisZ); if (widget == null) { widget = vtkOrientationMarkerWidget.New(); axes = vtkAxesActor.New(); widget.SetOutlineColor(0.9300, 0.5700, 0.1300); widget.SetInteractor(CurrentWorld.iren); widget.SetViewport(0.0, 0.0, 0.4, 0.4); widget.SetEnabled(0); // widget.InteractiveOn(); if (this.comboBoxDescriptorX.SelectedItem == null) axes.SetXAxisLabelText(this.comboBoxDescriptorX.Items[0].ToString()); else axes.SetXAxisLabelText(this.comboBoxDescriptorX.SelectedItem.ToString()); if (this.comboBoxDescriptorY.SelectedItem == null) axes.SetYAxisLabelText(this.comboBoxDescriptorY.Items[0].ToString()); else axes.SetYAxisLabelText(this.comboBoxDescriptorY.SelectedItem.ToString()); if (this.comboBoxDescriptorZ.SelectedItem == null) axes.SetZAxisLabelText(this.comboBoxDescriptorZ.Items[0].ToString()); else axes.SetZAxisLabelText(this.comboBoxDescriptorZ.SelectedItem.ToString()); widget.SetOrientationMarker(axes); } else { if(this.comboBoxDescriptorX.SelectedItem!=null) axes.SetXAxisLabelText(this.comboBoxDescriptorX.SelectedItem.ToString()); if (this.comboBoxDescriptorY.SelectedItem != null) axes.SetYAxisLabelText(this.comboBoxDescriptorY.SelectedItem.ToString()); if (this.comboBoxDescriptorZ.SelectedItem != null) axes.SetZAxisLabelText(this.comboBoxDescriptorZ.SelectedItem.ToString()); widget.SetOrientationMarker(axes); } // //vtkCameraWidget Wid = vtkCameraWidget.New(); //Wid.SetInteractor(CurrentWorld.iren); //Wid.SetEnabled(1); // Wid.InteractiveOn(); //vtkDistanceWidget distanceWidget = vtkDistanceWidget.New(); //distanceWidget.SetInteractor(CurrentWorld.iren); //distanceWidget.SetEnabled(1); //distanceWidget.CreateDefaultRepresentation(); //((vtkDistanceRepresentation)distanceWidget.GetRepresentation()).SetLabelFormat("%-#6.3g mm"); /*static_cast<vtkDistanceRepresentation*>(distanceWidget->GetRepresentation()) ->SetLabelFormat("%-#6.3g mm"); */ // Plate3D.GenerateAndDisplayBoundingBox(1, Color.White, false, CurrentWorld); //c3DText CaptionX = new c3DText(CurrentWorld, CompleteScreening.ListDescriptors[DescX].GetName(), new cPoint3D(MaxX, MinY, MinZ), Color.DarkRed, this.FontSize); //c3DLine LineX = new c3DLine(new cPoint3D(MinX, MinY, MinZ), new cPoint3D(MaxX, MinY, MinZ), Color.DarkRed); //CurrentWorld.AddGeometric3DObject(LineX); //c3DText CaptionY = new c3DText(CurrentWorld, CompleteScreening.ListDescriptors[DescY].GetName(), new cPoint3D(MinX, MaxY, MinZ), Color.DarkGreen, this.FontSize); //c3DLine LineY = new c3DLine(new cPoint3D(MinX, MinY, MinZ), new cPoint3D(MinX, MaxY, MinZ), Color.DarkGreen); //CurrentWorld.AddGeometric3DObject(LineY); //c3DText CaptionZ = new c3DText(CurrentWorld, CompleteScreening.ListDescriptors[DescZ].GetName(), new cPoint3D(MinX, MinY, MaxZ), Color.DarkBlue, this.FontSize); //c3DLine LineZ = new c3DLine(new cPoint3D(MinX, MinY, MinZ), new cPoint3D(MinX, MinY, MaxZ), Color.DarkBlue); //CurrentWorld.AddGeometric3DObject(LineZ); CurrentWorld.SimpleRender();// Render(); }
public void AddText(String Text, c3DWorld CurrentWorld, double scale, Color colour) { AddText(Text, CurrentWorld, scale); TextActor.GetProperty().SetColor(Colour.R / 255.0, Colour.G / 255.0, Colour.B / 255.0); }
//public void AddPointingArrow(double scale, Color Colour) //{ // vtkArrowSource ArrowSource = vtkArrowSource.New(); // ArrowActor = vtkActor.New(); // vtkPolyDataMapper ArrowMapper = vtkPolyDataMapper.New(); // ArrowMapper.SetInputConnection(ArrowSource.GetOutputPort()); // ArrowActor.SetMapper(ArrowMapper); // ArrowActor.SetPosition(Position.X - 6, Position.Y - 0, Position.Z - 6); // ArrowActor.RotateY(-45); // ArrowActor.SetScale(scale); // ArrowActor.SetPickable(0); // Color C = Color.MediumPurple; // ArrowActor.GetProperty().SetColor(Colour.R / 255.0, Colour.G / 255.0, Colour.G / 255.0); // // CreateVTK3DObject(); // // CurrentWorld.ren1.AddActor(ArrowActor); //} //public void AddPointingArrow(double scale) //{ // AddPointingArrow(scale, Color.White); //} public void DisplayCentroid(c3DWorld CurrentWorld, double scale) { if (SphereActor == null) { vtkSphereSource SphereSource = vtkSphereSource.New(); vtkPolyDataMapper SphereMapper = vtkPolyDataMapper.New(); SphereActor = vtkActor.New(); SphereMapper = vtkPolyDataMapper.New(); SphereMapper.SetInputConnection(SphereSource.GetOutputPort()); SphereActor.SetMapper(SphereMapper); double[] CenterPos = vtk_Actor.GetCenter(); SphereActor.SetPosition(CenterPos[0], CenterPos[1], CenterPos[2]); SphereActor.SetScale(scale); SphereActor.SetPickable(0); Color C = Color.YellowGreen; SphereActor.GetProperty().SetColor(C.R / 255.0, C.G / 255.0, C.B / 255.0); CurrentWorld.ren1.AddActor(SphereActor); } else { if (SphereActor.GetVisibility() == 0) SphereActor.SetVisibility(1); else SphereActor.SetVisibility(0); } }
public void AddPointingArrow(c3DWorld CurrentWorld, double scale) { AddPointingArrow(CurrentWorld, scale, Color.White); }
public void AddPointingArrow(c3DWorld CurrentWorld, double scale, Color Colour) { vtkArrowSource ArrowSource = vtkArrowSource.New(); ArrowActor = vtkActor.New(); vtkPolyDataMapper ArrowMapper = vtkPolyDataMapper.New(); ArrowMapper.SetInputConnection(ArrowSource.GetOutputPort()); ArrowActor.SetMapper(ArrowMapper); ArrowActor.SetPosition(Position.X - 6, Position.Y - 0, Position.Z - 6); ArrowActor.RotateY(-45); ArrowActor.SetScale(scale); ArrowActor.SetPickable(0); Color C = Color.MediumPurple; ArrowActor.GetProperty().SetColor(Colour.R / 255.0, Colour.G / 255.0, Colour.G / 255.0); // CreateVTK3DObject(); CurrentWorld.ren1.AddActor(ArrowActor); }