程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> 關於.NET >> 基於Composer Player 模型加載和相關屬性設置,composerplayer

基於Composer Player 模型加載和相關屬性設置,composerplayer

編輯:關於.NET

基於Composer Player 模型加載和相關屬性設置,composerplayer


主要是基於達索軟件Composer Player、的基礎上做些二次開發。

public class ComposerToolBarSetting { public bool AntiAliasingOnIdle { get; set; }//抗鋸齒化 public bool AssySelectionMode { get; set; }//使能選擇裝配樹 public bool AssySelectionModeViewportIndicator { get; set; }//裝配樹選擇模式 public bool AutoKeyMode { get; set; }//使能自動鍵 public bool AutoPlay { get; set; } //自動播放 public bool BorderMask { get; set; }//在控件窗體應用border public bool CameraInertia { get; set; }//照相機慣性模式 public bool CameraPlayMode { get; set; }//照相機播放模式 public bool GroundGrid { get; set; }//地面 public bool LoopPlay { get; set; }//循環播放 public bool NoHighlight { get; set; }//高亮顯示 public bool RemoveMeasurementCommands { get; set; }//移除測量工具條 public bool RenderGroundShadow { get; set; }//渲染地面陰影 public bool ShowAnnotationToolBar { get; set; }//注釋工具條 public bool ShowAssemblyTreeBar { get; set; }//裝配樹 public bool ShowBomTreeBar { get; set; }//BOM樹 public bool ShowCameraToolBar { get; set; }//照相機工具條 public bool ShowCameraViewToolBar { get; set; }//照相機視圖工具條 public bool ShowCollabToolBar { get; set; }//協同工具條 public bool ShowCollabTreeBar { get; set; }//協同樹 public bool ShowCuttingPlaneToolBar { get; set; }//剖切工具條 public bool ShowGeometryToolBar { get; set; }//幾何圖形工具條 public bool ShowMain3DToolBar { get; set; }//主要3D工具條 public bool ShowMarkerBar { get; set; }//標記工具條 public bool ShowMeasurementToolBar { get; set; }//測量工具條 public bool ShowPaper { get; set; }//顯示白紙頁面 public bool ShowPropertyBar { get; set; }//屬性 public bool ShowRedlineToolBar { get; set; }//紅線工具條 public bool ShowRenderToolBar { get; set; }//渲染工具條 public bool ShowStandardToolBar { get; set; }//標准工具條 public bool ShowStatusBar { get; set; }//狀態條 public bool ShowTimelineBar { get; set; }//時間線 public bool ShowTreesBar { get; set; }//樹 public bool ShowViewBar { get; set; }//視圖條 public bool ShowVisibilityToolBar { get; set; }//可見性工具條 public bool UseGUID { get; set; }//是否返回GUID } Composer 工具欄 public class ComposerManager { /// <summary> /// 設置控件的屬性 /// </summary> /// <param name="player">控件的名字</param> public static void SetComposerPlayerToolsBar(AxDS3DVIAPlayerActiveXLib.AxDS3DVIAPlayerActiveX player) { player.AntiAliasingOnIdle = GetCompserPlayerToolBar().AntiAliasingOnIdle; player.AssySelectionMode = GetCompserPlayerToolBar().AssySelectionMode; player.AssySelectionModeViewportIndicator = GetCompserPlayerToolBar().AssySelectionModeViewportIndicator; player.AutoKeyMode = GetCompserPlayerToolBar().AutoKeyMode; player.AutoPlay = GetCompserPlayerToolBar().AutoPlay; player.BorderMask = GetCompserPlayerToolBar().BorderMask; player.CameraInertia = GetCompserPlayerToolBar().CameraInertia; player.CameraPlayMode = GetCompserPlayerToolBar().CameraPlayMode; player.GroundGrid = GetCompserPlayerToolBar().GroundGrid; player.LoopPlay = GetCompserPlayerToolBar().LoopPlay; player.NoHighlight = GetCompserPlayerToolBar().NoHighlight; player.RemoveMeasurementCommands = GetCompserPlayerToolBar().RemoveMeasurementCommands; player.RenderGroundShadow = GetCompserPlayerToolBar().RenderGroundShadow; player.ShowAnnotationToolBar = GetCompserPlayerToolBar().ShowAnnotationToolBar; player.ShowAssemblyTreeBar = GetCompserPlayerToolBar().ShowAssemblyTreeBar; player.ShowBOMTreeBar = GetCompserPlayerToolBar().ShowBomTreeBar; player.ShowCameraToolBar = GetCompserPlayerToolBar().ShowCameraToolBar; player.ShowCameraViewToolBar = GetCompserPlayerToolBar().ShowCameraViewToolBar; player.ShowCollabToolBar = GetCompserPlayerToolBar().ShowCollabToolBar; player.ShowCollabTreeBar = GetCompserPlayerToolBar().ShowCollabTreeBar; player.ShowCuttingPlaneToolBar = GetCompserPlayerToolBar().ShowCuttingPlaneToolBar; player.ShowGeometryToolBar = GetCompserPlayerToolBar().ShowGeometryToolBar; player.ShowMain3DToolBar = GetCompserPlayerToolBar().ShowMain3DToolBar; player.ShowMarkerBar = GetCompserPlayerToolBar().ShowMarkerBar; player.ShowMeasurementToolBar = GetCompserPlayerToolBar().ShowMeasurementToolBar; player.ShowPaper = GetCompserPlayerToolBar().ShowPaper; player.ShowPropertyBar = GetCompserPlayerToolBar().ShowPropertyBar; player.ShowRedlineToolBar = GetCompserPlayerToolBar().ShowRedlineToolBar; player.ShowRenderToolBar = GetCompserPlayerToolBar().ShowRenderToolBar; player.ShowStandardToolBar = GetCompserPlayerToolBar().ShowStandardToolBar; player.ShowStatusBar = GetCompserPlayerToolBar().ShowStatusBar; player.ShowTimelineBar = GetCompserPlayerToolBar().ShowTimelineBar; player.ShowTreesBar = GetCompserPlayerToolBar().ShowTreesBar; player.ShowViewBar = GetCompserPlayerToolBar().ShowViewBar; player.ShowVisibilityToolBar = GetCompserPlayerToolBar().ShowVisibilityToolBar; player.UseGUID = GetCompserPlayerToolBar().UseGUID; } /// <summary> /// 將字符類型轉化為Boolen類型 /// </summary> /// <param name="str"></param> /// <returns></returns> static bool StringToBool(string str) { bool result = false; if (str != null) { if (str == "false") { result = false; } else if (str == "true") { result = true; } } return result; } /// <summary> /// 將Boolen類型轉化為字符類型 /// </summary> /// <param name="result"></param> /// <returns></returns> static string BoolToString(bool result) { string str = ""; if (result) { str = "true"; } else { str = "false"; } return str; } /// <summary> /// 讀取app.config裡的key對應的值,並賦值給ComposerToolBarSetting類 /// </summary> /// <returns></returns> public static ComposerToolBarSetting GetCompserPlayerToolBar() { ComposerToolBarSetting set = new ComposerToolBarSetting(); set.AntiAliasingOnIdle = StringToBool(AppConfigManager.GetValue("AntiAliasingOnIdle", ConfigFileType.AppConfig)); set.AssySelectionMode=StringToBool(AppConfigManager.GetValue("AssySelectionMode",ConfigFileType.AppConfig)); set.AssySelectionModeViewportIndicator = StringToBool(AppConfigManager.GetValue("AssySelectionModeViewportIndicator", ConfigFileType.AppConfig)); set.AutoKeyMode = StringToBool(AppConfigManager.GetValue("AutoKeyMode", ConfigFileType.AppConfig)); set.AutoPlay = StringToBool(AppConfigManager.GetValue("AutoPlay", ConfigFileType.AppConfig)); set.BorderMask = StringToBool(AppConfigManager.GetValue("BorderMask", ConfigFileType.AppConfig)); set.CameraInertia = StringToBool(AppConfigManager.GetValue("CameraInertia", ConfigFileType.AppConfig)); set.CameraPlayMode = StringToBool(AppConfigManager.GetValue("CameraPlayMode", ConfigFileType.AppConfig)); set.GroundGrid = StringToBool(AppConfigManager.GetValue("GroundGrid", ConfigFileType.AppConfig)); set.LoopPlay = StringToBool(AppConfigManager.GetValue("LoopPlay", ConfigFileType.AppConfig)); set.NoHighlight = StringToBool(AppConfigManager.GetValue("NoHighlight", ConfigFileType.AppConfig)); set.RemoveMeasurementCommands = StringToBool(AppConfigManager.GetValue("RemoveMeasurementCommands", ConfigFileType.AppConfig)); set.RenderGroundShadow = StringToBool(AppConfigManager.GetValue("RenderGroundShadow", ConfigFileType.AppConfig)); set.ShowAnnotationToolBar = StringToBool(AppConfigManager.GetValue("ShowAnnotationToolBar", ConfigFileType.AppConfig)); set.ShowAssemblyTreeBar = StringToBool(AppConfigManager.GetValue("ShowAssemblyTreeBar", ConfigFileType.AppConfig)); set.ShowBomTreeBar = StringToBool(AppConfigManager.GetValue("ShowBOMTreeBar", ConfigFileType.AppConfig)); set.ShowCameraToolBar = StringToBool(AppConfigManager.GetValue("ShowCameraToolBar", ConfigFileType.AppConfig)); set.ShowCameraViewToolBar = StringToBool(AppConfigManager.GetValue("ShowCameraViewToolBar", ConfigFileType.AppConfig)); set.ShowCollabToolBar = StringToBool(AppConfigManager.GetValue("ShowCollabToolBar", ConfigFileType.AppConfig)); set.ShowCollabTreeBar = StringToBool(AppConfigManager.GetValue("ShowCollabTreeBar", ConfigFileType.AppConfig)); set.ShowCuttingPlaneToolBar = StringToBool(AppConfigManager.GetValue("ShowCuttingPlaneToolBar", ConfigFileType.AppConfig)); set.ShowGeometryToolBar = StringToBool(AppConfigManager.GetValue("ShowGeometryToolBar", ConfigFileType.AppConfig)); set.ShowMain3DToolBar = StringToBool(AppConfigManager.GetValue("ShowMain3DToolBar", ConfigFileType.AppConfig)); set.ShowMarkerBar = StringToBool(AppConfigManager.GetValue("ShowMarkerBar", ConfigFileType.AppConfig)); set.ShowMeasurementToolBar = StringToBool(AppConfigManager.GetValue("ShowMeasurementToolBar", ConfigFileType.AppConfig)); set.ShowPaper = StringToBool(AppConfigManager.GetValue("ShowPaper", ConfigFileType.AppConfig)); set.ShowPropertyBar = StringToBool(AppConfigManager.GetValue("ShowPropertyBar", ConfigFileType.AppConfig)); set.ShowRedlineToolBar = StringToBool(AppConfigManager.GetValue("ShowRedlineToolBar", ConfigFileType.AppConfig)); set.ShowRenderToolBar = StringToBool(AppConfigManager.GetValue("ShowRenderToolBar", ConfigFileType.AppConfig)); set.ShowStandardToolBar = StringToBool(AppConfigManager.GetValue("ShowStandardToolBar", ConfigFileType.AppConfig)); set.ShowStatusBar = StringToBool(AppConfigManager.GetValue("ShowStatusBar", ConfigFileType.AppConfig)); set.ShowTimelineBar = StringToBool(AppConfigManager.GetValue("ShowTimelineBar", ConfigFileType.AppConfig)); set.ShowTreesBar = StringToBool(AppConfigManager.GetValue("ShowTreesBar", ConfigFileType.AppConfig)); set.ShowViewBar = StringToBool(AppConfigManager.GetValue("ShowViewBar", ConfigFileType.AppConfig)); set.ShowVisibilityToolBar = StringToBool(AppConfigManager.GetValue("ShowVisibilityToolBar", ConfigFileType.AppConfig)); set.UseGUID = StringToBool(AppConfigManager.GetValue("UseGUID", ConfigFileType.AppConfig)); return set; } } Composer 工具欄配置 public class ComposerTreeView { //建立xml的路徑 string xmlpath = AppDomain.CurrentDomain.BaseDirectory + "21.Xml"; //判斷字符是否為中文 static bool IsChinese(string CString) { return Regex.IsMatch(CString, @"^[\u4e00-\u9fa5]+$"); } /// <summary> /// 創建頭結點和下一級節點 /// </summary> /// <param name="player">控件的名稱</param> /// <param name="treeview">TreeView的名字</param> public static void CreateFirstNode(AxDS3DVIAPlayerActiveXLib.AxDS3DVIAPlayerActiveX player,TreeView treeview) { var rnode = new TreeNode(); string rootstr = player.GetAssyRoot(); string[] RArray = rootstr.Split('"'); foreach (var item in RArray) { if ( item.Length == 2 && IsChinese(item) ) { TreeNode node = new TreeNode(); node.Text = item; rnode.Nodes.Add(node); } } treeview.Nodes.Add(rnode); } /// <summary> /// 建立xml信息 /// </summary> /// <param name="xmlname">xml文件的名字</param> private void FillXml(string xmlname) { if (File.Exists(xmlpath)) { File.Delete(xmlpath); } XElement root = XElement.Parse(xmlname); root.Save(xmlpath); } /// <summary> /// 將子節點添加到父節點 /// </summary> /// <param name="tnode">子節點</param> /// <param name="parentnode">父節點</param> private void addTreeNode(TreeNode tnode, TreeNode parentnode) { parentnode.Nodes.Add(tnode); } List<TreeNode> nodelist = new List<TreeNode>(); /// <summary> ///返回選中節點下的子節點名字集合 /// </summary> /// <param name="player">控件的名字</param> /// <param name="treeview">TreeView的名字</param> /// <returns></returns> private List<TreeNode> createTreeNode(AxDS3DVIAPlayerActiveXLib.AxDS3DVIAPlayerActiveX player, TreeView treeview) { List<string> childlist = new List<string>(); string childname = treeview.SelectedNode.Text; if (childname != null) { string childrenstr = player.GetAssyChild(CLitSelectionName(childname)); FillXml(childrenstr); XDocument doc = XDocument.Load(xmlpath); var query = from fx in doc.Descendants("CLitModifiable") select new { NodeName = fx.Attribute("Name").Value }; foreach (var item in query) { TreeNode node1 = new TreeNode(); node1.Text = item.NodeName; if (!nodelist.Contains(node1)) { nodelist.Add(node1); } } } return nodelist; } /// <summary> /// 准備好選擇對象的字符串 /// </summary> /// <param name="name">指定對象的名字</param> /// <returns></returns> static string CLitSelectionName(string name) { return "<CLitSelection Name='' ><CLitModifiable Name='" + name + "'/></CLitSelection>"; } /// <summary> /// 根據點擊選擇的節點,查詢出其下面的子節點信息 /// </summary> /// <param name="player"></param> /// <param name="treeview"></param> public void TreeViewAfterSelect(AxDS3DVIAPlayerActiveXLib.AxDS3DVIAPlayerActiveX player, TreeView treeview) { nodelist.Clear(); nodelist = createTreeNode(player, treeview); var parent = from fx in nodelist select fx; treeview.SelectedNode.Nodes.Clear(); foreach (var item in parent) { TreeNode node = new TreeNode(); node.Text = item.Text; if (!treeview.SelectedNode.Nodes.Contains(node)) { treeview.SelectedNode.Nodes.Add(node); } } treeview.ExpandAll(); } } 自定義結構樹設置

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved