Example #1
0
        private void write_labels(IVRBranch branch, XmlWriter writer)
        {
            if (branch.HasChildren)
            {
                foreach (IVRBranch child in branch.Children)
                {
                    write_labels(child, writer);
                }
            }
            else
            {
                VRVector3D pos;
                string     name;

                if (calc_label(branch, out pos, out name))
                {
                    writer.WriteStartElement("Label");
                    writer.WriteAttributeString("x", pos.X.ToString(System.Globalization.CultureInfo.InvariantCulture));
                    writer.WriteAttributeString("y", pos.Y.ToString(System.Globalization.CultureInfo.InvariantCulture));
                    writer.WriteAttributeString("z", pos.Z.ToString(System.Globalization.CultureInfo.InvariantCulture));
                    writer.WriteAttributeString("name", name);
                    writer.WriteEndElement();
                }
            }
        }
Example #2
0
        void BranchManager_SelectionChanged(object sender, VRBranchesEventArgs e)
        {
            // Just to be 100% sure ignore when branches array is a null pointer.
            if (e.Branches == null)
            {
                return;
            }

            // This variable will contain a null pointer, or the instance corresponding with the
            // CAD Hierarchy branch selected by the user.
            IVRBranch branch_cad = null;

            // Iterate all the selected branches (normally 0, CAD or FRT, or both CAD and FRT)
            foreach (IVRBranch branch in e.Branches)
            {
                // If branch.Kind is greater than VRBranchKind.Cad, then it is not CAD. Probably it is FRT.
                if (branch.Kind > VRBranchKind.Cad)
                {
                    continue;
                }
                // Assign branch_cad to the found instance.
                branch_cad = branch;
            }

            // Test that a Branch for the CAD branch was found.
            // (Could be there was no CAD selected but only a FRT)
            if (branch_cad == null)
            {
                m_RichTextBox.Text = "No Cad Hierarchy branch selected.";
                return;
            }

            // Set the text of the rich textbox equal to the name of the branch.
            m_RichTextBox.Text = branch_cad.Name;
        }
 public AssetDatas( IVRBranch branch, AssetDocuments documents, AssetScadaDatas scadaDatas )
 {
     _name = branch.Name;
     _id = branch.ID;
     _position = branch.OBB.Position;
     _scadaDatas = new AssetScadaDatas();
     _documents = documents;
 }
