├── show.jpg
├── show2.png
├── RapidCAX
├── app.ico
├── Resources
│ ├── app.ico
│ ├── icon.png
│ └── StringResource.xaml
├── App.config
├── Properties
│ ├── Settings.settings
│ ├── Settings.Designer.cs
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ └── Resources.resx
├── packages.config
├── App.xaml.cs
├── Controls
│ ├── CommandLineCtrl.xaml.cs
│ ├── RapidBackstageCtrl.xaml.cs
│ ├── CommandLineCtrl.xaml
│ └── RapidBackstageCtrl.xaml
├── App.xaml
├── PropertyUI
│ ├── BasicPage.xaml
│ ├── BasicPage.xaml.cs
│ ├── TransformPage.xaml
│ └── TransformPage.xaml.cs
├── MainWindow.xaml.cs
├── MainWindow.xaml
└── RapidCAX.csproj
├── README.md
├── AnyCAD.Rapid.Core
├── packages.config
├── Command
│ ├── UICommand.cs
│ ├── UICommandContext.cs
│ └── UICommandManager.cs
├── CommandEx
│ ├── ShapeCommand.cs
│ ├── AddTagCommand.cs
│ ├── ViewCommands.cs
│ └── FileCommands.cs
├── Data
│ ├── SphereElementSchema.cs
│ └── MyTextElement.cs
├── Properties
│ └── AssemblyInfo.cs
├── MyDocumentListener.cs
├── MyDocumentViewer.cs
└── AnyCAD.Rapid.Core.csproj
├── .gitignore
└── RapidCAX.sln
/show.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anycad/RapidCAX/HEAD/show.jpg
--------------------------------------------------------------------------------
/show2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anycad/RapidCAX/HEAD/show2.png
--------------------------------------------------------------------------------
/RapidCAX/app.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anycad/RapidCAX/HEAD/RapidCAX/app.ico
--------------------------------------------------------------------------------
/RapidCAX/Resources/app.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anycad/RapidCAX/HEAD/RapidCAX/Resources/app.ico
--------------------------------------------------------------------------------
/RapidCAX/Resources/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anycad/RapidCAX/HEAD/RapidCAX/Resources/icon.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # RapidCAX
2 | The Rapid UI framework for CAD/CAE/CAM ...
3 |
4 |
5 | 
6 | 
--------------------------------------------------------------------------------
/AnyCAD.Rapid.Core/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/RapidCAX/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/RapidCAX/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # This .gitignore file was automatically created by Microsoft(R) Visual Studio.
3 | ################################################################################
4 |
5 | /packages
6 | /.vs
7 | obj
8 | bin
9 |
--------------------------------------------------------------------------------
/AnyCAD.Rapid.Core/Command/UICommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace AnyCAD.Rapid.Core
8 | {
9 | public class UICommand
10 | {
11 | public String Name = "";
12 | public UICommand()
13 | {
14 |
15 | }
16 |
17 | public virtual bool Execute(UICommandContext ctx)
18 | {
19 | return false;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/RapidCAX/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/RapidCAX/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using Fluent;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Configuration;
5 | using System.Data;
6 | using System.Linq;
7 | using System.Threading.Tasks;
8 | using System.Windows;
9 |
10 | namespace RapidCAX
11 | {
12 | ///
13 | /// Interaction logic for App.xaml
14 | ///
15 | public partial class App : Application
16 | {
17 | protected override void OnStartup(StartupEventArgs e)
18 | {
19 | AnyCAD.Foundation.GlobalInstance.Initialize();
20 | base.OnStartup(e);
21 | }
22 |
23 | protected override void OnExit(ExitEventArgs e)
24 | {
25 | AnyCAD.Foundation.GlobalInstance.Destroy();
26 | base.OnExit(e);
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/RapidCAX/Controls/CommandLineCtrl.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 |
16 | namespace RapidCAX
17 | {
18 | ///
19 | /// Interaction logic for CommandLineControl.xaml
20 | ///
21 | public partial class CommandLineControl : UserControl
22 | {
23 | public CommandLineControl()
24 | {
25 | InitializeComponent();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/RapidCAX/Controls/RapidBackstageCtrl.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 |
16 | namespace RapidCAX
17 | {
18 | ///
19 | /// Interaction logic for RapidBackstageCtrl.xaml
20 | ///
21 | public partial class RapidBackstageCtrl : UserControl
22 | {
23 | public RapidBackstageCtrl()
24 | {
25 | InitializeComponent();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/RapidCAX/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/AnyCAD.Rapid.Core/CommandEx/ShapeCommand.cs:
--------------------------------------------------------------------------------
1 | using AnyCAD.Forms;
2 | using AnyCAD.Foundation;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Reflection;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace AnyCAD.Rapid.Core
11 | {
12 |
13 |
14 | class ShapeCommand : UICommand
15 | {
16 | public ShapeCommand()
17 | {
18 | this.Name = "Sphere";
19 | }
20 |
21 | public override bool Execute(UICommandContext ctx)
22 | {
23 | //创建事务
24 | var transaction = new UndoTransaction(ctx.Document);
25 | transaction.Start(this.Name);
26 |
27 | //创建个球
28 | var element = SphereElementSchema.Create(ctx.Document);
29 | // 显示
30 | ctx.ShowElement(element);
31 |
32 | //提交事务
33 | transaction.Commit();
34 |
35 | ctx.RequestUpdate();
36 |
37 | return true;
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/AnyCAD.Rapid.Core/CommandEx/AddTagCommand.cs:
--------------------------------------------------------------------------------
1 | using AnyCAD.Foundation;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace AnyCAD.Rapid.Core
9 | {
10 | class AddTagCommand : UICommand
11 | {
12 | public AddTagCommand()
13 | {
14 | this.Name = "AddTag";
15 | }
16 |
17 | public override bool Execute(UICommandContext ctx)
18 | {
19 | //创建事务
20 | var transaction = new UndoTransaction(ctx.Document);
21 | transaction.Start(this.Name);
22 |
23 | var text = new MyTextElement();
24 | text.Text = "这是一个好引擎!";
25 | text.Position = new Vector3(100, 100, 100);
26 |
27 | text.AddElement(ctx.Document);
28 |
29 | text.Show(ctx.RenderView.GetScene());
30 |
31 |
32 | //提交事务
33 | transaction.Commit();
34 |
35 | ctx.RequestUpdate();
36 |
37 | return true;
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/RapidCAX/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace RapidCAX.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/RapidCAX/PropertyUI/BasicPage.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/RapidCAX/PropertyUI/BasicPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using AnyCAD.Foundation;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using System.Windows.Controls;
9 | using System.Windows.Data;
10 | using System.Windows.Documents;
11 | using System.Windows.Input;
12 | using System.Windows.Media;
13 | using System.Windows.Media.Imaging;
14 | using System.Windows.Navigation;
15 | using System.Windows.Shapes;
16 |
17 | namespace RapidCAX
18 | {
19 | ///
20 | /// Interaction logic for BasicPage.xaml
21 | ///
22 | public partial class BasicPage : UserControl
23 | {
24 | private Element mElement;
25 | public BasicPage(Element element)
26 | {
27 | mElement = element;
28 |
29 | InitializeComponent();
30 |
31 | DataContext = this;
32 | }
33 |
34 | public string ElementName
35 | {
36 | get { return mElement.GetName(); }
37 | set {
38 | mElement.SetName(value);
39 | }
40 | }
41 |
42 | public string ElementSchemaName
43 | {
44 | get { return mElement.GetSchemaName(); }
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/AnyCAD.Rapid.Core/Command/UICommandContext.cs:
--------------------------------------------------------------------------------
1 | using AnyCAD.Forms;
2 | using AnyCAD.Foundation;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace AnyCAD.Rapid.Core
10 | {
11 | public class UICommandContext
12 | {
13 | public MyDocumentViewer mDocView;
14 |
15 | public UICommandContext(MyDocumentViewer docView)
16 | {
17 | mDocView = docView;
18 | }
19 |
20 |
21 | public Document Document
22 | {
23 | get { return mDocView.mDocument; }
24 | }
25 |
26 | public ElementId DefaultMaterialId
27 | {
28 | get { return mDocView.mMaterialId; }
29 | }
30 |
31 | public RenderControl RenderView
32 | {
33 | get { return mDocView.mRenderCtrl; }
34 | }
35 |
36 | public void ShowElement(DrawableElement element)
37 | {
38 | mDocView.mDbView.ShowElement(element);
39 | }
40 |
41 | public void RequestUpdate()
42 | {
43 | mDocView.mRootSceneNode.ComputeBoundingBox();
44 | mDocView.mRootSceneNode.RequstUpdate();
45 | mDocView.mRenderCtrl.RequestDraw(EnumUpdateFlags.Scene);
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/AnyCAD.Rapid.Core/Command/UICommandManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace AnyCAD.Rapid.Core
9 | {
10 | public class UICommandManager
11 | {
12 |
13 | private static Dictionary mCommands = new Dictionary();
14 |
15 | private UICommandManager()
16 | {
17 |
18 | }
19 |
20 | public static void LoadCommands(Assembly assembly)
21 | {
22 | var types = assembly.GetTypes();
23 | foreach (var type in types)
24 | {
25 | if (type.IsSubclassOf(typeof(UICommand)))
26 | {
27 | var command = Activator.CreateInstance(type) as UICommand;
28 | if (command.Name.Length == 0)
29 | continue;
30 | mCommands[command.Name] = command;
31 | }
32 | }
33 |
34 | }
35 |
36 | public static bool ExecuteCommand(string name, UICommandContext ctx)
37 | {
38 | UICommand command;
39 | if (mCommands.TryGetValue(name, out command))
40 | {
41 | return command.Execute(ctx);
42 | }
43 |
44 | return false;
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/AnyCAD.Rapid.Core/Data/SphereElementSchema.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AnyCAD.Foundation;
7 |
8 | namespace AnyCAD.Rapid.Core
9 | {
10 | ///
11 | /// 球类型的模板
12 | ///
13 | class SphereElementSchema : ElementSchema
14 | {
15 | public SphereElementSchema()
16 | : base("Sphere")
17 | {
18 | //增加参数
19 | AddParameter("Radius", ParameterCreator.Create(5.0f));
20 | }
21 |
22 | ///
23 | /// 参数化驱动构造模型
24 | ///
25 | ///
26 | ///
27 | ///
28 | public override bool OnParameterChanged(Element instance, ParameterDict parameters)
29 | {
30 | var shape = CastShapeElement(instance);
31 | var radius = parameters.Cast("Radius", 5.0f);
32 | shape.SetShape(ShapeBuilder.MakeSphere(GP.Origin(), radius));
33 | return true;
34 | }
35 |
36 | ///
37 | /// 创建一个实例对象
38 | ///
39 | ///
40 | ///
41 | static public ShapeElement Create(Document doc)
42 | {
43 | return ElementSchemaManager.Instance().CreateShapeInstance("Sphere", doc);
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/RapidCAX/PropertyUI/TransformPage.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/RapidCAX/Controls/CommandLineCtrl.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/AnyCAD.Rapid.Core/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("AnyCAD.Rapid.Core")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("AnyCAD.Rapid.Core")]
13 | [assembly: AssemblyCopyright("Copyright © 2020")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("71c38993-984b-4ae8-8cdd-27c9eaa60440")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/RapidCAX/Resources/StringResource.xaml:
--------------------------------------------------------------------------------
1 |
5 | File
6 | Save
7 | Undo
8 | Redo
9 | Open
10 | Ready
11 | Home
12 | Design
13 | Simulation
14 | Project
15 | Properties
16 | Output
17 | Command
18 | Execute
19 | 3D
20 | Import
21 | STEP
22 | IGES
23 | View
24 | Zoom All
25 | Background
26 | Color
27 | Image
28 |
--------------------------------------------------------------------------------
/RapidCAX.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30204.135
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RapidCAX", "RapidCAX\RapidCAX.csproj", "{13AB947F-AE96-44AB-B461-CE55A2450F02}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnyCAD.Rapid.Core", "AnyCAD.Rapid.Core\AnyCAD.Rapid.Core.csproj", "{71C38993-984B-4AE8-8CDD-27C9EAA60440}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {13AB947F-AE96-44AB-B461-CE55A2450F02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {13AB947F-AE96-44AB-B461-CE55A2450F02}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {13AB947F-AE96-44AB-B461-CE55A2450F02}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {13AB947F-AE96-44AB-B461-CE55A2450F02}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {71C38993-984B-4AE8-8CDD-27C9EAA60440}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {71C38993-984B-4AE8-8CDD-27C9EAA60440}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {71C38993-984B-4AE8-8CDD-27C9EAA60440}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {71C38993-984B-4AE8-8CDD-27C9EAA60440}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {9336BABF-B1C7-4F3E-B2ED-9D78D19B787C}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/RapidCAX/Controls/RapidBackstageCtrl.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 | 新建一个新项目?
15 |
16 |
17 |
18 |
19 |
20 |
23 |
24 |
25 |
28 |
29 |
30 |
31 |
32 |
33 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/AnyCAD.Rapid.Core/Data/MyTextElement.cs:
--------------------------------------------------------------------------------
1 | using AnyCAD.Foundation;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace AnyCAD.Rapid.Core
9 | {
10 | class MyTextElement
11 | {
12 | public string Text = "";
13 | public Vector3 Position = new Vector3(0);
14 | public ElementId Id;
15 | public TextSceneNode Node;
16 | public MyTextElement()
17 | {
18 |
19 | }
20 |
21 | public MyTextElement(string text, Vector3 position)
22 | {
23 | Text = text;
24 | Position = position;
25 | }
26 |
27 | static public bool IsKindOf(Element element)
28 | {
29 | return element.GetSchemaName() == "TextSceneNode";
30 | }
31 |
32 | ///
33 | /// 只能加一次
34 | ///
35 | ///
36 | public void AddElement(Document doc)
37 | {
38 | var element = new UserElement();
39 | element.SetName(Text);
40 | element.SetSchemaName("TextSceneNode");
41 | Id = doc.AddElement(element);
42 |
43 | element.AddParameter("PositionX", ParameterCreator.Create(Position.x));
44 | element.AddParameter("PositionY", ParameterCreator.Create(Position.y));
45 | element.AddParameter("PositionZ", ParameterCreator.Create(Position.z));
46 | }
47 |
48 | public void Load(UserElement element)
49 | {
50 | Text = element.GetName();
51 | Position.x = ParameterCast.Cast(element.FindParameter("PositionX"), 0.0f);
52 | Position.y = ParameterCast.Cast(element.FindParameter("PositionY"), 0.0f);
53 | Position.z = ParameterCast.Cast(element.FindParameter("PositionZ"), 0.0f);
54 | Id = element.GetId();
55 | }
56 |
57 | public void Show(Scene scene)
58 | {
59 | if (Node != null)
60 | return;
61 |
62 | Node = new TextSceneNode(Text, 10, Vector3.Blue, new Vector3(-1), true);
63 | Node.SetTransform(Matrix4.makeTranslation(Position));
64 | Node.SetUserId(Id.GetInteger());
65 | Node.RequstUpdate();
66 |
67 | scene.AddNode(Node);
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/AnyCAD.Rapid.Core/MyDocumentListener.cs:
--------------------------------------------------------------------------------
1 | using AnyCAD.Foundation;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Collections.ObjectModel;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace AnyCAD.Rapid.Core
10 | {
11 | ///
12 | /// 保存树节点信息
13 | ///
14 | public class BrowerNodeItem
15 | {
16 | public string Icon { get; set; }
17 | public string DisplayName { get; set; }
18 | public Object Tag { get; set; }
19 |
20 | public ObservableCollection Children { get; set; }
21 |
22 | public BrowerNodeItem()
23 | {
24 | Children = new ObservableCollection();
25 | }
26 | }
27 |
28 | ///
29 | /// 用于接收文档变化的监听器
30 | ///
31 | public class MyDocumentListener : DocumentListener
32 | {
33 | public ObservableCollection mProjectBrower = new ObservableCollection();
34 |
35 | public MyDocumentListener()
36 | {
37 | DocumentListener.SetListener(this);
38 | }
39 |
40 | ///
41 | /// 当增加图元的调用
42 | ///
43 | ///
44 | /// 图元的ID列表
45 | public override void OnAddElements(Document pDocument, ElementIdSet ids)
46 | {
47 | foreach(var id in ids)
48 | {
49 | var element = DrawableElement.Cast(pDocument.FindElement(id));
50 | if (element == null)
51 | continue;
52 |
53 | var item = new BrowerNodeItem();
54 | item.DisplayName = String.Format("{0}({1})", element.GetName(), element.GetId().GetInteger());
55 | item.Tag = element.GetId();
56 | mProjectBrower.Add(item);
57 | }
58 |
59 | }
60 |
61 | ///
62 | /// 当删除图元时候调用
63 | ///
64 | ///
65 | /// 删除图元的ID列表
66 | public override void OnRemoveElements(Document pDocument, ElementIdSet ids)
67 | {
68 | var nodes = mProjectBrower.Where(x => ids.Contains((ElementId)x.Tag)).ToList();
69 | foreach (var node in nodes)
70 | {
71 | mProjectBrower.Remove(node);
72 | }
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/RapidCAX/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("RapidCAX")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("RapidCAX")]
15 | [assembly: AssemblyCopyright("Copyright © 2020")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | //In order to begin building localizable applications, set
25 | //CultureYouAreCodingWith in your .csproj file
26 | //inside a . For example, if you are using US english
27 | //in your source files, set the to en-US. Then uncomment
28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
29 | //the line below to match the UICulture setting in the project file.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36 | //(used if a resource is not found in the page,
37 | // or application resource dictionaries)
38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39 | //(used if a resource is not found in the page,
40 | // app, or any theme specific resource dictionaries)
41 | )]
42 |
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/AnyCAD.Rapid.Core/CommandEx/ViewCommands.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows.Forms;
7 | using AnyCAD.Foundation;
8 |
9 | namespace AnyCAD.Rapid.Core
10 | {
11 | class ZoomAllCommand : UICommand
12 | {
13 | public ZoomAllCommand()
14 | {
15 | this.Name = "ZoomAll";
16 | }
17 |
18 | public override bool Execute(UICommandContext ctx)
19 | {
20 | ctx.RenderView.ZoomAll(1.2f);
21 | return true;
22 | }
23 | }
24 |
25 | class UndoCommand : UICommand
26 | {
27 | public UndoCommand()
28 | {
29 | this.Name = "Undo";
30 | }
31 |
32 | public override bool Execute(UICommandContext ctx)
33 | {
34 | ctx.Document.Undo();
35 | ctx.RequestUpdate();
36 |
37 | return true;
38 | }
39 | }
40 | class RedoCommand : UICommand
41 | {
42 | public RedoCommand()
43 | {
44 | this.Name = "Redo";
45 | }
46 |
47 | public override bool Execute(UICommandContext ctx)
48 | {
49 | ctx.Document.Redo();
50 | ctx.RequestUpdate();
51 | return true;
52 | }
53 | }
54 |
55 | class ColorBackgroundCommand : UICommand
56 | {
57 | public ColorBackgroundCommand()
58 | {
59 | this.Name = "BackgroundColor";
60 | }
61 |
62 | public override bool Execute(UICommandContext ctx)
63 | {
64 | var dlg = new System.Windows.Forms.ColorDialog();
65 | if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
66 | {
67 | ctx.RenderView.SetBackgroundColor(dlg.Color.R / 255.0f, dlg.Color.G / 255.0f, dlg.Color.B / 255.0f, 1);
68 | }
69 | return true;
70 | }
71 | }
72 |
73 | class ImageBackgroundCommand : UICommand
74 | {
75 | public ImageBackgroundCommand()
76 | {
77 | this.Name = "BackgroundImage";
78 | }
79 |
80 | public override bool Execute(UICommandContext ctx)
81 | {
82 | OpenFileDialog dlg = new OpenFileDialog();
83 | dlg.Filter = "Image Files(*.jpg;*.png)|*.jpg;*.png";
84 | if (dlg.ShowDialog() == DialogResult.OK)
85 | {
86 | var bkg = new ImageBackground(ImageTexture2D.Create(dlg.FileName));
87 | ctx.RenderView.GetViewer().SetBackground(bkg);
88 | }
89 | return true;
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/RapidCAX/PropertyUI/TransformPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using AnyCAD.Foundation;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.ComponentModel;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using System.Windows;
9 | using System.Windows.Controls;
10 | using System.Windows.Data;
11 | using System.Windows.Documents;
12 | using System.Windows.Input;
13 | using System.Windows.Media;
14 | using System.Windows.Media.Imaging;
15 | using System.Windows.Navigation;
16 | using System.Windows.Shapes;
17 |
18 | namespace RapidCAX
19 | {
20 | ///
21 | /// Interaction logic for TransformPage.xaml
22 | ///
23 | public partial class TransformPage : UserControl, INotifyPropertyChanged
24 | {
25 | private GPnt mLocation;
26 | private DrawableElement mElement;
27 | private bool mModified = false;
28 | public TransformPage(DrawableElement element)
29 | {
30 | mElement = element;
31 | var loc = mElement.GetCoordinateSystem().Location();
32 | mLocation = new GPnt(loc.XYZ());
33 | InitializeComponent();
34 |
35 | this.DataContext = this;
36 | }
37 |
38 | public double LocationX
39 | {
40 | get { return mLocation.X(); }
41 | set { mLocation.SetX(value); LocationModified = true; }
42 | }
43 |
44 | public double LocationY
45 | {
46 | get { return mLocation.Y(); }
47 | set { mLocation.SetY(value); LocationModified = true; }
48 | }
49 | public double LocationZ
50 | {
51 | get { return mLocation.Z(); }
52 | set { mLocation.SetZ(value); LocationModified = true; }
53 | }
54 |
55 | public bool LocationModified
56 | {
57 | get { return mModified; }
58 | set { mModified = value; OnPropertyChanged("LocationModified"); }
59 | }
60 |
61 | public event PropertyChangedEventHandler PropertyChanged;
62 | private void OnPropertyChanged(string propertyName)
63 | {
64 | PropertyChangedEventHandler handler = this.PropertyChanged;
65 | if (handler != null)
66 | {
67 | handler(this, new PropertyChangedEventArgs(propertyName));
68 | }
69 | }
70 |
71 | public delegate void UpdateViewHandler();
72 | public event UpdateViewHandler UpdateViewEvent;
73 | private void Button_Click(object sender, RoutedEventArgs e)
74 | {
75 | UndoTransaction undo = new UndoTransaction(mElement);
76 | undo.Start("Transform");
77 | var cs = new GAx3();
78 | cs.SetLocation(mLocation);
79 | mElement.SetCoordinateSystem(cs);
80 | undo.Commit();
81 |
82 | LocationModified = false;
83 |
84 | if (UpdateViewEvent != null)
85 | UpdateViewEvent();
86 | }
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/RapidCAX/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace RapidCAX.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RapidCAX.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Looks up a localized resource of type System.Drawing.Bitmap.
65 | ///
66 | internal static System.Drawing.Bitmap icon {
67 | get {
68 | object obj = ResourceManager.GetObject("icon", resourceCulture);
69 | return ((System.Drawing.Bitmap)(obj));
70 | }
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/RapidCAX/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using AnyCAD.Foundation;
2 | using AnyCAD.Rapid.Core;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using System.Windows;
9 | using System.Windows.Controls;
10 | using System.Windows.Data;
11 | using System.Windows.Documents;
12 | using System.Windows.Input;
13 | using System.Windows.Media;
14 | using System.Windows.Media.Imaging;
15 | using System.Windows.Navigation;
16 | using System.Windows.Shapes;
17 |
18 | namespace RapidCAX
19 | {
20 |
21 | ///
22 | /// Interaction logic for MainWindow.xaml
23 | ///
24 | public partial class MainWindow
25 | {
26 | public static readonly RoutedCommand RapidCommand = new RoutedCommand("Rapid", typeof(MainWindow));
27 |
28 | public MyDocumentViewer mDocumentView;
29 | public MyDocumentListener mDocumentListener;
30 | public MainWindow()
31 | {
32 | InitializeComponent();
33 |
34 | //命令绑定
35 | CommandBindings.Add(new CommandBinding(RapidCommand, RapidExecuted));
36 | // 注册文档消息
37 | mDocumentListener = new MyDocumentListener();
38 | }
39 |
40 | private void Window_Loaded(object sender, RoutedEventArgs e)
41 | {
42 | //创建文档视图控件
43 | mDocumentView = new MyDocumentViewer(this.documentViewHost,
44 | (PickedItem item, Document doc, ElementId id)=>
45 | {
46 |
47 | propertyBrowser.Children.Clear();
48 |
49 | if (!id.IsValid())
50 | return;
51 |
52 | //增加一条日志
53 | this.outputCtrl.outputList.Items.Add(id.GetInteger());
54 |
55 | //显示选中图元的属性
56 | CreateElementPropertyUI(doc, id);
57 | });
58 | // 绑定构件浏览数据
59 | this.projectBrowser.ItemsSource = mDocumentListener.mProjectBrower;
60 | }
61 |
62 | void RapidExecuted(object sender, ExecutedRoutedEventArgs e)
63 | {
64 | mDocumentView.ExecuteCommand(e.Parameter.ToString());
65 | }
66 |
67 | ///
68 | /// 创建属性
69 | ///
70 | ///
71 | ///
72 | void CreateElementPropertyUI(Document doc, ElementId id)
73 | {
74 | var element = doc.FindElement(id);
75 | if (element == null)
76 | return;
77 | {
78 | Expander expander = new Expander();
79 | expander.Header = "Element";
80 | expander.Content = new BasicPage(element);
81 | propertyBrowser.Children.Add(expander);
82 | expander.IsExpanded = true;
83 | }
84 |
85 | DrawableElement de = DrawableElement.Cast(element);
86 | if(de != null)
87 | {
88 | Expander expander = new Expander();
89 | expander.Header = "Location";
90 | var page = new TransformPage(de);
91 | page.UpdateViewEvent += mDocumentView.UpdateView;
92 | expander.Content = page;
93 | propertyBrowser.Children.Add(expander);
94 | expander.IsExpanded = true;
95 | }
96 | }
97 |
98 | private void projectBrowser_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs