Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        private void AnalyseSequence(cImage SeqToAnalyse)
        {
            //    //FormForThumbnails WindThumbnail = new FormForThumbnails();

            //    //for (int k = 0; k < ListFormForControl.Count; k++)
            //    //{
            //    //        FormForControl Obj = ListFormForControl.ElementAt(ListFormForControl.Count - k-1);
            //    //        Obj.DisplayThumbnail(WindThumbnail);
            //    //}
            //    //WindThumbnail.Show();

            //    //return;

            #region initialization

            if (SeqToAnalyse == null) return;

            // create World
            if (Current3DWorld == null)
            {
                Current3DWorld = new c3DNewWorld(new cPoint3D(SeqToAnalyse.Width, SeqToAnalyse.Height, SeqToAnalyse.Depth),
                                                 new cPoint3D(SeqToAnalyse.Resolution));
            }
              else
            {
            //     //   Current3DWorld.ren1.
              //  Current3DWorld.Terminate();
                Current3DWorld = null;
                 Current3DWorld = new c3DNewWorld(new cPoint3D(SeqToAnalyse.Width, SeqToAnalyse.Height, SeqToAnalyse.Depth),
                                                         new cPoint3D(SeqToAnalyse.Resolution));

            }

            for (int k = 0; k < ListFormForControl.Count; k++)
            {
                FormForControl Obj = ListFormForControl.ElementAt(ListFormForControl.Count - k-1);
                if (Obj.numericUpDownChannel.Value >= SeqToAnalyse.GetNumChannels())
                {
                    MessageBox.Show("Wrong number of channels", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            //   // Current3DWorld.ListObjControl = ListFormForControl;
            //    //   dataGridViewForClassif.DataSource = CurrentTable;
            //    if (DataGrid == null)
            //    {
            //        DataGrid = new FormForDataGridView();
            //        DataGrid.Show();
            //    }
            //    Current3DWorld.SetLinkToDataGridView(DataGrid.dataGridViewForResults);

            Current3DWorld.ListMetaObjectList = new List<cMetaBiologicalObjectList>();
            cMetaBiologicalObjectList ListMetacells = new cMetaBiologicalObjectList("List Meta Objects");
            Current3DWorld.ListMetaObjectList.Add(ListMetacells);
            #endregion

            #region Detection
            for (int k = 0; k < ListFormForControl.Count; k++)
            {
                FormForControl Obj = ListFormForControl.ElementAt(ListFormForControl.Count - k -1);

                if (Obj.radioButtonIsVolume.Checked)    // we have to detect a volume !
                {
                    cVolumeDetection Detection = new cVolumeDetection(SeqToAnalyse, (int)Obj.numericUpDownChannel.Value, Obj.WindowForVolumeDetection.checkBoxIsBorderKill.Checked);
                    Detection.SetShift(new cPoint3D((float)Obj.WindowForPreProcessing.numericUpDownShiftX.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftY.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftZ.Value));

                    if ((Obj.checkBoxPreProcessings.Checked == false) || (Obj.WindowForPreProcessing.checkBoxMedianIsDisabled.Checked))
                    {
                        Detection.SetMedian(-1);
                        Detection.SetShift(new cPoint3D(0, 0, 0));
                    }
                    else
                    {
                        Detection.SetMedian((int)Obj.WindowForPreProcessing.numericUpDownMedianKernel.Value);
                        Detection.SetShift(new cPoint3D((float)Obj.WindowForPreProcessing.numericUpDownShiftX.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftY.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftZ.Value));
                    }

                    if (Obj.WindowForVolumeDetection.checkBoxVolumeSmooth.Checked)
                        Detection.MeshSmoother = new cMeshSmoother((int)Obj.WindowForVolumeDetection.numericUpDownSmoothIterations.Value);

                    if ((Obj.comboBoxContainer.SelectedItem !=null) && (Obj.comboBoxContainer.SelectedItem.ToString() != ""))
                    {
                        Detection.SetContainers(Current3DWorld.GetListBiologicalObjectsOfType(Obj.comboBoxContainer.Items[0].ToString()));
                        if (Obj.InOrOut.radioButtonIn.Checked) Detection.SetContainersMode(0);
                        else Detection.SetContainersMode(1);
                    }
                    else
                        Detection.SetContainers(null);

                    if (Obj.WindowForVolumeDetection.checkBoxIsRegionGrowing.Checked == false)  // no region growing direct detection
                    {
                        Obj.AssociatedBiologicalObjectList = Detection.IntensityThreshold((float)Obj.WindowForVolumeDetection.numericUpDownIntensityThreshold.Value,
                                                                                          (float)Obj.WindowForVolumeDetection.numericUpDownVolumeMinVol.Value,
                                                                                          (float)Obj.WindowForVolumeDetection.numericUpDownVolumeMaxVol.Value);
                    }
                   else // region growing
                   {
                        if (Obj.WindowForVolumeDetection.radioButtonRegionsBased.Checked) // start from a segmentation
                        {
                            if (Obj.WindowForVolumeDetection.radioButtonVolumeDetectionNew.Checked) // a new segmentation has to be performed
                            {
            //                        // Image3D CurrentPatch = new Image3D(2 * Radius, 2 * Radius, 1, CurrentImageToProcess.NumBands);
                                cImage CurrentBinary = new cImage(SeqToAnalyse.Width, SeqToAnalyse.Height, SeqToAnalyse.Depth, 1);

                                for (int i = 0; i < CurrentBinary.ImageSize; i++)
                                {
                                    if (SeqToAnalyse.SingleChannelImage[(int)Obj.numericUpDownChannel.Value].Data[i] >= (float)Obj.WindowForVolumeDetection.numericUpDownIntensityThreshold.Value)
                                        CurrentBinary.SingleChannelImage[0].Data[i] = 1;
                                }

                                eConnectivity CurrentConnectivity = eConnectivity.TWOD_4;
                                if (CurrentBinary.Depth > 1)
                                    CurrentConnectivity = eConnectivity.THREED_6;

                                ConnectedComponentSet OFNucleus = new ConnectedComponentSet(CurrentBinary, null, null, 0, CurrentConnectivity, (int)Obj.WindowForVolumeDetection.numericUpDownRegionBasedMinArea.Value, (int)Obj.WindowForVolumeDetection.numericUpDownRegionBasedMaxArea.Value);
            //                      //  RegionGrowing = new cRegionGrowing(OFNucleus, NewSeq[0], (int)numericUpDownChannelForRegionGrowing.Value, (float)numericUpDownIntensityForRegionGrowing.Value, (int)numericUpDownMaxNucleusArea.Value);
                                int NumIterations = -1;
                                if (Obj.WindowForVolumeDetection.checkBoxIsConvergence.Checked == false) NumIterations = (int)Obj.WindowForVolumeDetection.numericUpDownIterationNumber.Value;

                                float MergingRatio = (float)((Obj.WindowForVolumeDetection.trackBarMergingStrength.Maximum - Obj.WindowForVolumeDetection.trackBarMergingStrength.Value) / 100.0);
                                Obj.AssociatedBiologicalObjectList = Detection.RegionGrowing(OFNucleus,
                                                                                            (float)Obj.WindowForVolumeDetection.numericUpDownIntensityForRegionGrowing.Value,
                                                                                            (float)Obj.WindowForVolumeDetection.numericUpDownVolumeMinVol.Value,
                                                                                            (float)Obj.WindowForVolumeDetection.numericUpDownVolumeMaxVol.Value, NumIterations, MergingRatio);

                            }
            //                    else
            //                    {
            //                        throw new System.ArgumentException("Not implemented", "Error");
            //                    }
            //                }
            //                else // start from seeds points
            //                {

            //                        // first gather the seeds
            //                        if (Obj.WindowForVolumeDetection.comboBoxExistingSpotsDetected.Items.Count == 0) break;
            //                       List<cBiological3DObject> ListSeeds = Current3DWorld.GetListBiologicalObjectsOfType(Obj.WindowForVolumeDetection.comboBoxExistingSpotsDetected.Items[0].ToString());

            //                       int NumIterations = -1;
            //                       if (Obj.WindowForVolumeDetection.checkBoxIsConvergence.Checked == false) NumIterations = (int)Obj.WindowForVolumeDetection.numericUpDownIterationNumber.Value;

            //                       float MergingRatio = (float)((Obj.WindowForVolumeDetection.trackBarMergingStrength.Maximum - Obj.WindowForVolumeDetection.trackBarMergingStrength.Value) / 100.0);
            //                       Obj.AssociatedBiologicalObjectList = Detection.RegionGrowing(ListSeeds,
            //                                                                                   (float)Obj.WindowForVolumeDetection.numericUpDownIntensityForRegionGrowing.Value,
            //                                                                                   (float)Obj.WindowForVolumeDetection.numericUpDownVolumeMinVol.Value,
            //                                                                                   (float)Obj.WindowForVolumeDetection.numericUpDownVolumeMaxVol.Value, NumIterations, MergingRatio);
                        }
                    }
                    if (Obj.AssociatedBiologicalObjectList != null)
                    {
                        Obj.richTextBoxInfo.AppendText(Obj.AssociatedBiologicalObjectList.Count + " objects detected.");

                        for (int i = 0; i < Obj.AssociatedBiologicalObjectList.Count; i++)
                        {
                            cBiological3DVolume TmpVol = (cBiological3DVolume)Obj.AssociatedBiologicalObjectList[i];
                            Obj.AssociatedBiologicalObjectList[i].SetType(Obj.textBoxName.Text);
            //                    TmpVol.ThumbnailnewImage = imageListForThumbnail.Images[Obj.AssociatedBiologicalObjectList[i].GetType() + ".jpg"];
                            Obj.AssociatedBiologicalObjectList[i].Name = Obj.textBoxName.Text + " " + i;
              //                  Obj.AssociatedBiologicalObjectList[i].IsMaster = Obj.IsMasterObject();
            //                    List<double> Res = TmpVol.Information.GetInformation();

                            if (Obj.checkBoxIsDisplayName.Checked)
                            {
                                cGeometric3DObject AssociatedText = TmpVol.AttachText(TmpVol.Name, 10, Color.White);
                                AssociatedText.IsStayInFrontOfCamera = true;
                                Current3DWorld.AddGeometric3DObject(AssociatedText);

                                //                        TmpVol.AddText(TmpVol.Name, Current3DWorld, (double)Obj.ForText.numericUpDownArrowScale.Value, Obj.ForText.buttonChangeColorPositive.BackColor);
                            }

                            if (Obj.checkIsBoxPointingArrow.Checked)
                            {
                                cGeometric3DObject AssociatedArrow = TmpVol.AttachPointingArrow((double)Obj.ForArrow.numericUpDownArrowScale.Value,
                                                            Obj.ForArrow.buttonChangeColorPositive.BackColor);

                                Current3DWorld.AddGeometric3DObject(AssociatedArrow);

                            }

                            Obj.AssociatedBiologicalObjectList[i].SetOpacity((double)Obj.ColorOpacity.numericUpDownValue.Value);

                            // if the object it the Master then create a meta-object and put it inside
                            if (Obj.IsMasterObject())
                            {
                                cMetaBiologicalObject Cell = new cMetaBiologicalObject(Obj.WindowForMaster.textBoxName.Text + i, Current3DWorld.ListMetaObjectList[0], Obj.AssociatedBiologicalObjectList[i]);
            //                        // Cell.AddObject(Obj.AssociatedBiologicalObjectList[i]);
                                Current3DWorld.ListMetaObjectList[0].Add(Cell);
                            }
                        }

                        if (Obj.radioButtonColorSingle.Checked)
                            Current3DWorld.AddBiological3DObjects(Obj.AssociatedBiologicalObjectList, Obj.buttonChangeColorPositive.BackColor, eColorMode.Regular);
                        else if (Obj.radioButtonColorRandom.Checked)
                            Current3DWorld.AddBiological3DObjects(Obj.AssociatedBiologicalObjectList, Obj.buttonChangeColorPositive.BackColor, eColorMode.Random);
                        else if (Obj.radioButtonColorIndexed.Checked)
                            Current3DWorld.AddBiological3DObjects(Obj.AssociatedBiologicalObjectList, Obj.buttonChangeColorPositive.BackColor, eColorMode.Indexed);
                    }

                }
                else if (Obj.RadioButtonIsSpot.Checked)
                {
                    cSpotDetection Detection = new cSpotDetection(SeqToAnalyse, (int)Obj.numericUpDownChannel.Value);

                    if ((Obj.checkBoxPreProcessings.Checked == false) || (Obj.WindowForPreProcessing.checkBoxMedianIsDisabled.Checked))
                    {
                        Detection.SetMedian(-1);
                        Detection.SetShift(new cPoint3D(0, 0, 0));
                    }
                    else
                    {
                        Detection.SetMedian((int)Obj.WindowForPreProcessing.numericUpDownMedianKernel.Value);
                        Detection.SetShift(new cPoint3D((float)Obj.WindowForPreProcessing.numericUpDownShiftX.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftY.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftZ.Value));
                    }

                    if ((Obj.comboBoxContainer.Items.Count > 0) && (Obj.comboBoxContainer.SelectedItem != null))
                    {
                        Detection.SetContainers(Current3DWorld.GetListBiologicalObjectsOfType(Obj.comboBoxContainer.SelectedItem.ToString()));
                        if (Obj.InOrOut.radioButtonIn.Checked) Detection.SetContainersMode(0);
                        else Detection.SetContainersMode(1);
                    }

                    Obj.AssociatedBiologicalObjectList = Detection.HessianDetection((float)Obj.WindowForSpotDetection.numericUpDownSpotRadius.Value,
                                                                                    (float)Obj.WindowForSpotDetection.numericUpDownIntensityThreshold.Value,
                                                                                    (int)Obj.WindowForSpotDetection.numericUpDownSpotLocality.Value,
                                                                                    (double)Obj.WindowForSpotDetection.numericUpDownSphereDisplayRadius.Value);

                    Obj.richTextBoxInfo.AppendText(Obj.AssociatedBiologicalObjectList.Count + " objects detected.");
                    for (int i = 0; i < Obj.AssociatedBiologicalObjectList.Count; i++)
                    {
                        cBiologicalSpot TmpSpot = (cBiologicalSpot)Obj.AssociatedBiologicalObjectList[i];
                        TmpSpot.Name = Obj.textBoxName.Text + " " + i;
                        TmpSpot.SetType(Obj.textBoxName.Text);
            //                TmpSpot.ThumbnailnewImage = imageListForThumbnail.Images[Obj.AssociatedBiologicalObjectList[i].GetType() + ".jpg"];

            //                if (Obj.checkBoxIsDisplayName.Checked)
            //                    TmpSpot.AddText(TmpSpot.Name, Current3DWorld, (double)Obj.ForText.numericUpDownArrowScale.Value, Obj.ForText.buttonChangeColorPositive.BackColor);

                            if (Obj.checkIsBoxPointingArrow.Checked)
                            {
                                cGeometric3DObject AssociatedArrow = TmpSpot.AttachPointingArrow((double)Obj.ForArrow.numericUpDownArrowScale.Value, Obj.ForArrow.buttonChangeColorPositive.BackColor);
                                Current3DWorld.AddGeometric3DObject(AssociatedArrow);
                            }

            //                TmpSpot.SetOpacity((double)Obj.ColorOpacity.numericUpDownValue.Value);

            //                // if the object it the Master then create a meta-object and put it inside
                        if (Obj.IsMasterObject())
                        {
                            cMetaBiologicalObject Cell = new cMetaBiologicalObject("Cell " + i, Current3DWorld.ListMetaObjectList[0], Obj.AssociatedBiologicalObjectList[i]);
            //                 //   Cell.AddObject(Obj.AssociatedBiologicalObjectList[i]);
                            Current3DWorld.ListMetaObjectList[0].Add(Cell);
                        }

            //                /*cMetaBiologicalObject Cell = */
            //                //Current3DWorld.ListMetaObjectList[0].AssociateWith(Current3DWorld.ListMetaObjectList[0].FindTheClosestVolumeFrom(TmpSpot.GetCentroid(), 20), TmpSpot);
                    }

            //            if (Obj.radioButtonColorSingle.Checked)
            //                Current3DWorld.AddBiological3DObjects(Obj.AssociatedBiologicalObjectList, Obj.buttonChangeColorPositive.BackColor, eColorMode.Regular);
            //            else if (Obj.radioButtonColorRandom.Checked)
            //                Current3DWorld.AddBiological3DObjects(Obj.AssociatedBiologicalObjectList, Obj.buttonChangeColorPositive.BackColor, eColorMode.Random);
            //            else if (Obj.radioButtonColorIndexed.Checked)
            //                Current3DWorld.AddBiological3DObjects(Obj.AssociatedBiologicalObjectList, Obj.buttonChangeColorPositive.BackColor, eColorMode.Indexed);

                }
                else if (Obj.radioButtonIsVolumeRendering.Checked)
                {
                    Current3DWorld.AddVolume3D(new cVolumeRendering3D(this.AssociatedImage.SingleChannelImage[(int)Obj.numericUpDownChannel.Value],
                                               new cPoint3D((float)Obj.WindowForPreProcessing.numericUpDownShiftX.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftY.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftZ.Value),
                                               null, Current3DWorld));

                  //  cVolume3D Volume = new cVolume3D(SeqToAnalyse, (int)Obj.numericUpDownChannel.Value, new cPoint3D((float)Obj.WindowForPreProcessing.numericUpDownShiftX.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftY.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftZ.Value));
                  //  Current3DWorld.AddVolume3D(Volume, Color.Black, Obj.buttonChangeColorPositive.BackColor);
                }

            //        Thread oThread = new Thread(new ThreadStart(Obj.DisplayDone));

            }
            #endregion

            #region Objects Association
            cMetaBiologicalObjectList MetaCellList = Current3DWorld.ListMetaObjectList[0];

            // let's associate the objects
            for (int k = 0; k < ListFormForControl.Count; k++)
            {
                FormForControl Obj = ListFormForControl.ElementAt(ListFormForControl.Count - k -1);

                // that's a volume rendering ... no connection
                if (Obj.radioButtonIsVolumeRendering.Checked) continue;

                // the object is the master
                if (Obj.IsMasterObject()) continue;

                // this object has not connections ... is not associated to the master
                if (Obj.comboBoxLinkToTheMaster.SelectedIndex == 0) continue;

                cPoint3D ClosestPt = new cPoint3D(0, 0, 0);

                foreach (cBiological3DVolume CurrentSubObj in Obj.AssociatedBiologicalObjectList)
                {
                    cBiological3DVolume ObjectToIdentify = null;
                    switch (Obj.comboBoxLinkToTheMaster.SelectedIndex)
                    {
                        case 1:         // association by distance to the master centroid
                            ObjectToIdentify = MetaCellList.FindTheClosestVolumeCentroidFrom(CurrentSubObj.GetCentroid(), (double)Obj.WindowDistanceToMaster.numericUpDownDistanceMaxToMaster.Value);
                            break;
                        case 2:
            //                    //cBiological3DVolume CurrentVolume
                            ObjectToIdentify = MetaCellList.FindTheClosestVolumeFrom(CurrentSubObj, (double)Obj.WindowDistanceToMaster.numericUpDownDistanceMaxToMaster.Value, out ClosestPt);
                            break;
                        default:
                            break;
                   }

                    if (ObjectToIdentify == null) continue;
                    cMetaBiologicalObject Cell = MetaCellList.AssociateWith(ObjectToIdentify, CurrentSubObj);

            //            // --------------  draw information and links between the objects ---------------------
                    if (Obj.WindowDistanceToMaster.checkBoxDrawLinkToMasterCenter.Checked)
                    {
                        c3DLine CurrLine = new c3DLine(CurrentSubObj.GetCentroid(), ObjectToIdentify.GetCentroid());
                        Current3DWorld.AddGeometric3DObject(CurrLine);

                        //if (Obj.WindowDistanceToMaster.checkBoxDisplayBranchToCenterDistance.Checked)
                        //    CurrLine.DisplayLenght(Current3DWorld, 0.4);
                    }

            //            // --------------  draw information and links between the objects ---------------------
                    if (Obj.WindowDistanceToMaster.checkBoxDrawLinkToMasterEdges.Checked)
                    {
                        c3DLine CurrLine1 = new c3DLine(CurrentSubObj.GetCentroid(), ClosestPt);

                        Current3DWorld.AddGeometric3DObject(CurrLine1);

                        //if(Obj.WindowDistanceToMaster.checkBoxDisplayBranchToEdgesDistance.Checked)
                        //    CurrLine1.DisplayLenght(Current3DWorld, 0.4);
                    }
                }
            }
            #endregion

            #region Post Processings
            for (int k = 0; k < ListFormForControl.Count; k++)
            {
                FormForControl Obj = ListFormForControl.ElementAt(ListFormForControl.Count - k - 1);
                // the object is the master
            //      //  if (!Obj.IsMasterObject()) continue;

                if (!Obj.WindowForMaster.checkBoxDrawAssociatedDelaunay.Checked) continue;
                foreach (cMetaBiologicalObject CurrentMeta in MetaCellList)
                {
                    Current3DWorld.AddGeometric3DObject(CurrentMeta.GenerateDelaunay(2.0f,true));
                }
            }

            if (PostProcessWindow.checkBoxRemoveUnAssociatedObjects.Checked)
            {
                int RemovedObjects = Current3DWorld.RemoveNonAssociatedObjects();
                Console.WriteLine(RemovedObjects + " objects removed.");
            }

            //    if (PostProcessWindow.checkBoxExportMetaObjectSignatures.Checked)
            //    {
            //        if (CurrentTable == null)
            //        {
            //            CurrentTable = new DataTable();

            //            if (CurrentExperiment == null)
            //                CurrentTable.Columns.Add(new DataColumn("Image Idx", typeof(int)));
            //            else
            //            {
            //                CurrentTable.Columns.Add(new DataColumn("Image Col.", typeof(int)));
            //                CurrentTable.Columns.Add(new DataColumn("Image Row", typeof(int)));
            //            }

            //            CurrentTable.Columns.Add(new DataColumn("Meta Object Name", typeof(string)));

            //            foreach (string DescName in MetaCellList[0].GetSignatureNames())
            //                CurrentTable.Columns.Add(new DataColumn(DescName, typeof(double)));

            //            CurrentTable.Columns.Add(new DataColumn("Class", typeof(double)));
            //        }

            //        foreach (cMetaBiologicalObject CurrentMeta in MetaCellList)
            //        {
            //            List<double> CurrentSignature = CurrentMeta.GetSignature();

            //            CurrentTable.Rows.Add();
            //            if (CurrentExperiment == null)
            //            {
            //                CurrentTable.Rows[CurrentTable.Rows.Count - 1][0] = IdxImageProcessed;
            //                CurrentTable.Rows[CurrentTable.Rows.Count - 1][1] = CurrentMeta.Name;

            //                for (int Idx = 0; Idx < CurrentSignature.Count; Idx++)
            //                    CurrentTable.Rows[CurrentTable.Rows.Count - 1][Idx + 2] = CurrentSignature[Idx];
            //            }
            //            else
            //            {
            //                CurrentTable.Rows[CurrentTable.Rows.Count - 1][0] = CurrentExperiment.Column;
            //                CurrentTable.Rows[CurrentTable.Rows.Count - 1][1] = CurrentExperiment.Row;
            //                CurrentTable.Rows[CurrentTable.Rows.Count - 1][2] = CurrentMeta.Name;

            //                for (int Idx = 0; Idx < CurrentSignature.Count; Idx++)
            //                    CurrentTable.Rows[CurrentTable.Rows.Count - 1][Idx + 3] = CurrentSignature[Idx];
            //            }

            //            // Current3DWorld.CopyMetaObjectSignatureToTable(CurrentMeta, 0);
            //        }
            //        if (DataGrid != null)
            //        {
            //            DataGrid.dataGridViewForResults.DataSource = CurrentTable;
            //            DataGrid.Update();
            //            IdxImageProcessed++;
            //        }
            //    }

            #endregion

            //    //CurrentTable = new DataTable();
            //    if (CurrentExperiment == null)
            //    {
            //        if (PostProcessWindow.checkBoxDisplayBottomPlate.Checked) Current3DWorld.DisplayBottom(Color.FromArgb(255, 255, 255));
            //        Current3DWorld.SetBackgroundColor(PostProcessWindow.buttonChangeColorPositive.BackColor);
            //        Current3DWorld.Render();
            //    }
            //    // Current3DWorld.SetLinkToDataGridView(dataGridViewForClassif);

            cViewer3D V3D = new cViewer3D();
            V3D.SetInputData(Current3DWorld);
            V3D.Run();

            cDisplayToWindow DTW = new cDisplayToWindow();
            DTW.SetInputData(V3D.GetOutPut());
            DTW.Run();
            DTW.Display();
        }
        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();
        }
Exemplo n.º 4
0
        public cFeedBackMessage Run(c3DNewWorld _3DWorld)
        {
            if (base.Start() == false)
            {
                base.FeedBackMessage.IsSucceed = false;
                return base.FeedBackMessage;
            }

            //if (this.Input == null)
            //{
            //    FeedBackMessage.IsSucceed = false;
            //    FeedBackMessage.Message = "No input data table defined.";
            //    return FeedBackMessage;
            //}

            #region Properties Management
            object _firstValue = base.ListProperties.FindByName("Normalized ?");
            bool IsNormalized = false;
            if (_firstValue == null)
            {
                base.GenerateError("-Normalized ?- not found !");
                return base.FeedBackMessage;
            }
            try
            {
                cProperty TmpProp = (cProperty)_firstValue;
                IsNormalized = (bool)TmpProp.GetValue();
            }
            catch (Exception)
            {
                base.GenerateError("-Normalized ?- cast didn't work");
                return base.FeedBackMessage;
            }

            _firstValue = base.ListProperties.FindByName("Draw Axis ?");
            bool IsdrawAxis = true;
            if (_firstValue == null)
            {
                base.GenerateError("-Draw Axis ?- not found !");
                return base.FeedBackMessage;
            }
            try
            {
                cProperty TmpProp = (cProperty)_firstValue;
                IsdrawAxis = (bool)TmpProp.GetValue();
            }
            catch (Exception)
            {
                base.GenerateError("-Draw Axis ?- cast didn't work");
                return base.FeedBackMessage;
            }

            _firstValue = base.ListProperties.FindByName("Link Points ?");
            bool IsLinked = false;
            if (_firstValue == null)
            {
                base.GenerateError("-Link Points ?- not found !");
                return base.FeedBackMessage;
            }
            try
            {
                cProperty TmpProp = (cProperty)_firstValue;
                IsLinked = (bool)TmpProp.GetValue();
            }
            catch (Exception)
            {
                base.GenerateError("-Link Points ?- cast didn't work");
                return base.FeedBackMessage;
               }
            #endregion

            cExtendedList ListLenghtsMax = new cExtendedList();

            ListObjects = new cListGeometric3DObject("Scatter Plot MetaObject");

            double MinX = this.Input.Min(0);
            double MaxX = this.Input.Max(0);
            double DeltaX = MaxX - MinX;
            ListLenghtsMax.Add(DeltaX);
            if (DeltaX == 0) DeltaX = 1;

            double MinY = this.Input.Min(1);
            double MaxY = this.Input.Max(1);
            double DeltaY = MaxY - MinY;
            ListLenghtsMax.Add(DeltaY);
            if (DeltaY == 0) DeltaY = 1;

            double MinZ = this.Input.Min(2);
            double MaxZ = this.Input.Max(2);
            double DeltaZ = MaxZ - MinZ;
            ListLenghtsMax.Add(DeltaZ);
            if (DeltaZ == 0) DeltaZ = 1;

            double MinRad = 0;
            double MaxRad = 0;
            double DeltaRad = 1;

            double MaxLenght = ListLenghtsMax.Min();
            if (MaxLenght <= 0) MaxLenght = 1;

            for (int CurrentSerie = 0; CurrentSerie < this.Input.Count; CurrentSerie++)
            {
                cExtendedTable CurrentTable = this.Input[CurrentSerie];
                if ((IndexColumnForSphereRadius > 0) && (IndexColumnForSphereRadius < CurrentTable.Count))
                {
                    MinRad = CurrentTable[IndexColumnForSphereRadius].Min();
                    MaxRad = CurrentTable[IndexColumnForSphereRadius].Max();

                    if (MaxRad != MinRad)
                        DeltaRad = MaxRad - MinRad;
                }

                if (CurrentTable.Count == 0) continue;

                cListGeometric3DObject TmpListObjects = new cListGeometric3DObject("Scatter MetaObject");
                TmpListObjects.Tag = CurrentTable.Tag;
                cPoint3D Pt = null;
                for (int IdxPt = 0; IdxPt < CurrentTable[0].Count; IdxPt++)
                {
                    if(IsNormalized)
                    Pt = new cPoint3D((CurrentTable[0][IdxPt] - MinX) / DeltaX, (CurrentTable[1][IdxPt] - MinY) / DeltaY, (CurrentTable[2][IdxPt] - MinZ) / DeltaZ);
                    else
                    Pt = new cPoint3D(CurrentTable[0][IdxPt], CurrentTable[1][IdxPt], CurrentTable[2][IdxPt]);

                    double Rad = this.Radius;
                    if ((IndexColumnForSphereRadius > 0) && (IndexColumnForSphereRadius < CurrentTable.Count))
                    {
                        Rad = this.Radius * ((CurrentTable[IndexColumnForSphereRadius][IdxPt] - MinRad)) / DeltaRad;
                        Rad /= 200;
                    }

                    if(IndexColumnForSphereRadius>-1)
                    Rad = CurrentTable[IndexColumnForSphereRadius][IdxPt];

                    if (IsNormalized) Rad /= 300.0;
                    else
                    {
                        Rad = MaxLenght / 100.0;
                    }

                    c3DSphere Sphere = new c3DSphere(Pt, Rad);
                    //c3DPoint Sphere = new c3DPoint(Pt);
                    if ((CurrentTable.ListRowNames != null) && (CurrentTable.ListRowNames.Count > IdxPt))
                    {
                        if (CurrentTable.ListRowNames[IdxPt] != null) Sphere.SetName(CurrentTable.ListRowNames[IdxPt]);
                        else
                            Sphere.SetName("Sphere " + IdxPt);
                    }
                    else
                    {
                        Sphere.SetName("Sphere " + IdxPt);
                    }

                    if ((CurrentTable.ListTags != null) && (CurrentTable.ListTags[IdxPt] != null) && (CurrentTable.ListTags[IdxPt].GetType() == typeof(cWell)))
                    {
                        if (CurrentTable.ListTags[IdxPt].GetType() == typeof(cWell))
                        {
                            Sphere.Colour = ((cWell)(CurrentTable.ListTags[IdxPt])).GetClassType().ColourForDisplay;
                            Sphere.Tag = CurrentTable.ListTags[IdxPt];
                        }
                    }
                    else //if (this.GlobalInfo != null)
                    {
                        Sphere.Colour = cGlobalInfo.ListCellularPhenotypes[CurrentSerie % cGlobalInfo.ListCellularPhenotypes.Count].ColourForDisplay;
                    }

                    TmpListObjects.AddObject(Sphere);

                    if ((ValueToBeDisplayed > 0) && (ValueToBeDisplayed < CurrentTable.Count))
                    {
                        if (_3DWorld != null)
                            TmpListObjects.Add(new c3DText(_3DWorld, CurrentTable[ValueToBeDisplayed][IdxPt].ToString("N3"), new cPoint3D(Pt.X + 0.02, Pt.Y + 0.02, Pt.Z + 0.02), Color.White, 0.01));
                    }
                }

                ListObjects.AddRange(TmpListObjects);

                #region Draw Links
                if (IsLinked)
                {
                    cListGeometric3DObject ListLinks = new cListGeometric3DObject( "Links MetaObject");

                    for (int IdxPt = 1; IdxPt < CurrentTable[0].Count; IdxPt++)
                    {
                        cPoint3D Pt1 = null;
                        cPoint3D Pt0 = null;

                        if (IsNormalized)
                        {
                            Pt1 = new cPoint3D((CurrentTable[0][IdxPt] - MinX) / DeltaX, (CurrentTable[1][IdxPt] - MinY) / DeltaY, (CurrentTable[2][IdxPt] - MinZ) / DeltaZ);
                            Pt0 = new cPoint3D((CurrentTable[0][IdxPt - 1] - MinX) / DeltaX, (CurrentTable[1][IdxPt - 1] - MinY) / DeltaY, (CurrentTable[2][IdxPt - 1] - MinZ) / DeltaZ);
                        }
                        else
                        {
                            Pt1 = new cPoint3D(CurrentTable[0][IdxPt], CurrentTable[1][IdxPt] , CurrentTable[2][IdxPt] );
                            Pt0 = new cPoint3D(CurrentTable[0][IdxPt - 1] , CurrentTable[1][IdxPt - 1] , CurrentTable[2][IdxPt - 1] );
                        }
                       // new cPoint3D((CurrentTable[0][IdxPt] - MinX) / DeltaX, (CurrentTable[1][IdxPt] - MinY) / DeltaY, (CurrentTable[2][IdxPt] - MinZ) / DeltaZ);
                        //cPoint3D Pt0 = new cPoint3D((CurrentTable[0][IdxPt - 1] - MinX) / DeltaX, (CurrentTable[1][IdxPt - 1] - MinY) / DeltaY, (CurrentTable[2][IdxPt - 1] - MinZ) / DeltaZ);

                        c3DLine Line = new c3DLine(Pt0, Pt1);
                        Line.SetName("Link ["+(IdxPt-1)+";"+IdxPt+"]");
                        ListLinks.AddObject(Line);
                    }

                    ListObjects.AddRange(ListLinks);
                }
                #endregion

            }

            #region Draw Axis
            if (IsdrawAxis && (this.Input[0].Count > 2))
            {
                c3DObject_Axis Axis = new c3DObject_Axis();
                cExtendedTable T = new cExtendedTable();
                T.Add(new cExtendedList(Input[0][0].Name));
                if (IsNormalized)
                {
                    T[0].Tag = Input[0][0].Tag;
                    T[0].Add(0);
                    T[0].Add(1);
                    T.Add(new cExtendedList(Input[0][1].Name));
                    T[1].Tag = Input[0][1].Tag;
                    T[1].Add(0);
                    T[1].Add(1);
                    T.Add(new cExtendedList(Input[0][2].Name));
                    T[2].Tag = Input[0][2].Tag;
                    T[2].Add(0);
                    T[2].Add(1);
                }
                else
                {
                    T[0].Tag = Input[0][0].Tag;
                    T[0].Add(MinX);
                    T[0].Add(MaxX);
                    T.Add(new cExtendedList(Input[0][1].Name));
                    T[1].Tag = Input[0][1].Tag;
                    T[1].Add(MinY);
                    T[1].Add(MaxY);
                    T.Add(new cExtendedList(Input[0][2].Name));
                    T[2].Tag = Input[0][2].Tag;
                    T[2].Add(MinZ);
                    T[2].Add(MaxZ);
                }

                Axis.SetInputData(T);
                Axis.Run(_3DWorld);

                ListObjects.AddRange(Axis.GetOutPut());
            }
            #endregion

            // _3DWorld.AddGeometric3DObjects(this.ListObjects);

            return base.FeedBackMessage;
        }
Exemplo n.º 5
0
        public cFeedBackMessage Run(c3DNewWorld _3DWorld)
        {
            if (this.Input == null)
            {
                FeedBackMessage.IsSucceed = false;
                FeedBackMessage.Message = "No input data table defined.";
                return FeedBackMessage;
            }

            ListObjects = new cListGeometric3DObject("Axis MetaObject");
            cExtendedList ListLenghts = new cExtendedList();
            double MinLenght;
            cPoint3D Pt1 = null;
            cPoint3D Pt2 = null;
            cPoint3D Pt3 = null;

            if (this.Input.Count == 1)
            {
                cPoint3D Pt0 = new cPoint3D(this.Input[0][0], 0, 0);
                Pt1 = new cPoint3D(this.Input[0][1], 0, 0);
                ListLenghts.Add(Pt0.DistTo(Pt1));

                MinLenght = ListLenghts.Min();

                if (MinLenght == 0) MinLenght = 1;

                c3DLine XAxis = new c3DLine(Pt0, Pt1);
                XAxis.Tag = this.Input[0].Tag;
                XAxis.SetName("Axis - " + this.Input[0].Name);
                ListObjects.AddObject(XAxis);

            }
            else if (this.Input.Count == 2)
            {
                cPoint3D Pt0 = new cPoint3D(this.Input[0][0], this.Input[1][0], 0);
                Pt1 = new cPoint3D(this.Input[0][1], this.Input[1][0], 0);
                ListLenghts.Add(Pt0.DistTo(Pt1));
                Pt2 = new cPoint3D(this.Input[0][0], this.Input[1][1], 0);
                ListLenghts.Add(Pt0.DistTo(Pt2));

                MinLenght = ListLenghts.Min();

                if (MinLenght == 0) MinLenght = 1;

                c3DLine XAxis = new c3DLine(Pt0, Pt1);
                XAxis.Tag = this.Input[0].Tag;
                XAxis.SetName("Axis - " + this.Input[0].Name);
                ListObjects.AddObject(XAxis);

                c3DLine YAxis = new c3DLine(Pt0, Pt2);
                YAxis.Tag = this.Input[1].Tag;
                YAxis.SetName("Axis - " + this.Input[1].Name);
                ListObjects.AddObject(YAxis);

            }
            else
            {
                cPoint3D Pt0 = new cPoint3D(this.Input[0][0], this.Input[1][0], this.Input[2][0]);
                Pt1 = new cPoint3D(this.Input[0][1], this.Input[1][0], this.Input[2][0]);
                ListLenghts.Add(Pt0.DistTo(Pt1));

                Pt2 = new cPoint3D(this.Input[0][0], this.Input[1][1], this.Input[2][0]);
                ListLenghts.Add(Pt0.DistTo(Pt2));

                Pt3 = new cPoint3D(this.Input[0][0], this.Input[1][0], this.Input[2][1]);
                ListLenghts.Add(Pt0.DistTo(Pt3));

                MinLenght = ListLenghts.Min();

                if (MinLenght == 0) MinLenght = 1;

                c3DLine XAxis = new c3DLine(Pt0, Pt1,Color.Black);
                XAxis.Tag = this.Input[0].Tag;
                XAxis.SetName("Axis - " + this.Input[0].Name);

                ListObjects.AddObject(XAxis);

                c3DLine YAxis = new c3DLine(Pt0, Pt2,Color.Black);
                YAxis.Tag = this.Input[1].Tag;
                YAxis.SetName("Axis - " + this.Input[1].Name);
                ListObjects.AddObject(YAxis);

                c3DLine ZAxis = new c3DLine(Pt0, Pt3,Color.Black);
                ZAxis.Tag = this.Input[2].Tag;
                ZAxis.SetName("Axis - " + this.Input[2].Name);
                ListObjects.AddObject(ZAxis);

            }

            #region draw text
            double TextScale = MinLenght;

            if (MinLenght == 1) TextScale = 1;

            cPoint3D PosText = Pt1;

            // display the axis name
            c3DText TmpText = new c3DText(_3DWorld, this.Input[0].Name, PosText, Color.Black, 0.02 * TextScale);
            TmpText.Tag = this.Input[0].Tag;
            ListObjects.AddObject(TmpText);

            // MinX
            PosText = new cPoint3D(0, 0, 0);

            PosText.X = this.Input[0][0];
            if (this.Input.Count > 1) PosText.Y = this.Input[1][0];
            if (this.Input.Count > 2) PosText.Z = this.Input[2][0] - TextScale * 0.03;

            ListObjects.AddObject(new c3DText(_3DWorld, this.Input[0][0].ToString("N3"), PosText, Color.DimGray, 0.01 * TextScale));

            // MaxX
            PosText.X = this.Input[0][1];
            if (this.Input.Count > 1) PosText.Y = this.Input[1][0];
            if (this.Input.Count > 2) PosText.Z = this.Input[2][0] - TextScale * 0.03;

            if (this.Input.Count > 1) ListObjects.AddObject(new c3DText(_3DWorld, this.Input[0][1].ToString("N3"), PosText, Color.DimGray, 0.01 * TextScale));

            if (Pt2 != null)
            {
                PosText = Pt2;
                TmpText = new c3DText(_3DWorld, this.Input[1].Name, PosText, Color.Black, 0.02 * TextScale);
                TmpText.Tag = this.Input[1].Tag;
                ListObjects.AddObject(TmpText);

                // MinY
                PosText.X = this.Input[0][0] - TextScale * 0.03;// + TextScale*0.02;
                if (this.Input.Count > 1) PosText.Y = this.Input[1][0];// -TextScale * 0.03;
                if (this.Input.Count > 2) PosText.Z = this.Input[2][0] - TextScale * 0.03;
                ListObjects.AddObject(new c3DText(_3DWorld, this.Input[1][0].ToString("N3"), PosText, Color.DimGray, 0.01 * TextScale));

                PosText.X = this.Input[0][0] - TextScale * 0.03;// + TextScale*0.02;
                if (this.Input.Count > 1) PosText.Y = this.Input[1][1];// -TextScale * 0.03;
                if (this.Input.Count > 2) PosText.Z = this.Input[2][0] - TextScale * 0.03;
                ListObjects.AddObject(new c3DText(_3DWorld, this.Input[1][1].ToString("N3"), PosText, Color.DimGray, 0.01 * TextScale));
            }

            if (Pt3 != null)
            {

                PosText = Pt3;
                TmpText = new c3DText(_3DWorld, this.Input[2].Name, /*new cPoint3D(-0.04, -0.04, 0.45)*/ PosText, Color.Black, 0.02 * TextScale);
                TmpText.Tag = this.Input[2].Tag;
                ListObjects.AddObject(TmpText);

                PosText.X = this.Input[0][0] - TextScale * 0.03;// + TextScale*0.02;
                PosText.Y = this.Input[1][0];// -TextScale * 0.03;
                PosText.Z = this.Input[2][0];
                ListObjects.AddObject(new c3DText(_3DWorld, this.Input[2][0].ToString("N3"), PosText, Color.DimGray, 0.01 * TextScale));

                PosText.X = this.Input[0][0] - TextScale * 0.03;// + TextScale*0.02;
                PosText.Y = this.Input[1][0];// -TextScale * 0.03;
                PosText.Z = this.Input[2][1];

                ListObjects.AddObject(new c3DText(_3DWorld, this.Input[2][1].ToString("N3"), PosText, Color.DimGray, 0.01 * TextScale));
            }
            #endregion

            return base.FeedBackMessage;
        }