Example #4
0
 private bool calc_label(IVRBranch branch, out VRVector3D pos, out string name)
 {
     name = branch.Name;
     pos  = branch.AABB.Center;
     if ((pos.X == 0) && (pos.Y == 0) && (pos.Z == 0))
     {
         return(false);
     }
     return(true);
 }
        protected int ListenerAsset(IVRBranch branch, string branchParentName, int rank, ref StreamWriter csvFile)
        {
            string branchName = getName(branch.Name);
            status.Text = branchName;

            if (!branchName.Contains("CIVI") && !branchName.Contains("STRU"))
            {
                rank++;

                if (!branchName.Contains(branchParentName) || rank < 5)
                {
                    switch (rank)
                    {
                        case 1:
                        case 2:
                        case 3:
                        case 4:
                            break;
                        default:
                            // Tag
                            csvFile.Write(branchName);
                            csvFile.Write(";");
                            // Project
                            csvFile.Write(branch.Project.Name);
                            csvFile.Write(";");
                            // Position
                            csvFile.Write(branch.OBB.Position.X);
                            csvFile.Write(";");
                            csvFile.Write(branch.OBB.Position.Y);
                            csvFile.Write(";");
                            csvFile.Write(branch.OBB.Position.Z);
                            csvFile.Write(";");
                            // Lien
                            csvFile.Write("http://localhost:5050/WVRequest?Project=" + branch.Project.Name + "&Tag=" + branchName.Substring(1));
                            csvFile.Write("\r\n");
                            break;
                    }

                    if (rank < 5)
                    {
                        foreach (IVRBranch br in branch.Children)
                        {
                            rank = ListenerAsset(br, branchName, rank, ref csvFile);
                        }
                    }
                }
                rank--;
            }
            return rank;
        }
        protected static int ListenerAsset(IVRBranch branch, string branchParentName, int rank, ref XmlTextWriter myXmlTextWriter)
        {
            string elementXML = string.Empty;
            string branchName = getName(branch.Name);

            if (!branchName.Contains("CIVI") && !branchName.Contains("STRU"))
            {
                rank++;

                if (!branchName.Contains(branchParentName) || rank < 5)
                {
                    switch (rank)
                    {
                        case 1:
                            elementXML = "Project";
                            myXmlTextWriter.WriteStartElement(elementXML);
                            myXmlTextWriter.WriteAttributeString("ID", branchName);
                            break;
                        case 2:
                            elementXML = "Area";
                            myXmlTextWriter.WriteStartElement(elementXML);
                            myXmlTextWriter.WriteAttributeString("Name", branchName);
                            break;
                        case 3:
                        case 4:
                            elementXML = "Tags by type";
                            myXmlTextWriter.WriteStartElement(elementXML);
                            myXmlTextWriter.WriteAttributeString("Type", branchName);
                            break;
                        default:
                            elementXML = "Tag";
                            myXmlTextWriter.WriteStartElement(elementXML);
                            myXmlTextWriter.WriteElementString("Name", branchName);
                            myXmlTextWriter.WriteElementString("Position", branch.OBB.Position.ToString());
                            break;
                    }

                    if (rank < 5)
                    {
                        foreach (IVRBranch br in branch.Children)
                        {
                            rank = ListenerAsset(br, branchName, rank, ref myXmlTextWriter);
                        }
                    }
                }
                rank--;
                myXmlTextWriter.WriteEndElement();
            }
            return rank;
        }
        // Get the information about the asset and displays it
        public void ShowAsset( IVRBranch branch )
        {
            AssetDatas assetDatas = new AssetDatas( branch );

            if( _currentAssetView == null )
            {
                _currentAssetView = ( AssetView )AssetDatasViewer.CurrentViewer.UI.OpenForm( typeof( AssetView ) );
                _currentAssetView.FormClosing += new FormClosingEventHandler( assetView_Closed );
            }

            mDeleg_DocumentsAndScada = new Deleg( _service.GetAssetDocumentsAndScada );
            AsyncCallback callback_DocumentsAndScada = new AsyncCallback( buildAssetView );
            mDeleg_DocumentsAndScada.BeginInvoke( assetDatas, callback_DocumentsAndScada, null );
        }
 protected static IVRBranch RecursiveSearchBranch(IVRBranch branch, string tagName)
 {
     IVRBranch branchSelect = branch;
     if (!branch.Name.Contains(tagName))
     {
         foreach (IVRBranch br in branchSelect.Children)
         {
             branchSelect = RecursiveSearchBranch(br, tagName);
             if (branchSelect.Name.Contains(tagName))
             {
                 return branchSelect;
             }
         }
     }
     return branchSelect;
 }
        private void ListenerAsset(IVRBranch branch, ref StreamWriter csvFile)
        {
            WIPlugin.currentViewer.UI.SetPercentage((int) branch.ID / WIPlugin.nbBranch);
            WIPlugin.currentViewer.UI.ShowInformation(string.Format(Resource.ExportBranch, branch.Name));

            Excel.WriteAssetToExcel(branch.Name,
                branch.Project.Name,
                branch.OBB.Position.X.ToString(),
                branch.OBB.Position.Y.ToString(),
                branch.OBB.Position.Z.ToString());

            foreach (IVRBranch br in branch.Children)
            {
                ListenerAsset(br, ref csvFile);
            }
        }
        public void WriteAssets(IVRBranch root, ref StreamWriter file)
        {
            DataExporter.CurrentViewer.UI.SetPercentage((int) root.ID / DataExporter.NbBranches);
            DataExporter.CurrentViewer.UI.ShowInformation(string.Format(Resource.ExportBranch, root.Name));

            string name = root.Name;
            if( name.StartsWith( "/" ) )
                name = name.Substring( 1 );

            file.Write( String.Format("{0};{1};{2};{3};{4};{5}\r\n",
                name,
                root.Project.Name,
                root.OBB.Position.X.ToString(),
                root.OBB.Position.Y.ToString(),
                root.OBB.Position.Z.ToString(),
                string.Format( Resource.UrlRefTag, root.Project.Name, name )
                ));

            foreach( IVRBranch branch in root.Children )
            {
                WriteAssets( branch, ref file );
            }
        }
        /// <summary>
        /// The method called by walkinside, just before the plugin is removed from walkinside environment.
        /// </summary>
        /// <param name="viewer">The context of the viewer when plugin is created.</param>
        /// <returns>True if destruction of plugin succeeded.</returns>
        public bool DestroyPlugin(IVRViewerSdk viewer)
        {
            // Export scenario
            m_ToolStripItem2.Click -= m_ToolStripItem_Click;
            viewer.UI.PluginMenu.DropDownItems.Remove(m_ToolStripItem2);
            m_ToolStripItem2 = null;
            // Export asset
            viewer.ProjectManager.OnProjectOpen -= new VRProjectEventHandler(ProjectManager_OnProjectOpen);
            viewer.UI.UnregisterVRFORM(m_ToolStripItem1, typeof(ExportScenarioView));
            viewer.UI.PluginMenu.DropDownItems.Remove(m_ToolStripItem1);
            m_ToolStripItem1 = null;
            // HTTP server
            CurrentViewer.HTTPServer.RemoveEvent("WVRequest", new VRHTTPEventHandler(OnReceiveWebRequest));
            CurrentViewer.HTTPServer.Stop();

            Branch = null;
            return true;
        }
 static void ProjectManager_OnProjectOpen(object sender, VRProjectEventArgs e)
 {
     if (e.Project.ProjectManager.CurrentProject.Name != "startup")
     {
         IVRBranch[] rootarray = e.Project.ProjectManager.CurrentProject.BranchManager.GetBranchesByType(0);
         if (rootarray.Length != 0)
         {
             Branch = rootarray[0];
             NbBranches = rootarray.Length;
         }
     }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            branch = SDKViewer.ProjectManager.CurrentProject.BranchManager.GetBranchesByType(0)[0];
            //SDKViewer.UI.StatusMessage.Text
            //SDKViewer.UI.ProgressBar
            button1.Enabled = false;

            progressBar1.Visible = true;
            progressBar1.Minimum = 0;
            progressBar1.Maximum = branch.Children.Count();
            progressBar1.Value = 0;
            progressBar1.Step = 1;

            //string destination = "\\" + hostname.Text + ":" + port.Text + "\\";
                                                                            // TODO - Ici mettre le chemin scpécific à ce fichier
            string destination = "C:\\Users\\saad\\Desktop\\";
            if (Directory.Exists(destination))
            {
                status.Text = "Start extraction";

                ExportToEXCEL(destination);

                status.Text = "Finish";
            }
            else
            {
                status.Text = "Error: path not found";
            }
            button1.Enabled = true;
        }
        /// <summary>
        /// The method called by walkinside, just before the plugin is removed from walkinside environment.
        /// </summary>
        /// <param name="viewer">The context of the viewer when plugin is created.</param>
        /// <returns>True if destruction of plugin succeeded.</returns>
        public bool DestroyPlugin( IVRViewerSdk viewer )
        {
            _avevaManager.OnClosing();

            viewer.ProjectManager.OnProjectOpen -= new VRProjectEventHandler( ProjectManager_OnProjectOpen );
            viewer.ProjectManager.OnProjectClose -= new VRProjectEventHandler( ProjectManager_OnProjectClose );
            viewer.ProjectManager.OnBranchSelect -= new VROnBranchSelectedEventHandler( ProjectManager_OnBranchSelect );

            viewer.UI.UnregisterVRFORM( m_ToolStripItem1, typeof( AssetView ) );
            viewer.UI.PluginMenu.DropDownItems.Remove( m_ToolStripItem1 );
            m_ToolStripItem1 = null;

            _avevaManager = null;
            Root = null;

            return true;
        }
        void ProjectManager_OnProjectOpen( object o, VRProjectEventArgs e )
        {
            IVRBranch[] rootarray = e.Project.ProjectManager.CurrentProject.BranchManager.GetBranchesByType( 0 );
            if( rootarray.Length > 0 )
            {
                Root = rootarray[0];
                _avevaManager = new AssetViewManager();

                IVRSelection first = CurrentViewer.CreateSelection();
                first.Add( Root.Manager.GetBranch( 35626 ) );
                first.GoTo();
                first.Dispose();
            }
        }