diff --git a/samples/CSharp/CSharp.sln b/samples/CSharp/CSharp.sln new file mode 100644 index 0000000000..6ec2e629d4 --- /dev/null +++ b/samples/CSharp/CSharp.sln @@ -0,0 +1,45 @@ +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IE_WPF", "WPF\IE_WPF.csproj", "{D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IE_WinForms", "WinForms\IE_WinForms.csproj", "{B9914BB3-B886-4B41-B48D-350EBEBEFD1F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OCCTProxy", "OCCTProxy\OCCTProxy.vcproj", "{969912D9-78E7-4AB8-B4FF-6B52B4F03991}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Debug|Win32.ActiveCfg = Debug|x86 + {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Debug|Win32.Build.0 = Debug|x86 + {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Debug|x64.ActiveCfg = Debug|x64 + {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Debug|x64.Build.0 = Debug|x64 + {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Release|Win32.ActiveCfg = Release|x86 + {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Release|Win32.Build.0 = Release|x86 + {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Release|x64.ActiveCfg = Release|x64 + {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Release|x64.Build.0 = Release|x64 + {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Debug|Win32.ActiveCfg = Debug|x86 + {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Debug|Win32.Build.0 = Debug|x86 + {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Debug|x64.ActiveCfg = Debug|x64 + {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Debug|x64.Build.0 = Debug|x64 + {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Release|Win32.ActiveCfg = Release|x86 + {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Release|Win32.Build.0 = Release|x86 + {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Release|x64.ActiveCfg = Release|x64 + {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Release|x64.Build.0 = Release|x64 + {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Debug|Win32.ActiveCfg = Debug|Win32 + {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Debug|Win32.Build.0 = Debug|Win32 + {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Debug|x64.ActiveCfg = Debug|x64 + {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Debug|x64.Build.0 = Debug|x64 + {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Release|Win32.ActiveCfg = Release|Win32 + {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Release|Win32.Build.0 = Release|Win32 + {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Release|x64.ActiveCfg = Release|x64 + {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/samples/CSharp/IE/AboutDialog.cs b/samples/CSharp/IE/AboutDialog.cs deleted file mode 100755 index 99a4002225..0000000000 --- a/samples/CSharp/IE/AboutDialog.cs +++ /dev/null @@ -1,157 +0,0 @@ -using System; -using System.Drawing; -using System.Collections; -using System.ComponentModel; -using System.Windows.Forms; - -namespace IE -{ - /// - /// Summary description for AboutDialog. - /// - public class AboutDialog : System.Windows.Forms.Form - { - private System.Windows.Forms.PictureBox pictureBox1; - private System.Windows.Forms.Button button1; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.Label myVersion; - /// - /// Required designer variable. - /// - private System.ComponentModel.Container components = null; - - public AboutDialog() - { - // - // Required for Windows Form Designer support - // - InitializeComponent(); - // - // TODO: Add any constructor code after InitializeComponent call - // - shell t = new shell(); - t.InitOCCViewer(); - float version = t.GetOCCVersion(); - this.myVersion.Text=this.myVersion.Text+version; - } - - /// - /// Clean up any resources being used. - /// - protected override void Dispose( bool disposing ) - { - if( disposing ) - { - if(components != null) - { - components.Dispose(); - } - } - base.Dispose( disposing ); - } - - #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AboutDialog)); - this.pictureBox1 = new System.Windows.Forms.PictureBox(); - this.button1 = new System.Windows.Forms.Button(); - this.label1 = new System.Windows.Forms.Label(); - this.myVersion = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); - this.SuspendLayout(); - // - // pictureBox1 - // - this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image"))); - this.pictureBox1.Location = new System.Drawing.Point(59, 64); - this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(196, 102); - this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; - this.pictureBox1.TabIndex = 0; - this.pictureBox1.TabStop = false; - // - // button1 - // - this.button1.Location = new System.Drawing.Point(96, 248); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(128, 24); - this.button1.TabIndex = 1; - this.button1.Text = "OK"; - this.button1.Click += new System.EventHandler(this.button1_Click); - // - // label1 - // - this.label1.Location = new System.Drawing.Point(16, 9); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(288, 24); - this.label1.TabIndex = 2; - this.label1.Text = "Import/Export Sample,"; - this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // myVersion - // - this.myVersion.Location = new System.Drawing.Point(16, 32); - this.myVersion.Name = "myVersion"; - this.myVersion.Size = new System.Drawing.Size(288, 16); - this.myVersion.TabIndex = 3; - this.myVersion.Text = "Open CASCADE Technology "; - this.myVersion.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // label3 - // - this.label3.Location = new System.Drawing.Point(24, 168); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(280, 23); - this.label3.TabIndex = 4; - this.label3.Text = "Copyright (C) 2004-2012, Open CASCADE S.A.S"; - this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // label4 - // - this.label4.Location = new System.Drawing.Point(8, 200); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(296, 24); - this.label4.TabIndex = 5; - this.label4.Text = "http://www.opencascade.com"; - this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // AboutDialog - // - this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); - this.ClientSize = new System.Drawing.Size(312, 285); - this.ControlBox = false; - this.Controls.Add(this.label4); - this.Controls.Add(this.label3); - this.Controls.Add(this.myVersion); - this.Controls.Add(this.label1); - this.Controls.Add(this.button1); - this.Controls.Add(this.pictureBox1); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "AboutDialog"; - this.Text = "About Import/Export Sample"; - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - #endregion - - private void button1_Click(object sender, System.EventArgs e) - { - this.Close(); - } - } -} diff --git a/samples/CSharp/IE/Form1.cs b/samples/CSharp/IE/Form1.cs deleted file mode 100755 index aaead88517..0000000000 --- a/samples/CSharp/IE/Form1.cs +++ /dev/null @@ -1,1103 +0,0 @@ -using System; -using System.Drawing; -using System.Collections; -using System.ComponentModel; -using System.Windows.Forms; -using System.Data; - -namespace IE -{ - /// - /// Summary description for Form1. - /// - public class Form1 : System.Windows.Forms.Form - { - private System.Windows.Forms.MainMenu mainMenu1; - private System.Windows.Forms.MenuItem FileNew; - private System.Windows.Forms.MenuItem FileClose; - private System.Windows.Forms.MenuItem FileExport; - private System.Windows.Forms.MenuItem FileImport; - private System.Windows.Forms.MenuItem ImportBRep; - private System.Windows.Forms.MenuItem ExportImage; - private System.Windows.Forms.MenuItem File; - private System.Windows.Forms.MenuItem Window; - private System.Windows.Forms.ToolBarButton New; - private System.Windows.Forms.ImageList imageList1; - private System.Windows.Forms.ToolBarButton About; - private System.Windows.Forms.StatusBar myStatusBar; - private System.Windows.Forms.MenuItem ImportIges; - private System.Windows.Forms.MenuItem ImportStep; - private System.Windows.Forms.MenuItem ExportBRep; - private System.Windows.Forms.MenuItem ExportIges; - private System.Windows.Forms.MenuItem ExportStep; - private System.Windows.Forms.MenuItem ExportStl; - private System.Windows.Forms.MenuItem ExportVrml; - private System.ComponentModel.IContainer components; - private System.Windows.Forms.MenuItem menuItem1; - private System.Windows.Forms.MenuItem menuItem2; - private System.Windows.Forms.MenuItem menuItem3; - private System.Windows.Forms.MenuItem View; - private System.Windows.Forms.MenuItem Help; - private System.Windows.Forms.MenuItem HelpAbout; - private System.Windows.Forms.MenuItem ViewToolbar; - private System.Windows.Forms.MenuItem ViewStatusBar; - private System.Windows.Forms.MenuItem menuItem4; - private System.Windows.Forms.MenuItem WindowCascade; - private System.Windows.Forms.MenuItem WindowTile; - - protected IE.ModelFormat myModelFormat; - private System.Windows.Forms.ToolBarButton wireframe; - private System.Windows.Forms.ToolBarButton shading; - private System.Windows.Forms.ToolBarButton toolBarButton1; - private System.Windows.Forms.ToolBarButton color; - private System.Windows.Forms.ToolBarButton transparency; - private System.Windows.Forms.ToolBarButton delete; - private System.Windows.Forms.ToolBarButton material; - private System.Windows.Forms.ToolBarButton ZoomAll; - private System.Windows.Forms.ToolBarButton ZoomWin; - private System.Windows.Forms.ToolBarButton ZoomProg; - private System.Windows.Forms.ToolBarButton Pan; - private System.Windows.Forms.ToolBarButton PanGlo; - private System.Windows.Forms.ToolBarButton Front; - private System.Windows.Forms.ToolBarButton Back; - private System.Windows.Forms.ToolBarButton TOP; - private System.Windows.Forms.ToolBarButton BOTTOM; - private System.Windows.Forms.ToolBarButton RIGHT; - private System.Windows.Forms.ToolBarButton LEFT; - private System.Windows.Forms.ToolBarButton Axo; - private System.Windows.Forms.ToolBarButton Rot; - private System.Windows.Forms.ToolBarButton Reset; - private System.Windows.Forms.ToolBarButton HlrOn; - private System.Windows.Forms.ToolBarButton HlrOff; - private System.Windows.Forms.ToolBar toolBarTool; - private System.Windows.Forms.ToolBar toolBarView; - protected static int myNbOfChildren; - - public Form1() - { - // - // Required for Windows Form Designer support - // - InitializeComponent(); - - // - // TODO: Add any constructor code after InitializeComponent call - // - IE.Form1.myNbOfChildren=0; - } - - /// - /// Clean up any resources being used. - /// - protected override void Dispose( bool disposing ) - { - if( disposing ) - { - if (components != null) - { - components.Dispose(); - } - } - base.Dispose( disposing ); - } - - #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader(); - System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1)); - this.mainMenu1 = new System.Windows.Forms.MainMenu(); - this.File = new System.Windows.Forms.MenuItem(); - this.FileNew = new System.Windows.Forms.MenuItem(); - this.FileExport = new System.Windows.Forms.MenuItem(); - this.ImportBRep = new System.Windows.Forms.MenuItem(); - this.ImportIges = new System.Windows.Forms.MenuItem(); - this.ImportStep = new System.Windows.Forms.MenuItem(); - this.FileImport = new System.Windows.Forms.MenuItem(); - this.ExportBRep = new System.Windows.Forms.MenuItem(); - this.ExportIges = new System.Windows.Forms.MenuItem(); - this.ExportStep = new System.Windows.Forms.MenuItem(); - this.ExportStl = new System.Windows.Forms.MenuItem(); - this.ExportVrml = new System.Windows.Forms.MenuItem(); - this.menuItem3 = new System.Windows.Forms.MenuItem(); - this.ExportImage = new System.Windows.Forms.MenuItem(); - this.FileClose = new System.Windows.Forms.MenuItem(); - this.menuItem2 = new System.Windows.Forms.MenuItem(); - this.menuItem1 = new System.Windows.Forms.MenuItem(); - this.View = new System.Windows.Forms.MenuItem(); - this.ViewToolbar = new System.Windows.Forms.MenuItem(); - this.ViewStatusBar = new System.Windows.Forms.MenuItem(); - this.Window = new System.Windows.Forms.MenuItem(); - this.menuItem4 = new System.Windows.Forms.MenuItem(); - this.WindowCascade = new System.Windows.Forms.MenuItem(); - this.WindowTile = new System.Windows.Forms.MenuItem(); - this.Help = new System.Windows.Forms.MenuItem(); - this.HelpAbout = new System.Windows.Forms.MenuItem(); - this.toolBarTool = new System.Windows.Forms.ToolBar(); - this.New = new System.Windows.Forms.ToolBarButton(); - this.About = new System.Windows.Forms.ToolBarButton(); - this.toolBarButton1 = new System.Windows.Forms.ToolBarButton(); - this.wireframe = new System.Windows.Forms.ToolBarButton(); - this.shading = new System.Windows.Forms.ToolBarButton(); - this.color = new System.Windows.Forms.ToolBarButton(); - this.material = new System.Windows.Forms.ToolBarButton(); - this.transparency = new System.Windows.Forms.ToolBarButton(); - this.delete = new System.Windows.Forms.ToolBarButton(); - this.imageList1 = new System.Windows.Forms.ImageList(this.components); - this.myStatusBar = new System.Windows.Forms.StatusBar(); - this.toolBarView = new System.Windows.Forms.ToolBar(); - this.ZoomAll = new System.Windows.Forms.ToolBarButton(); - this.ZoomWin = new System.Windows.Forms.ToolBarButton(); - this.ZoomProg = new System.Windows.Forms.ToolBarButton(); - this.Pan = new System.Windows.Forms.ToolBarButton(); - this.PanGlo = new System.Windows.Forms.ToolBarButton(); - this.Front = new System.Windows.Forms.ToolBarButton(); - this.Back = new System.Windows.Forms.ToolBarButton(); - this.TOP = new System.Windows.Forms.ToolBarButton(); - this.BOTTOM = new System.Windows.Forms.ToolBarButton(); - this.LEFT = new System.Windows.Forms.ToolBarButton(); - this.RIGHT = new System.Windows.Forms.ToolBarButton(); - this.Axo = new System.Windows.Forms.ToolBarButton(); - this.Rot = new System.Windows.Forms.ToolBarButton(); - this.Reset = new System.Windows.Forms.ToolBarButton(); - this.HlrOn = new System.Windows.Forms.ToolBarButton(); - this.HlrOff = new System.Windows.Forms.ToolBarButton(); - this.SuspendLayout(); - // - // mainMenu1 - // - this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { - this.File, - this.View, - this.Window, - this.Help}); - // - // File - // - this.File.Index = 0; - this.File.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { - this.FileNew, - this.FileExport, - this.FileImport, - this.FileClose, - this.menuItem2, - this.menuItem1}); - this.File.Text = "&File"; - this.File.Popup += new System.EventHandler(this.File_Popup); - // - // FileNew - // - this.FileNew.Index = 0; - this.FileNew.Text = "&New"; - this.FileNew.Click += new System.EventHandler(this.menuItem2_Click); - // - // FileExport - // - this.FileExport.Index = 1; - this.FileExport.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { - this.ImportBRep, - this.ImportIges, - this.ImportStep}); - this.FileExport.Text = "&Import"; - this.FileExport.Visible = false; - // - // ImportBRep - // - this.ImportBRep.Index = 0; - this.ImportBRep.Text = "&BRep ..."; - this.ImportBRep.Click += new System.EventHandler(this.ImportBRep_Click); - // - // ImportIges - // - this.ImportIges.Index = 1; - this.ImportIges.Text = "&Iges ..."; - this.ImportIges.Click += new System.EventHandler(this.ImportIges_Click); - // - // ImportStep - // - this.ImportStep.Index = 2; - this.ImportStep.Text = "&Step ..."; - this.ImportStep.Click += new System.EventHandler(this.ImportStep_Click); - // - // FileImport - // - this.FileImport.Index = 2; - this.FileImport.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { - this.ExportBRep, - this.ExportIges, - this.ExportStep, - this.ExportStl, - this.ExportVrml, - this.menuItem3, - this.ExportImage}); - this.FileImport.Text = "&Export"; - this.FileImport.Visible = false; - this.FileImport.Popup += new System.EventHandler(this.FileImport_Popup); - // - // ExportBRep - // - this.ExportBRep.Enabled = false; - this.ExportBRep.Index = 0; - this.ExportBRep.Text = "&BRep ..."; - this.ExportBRep.Click += new System.EventHandler(this.ExportBRep_Click); - // - // ExportIges - // - this.ExportIges.Enabled = false; - this.ExportIges.Index = 1; - this.ExportIges.Text = "&Iges ..."; - this.ExportIges.Click += new System.EventHandler(this.ExportIges_Click); - // - // ExportStep - // - this.ExportStep.Enabled = false; - this.ExportStep.Index = 2; - this.ExportStep.Text = "&Step ..."; - this.ExportStep.Click += new System.EventHandler(this.ExportStep_Click); - // - // ExportStl - // - this.ExportStl.Enabled = false; - this.ExportStl.Index = 3; - this.ExportStl.Text = "&Stl ..."; - this.ExportStl.Click += new System.EventHandler(this.ExportStl_Click); - // - // ExportVrml - // - this.ExportVrml.Enabled = false; - this.ExportVrml.Index = 4; - this.ExportVrml.Text = "&Vrml ..."; - this.ExportVrml.Click += new System.EventHandler(this.ExportVrml_Click); - // - // menuItem3 - // - this.menuItem3.Index = 5; - this.menuItem3.Text = "-"; - // - // ExportImage - // - this.ExportImage.Index = 6; - this.ExportImage.Text = "Image ..."; - this.ExportImage.Click += new System.EventHandler(this.ExportImage_Click); - // - // FileClose - // - this.FileClose.Enabled = false; - this.FileClose.Index = 3; - this.FileClose.Text = "&Close"; - this.FileClose.Click += new System.EventHandler(this.menuItem3_Click); - // - // menuItem2 - // - this.menuItem2.Index = 4; - this.menuItem2.Text = "-"; - // - // menuItem1 - // - this.menuItem1.Index = 5; - this.menuItem1.Text = "&Quit"; - this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click); - // - // View - // - this.View.Index = 1; - this.View.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { - this.ViewToolbar, - this.ViewStatusBar}); - this.View.Text = "&View"; - // - // ViewToolbar - // - this.ViewToolbar.Checked = true; - this.ViewToolbar.Index = 0; - this.ViewToolbar.Text = "&Toolbar"; - this.ViewToolbar.Click += new System.EventHandler(this.ViewToolbar_Click); - // - // ViewStatusBar - // - this.ViewStatusBar.Checked = true; - this.ViewStatusBar.Index = 1; - this.ViewStatusBar.Text = "&Statusbar"; - this.ViewStatusBar.Click += new System.EventHandler(this.ViewStatusBar_Click); - // - // Window - // - this.Window.Index = 2; - this.Window.MdiList = true; - this.Window.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { - this.menuItem4, - this.WindowCascade, - this.WindowTile}); - this.Window.Text = "&Window"; - this.Window.Visible = false; - // - // menuItem4 - // - this.menuItem4.Index = 0; - this.menuItem4.Text = "&New 3d View"; - this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click); - // - // WindowCascade - // - this.WindowCascade.Index = 1; - this.WindowCascade.Text = "&Cascade"; - this.WindowCascade.Click += new System.EventHandler(this.WindowCascade_Click); - // - // WindowTile - // - this.WindowTile.Index = 2; - this.WindowTile.Text = "&Tile"; - this.WindowTile.Click += new System.EventHandler(this.WindowTile_Click); - // - // Help - // - this.Help.Index = 3; - this.Help.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { - this.HelpAbout}); - this.Help.Text = "&Help"; - // - // HelpAbout - // - this.HelpAbout.Index = 0; - this.HelpAbout.Shortcut = System.Windows.Forms.Shortcut.F1; - this.HelpAbout.Text = "&About"; - this.HelpAbout.Click += new System.EventHandler(this.HelpAbout_Click); - // - // toolBarTool - // - this.toolBarTool.AccessibleRole = System.Windows.Forms.AccessibleRole.ToolBar; - this.toolBarTool.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] { - this.New, - this.About, - this.toolBarButton1, - this.wireframe, - this.shading, - this.color, - this.material, - this.transparency, - this.delete}); - this.toolBarTool.DropDownArrows = true; - this.toolBarTool.ImageList = this.imageList1; - this.toolBarTool.Location = new System.Drawing.Point(0, 0); - this.toolBarTool.Name = "toolBarTool"; - this.toolBarTool.ShowToolTips = true; - this.toolBarTool.Size = new System.Drawing.Size(560, 28); - this.toolBarTool.TabIndex = 1; - this.toolBarTool.Enter += new System.EventHandler(this.menuItem3_Click); - this.toolBarTool.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick); - this.toolBarTool.MouseHover += new System.EventHandler(this.toolBar1_MouseHover); - this.toolBarTool.MouseLeave += new System.EventHandler(this.toolBar1_MouseLeave); - // - // New - // - this.New.ImageIndex = 0; - this.New.ToolTipText = "New"; - this.New.Visible = ((bool)(configurationAppSettings.GetValue("New.Visible", typeof(bool)))); - // - // About - // - this.About.ImageIndex = 1; - this.About.ToolTipText = "About(F1)"; - this.About.Visible = ((bool)(configurationAppSettings.GetValue("About.Visible", typeof(bool)))); - // - // toolBarButton1 - // - this.toolBarButton1.Style = System.Windows.Forms.ToolBarButtonStyle.Separator; - // - // wireframe - // - this.wireframe.Enabled = ((bool)(configurationAppSettings.GetValue("wireframe.Enabled", typeof(bool)))); - this.wireframe.ImageIndex = 2; - this.wireframe.Pushed = ((bool)(configurationAppSettings.GetValue("wireframe.Pushed", typeof(bool)))); - this.wireframe.ToolTipText = "Wireframe"; - this.wireframe.Visible = ((bool)(configurationAppSettings.GetValue("wireframe.Visible", typeof(bool)))); - // - // shading - // - this.shading.Enabled = ((bool)(configurationAppSettings.GetValue("shading.Enabled", typeof(bool)))); - this.shading.ImageIndex = 3; - this.shading.Pushed = ((bool)(configurationAppSettings.GetValue("shading.Pushed", typeof(bool)))); - this.shading.ToolTipText = "Shading"; - this.shading.Visible = ((bool)(configurationAppSettings.GetValue("shading.Visible", typeof(bool)))); - // - // color - // - this.color.Enabled = ((bool)(configurationAppSettings.GetValue("color.Enabled", typeof(bool)))); - this.color.ImageIndex = 4; - this.color.ToolTipText = "Color"; - this.color.Visible = ((bool)(configurationAppSettings.GetValue("color.Visible", typeof(bool)))); - // - // material - // - this.material.Enabled = ((bool)(configurationAppSettings.GetValue("material.Enabled", typeof(bool)))); - this.material.ImageIndex = 5; - this.material.ToolTipText = "Material"; - this.material.Visible = ((bool)(configurationAppSettings.GetValue("material.Visible", typeof(bool)))); - // - // transparency - // - this.transparency.Enabled = ((bool)(configurationAppSettings.GetValue("transparency.Enabled", typeof(bool)))); - this.transparency.ImageIndex = 6; - this.transparency.ToolTipText = "Transparency"; - this.transparency.Visible = ((bool)(configurationAppSettings.GetValue("transparency.Visible", typeof(bool)))); - // - // delete - // - this.delete.Enabled = ((bool)(configurationAppSettings.GetValue("delete.Enabled", typeof(bool)))); - this.delete.ImageIndex = 7; - this.delete.ToolTipText = "Delete"; - this.delete.Visible = ((bool)(configurationAppSettings.GetValue("delete.Visible", typeof(bool)))); - // - // imageList1 - // - this.imageList1.ImageSize = new System.Drawing.Size(16, 16); - this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream"))); - this.imageList1.TransparentColor = System.Drawing.Color.Transparent; - // - // myStatusBar - // - this.myStatusBar.AccessibleRole = System.Windows.Forms.AccessibleRole.StatusBar; - this.myStatusBar.Location = new System.Drawing.Point(0, 363); - this.myStatusBar.Name = "myStatusBar"; - this.myStatusBar.Size = new System.Drawing.Size(560, 22); - this.myStatusBar.TabIndex = 3; - // - // toolBarView - // - this.toolBarView.AccessibleRole = System.Windows.Forms.AccessibleRole.ToolBar; - this.toolBarView.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] { - this.ZoomAll, - this.ZoomWin, - this.ZoomProg, - this.Pan, - this.PanGlo, - this.Front, - this.Back, - this.TOP, - this.BOTTOM, - this.LEFT, - this.RIGHT, - this.Axo, - this.Rot, - this.Reset, - this.HlrOn, - this.HlrOff}); - this.toolBarView.DropDownArrows = true; - this.toolBarView.ImageList = this.imageList1; - this.toolBarView.Location = new System.Drawing.Point(0, 28); - this.toolBarView.Name = "toolBarView"; - this.toolBarView.ShowToolTips = true; - this.toolBarView.Size = new System.Drawing.Size(560, 28); - this.toolBarView.TabIndex = 5; - this.toolBarView.Visible = false; - this.toolBarView.Wrappable = false; - this.toolBarView.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBarView_ButtonClick); - this.toolBarView.MouseHover += new System.EventHandler(this.toolBarView_MouseHover); - this.toolBarView.MouseLeave += new System.EventHandler(this.toolBarView_MouseLeave); - // - // ZoomAll - // - this.ZoomAll.ImageIndex = 8; - this.ZoomAll.ToolTipText = "FitAll"; - // - // ZoomWin - // - this.ZoomWin.ImageIndex = 9; - this.ZoomWin.ToolTipText = "Zoom Window"; - // - // ZoomProg - // - this.ZoomProg.ImageIndex = 10; - this.ZoomProg.ToolTipText = "Dynamic Zooming"; - // - // Pan - // - this.Pan.ImageIndex = 11; - this.Pan.ToolTipText = "Dynamic Panning"; - // - // PanGlo - // - this.PanGlo.ImageIndex = 12; - this.PanGlo.ToolTipText = "GlobalPanning"; - // - // Front - // - this.Front.ImageIndex = 13; - this.Front.ToolTipText = "Front"; - // - // Back - // - this.Back.ImageIndex = 14; - this.Back.ToolTipText = "Back"; - // - // TOP - // - this.TOP.ImageIndex = 15; - this.TOP.ToolTipText = "Top"; - // - // BOTTOM - // - this.BOTTOM.ImageIndex = 16; - this.BOTTOM.ToolTipText = "Bottom"; - // - // LEFT - // - this.LEFT.ImageIndex = 17; - this.LEFT.ToolTipText = "Left"; - // - // RIGHT - // - this.RIGHT.ImageIndex = 18; - this.RIGHT.ToolTipText = "Right"; - // - // Axo - // - this.Axo.ImageIndex = 19; - this.Axo.ToolTipText = "Axo"; - // - // Rot - // - this.Rot.ImageIndex = 20; - this.Rot.ToolTipText = "Dynamic Rotation"; - // - // Reset - // - this.Reset.ImageIndex = 21; - this.Reset.ToolTipText = "Reset"; - // - // HlrOn - // - this.HlrOn.ImageIndex = 22; - this.HlrOn.Pushed = true; - this.HlrOn.ToolTipText = "Hidden On"; - // - // HlrOff - // - this.HlrOff.ImageIndex = 23; - this.HlrOff.ToolTipText = "Hidden Off"; - // - // Form1 - // - this.AccessibleRole = System.Windows.Forms.AccessibleRole.Application; - this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); - this.ClientSize = new System.Drawing.Size(560, 385); - this.Controls.Add(this.toolBarView); - this.Controls.Add(this.myStatusBar); - this.Controls.Add(this.toolBarTool); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.IsMdiContainer = true; - this.Menu = this.mainMenu1; - this.Name = "Form1"; - this.Text = "Sample Import / Export"; - this.Activated += new System.EventHandler(this.Form1_Activated); - this.ResumeLayout(false); - - } - #endregion - - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - Application.Run(new Form1()); - } - - private void menuItem2_Click(object sender, System.EventArgs e) - { - - this.Cursor=System.Windows.Forms.Cursors.WaitCursor; - this.OnNewFile(); - } - - private void menuItem3_Click(object sender, System.EventArgs e) - { - if ( this.MdiChildren.Length > 0 ) - this.ActiveMdiChild.Close(); - - } - - private void ImportBRep_Click(object sender, System.EventArgs e) - { - - Form2 curForm = (Form2) this.ActiveMdiChild; - if (curForm == null) - return; - this.myModelFormat=ModelFormat.BREP; - curForm.ImportModel(this.myModelFormat); - - } - - private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e) - { - - Form2 curForm = (Form2) this.ActiveMdiChild; - switch(toolBarTool.Buttons.IndexOf(e.Button)) - { - case 0: - this.Cursor=System.Windows.Forms.Cursors.WaitCursor; - this.OnNewFile(); - break; - case 1: - AboutDialog myDlg = new AboutDialog(); - myDlg.ShowDialog(this); - break; - - case 2: //just separator - break; - case 3: - if (curForm == null) - return; - curForm.SetDisplayMode(0); //wireframe - this.wireframe.Enabled=false; - this.shading.Enabled=true; - this.transparency.Enabled=false; - break; - case 4: - if (curForm == null) - return; - curForm.SetDisplayMode(1); //shading - this.shading.Enabled=false; - this.wireframe.Enabled=true; - this.transparency.Enabled=true; - break; - case 5: - if (curForm == null) - return; - curForm.ChangeColor(true); - break; - case 6: - if (curForm == null) - return; - MaterialDialog m = new MaterialDialog(); - m.View=curForm.View; - m.ShowDialog(curForm); - break; - case 7: - if (curForm == null) - return; - IE.TransparencyDialog t = new TransparencyDialog(); - t.View=curForm.View; - t.ShowDialog(curForm); - break; - case 8: - if (curForm == null) - return; - curForm.DeleteObjects(); - break; - default: - break; - } - } - - private void toolBar1_MouseHover(object sender, System.EventArgs e) - { - this.myStatusBar.Text="Document toolbar"; - } - - private void toolBar1_MouseLeave(object sender, System.EventArgs e) - { - this.myStatusBar.Text=""; - } - - private void ImportCsfdb_Click(object sender, System.EventArgs e) - { - Form2 curForm = (Form2) this.ActiveMdiChild; - if (curForm == null) - return; - this.myModelFormat=IE.ModelFormat.CSFDB; - curForm.ImportModel(this.myModelFormat); - } - - private void ImportIges_Click(object sender, System.EventArgs e) - { - Form2 curForm = (Form2) this.ActiveMdiChild; - if (curForm == null) - return; - this.myModelFormat=IE.ModelFormat.IGES; - curForm.ImportModel(this.myModelFormat); - } - - private void ImportStep_Click(object sender, System.EventArgs e) - { - Form2 curForm = (Form2) this.ActiveMdiChild; - if (curForm == null) - return; - this.myModelFormat=IE.ModelFormat.STEP; - curForm.ImportModel(this.myModelFormat); - } - - private void ExportBRep_Click(object sender, System.EventArgs e) - { - Form2 curForm = (Form2) this.ActiveMdiChild; - if (curForm == null) - return; - this.myModelFormat=IE.ModelFormat.BREP; - curForm.ExportModel(this.myModelFormat); - } - - private void ExportCsfdb_Click(object sender, System.EventArgs e) - { - Form2 curForm = (Form2) this.ActiveMdiChild; - if (curForm == null) - return; - this.myModelFormat=IE.ModelFormat.CSFDB; - curForm.ExportModel(this.myModelFormat); - } - - private void ExportIges_Click(object sender, System.EventArgs e) - { - Form2 curForm = (Form2) this.ActiveMdiChild; - if (curForm == null) - return; - this.myModelFormat=IE.ModelFormat.IGES; - curForm.ExportModel(this.myModelFormat); - } - - private void ExportStep_Click(object sender, System.EventArgs e) - { - Form2 curForm = (Form2) this.ActiveMdiChild; - if (curForm == null) - return; - this.myModelFormat=IE.ModelFormat.STEP; - curForm.ExportModel(this.myModelFormat); - } - - private void ExportStl_Click(object sender, System.EventArgs e) - { - Form2 curForm = (Form2) this.ActiveMdiChild; - if (curForm == null) - return; - this.myModelFormat=IE.ModelFormat.STL; - curForm.ExportModel(this.myModelFormat); - } - - private void ExportVrml_Click(object sender, System.EventArgs e) - { - Form2 curForm = (Form2) this.ActiveMdiChild; - if (curForm == null) - return; - this.myModelFormat=IE.ModelFormat.VRML; - curForm.ExportModel(this.myModelFormat); - } - - private void ExportImage_Click(object sender, System.EventArgs e) - { - Form2 curForm = (Form2) this.ActiveMdiChild; - if (curForm == null) - return; - this.myModelFormat=IE.ModelFormat.IMAGE; - curForm.ExportModel(this.myModelFormat); - } - - private void HelpAbout_Click(object sender, System.EventArgs e) - { - AboutDialog myDlg = new AboutDialog(); - myDlg.ShowDialog(this); - } - - private void ViewToolbar_Click(object sender, System.EventArgs e) - { - - if (this.ViewToolbar.Checked) - { - if (this.MdiChildren.Length > 0) - { - this.New.Visible=false; - this.About.Visible=false; - } - else - this.toolBarTool.Hide(); - this.ViewToolbar.Checked=false; - } - else - { - if (this.MdiChildren.Length > 0) - { - this.New.Visible=true; - this.About.Visible=true; - } - else - this.toolBarTool.Show(); - this.ViewToolbar.Checked=true; - } - - } - - private void ViewStatusBar_Click(object sender, System.EventArgs e) - { - if (this.ViewStatusBar.Checked) - { - this.myStatusBar.Hide(); - this.ViewStatusBar.Checked=false; - } - else - { - this.myStatusBar.Show(); - this.ViewStatusBar.Checked=true; - } - } - - public void OnNewFile() - { - Form2 newForm = new Form2(); - newForm.MdiParent=this; - IE.Form1.myNbOfChildren=IE.Form1.myNbOfChildren+1; - string str = System.String.Format(newForm.Text+" {0}:{1}", IE.Form1.myNbOfChildren, 1); - newForm.Text=str;; - newForm.Show(); - newForm.InitView(); - newForm.InitV3D(); - this.FileExport.Visible=true; - this.FileImport.Visible=true; - this.Window.Visible=true; - this.wireframe.Visible=true; - this.shading.Visible=true; - this.color.Visible=true; - this.material.Visible=true; - this.transparency.Visible=true; - this.delete.Visible=true; - this.Cursor=System.Windows.Forms.Cursors.Default; - this.toolBarView.Visible=true; - } - - private void FileImport_Popup(object sender, System.EventArgs e) - { - IE.Form2 curForm = (IE.Form2) this.ActiveMdiChild; - if (curForm==null) - return; - if ( curForm.View.IsObjectSelected()) - { - this.ExportBRep.Enabled=true; - this.ExportIges.Enabled=true; - this.ExportStep.Enabled=true; - this.ExportVrml.Enabled=true; - this.ExportStl.Enabled=true; - } - - } - - private void menuItem1_Click(object sender, System.EventArgs e) - { - this.Close(); - } - - private void File_Popup(object sender, System.EventArgs e) - { - if (this.MdiChildren.Length > 0 ) - this.FileClose.Enabled=true; - else - { - this.FileClose.Enabled=false; - this.FileExport.Visible=false; - this.FileImport.Visible=false; - } - } - - private void menuItem4_Click(object sender, System.EventArgs e) - { - IE.Form2 curForm = (IE.Form2) this.ActiveMdiChild; - IE.Form2 newView = new Form2(); - newView.MdiParent=this; - newView.Show(); - newView.InitView(); - newView.SetContext(curForm.View); - newView.View.CreateNewView(newView.Handle); - string title = curForm.Text; - System.Text.StringBuilder bld= new System.Text.StringBuilder(title); - char c = bld[title.Length-1]; - string s=c.ToString(); - int NbOfView = newView.View.CharToInt(s); - NbOfView++; - bld.Remove(title.Length-1, 1); - bld.Append(NbOfView); - newView.Text=bld.ToString(); - } - - private void WindowCascade_Click(object sender, System.EventArgs e) - { - this.LayoutMdi(System.Windows.Forms.MdiLayout.Cascade); - } - - private void WindowTile_Click(object sender, System.EventArgs e) - { - this.LayoutMdi(System.Windows.Forms.MdiLayout.TileVertical); - } - - public void SelectionChanged() - { - if (this.MdiChildren.Length == 0 ) - return; - IE.Form2 curForm = (IE.Form2) this.ActiveMdiChild; - if ( curForm == null ) - return; - switch (curForm.View.DisplayMode()) - { - case -1: - this.shading.Enabled=false; - this.wireframe.Enabled=false; - break; - case 0: - this.wireframe.Enabled=false; - this.shading.Enabled=true; - this.transparency.Enabled=false; - break; - case 1: - this.wireframe.Enabled=true; - this.shading.Enabled=false; - this.transparency.Enabled=true; - break; - case 10: - this.wireframe.Enabled=true; - this.shading.Enabled=true; - this.transparency.Enabled=true; - break; - default: - break; - } - bool IsSelected = curForm.View.IsObjectSelected(); - if (IsSelected) - { - this.color.Enabled=true; - this.material.Enabled=true; - this.delete.Enabled=true; - } - else - { - this.color.Enabled=false; - this.material.Enabled=false; - this.transparency.Enabled=false; - this.delete.Enabled=false; - } - if (curForm.DegenerateMode) - { - this.HlrOff.Pushed=false; - this.HlrOn.Pushed=true; - } - else - { - this.HlrOff.Pushed=true; - this.HlrOn.Pushed=false; - } - if (curForm.Mode == IE.CurrentAction3d.CurAction3d_WindowZooming) - this.ZoomWin.Pushed=false; - - } - - public StatusBar StatusBar - { - get - { - return this.myStatusBar; - } - } - - public void OnFileClose() - { - if ( this.MdiChildren.Length <= 1) - { - this.FileClose.Enabled=false; - this.Window.Visible=false; - this.wireframe.Visible=false; - this.shading.Visible=false; - this.color.Visible=false; - this.material.Visible=false; - this.transparency.Visible=false; - this.delete.Visible=false; - this.toolBarView.Visible=false; - } - } - - private void toolBarView_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e) - { - IE.Form2 curForm = (IE.Form2) this.ActiveMdiChild; - if ( curForm == null ) - return; - switch(toolBarView.Buttons.IndexOf(e.Button)) - { - case 0: - curForm.View.ZoomAllView(); - break; - case 1: - curForm.Mode=CurrentAction3d.CurAction3d_WindowZooming; - this.ZoomWin.Pushed=true; - break; - case 2: - curForm.Mode=CurrentAction3d.CurAction3d_DynamicZooming; - break; - case 3: - curForm.Mode=CurrentAction3d.CurAction3d_DynamicPanning; - break; - case 4: - curForm.Zoom=curForm.View.Scale(); - curForm.Mode=CurrentAction3d.CurAction3d_GlobalPanning; - break; - case 5: - curForm.View.FrontView(); - break; - case 6: - curForm.View.TopView(); - break; - case 7: - curForm.View.LeftView(); - break; - case 8: - curForm.View.BackView(); - break; - case 9: - curForm.View.RightView(); - break; - case 10: - curForm.View.BottomView(); - break; - case 11: - curForm.View.AxoView(); - break; - case 12: - curForm.Mode=CurrentAction3d.CurAction3d_DynamicRotation; - break; - case 13: - curForm.View.Reset(); - break; - case 14: - curForm.View.SetDegenerateModeOn(); - curForm.DegenerateMode=true; - this.HlrOff.Pushed=false; - this.HlrOn.Pushed=true; - break; - case 15: - curForm.View.SetDegenerateModeOff(); - curForm.DegenerateMode=false; - this.HlrOn.Pushed=false; - this.HlrOff.Pushed=true; - break; - default: - break; - } - } - - private void Form1_Activated(object sender, System.EventArgs e) - { - if (this.toolBarView.Visible) - this.SelectionChanged(); - } - - private void toolBarView_MouseHover(object sender, System.EventArgs e) - { - this.myStatusBar.Text="View toolbar"; - } - - private void toolBarView_MouseLeave(object sender, System.EventArgs e) - { - this.myStatusBar.Text=""; - } - - } - -} \ No newline at end of file diff --git a/samples/CSharp/IE/Form2.cs b/samples/CSharp/IE/Form2.cs deleted file mode 100755 index 2019e8c7b7..0000000000 --- a/samples/CSharp/IE/Form2.cs +++ /dev/null @@ -1,942 +0,0 @@ -using System; -using System.Drawing; -using System.Collections; -using System.ComponentModel; -using System.Windows.Forms; - - -namespace IE -{ - public enum CurrentAction3d - { - CurAction3d_Nothing, - CurAction3d_DynamicZooming, - CurAction3d_WindowZooming, - CurAction3d_DynamicPanning, - CurAction3d_GlobalPanning, - CurAction3d_DynamicRotation - } - public enum CurrentPressedKey - { - CurPressedKey_Nothing, - CurPressedKey_Ctrl, - CurPressedKey_Shift - } - public enum ModelFormat - { - BREP, - CSFDB, - STEP, - IGES, - VRML, - STL, - IMAGE - } - /// - /// Summary description for Form2. - /// - public class Form2 : System.Windows.Forms.Form - { - private System.ComponentModel.IContainer components; - - public Form2() - { - // - // Required for Windows Form Designer support - // - InitializeComponent(); - - // - // TODO: Add any constructor code after InitializeComponent call - // - myView = new shell(); - myCurrentMode=CurrentAction3d.CurAction3d_Nothing; - myCurrentPressedKey=CurrentPressedKey.CurPressedKey_Nothing; - myDegenerateModeIsOn=true; - IsRectVisible=false; - } - - /// - /// Clean up any resources being used. - /// - protected override void Dispose( bool disposing ) - { - if( disposing ) - { - if(components != null) - { - components.Dispose(); - } - } - base.Dispose( disposing ); - } - - #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form2)); - this.imageList1 = new System.Windows.Forms.ImageList(this.components); - this.myPopup = new System.Windows.Forms.ContextMenu(); - this.menuItem1 = new System.Windows.Forms.MenuItem(); - this.myPopupObject = new System.Windows.Forms.ContextMenu(); - this.ContextWireframe = new System.Windows.Forms.MenuItem(); - this.ContextShading = new System.Windows.Forms.MenuItem(); - this.ContextColor = new System.Windows.Forms.MenuItem(); - this.ContextMaterial = new System.Windows.Forms.MenuItem(); - this.ContMatBrass = new System.Windows.Forms.MenuItem(); - this.ContMenBronze = new System.Windows.Forms.MenuItem(); - this.ContMenCopper = new System.Windows.Forms.MenuItem(); - this.ContMenGold = new System.Windows.Forms.MenuItem(); - this.ContMenPewt = new System.Windows.Forms.MenuItem(); - this.ContMenPlaster = new System.Windows.Forms.MenuItem(); - this.ContMenPlastic = new System.Windows.Forms.MenuItem(); - this.ContMenSilver = new System.Windows.Forms.MenuItem(); - this.ContMenTranc = new System.Windows.Forms.MenuItem(); - this.ContMenDelete = new System.Windows.Forms.MenuItem(); - // - // imageList1 - // - this.imageList1.ImageSize = new System.Drawing.Size(16, 16); - this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream"))); - this.imageList1.TransparentColor = System.Drawing.Color.Transparent; - // - // myPopup - // - this.myPopup.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { - this.menuItem1}); - // - // menuItem1 - // - this.menuItem1.Index = 0; - this.menuItem1.Text = "Change &Background"; - this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click); - // - // myPopupObject - // - this.myPopupObject.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { - this.ContextWireframe, - this.ContextShading, - this.ContextColor, - this.ContextMaterial, - this.ContMenTranc, - this.ContMenDelete}); - this.myPopupObject.Popup += new System.EventHandler(this.myPopupObject_Popup); - // - // ContextWireframe - // - this.ContextWireframe.Index = 0; - this.ContextWireframe.Text = "Wireframe"; - this.ContextWireframe.Click += new System.EventHandler(this.ContextWireframe_Click); - // - // ContextShading - // - this.ContextShading.Index = 1; - this.ContextShading.Text = "Shading"; - this.ContextShading.Click += new System.EventHandler(this.ContextShading_Click); - // - // ContextColor - // - this.ContextColor.Index = 2; - this.ContextColor.Text = "Color"; - this.ContextColor.Click += new System.EventHandler(this.ContextColor_Click); - // - // ContextMaterial - // - this.ContextMaterial.Index = 3; - this.ContextMaterial.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { - this.ContMatBrass, - this.ContMenBronze, - this.ContMenCopper, - this.ContMenGold, - this.ContMenPewt, - this.ContMenPlaster, - this.ContMenPlastic, - this.ContMenSilver}); - this.ContextMaterial.Text = "Material"; - // - // ContMatBrass - // - this.ContMatBrass.Index = 0; - this.ContMatBrass.Text = "&Brass"; - this.ContMatBrass.Click += new System.EventHandler(this.ContMatBrass_Click); - // - // ContMenBronze - // - this.ContMenBronze.Index = 1; - this.ContMenBronze.Text = "&Bronze"; - this.ContMenBronze.Click += new System.EventHandler(this.ContMenBronze_Click); - // - // ContMenCopper - // - this.ContMenCopper.Index = 2; - this.ContMenCopper.Text = "&Copper"; - this.ContMenCopper.Click += new System.EventHandler(this.ContMenCopper_Click); - // - // ContMenGold - // - this.ContMenGold.Index = 3; - this.ContMenGold.Text = "&Gold"; - this.ContMenGold.Click += new System.EventHandler(this.ContMenGold_Click); - // - // ContMenPewt - // - this.ContMenPewt.Index = 4; - this.ContMenPewt.Text = "&Pewter"; - this.ContMenPewt.Click += new System.EventHandler(this.ContMenPewt_Click); - // - // ContMenPlaster - // - this.ContMenPlaster.Index = 5; - this.ContMenPlaster.Text = "&Plaster"; - this.ContMenPlaster.Click += new System.EventHandler(this.ContMenPlaster_Click); - // - // ContMenPlastic - // - this.ContMenPlastic.Index = 6; - this.ContMenPlastic.Text = "&Plastic"; - this.ContMenPlastic.Click += new System.EventHandler(this.ContMenPlastic_Click); - // - // ContMenSilver - // - this.ContMenSilver.Index = 7; - this.ContMenSilver.Text = "&Silver"; - this.ContMenSilver.Click += new System.EventHandler(this.ContMenSilver_Click); - // - // ContMenTranc - // - this.ContMenTranc.Index = 4; - this.ContMenTranc.Text = "&Trancparency"; - this.ContMenTranc.Click += new System.EventHandler(this.ContMenTranc_Click); - // - // ContMenDelete - // - this.ContMenDelete.Index = 5; - this.ContMenDelete.Text = "&Delete"; - this.ContMenDelete.Click += new System.EventHandler(this.ContMenDelete_Click); - // - // Form2 - // - this.AccessibleRole = System.Windows.Forms.AccessibleRole.Window; - this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); - this.ClientSize = new System.Drawing.Size(320, 261); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.Name = "Form2"; - this.Text = "Document"; - this.WindowState = System.Windows.Forms.FormWindowState.Maximized; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form2_KeyDown); - this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form2_MouseDown); - this.SizeChanged += new System.EventHandler(this.Form2_SizeChanged); - this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Form2_MouseUp); - this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.Form2_KeyUp); - this.Closed += new System.EventHandler(this.Form2_Closed); - this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form2_Paint); - this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form2_MouseMove); - - } - #endregion - - private System.Windows.Forms.ImageList imageList1; - private System.Windows.Forms.ContextMenu myPopup; - private System.Windows.Forms.ContextMenu myPopupObject; - private System.Windows.Forms.MenuItem ContextWireframe; - private System.Windows.Forms.MenuItem ContextShading; - private System.Windows.Forms.MenuItem ContextColor; - private System.Windows.Forms.MenuItem ContextMaterial; - private System.Windows.Forms.MenuItem ContMatBrass; - private System.Windows.Forms.MenuItem ContMenBronze; - private System.Windows.Forms.MenuItem ContMenCopper; - private System.Windows.Forms.MenuItem ContMenGold; - private System.Windows.Forms.MenuItem ContMenPewt; - private System.Windows.Forms.MenuItem ContMenPlaster; - private System.Windows.Forms.MenuItem ContMenPlastic; - private System.Windows.Forms.MenuItem ContMenSilver; - private System.Windows.Forms.MenuItem ContMenTranc; - private System.Windows.Forms.MenuItem ContMenDelete; - private System.Windows.Forms.MenuItem menuItem1; - - private shell myView; - - public void InitV3D() - { - - if( !myView.InitViewer(this.Handle) ) - MessageBox.Show("Fatal Error during the graphic initialisation", "Error!", - MessageBoxButtons.OK, MessageBoxIcon.Error); - } - - public bool ImportBRep(System.String filename) - { - return myView.ImportBrep(filename); - } - - private void Form2_SizeChanged(object sender, System.EventArgs e) - { - myView.UpdateView(); - } - - private void Form2_Paint(object sender, System.Windows.Forms.PaintEventArgs e) - { - myView.RedrawView(); - myView.UpdateView(); - } - - protected CurrentAction3d myCurrentMode; - protected CurrentPressedKey myCurrentPressedKey; - protected float myCurZoom;// ~ Quantity_Factor - protected bool myDegenerateModeIsOn; - protected int myXmin; - protected int myYmin; - protected int myXmax; - protected int myYmax; - protected int theButtonDownX; - protected int theButtonDownY; - // for erasing of rectangle - protected int theRectDownX; - protected int theRectDownY; - protected bool IsRectVisible; - - private void Form2_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) - { - switch (e.Button) - { - case MouseButtons.Left: - myXmin=e.X; myYmin=e.Y; - myXmax=e.X; myYmax=e.Y; - if (myCurrentPressedKey==CurrentPressedKey.CurPressedKey_Ctrl) - // start the dinamic zooming.... - myCurrentMode=CurrentAction3d.CurAction3d_DynamicZooming; - else - { - switch(myCurrentMode) - { - case CurrentAction3d.CurAction3d_Nothing: - if (myCurrentPressedKey==CurrentPressedKey.CurPressedKey_Shift) - MultiDragEvent(myXmax, myYmax, -1); - else - DragEvent(myXmax, myYmax, -1); - break; - case CurrentAction3d.CurAction3d_DynamicRotation: - if (!myDegenerateModeIsOn) - myView.SetDegenerateModeOn(); - //start the rotation - myView.StartRotation(e.X, e.Y); - break; - case IE.CurrentAction3d.CurAction3d_WindowZooming: - this.Cursor=System.Windows.Forms.Cursors.Hand; - break; - default: - break; - } - } - break; - case MouseButtons.Right: - //MessageBox.Show("right mouse button is down"); - if (myCurrentPressedKey==CurrentPressedKey.CurPressedKey_Ctrl) - { - if (!myDegenerateModeIsOn) - myView.SetDegenerateModeOn(); - myView.StartRotation(e.X, e.Y); - } - else - Popup(e.X, e.Y); - break; - default: - break; - } - - } - - private void Form2_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) - { - if (e.Shift) - myCurrentPressedKey=CurrentPressedKey.CurPressedKey_Shift; - else if (e.Control) - myCurrentPressedKey=CurrentPressedKey.CurPressedKey_Ctrl; - } - - private void Form2_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e) - { - myCurrentPressedKey=CurrentPressedKey.CurPressedKey_Nothing; - } - - protected void MultiDragEvent(int x, int y, int theState) - { - if ( theState==-1) - { - theButtonDownX=x; - theButtonDownY=y; - } - else if (theState==1) - myView.ShiftSelect(Math.Min(theButtonDownX,x), Math.Min(theButtonDownY,y), - Math.Max(theButtonDownX, x), Math.Max(theButtonDownY, y)); - } - - protected void DragEvent(int x, int y, int theState) - { - if (theState==-1) //mouse is down - { - theButtonDownX=x; - theButtonDownY=y; - } - else if (theState==1) //mouse is up - { - myView.Select(Math.Min(theButtonDownX, x), Math.Min(theButtonDownY,y), - Math.Max(theButtonDownX, x), Math.Max(theButtonDownY,y)); - } - } - - protected void Popup(int x, int y) - { - System.Drawing.Point p = new Point(x,y); - if (this.myView.IsObjectSelected()) - this.myPopupObject.Show(this, p); - else - this.myPopup.Show(this, p); - } - - private void Form2_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) - { - switch(e.Button) - { - case MouseButtons.Left: - if (myCurrentPressedKey==CurrentPressedKey.CurPressedKey_Ctrl) - return; - switch(myCurrentMode) - { - case CurrentAction3d.CurAction3d_Nothing: - if( e.X==myXmin && e.Y==myYmin) - { - myXmax=e.X; myYmax=e.Y; - if (myCurrentPressedKey==CurrentPressedKey.CurPressedKey_Shift) - MultiInputEvent(myXmax, myYmax); - else - InputEvent(myXmax, myYmax); - } - else - { - myXmax=e.X; myYmax=e.Y; - DrawRectangle(false); - if (myCurrentPressedKey==CurrentPressedKey.CurPressedKey_Shift) - MultiDragEvent(myXmax, myYmax, 1); - else - DragEvent(myXmax, myYmax, 1); - } - break; - case CurrentAction3d.CurAction3d_DynamicZooming: - myCurrentMode=CurrentAction3d.CurAction3d_Nothing; - break; - case CurrentAction3d.CurAction3d_WindowZooming: - myXmax=e.X; myYmax=e.Y; - DrawRectangle(false); - int ValZWMin = 1; - if (Math.Abs(myXmax-myXmin)>ValZWMin && Math.Abs(myXmax-myYmax)>ValZWMin) - myView.WindowFitAll(myXmin, myYmin, myXmax, myYmax); - this.Cursor=System.Windows.Forms.Cursors.Default; - IE.Form1 f = (IE.Form1)this.ParentForm; - f.SelectionChanged(); - myCurrentMode=CurrentAction3d.CurAction3d_Nothing; - break; - case CurrentAction3d.CurAction3d_DynamicPanning: - myCurrentMode=CurrentAction3d.CurAction3d_Nothing; - break; - case CurrentAction3d.CurAction3d_GlobalPanning: - myView.Place(e.X, e.Y, myCurZoom); - myCurrentMode=CurrentAction3d.CurAction3d_Nothing; - break; - case CurrentAction3d.CurAction3d_DynamicRotation: - myCurrentMode=CurrentAction3d.CurAction3d_Nothing; - if (!myDegenerateModeIsOn) - { - myView.SetDegenerateModeOff(); - myDegenerateModeIsOn=false; - } - else - { - myView.SetDegenerateModeOn(); - myDegenerateModeIsOn=true; - } - break; - default: - break; - - } - break; - case MouseButtons.Right: - if (!myDegenerateModeIsOn) - { - myView.SetDegenerateModeOff(); - myDegenerateModeIsOn=false; - } - else - { - myView.SetDegenerateModeOn(); - myDegenerateModeIsOn=true; - } - break; - default: - break; - } - - IE.Form1 parent = (IE.Form1)this.ParentForm; - parent.SelectionChanged(); - } - - protected void MultiInputEvent(int x, int y) - { - myView.ShiftSelect(); - } - - protected void InputEvent(int x, int y) - { - myView.Select(); - } - - private void DrawRectangle(bool draw) - { - Graphics gr = Graphics.FromHwnd(this.Handle); - System.Drawing.Pen p = null; - if (this.IsRectVisible ||(!draw))//erase the rect - { - int r=myView.GetBGColR(); - int g=myView.GetBGColG(); - int b=myView.GetBGColB(); - p = new Pen(System.Drawing.Color.FromArgb( r,g, b)); - this.IsRectVisible=false; - this.myView.UpdateView(); - } - else if (draw) - { - p = new Pen(System.Drawing.Color.White); - this.IsRectVisible=true; - } - if ( p == null ) - return; - int x=Math.Min(this.myXmin, this.myXmax); - int y=Math.Min(this.myYmin, this.myYmax); - gr.DrawRectangle(p, x, y, Math.Abs(myXmax-myXmin), Math.Abs(myYmax - myYmin)); - this.theRectDownX=Math.Max(this.myXmin, this.myXmax); - this.theRectDownY=Math.Max(this.myYmin, this.myYmax); - } - - private void Form2_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) - { - if (e.Button == MouseButtons.Left) //left button is pressed - { - if (myCurrentPressedKey==CurrentPressedKey.CurPressedKey_Ctrl) - { - myView.Zoom(myXmax, myYmax, e.X, e.Y); - myXmax=e.X; myYmax=e.Y; - } - else - { - switch (myCurrentMode) - { - case CurrentAction3d.CurAction3d_Nothing: - DrawRectangle(false); - myXmax=e.X; myYmax=e.Y; - DrawRectangle(true); - break; - case CurrentAction3d.CurAction3d_DynamicZooming: - myView.Zoom(myXmax, myYmax, e.X, e.Y); - myXmax=e.X; myYmax=e.Y; - break; - case CurrentAction3d.CurAction3d_WindowZooming: - DrawRectangle(false); - myXmax=e.X; myYmax=e.Y; - DrawRectangle(true);//add brush here - break; - case CurrentAction3d.CurAction3d_DynamicPanning: - myView.Pan(e.X-myXmax, myYmax - e.Y); - myXmax=e.X; myYmax=e.Y; - break; - case CurrentAction3d.CurAction3d_GlobalPanning: - break; - case CurrentAction3d.CurAction3d_DynamicRotation: - myView.Rotation(e.X, e.Y); - myView.RedrawView(); - break; - default: - break; - } - } - } // e.Button == MouseButtons.Left - else if (e.Button==MouseButtons.Middle) - { - if (myCurrentPressedKey==CurrentPressedKey.CurPressedKey_Ctrl) - { - myView.Pan(e.X-myXmax, myYmax - e.Y); - myXmax=e.X; myYmax=e.Y; - } - }//e.Button=MouseButtons.Middle - else if (e.Button==MouseButtons.Right) //right button is pressed - { - if (myCurrentPressedKey == CurrentPressedKey.CurPressedKey_Ctrl) - myView.Rotation(e.X, e.Y); - } - else // no buttons are pressed - { - myXmax=e.X; myYmax=e.Y; - if (myCurrentPressedKey==CurrentPressedKey.CurPressedKey_Shift) - MultiMoveEvent(e.X, e.Y); - else - MoveEvent(e.X, e.Y); - } - - - } - - protected void MultiMoveEvent(int x, int y) - { - myView.MoveTo(x, y); - } - - protected void MoveEvent(int x, int y) - { - myView.MoveTo(x, y); - } - - public void SetDisplayMode(int aMode) - { - myView.SetDisplayMode(aMode); - } - - public void ChangeColor(bool IsObjectColor) - { - int r, g, b; - if (IsObjectColor) - { - r=myView.GetObjColR(); - g=myView.GetObjColG(); - b=myView.GetObjColB(); - } - else - { - r=myView.GetBGColR(); - g=myView.GetBGColG(); - b=myView.GetBGColB(); - } - System.Windows.Forms.ColorDialog ColDlg = new ColorDialog(); - ColDlg.Color=System.Drawing.Color.FromArgb(r, g, b); - if (ColDlg.ShowDialog() == DialogResult.OK) - { - Color c = ColDlg.Color; - r=c.R; - g=c.G; - b=c.B; - if (IsObjectColor) - myView.SetColor(r, g, b); - else - myView.SetBackgroundColor(r, g, b); - } - this.myView.UpdateCurrentViewer(); - - } - - public void DeleteObjects() - { - myView.EraseObjects(); - } - public void ImportModel(IE.ModelFormat format) - { - int theformat=10; - System.Windows.Forms.OpenFileDialog openDialog = new OpenFileDialog(); - - string DataDir=((Environment.GetEnvironmentVariable("CASROOT")) + "\\..\\data"); - - string filter=""; - - switch (format) - { - case ModelFormat.BREP: - openDialog.InitialDirectory = (DataDir + "\\occ"); - theformat=0; - filter= "BREP Files (*.brep *.rle)|*.brep; *.rle"; - break; - case ModelFormat.CSFDB: - theformat=1; - filter= "CSFDB Files (*.csfdb)|*.csfdb"; - break; - case IE.ModelFormat.STEP: - openDialog.InitialDirectory = (DataDir + "\\step"); - theformat=2; - filter="STEP Files (*.stp *.step)|*.stp; *.step"; - break; - case IE.ModelFormat.IGES: - openDialog.InitialDirectory = (DataDir + "\\iges"); - theformat=3; - filter="IGES Files (*.igs *.iges)|*.igs; *.iges"; - break; - default: - break; - } - openDialog.Filter = filter+"|All files (*.*)|*.*" ; - if(openDialog.ShowDialog() == DialogResult.OK) - { - string filename = openDialog.FileName; - if ( filename=="") - return; - this.Cursor=System.Windows.Forms.Cursors.WaitCursor; - if (!myView.TranslateModel(filename, theformat, true)) - MessageBox.Show("Cann't read this file", "Error!", - MessageBoxButtons.OK, MessageBoxIcon.Warning); - this.Cursor=System.Windows.Forms.Cursors.Default; - } - this.myView.ZoomAllView(); - } - - public void ExportModel(ModelFormat format) - { - int theformat=10; - System.Windows.Forms.SaveFileDialog saveDialog = new SaveFileDialog(); - string DataDir=((Environment.GetEnvironmentVariable("CASROOT")) + "\\..\\data"); - string filter=""; - switch (format) - { - case IE.ModelFormat.BREP: - saveDialog.InitialDirectory = (DataDir + "\\occ"); - theformat=0; - filter= "BREP Files (*.brep *.rle)|*.brep; *.rle"; - break; - case IE.ModelFormat.CSFDB: - theformat=1; - filter= "CSFDB Files (*.csfdb)|*.csfdb"; - break; - case IE.ModelFormat.STEP: - saveDialog.InitialDirectory = (DataDir + "\\step"); - theformat=2; - filter="STEP Files (*.stp *.step)|*.step; *.stp"; - break; - case IE.ModelFormat.IGES: - saveDialog.InitialDirectory = (DataDir + "\\iges"); - theformat=3; - filter="IGES Files (*.igs *.iges)| *.iges; *.igs"; - break; - case IE.ModelFormat.VRML: - saveDialog.InitialDirectory = (DataDir + "\\vrml"); - theformat=4; - filter="VRML Files (*.vrml)|*.vrml"; - break; - case IE.ModelFormat.STL: - saveDialog.InitialDirectory = (DataDir + "\\stl"); - theformat=5; - filter="STL Files (*.stl)|*.stl"; - break; - case IE.ModelFormat.IMAGE: - saveDialog.InitialDirectory = (DataDir + "\\images"); - theformat=6; - filter="Images Files (*.bmp *.gif *.xwd)| *.bmp; *.gif; *.xwd"; - break; - default: - break; - } - saveDialog.Filter = filter; - if(saveDialog.ShowDialog() == DialogResult.OK) - { - string filename = saveDialog.FileName; - if ( filename=="") - return; - this.Cursor=System.Windows.Forms.Cursors.WaitCursor; - if (!myView.TranslateModel(filename, theformat, false)) - MessageBox.Show("Cann't write this file", "Error!", - MessageBoxButtons.OK, MessageBoxIcon.Warning); - this.Cursor=System.Windows.Forms.Cursors.Default; - } - } - - private void ContextColor_Click(object sender, System.EventArgs e) - { - this.ChangeColor(true); - } - - private void menuItem1_Click(object sender, System.EventArgs e) - { - this.myView.UpdateCurrentViewer(); - this.ChangeColor(false); - } - - private void ContextWireframe_Click(object sender, System.EventArgs e) - { - this.SetDisplayMode(0); - this.myView.UpdateCurrentViewer(); - IE.Form1 parent=(IE.Form1)this.ParentForm; - parent.SelectionChanged(); - } - - private void ContextShading_Click(object sender, System.EventArgs e) - { - this.SetDisplayMode(1); - this.myView.UpdateCurrentViewer(); - IE.Form1 parent=(IE.Form1)this.ParentForm; - parent.SelectionChanged(); - } - - private void ContMenTranc_Click(object sender, System.EventArgs e) - { - IE.TransparencyDialog dlg = new TransparencyDialog(); - dlg.View=this.myView; - dlg.ShowDialog(this); - } - - private void ContMenDelete_Click(object sender, System.EventArgs e) - { - this.DeleteObjects(); - } - - private void ContMatBrass_Click(object sender, System.EventArgs e) - { - this.myView.UpdateCurrentViewer(); - this.myView.SetMaterial(0); - } - - private void ContMenBronze_Click(object sender, System.EventArgs e) - { - this.myView.UpdateCurrentViewer(); - this.myView.SetMaterial(1); - } - - private void ContMenCopper_Click(object sender, System.EventArgs e) - { - this.myView.UpdateCurrentViewer(); - this.myView.SetMaterial(2); - } - - private void ContMenGold_Click(object sender, System.EventArgs e) - { - this.myView.UpdateCurrentViewer(); - this.myView.SetMaterial(3); - } - - private void ContMenPewt_Click(object sender, System.EventArgs e) - { - this.myView.UpdateCurrentViewer(); - this.myView.SetMaterial(4); - } - - private void ContMenPlaster_Click(object sender, System.EventArgs e) - { - this.myView.UpdateCurrentViewer(); - this.myView.SetMaterial(5); - } - - private void ContMenPlastic_Click(object sender, System.EventArgs e) - { - this.myView.UpdateCurrentViewer(); - this.myView.SetMaterial(6); - } - - private void ContMenSilver_Click(object sender, System.EventArgs e) - { - this.myView.UpdateCurrentViewer(); - this.myView.SetMaterial(7); - } - - private void toolBar1_MouseHover(object sender, System.EventArgs e) - { - IE.Form1 parent=(IE.Form1)this.ParentForm; - parent.StatusBar.Text="View toolbar"; - - } - - private void toolBar1_MouseLeave(object sender, System.EventArgs e) - { - IE.Form1 parent=(IE.Form1)this.ParentForm; - parent.StatusBar.Text=""; - } - - private void myPopupObject_Popup(object sender, System.EventArgs e) - { - int mode=this.myView.DisplayMode(); - switch (mode) - { - case -1: - break; - case 0: - this.ContextWireframe.Enabled=false; - this.ContextShading.Enabled=true; - this.ContMenTranc.Enabled=false; - break; - case 1: - this.ContextShading.Enabled=false; - this.ContextWireframe.Enabled=true; - this.ContMenTranc.Enabled=true; - break; - case 10: - this.ContextShading.Enabled=true;; - this.ContextWireframe.Enabled=true; - this.ContMenTranc.Enabled=true; - break; - default: - break; - - } - } - - public shell View - { - get - { - return this.myView; - } - set - { - this.myView=value; - } - } - - public void InitView() - { - this.myView.InitOCCViewer(); - } - - public void SetContext(shell View) - { - this.myView.SetAISContext(View); - } - - private void Form2_Closed(object sender, System.EventArgs e) - { - IE.Form1 parent = (IE.Form1) this.ParentForm; - parent.OnFileClose(); - } - - public CurrentAction3d Mode - { - get - { - return this.myCurrentMode; - } - set - { - this.myCurrentMode=value; - } - } - - public float Zoom - { - set - { - this.myCurZoom=value; - } - } - - public bool DegenerateMode - { - get - { - return this.myDegenerateModeIsOn; - } - set - { - this.myDegenerateModeIsOn=value; - } - } - - } - -} \ No newline at end of file diff --git a/samples/CSharp/IE/IE.sln b/samples/CSharp/IE/IE.sln deleted file mode 100755 index 120ac23743..0000000000 --- a/samples/CSharp/IE/IE.sln +++ /dev/null @@ -1,56 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IE", "IE.csproj", "{B9914BB3-B886-4B41-B48D-350EBEBEFD1F}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OCC", "..\OCC\OCC.vcproj", "{DCB139CF-2190-412E-B72F-8B080CC01422}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shell", "..\shell\shell.vcproj", "{969912D9-78E7-4AB8-B4FF-6B52B4F03991}" - ProjectSection(ProjectDependencies) = postProject - {DCB139CF-2190-412E-B72F-8B080CC01422} = {DCB139CF-2190-412E-B72F-8B080CC01422} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|Mixed Platforms = Debug|Mixed Platforms - Debug|Win32 = Debug|Win32 - Release|Any CPU = Release|Any CPU - Release|Mixed Platforms = Release|Mixed Platforms - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Debug|Win32.ActiveCfg = Debug|Any CPU - {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Release|Any CPU.Build.0 = Release|Any CPU - {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Release|Win32.ActiveCfg = Release|Any CPU - {DCB139CF-2190-412E-B72F-8B080CC01422}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {DCB139CF-2190-412E-B72F-8B080CC01422}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {DCB139CF-2190-412E-B72F-8B080CC01422}.Debug|Mixed Platforms.Build.0 = Debug|Win32 - {DCB139CF-2190-412E-B72F-8B080CC01422}.Debug|Win32.ActiveCfg = Debug|Win32 - {DCB139CF-2190-412E-B72F-8B080CC01422}.Debug|Win32.Build.0 = Debug|Win32 - {DCB139CF-2190-412E-B72F-8B080CC01422}.Release|Any CPU.ActiveCfg = Release|Win32 - {DCB139CF-2190-412E-B72F-8B080CC01422}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {DCB139CF-2190-412E-B72F-8B080CC01422}.Release|Mixed Platforms.Build.0 = Release|Win32 - {DCB139CF-2190-412E-B72F-8B080CC01422}.Release|Win32.ActiveCfg = Release|Win32 - {DCB139CF-2190-412E-B72F-8B080CC01422}.Release|Win32.Build.0 = Release|Win32 - {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Debug|Mixed Platforms.Build.0 = Debug|Win32 - {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Debug|Win32.ActiveCfg = Debug|Win32 - {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Debug|Win32.Build.0 = Debug|Win32 - {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Release|Any CPU.ActiveCfg = Release|Win32 - {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Release|Mixed Platforms.Build.0 = Release|Win32 - {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Release|Win32.ActiveCfg = Release|Win32 - {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/samples/CSharp/IE/MaterialDialog.cs b/samples/CSharp/IE/MaterialDialog.cs deleted file mode 100755 index 159eb81887..0000000000 --- a/samples/CSharp/IE/MaterialDialog.cs +++ /dev/null @@ -1,248 +0,0 @@ -using System; -using System.Drawing; -using System.Collections; -using System.ComponentModel; -using System.Windows.Forms; - -namespace IE -{ - /// - /// Summary description for MaterialDialog. - /// - public class MaterialDialog : System.Windows.Forms.Form - { - /// - /// Required designer variable. - /// - private System.ComponentModel.Container components = null; - - public MaterialDialog() - { - // - // Required for Windows Form Designer support - // - InitializeComponent(); - - // - // TODO: Add any constructor code after InitializeComponent call - // - this.myView=null; - } - - /// - /// Clean up any resources being used. - /// - protected override void Dispose( bool disposing ) - { - if( disposing ) - { - if(components != null) - { - components.Dispose(); - } - } - base.Dispose( disposing ); - } - - #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MaterialDialog)); - this.BTN_PLASTER = new System.Windows.Forms.Button(); - this.BTN_BRASS = new System.Windows.Forms.Button(); - this.BTN_BRONZE = new System.Windows.Forms.Button(); - this.BTN_COPPER = new System.Windows.Forms.Button(); - this.BTN_GOLD = new System.Windows.Forms.Button(); - this.BTN_PEWTER = new System.Windows.Forms.Button(); - this.BTN_PLASTIC = new System.Windows.Forms.Button(); - this.BTN_SILVER = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // BTN_PLASTER - // - this.BTN_PLASTER.Location = new System.Drawing.Point(16, 8); - this.BTN_PLASTER.Name = "BTN_PLASTER"; - this.BTN_PLASTER.Size = new System.Drawing.Size(80, 24); - this.BTN_PLASTER.TabIndex = 0; - this.BTN_PLASTER.Text = "Plaster"; - this.BTN_PLASTER.Click += new System.EventHandler(this.button1_Click); - // - // BTN_BRASS - // - this.BTN_BRASS.Location = new System.Drawing.Point(16, 40); - this.BTN_BRASS.Name = "BTN_BRASS"; - this.BTN_BRASS.Size = new System.Drawing.Size(80, 24); - this.BTN_BRASS.TabIndex = 1; - this.BTN_BRASS.Text = "Brass"; - this.BTN_BRASS.Click += new System.EventHandler(this.BTN_BRASS_Click); - // - // BTN_BRONZE - // - this.BTN_BRONZE.Location = new System.Drawing.Point(16, 72); - this.BTN_BRONZE.Name = "BTN_BRONZE"; - this.BTN_BRONZE.Size = new System.Drawing.Size(80, 24); - this.BTN_BRONZE.TabIndex = 2; - this.BTN_BRONZE.Text = "Bronze"; - this.BTN_BRONZE.Click += new System.EventHandler(this.BTN_BRONZE_Click); - // - // BTN_COPPER - // - this.BTN_COPPER.Location = new System.Drawing.Point(16, 104); - this.BTN_COPPER.Name = "BTN_COPPER"; - this.BTN_COPPER.Size = new System.Drawing.Size(80, 24); - this.BTN_COPPER.TabIndex = 3; - this.BTN_COPPER.Text = "Copper"; - this.BTN_COPPER.Click += new System.EventHandler(this.BTN_COPPER_Click); - // - // BTN_GOLD - // - this.BTN_GOLD.Location = new System.Drawing.Point(16, 136); - this.BTN_GOLD.Name = "BTN_GOLD"; - this.BTN_GOLD.Size = new System.Drawing.Size(80, 24); - this.BTN_GOLD.TabIndex = 4; - this.BTN_GOLD.Text = "Gold"; - this.BTN_GOLD.Click += new System.EventHandler(this.BTN_GOLD_Click); - // - // BTN_PEWTER - // - this.BTN_PEWTER.Location = new System.Drawing.Point(16, 168); - this.BTN_PEWTER.Name = "BTN_PEWTER"; - this.BTN_PEWTER.Size = new System.Drawing.Size(80, 24); - this.BTN_PEWTER.TabIndex = 5; - this.BTN_PEWTER.Text = "Pewter"; - this.BTN_PEWTER.Click += new System.EventHandler(this.BTN_PEWTER_Click); - // - // BTN_PLASTIC - // - this.BTN_PLASTIC.Location = new System.Drawing.Point(16, 200); - this.BTN_PLASTIC.Name = "BTN_PLASTIC"; - this.BTN_PLASTIC.Size = new System.Drawing.Size(80, 24); - this.BTN_PLASTIC.TabIndex = 6; - this.BTN_PLASTIC.Text = "Plastic"; - this.BTN_PLASTIC.Click += new System.EventHandler(this.BTN_PLASTIC_Click); - // - // BTN_SILVER - // - this.BTN_SILVER.Location = new System.Drawing.Point(16, 232); - this.BTN_SILVER.Name = "BTN_SILVER"; - this.BTN_SILVER.Size = new System.Drawing.Size(80, 24); - this.BTN_SILVER.TabIndex = 7; - this.BTN_SILVER.Text = "Silver"; - this.BTN_SILVER.Click += new System.EventHandler(this.BTN_SILVER_Click); - // - // MaterialDialog - // - this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); - this.ClientSize = new System.Drawing.Size(112, 273); - this.Controls.Add(this.BTN_SILVER); - this.Controls.Add(this.BTN_PLASTIC); - this.Controls.Add(this.BTN_PEWTER); - this.Controls.Add(this.BTN_GOLD); - this.Controls.Add(this.BTN_COPPER); - this.Controls.Add(this.BTN_BRONZE); - this.Controls.Add(this.BTN_BRASS); - this.Controls.Add(this.BTN_PLASTER); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "MaterialDialog"; - this.Text = "MaterialDialog"; - this.ResumeLayout(false); - - } - #endregion - - private System.Windows.Forms.Button BTN_PLASTER; - private System.Windows.Forms.Button BTN_BRASS; - private System.Windows.Forms.Button BTN_BRONZE; - private System.Windows.Forms.Button BTN_COPPER; - private System.Windows.Forms.Button BTN_GOLD; - private System.Windows.Forms.Button BTN_PEWTER; - private System.Windows.Forms.Button BTN_PLASTIC; - private System.Windows.Forms.Button BTN_SILVER; - - private int myMaterial; - private shell myView; - - private void button1_Click(object sender, System.EventArgs e) - { - this.myMaterial=5; - ChangeMaterial(); - } - - private void BTN_BRASS_Click(object sender, System.EventArgs e) - { - this.myMaterial=0; - ChangeMaterial(); - } - - private void BTN_BRONZE_Click(object sender, System.EventArgs e) - { - this.myMaterial=1; - ChangeMaterial(); - } - - private void BTN_COPPER_Click(object sender, System.EventArgs e) - { - this.myMaterial=2; - ChangeMaterial(); - } - - private void BTN_GOLD_Click(object sender, System.EventArgs e) - { - this.myMaterial=3; - ChangeMaterial(); - } - - private void BTN_PEWTER_Click(object sender, System.EventArgs e) - { - this.myMaterial=4; - ChangeMaterial(); - } - - private void BTN_PLASTIC_Click(object sender, System.EventArgs e) - { - this.myMaterial=6; - ChangeMaterial(); - } - - private void BTN_SILVER_Click(object sender, System.EventArgs e) - { - this.myMaterial=7; - ChangeMaterial(); - } - - public int Material - { - get - { - return this.myMaterial; - } - set - { - this.myMaterial=value; - } - } - - public void ChangeMaterial() - { - if (myView==null) - return; - myView.SetMaterial(this.myMaterial); - - } - - public shell View - { - set - { - this.myView=value; - } - } - - } -} diff --git a/samples/CSharp/IE/TransparencyDialog.cs b/samples/CSharp/IE/TransparencyDialog.cs deleted file mode 100755 index 013cf7ab8f..0000000000 --- a/samples/CSharp/IE/TransparencyDialog.cs +++ /dev/null @@ -1,108 +0,0 @@ -using System; -using System.Drawing; -using System.Collections; -using System.ComponentModel; -using System.Windows.Forms; - -namespace IE -{ - /// - /// Summary description for TransparencyDialog. - /// - public class TransparencyDialog : System.Windows.Forms.Form - { - private System.Windows.Forms.NumericUpDown MyTransparency; - /// - /// Required designer variable. - /// - private System.ComponentModel.Container components = null; - private shell myView; - - public TransparencyDialog() - { - // - // Required for Windows Form Designer support - // - InitializeComponent(); - - // - // TODO: Add any constructor code after InitializeComponent call - // - myView=null; - } - - /// - /// Clean up any resources being used. - /// - protected override void Dispose( bool disposing ) - { - if( disposing ) - { - if(components != null) - { - components.Dispose(); - } - } - base.Dispose( disposing ); - } - - #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(TransparencyDialog)); - this.MyTransparency = new System.Windows.Forms.NumericUpDown(); - ((System.ComponentModel.ISupportInitialize)(this.MyTransparency)).BeginInit(); - this.SuspendLayout(); - // - // MyTransparency - // - this.MyTransparency.Location = new System.Drawing.Point(16, 16); - this.MyTransparency.Maximum = new System.Decimal(new int[] { - 10, - 0, - 0, - 0}); - this.MyTransparency.Name = "MyTransparency"; - this.MyTransparency.Size = new System.Drawing.Size(96, 20); - this.MyTransparency.TabIndex = 0; - this.MyTransparency.ValueChanged += new System.EventHandler(this.MyTransparency_ValueChanged); - // - // TransparencyDialog - // - this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); - this.ClientSize = new System.Drawing.Size(128, 53); - this.Controls.Add(this.MyTransparency); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "TransparencyDialog"; - this.Text = "TransparencyDialog"; - ((System.ComponentModel.ISupportInitialize)(this.MyTransparency)).EndInit(); - this.ResumeLayout(false); - - } - #endregion - - private void MyTransparency_ValueChanged(object sender, System.EventArgs e) - { - if (this.myView==null) - return; - int transp = (int)this.MyTransparency.Value; - this.myView.SetTransparency(transp); - } - - public shell View - { - set - { - this.myView=value; - } - } - - } -} diff --git a/samples/CSharp/IE/app.config b/samples/CSharp/IE/app.config deleted file mode 100755 index 61eb0bc699..0000000000 --- a/samples/CSharp/IE/app.config +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/CSharp/IE/res/document.ico b/samples/CSharp/IE/res/document.ico deleted file mode 100755 index 2a1f1ae6ef..0000000000 Binary files a/samples/CSharp/IE/res/document.ico and /dev/null differ diff --git a/samples/CSharp/OCC/OCC.cpp b/samples/CSharp/OCC/OCC.cpp deleted file mode 100755 index 1dd08627ab..0000000000 --- a/samples/CSharp/OCC/OCC.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// OCC.cpp : Defines the entry point for the DLL application. -// -//__declspec(dllexport) - -#include "stdafx.h" -#include "OCCViewer.h" -#pragma unmanaged -BOOL APIENTRY DllMain( HANDLE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved - ) -{ - return TRUE; -} - diff --git a/samples/CSharp/OCC/OCC.vcproj b/samples/CSharp/OCC/OCC.vcproj deleted file mode 100755 index abc8c2c3b2..0000000000 --- a/samples/CSharp/OCC/OCC.vcproj +++ /dev/null @@ -1,247 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/CSharp/OCC/OCCViewer.cpp b/samples/CSharp/OCC/OCCViewer.cpp deleted file mode 100755 index 214695c880..0000000000 --- a/samples/CSharp/OCC/OCCViewer.cpp +++ /dev/null @@ -1,581 +0,0 @@ -#include "StdAfx.h" -#include ".\occviewer.h" - -#pragma warning( disable : 4800 ) -OCCViewer::OCCViewer(void) -{ - myGraphicDriver=NULL; - myViewer=NULL; - myView=NULL; - myAISContext=NULL; -} - -OCCViewer::~OCCViewer(void) -{ - myView->Remove(); -} - -bool OCCViewer::InitViewer(void* wnd) -{ - try - { - Handle(Aspect_DisplayConnection) aDisplayConnection; - myGraphicDriver = Graphic3d::InitGraphicDriver (aDisplayConnection); - } - catch (Standard_Failure) - { - return false; - } - - TCollection_ExtendedString a3DName("Visu3D"); - myViewer = new V3d_Viewer (myGraphicDriver, a3DName.ToExtString(),"", 1000.0, - V3d_XposYnegZpos, Quantity_NOC_GRAY30, - V3d_ZBUFFER,V3d_GOURAUD,V3d_WAIT, - Standard_True, Standard_False); - - myViewer->Init(); - myViewer->SetDefaultLights(); - myViewer->SetLightOn(); - myView = myViewer->CreateView(); - Handle(WNT_Window) aWNTWindow = new WNT_Window (reinterpret_cast (wnd)); - myView->SetWindow(aWNTWindow); - if (!aWNTWindow->IsMapped()) - aWNTWindow->Map(); - myAISContext = new AIS_InteractiveContext(myViewer); - myAISContext->UpdateCurrentViewer(); - myView->Redraw(); - myView->MustBeResized(); - return true; - -} - -bool OCCViewer::ImportBRep(char* filename) -{ - Standard_CString aFileName = (Standard_CString) filename; - TopoDS_Shape aShape; - BRep_Builder aBuilder; - Standard_Boolean result = BRepTools::Read(aShape,aFileName,aBuilder); - if (!result) - return false; - if(myAISContext->HasOpenedContext()) - myAISContext->CloseLocalContext(); - myAISContext->Display(new AIS_Shape(aShape)); - return true; -} - -void OCCViewer::UpdateView(void) -{ - if (!myView.IsNull()) - myView->MustBeResized(); -} - -void OCCViewer::RedrawView(void) -{ - if (!myView.IsNull()) - myView->Redraw(); -} - -void OCCViewer::SetDegenerateModeOn(void) -{ - if (!myView.IsNull()) - myView->SetComputedMode (Standard_False); -} - -void OCCViewer::SetDegenerateModeOff(void) -{ - if (!myView.IsNull()) - myView->SetComputedMode (Standard_True); -} - -void OCCViewer::WindowFitAll(int Xmin, int Ymin, int Xmax, int Ymax) -{ - if (!myView.IsNull()) - myView->WindowFitAll(Xmin, Ymin, Xmax, Ymax); -} - -void OCCViewer::Place(int x, int y, float zoomFactor) -{ - Quantity_Factor aZoomFactor = zoomFactor; - if (!myView.IsNull()) - myView->Place(x, y, aZoomFactor); -} - -void OCCViewer::Zoom(int x1, int y1, int x2, int y2) -{ - if (!myView.IsNull()) - myView->Zoom(x1, y1, x2, y2); -} - -void OCCViewer::Pan(int x, int y) -{ - if (!myView.IsNull()) - myView->Pan(x, y); -} - -void OCCViewer::Rotation(int x, int y) -{ - if (!myView.IsNull()) - myView->Rotation(x, y); -} - -void OCCViewer::StartRotation(int x, int y) -{ - if (!myView.IsNull()) - myView->StartRotation(x, y); -} - -void OCCViewer::Select(int x1, int y1, int x2, int y2) -{ - if (!myAISContext.IsNull()) - myAISContext->Select(x1, y1, x2, y2, myView); -} - -void OCCViewer::Select(void) -{ - if (!myAISContext.IsNull()) - myAISContext->Select(); -} - -void OCCViewer::MoveTo(int x, int y) -{ - if ((!myAISContext.IsNull()) && (!myView.IsNull())) - myAISContext->MoveTo(x, y, myView); -} - -void OCCViewer::ShiftSelect(int x1, int y1, int x2, int y2) -{ - if ((!myAISContext.IsNull()) && (!myView.IsNull())) - myAISContext->ShiftSelect(x1, y1, x2, y2, myView); -} - -void OCCViewer::ShiftSelect(void) -{ - if (!myAISContext.IsNull()) - myAISContext->ShiftSelect(); -} - -void OCCViewer::BackgroundColor(int& r, int& g, int& b) -{ - Standard_Real R1; - Standard_Real G1; - Standard_Real B1; - if (!myView.IsNull()) - myView->BackgroundColor(Quantity_TOC_RGB,R1,G1,B1); - r = (int)R1*255; - g = (int)G1*255; - b = (int)B1*255; -} - - - -void OCCViewer::UpdateCurrentViewer(void) -{ - if (!myAISContext.IsNull()) - myAISContext->UpdateCurrentViewer(); -} - -void OCCViewer::FrontView(void) -{ - if (!myView.IsNull()) - myView->SetProj(V3d_Xpos); -} - -void OCCViewer::TopView(void) -{ - if (!myView.IsNull()) - myView->SetProj(V3d_Zpos); -} - -void OCCViewer::LeftView(void) -{ - if (!myView.IsNull()) - myView->SetProj(V3d_Ypos); -} - -void OCCViewer::BackView(void) -{ - if (!myView.IsNull()) - myView->SetProj(V3d_Xneg); -} - -void OCCViewer::RightView(void) -{ - if (!myView.IsNull()) - myView->SetProj(V3d_Yneg); -} - -void OCCViewer::BottomView(void) -{ - if (!myView.IsNull()) - myView->SetProj(V3d_Zneg); -} - -void OCCViewer::AxoView(void) -{ - if (!myView.IsNull()) - myView->SetProj(V3d_XposYnegZpos); -} - -void OCCViewer::ZoomAllView(void) -{ - if (!myView.IsNull()) - { - myView->FitAll(); - myView->ZFitAll(); - } -} - -float OCCViewer::Scale(void) -{ - if (myView.IsNull()) - return -1; - else - return (float)myView->Scale(); -} - -void OCCViewer::ResetView(void) -{ - if (!myView.IsNull()) - myView->Reset(); -} - -void OCCViewer::SetDisplayMode(int aMode) -{ - if (myAISContext.IsNull()) - return; - AIS_DisplayMode CurrentMode; - if (aMode == 0) - CurrentMode=AIS_WireFrame; - else - CurrentMode=AIS_Shaded; - if(myAISContext->NbCurrents()==0 || myAISContext->NbSelected()==0) - myAISContext->SetDisplayMode(CurrentMode); - else - { - for(myAISContext->InitCurrent();myAISContext->MoreCurrent();myAISContext->NextCurrent()) - myAISContext->SetDisplayMode(myAISContext->Current(),aMode,Standard_False); - - } - myAISContext->UpdateCurrentViewer(); -} - -void OCCViewer::SetColor(int r, int g, int b) -{ - if (myAISContext.IsNull()) - return; - Quantity_Color col = Quantity_Color(r/255.,g/255.,b/255.,Quantity_TOC_RGB); - for (;myAISContext->MoreCurrent ();myAISContext->NextCurrent ()) - myAISContext->SetColor (myAISContext->Current(),col.Name()); -} - -void OCCViewer::ObjectColor(int& r, int& g, int& b) -{ - if (myAISContext.IsNull()) - return; - r=255; - g=255; - b=255; - Handle_AIS_InteractiveObject Current ; - Quantity_Color ObjCol; - myAISContext->InitCurrent(); - if (!myAISContext->MoreCurrent()) - return; - Current = myAISContext->Current(); - if ( Current->HasColor () ) { - ObjCol = myAISContext->Color(myAISContext->Current()); - Quantity_Parameter r1, r2, r3; - ObjCol.Values(r1, r2, r3, Quantity_TOC_RGB); - r=(int)r1*255; - g=(int)r2*255; - b=(int)r3*255; - } -} - -void OCCViewer::SetBackgroundColor(int r, int g, int b) -{ - if (!myView.IsNull()) - myView->SetBackgroundColor(Quantity_TOC_RGB,r/255.,g/255.,b/255.); -} - -void OCCViewer::EraseObjects(void) -{ - if (myAISContext.IsNull()) - return; - for(myAISContext->InitCurrent();myAISContext->MoreCurrent();myAISContext->NextCurrent()) - myAISContext->Erase(myAISContext->Current(),Standard_True); - myAISContext->ClearCurrents(); -} - -float OCCViewer::GetVersion(void) -{ - return (float)OCC_VERSION; -} - -void OCCViewer::SetMaterial(int theMaterial) -{ - if (myAISContext.IsNull()) - return; - for ( myAISContext->InitCurrent(); myAISContext->MoreCurrent (); myAISContext->NextCurrent () ) - myAISContext->SetMaterial( myAISContext->Current(), (Graphic3d_NameOfMaterial)theMaterial ); - myAISContext->UpdateCurrentViewer(); -} - -void OCCViewer::SetTransparency(int theTrans) -{ - if (myAISContext.IsNull()) - return; - for( myAISContext->InitCurrent(); myAISContext->MoreCurrent(); myAISContext->NextSelected() ) - myAISContext->SetTransparency( myAISContext->Current(), ((Standard_Real)theTrans) / 10.0 ); -} - -bool OCCViewer::ImportCsfdb(char* filename) -{ - Standard_CString aFileName = (Standard_CString) filename; - if ( FSD_File::IsGoodFileType(aFileName) != Storage_VSOk ) - return false; - - static FSD_File fileDriver; - TCollection_AsciiString aName( aFileName ); - if ( fileDriver.Open( aName, Storage_VSRead ) != Storage_VSOk ) - return false; - - Handle(ShapeSchema) schema = new ShapeSchema(); - Handle(Storage_Data) data = schema->Read( fileDriver ); - if ( data->ErrorStatus() != Storage_VSOk ) - return false; - fileDriver.Close(); - - Handle(Storage_HSeqOfRoot) roots = data->Roots(); - for ( int i = 1; i <= roots->Length() ; i++ ) - { - Handle(Storage_Root) r = roots->Value( i ); - Handle(Standard_Persistent) p = r->Object(); - Handle(PTopoDS_HShape) aPShape = Handle(PTopoDS_HShape)::DownCast(p); - if ( !aPShape.IsNull() ) - { - PTColStd_PersistentTransientMap aMap; - TopoDS_Shape aTShape; - MgtBRep::Translate( aPShape, aMap, aTShape, MgtBRep_WithTriangle ); - myAISContext->Display(new AIS_Shape(aTShape)); - } - } - - return true; -} - -bool OCCViewer::ImportIges(char* filename) -{ - Standard_CString aFileName = (Standard_CString) filename; - IGESControl_Reader Reader; - int status = Reader.ReadFile( aFileName ); - - if ( status == IFSelect_RetDone ) - { - Reader.TransferRoots(); - TopoDS_Shape aShape = Reader.OneShape(); - myAISContext->Display(new AIS_Shape(aShape)); - } else - return false; - myAISContext->UpdateCurrentViewer(); - return true; -} - -bool OCCViewer::ImportStep(char* filename) -{ - Standard_CString aFileName = (Standard_CString) filename; - STEPControl_Reader aReader; - IFSelect_ReturnStatus status = aReader.ReadFile(aFileName); - if ( status == IFSelect_RetDone ) - { - bool failsonly = false; - aReader.PrintCheckLoad( failsonly, IFSelect_ItemsByEntity ); - - int nbr = aReader.NbRootsForTransfer(); - aReader.PrintCheckTransfer( failsonly, IFSelect_ItemsByEntity ); - for ( Standard_Integer n = 1; n <= nbr; n++ ) - { - Standard_Boolean ok = aReader.TransferRoot( n ); - int nbs = aReader.NbShapes(); - if ( nbs > 0 ) - { - for ( int i = 1; i <= nbs; i++ ) - { - TopoDS_Shape shape = aReader.Shape( i ); - myAISContext->Display(new AIS_Shape(shape)); - } - } - } - } else - return false; - return true; -} - -bool OCCViewer::ExportBRep(char* filename) -{ - myAISContext->InitCurrent(); - if (!myAISContext->MoreCurrent()) - return false; - Handle_AIS_InteractiveObject anIO = myAISContext->Current(); - Handle_AIS_Shape anIS=Handle_AIS_Shape::DownCast(anIO); - return (bool)BRepTools::Write( anIS->Shape(), (Standard_CString)filename ); ; -} - - -bool OCCViewer::ExportIges(char* filename) -{ - IGESControl_Controller::Init(); - IGESControl_Writer writer( Interface_Static::CVal( "XSTEP.iges.unit" ), - Interface_Static::IVal( "XSTEP.iges.writebrep.mode" ) ); - - - for ( myAISContext->InitCurrent(); myAISContext->MoreCurrent(); myAISContext->NextCurrent() ) - { - Handle_AIS_InteractiveObject anIO = myAISContext->Current(); - Handle_AIS_Shape anIS=Handle_AIS_Shape::DownCast(anIO); - TopoDS_Shape shape = anIS->Shape(); - writer.AddShape ( shape ); - } - writer.ComputeModel(); - return (bool)writer.Write( (Standard_CString)filename ); -} - -bool OCCViewer::ExpotStep(char* filename) -{ - STEPControl_StepModelType type = STEPControl_AsIs; - IFSelect_ReturnStatus status; - STEPControl_Writer writer; - for ( myAISContext->InitCurrent(); myAISContext->MoreCurrent(); myAISContext->NextCurrent() ) - { - Handle_AIS_InteractiveObject anIO = myAISContext->Current(); - Handle_AIS_Shape anIS=Handle_AIS_Shape::DownCast(anIO); - TopoDS_Shape shape = anIS->Shape(); - status = writer.Transfer( shape , type ); - if ( status != IFSelect_RetDone ) - return false; - } - - status = writer.Write( (Standard_CString)filename ); - if ( status != IFSelect_RetDone ) - return false; - return true; -} - -bool OCCViewer::ExportStl(char* filename) -{ - TopoDS_Compound comp; - BRep_Builder builder; - builder.MakeCompound( comp ); - - for ( myAISContext->InitCurrent(); myAISContext->MoreCurrent(); myAISContext->NextCurrent() ) - { - Handle_AIS_InteractiveObject anIO = myAISContext->Current(); - Handle_AIS_Shape anIS=Handle_AIS_Shape::DownCast(anIO); - TopoDS_Shape shape = anIS->Shape(); - if ( shape.IsNull() ) - return false; - builder.Add( comp, shape ); - } - - StlAPI_Writer writer; - writer.Write( comp, (Standard_CString)filename ); - return true; -} - -bool OCCViewer::ExportVrml(char* filename) -{ - TopoDS_Compound res; - BRep_Builder builder; - builder.MakeCompound( res ); - - for ( myAISContext->InitCurrent(); myAISContext->MoreCurrent(); myAISContext->NextCurrent() ) - { - Handle_AIS_InteractiveObject anIO = myAISContext->Current(); - Handle_AIS_Shape anIS=Handle_AIS_Shape::DownCast(anIO); - TopoDS_Shape shape = anIS->Shape(); - if ( shape.IsNull() ) - return false; - - builder.Add( res, shape ); - } - - VrmlAPI_Writer writer; - writer.Write( res, (Standard_CString)filename ); - - return true; -} - -bool OCCViewer::Dump(char *filename) -{ - if (myView.IsNull()) - return false; - myView->Redraw(); - return (bool)myView->Dump(filename); -} - -bool OCCViewer::IsObjectSelected(void) -{ - if (myAISContext.IsNull()) - return false; - myAISContext->InitCurrent(); - return (bool)myAISContext->MoreCurrent(); -} - -int OCCViewer::DisplayMode(void) -{ - if (myAISContext.IsNull()) - return -1; - int mode = -1; - bool OneOrMoreInShading=false; - bool OneOrMoreInWireframe=false; - for (myAISContext->InitCurrent(); myAISContext->MoreCurrent(); myAISContext->NextCurrent()) - { - if ( myAISContext->IsDisplayed( myAISContext->Current(), 1 ) ) - OneOrMoreInShading = true; - if ( myAISContext->IsDisplayed( myAISContext->Current(), 0 ) ) - OneOrMoreInWireframe = true; - } - if (OneOrMoreInShading&&OneOrMoreInWireframe) - mode=10; - else if(OneOrMoreInShading) - mode=1; - else if (OneOrMoreInWireframe) - mode=0; - return mode; -} - -void OCCViewer::CreateNewView(void* wnd) -{ - if (myAISContext.IsNull()) - return; - myView = myAISContext->CurrentViewer()->CreateView(); - if (myGraphicDriver.IsNull()) - { - Handle(Aspect_DisplayConnection) aDisplayConnection; - myGraphicDriver = Graphic3d::InitGraphicDriver (aDisplayConnection); - } - Handle(WNT_Window) aWNTWindow = new WNT_Window (reinterpret_cast (wnd)); - myView->SetWindow(aWNTWindow); - Standard_Integer w=100, h=100; - aWNTWindow->Size(w,h); - if (!aWNTWindow->IsMapped()) - aWNTWindow->Map(); -} - -bool OCCViewer::SetAISContext(OCCViewer* Viewer) -{ - this->myAISContext=Viewer->GetAISContext(); - if (myAISContext.IsNull()) - return false; - return true; -} - -Handle_AIS_InteractiveContext OCCViewer::GetAISContext(void) -{ - return myAISContext; -} - -int OCCViewer::CharToInt(char symbol) -{ - TCollection_AsciiString msg = symbol; - return msg.IntegerValue(); -} diff --git a/samples/CSharp/OCC/OCCViewer.h b/samples/CSharp/OCC/OCCViewer.h deleted file mode 100755 index 6f0c1182ac..0000000000 --- a/samples/CSharp/OCC/OCCViewer.h +++ /dev/null @@ -1,69 +0,0 @@ -#pragma once -#include "stdafx.h" - - -class OCCViewer -{ -public: - __declspec(dllexport) OCCViewer(void); - __declspec(dllexport) ~OCCViewer(void); -private: - Handle_V3d_Viewer myViewer; - Handle_V3d_View myView; - Handle_AIS_InteractiveContext myAISContext; - Handle_Graphic3d_GraphicDriver myGraphicDriver; -public: - __declspec(dllexport) bool InitViewer(void* wnd); - __declspec(dllexport) bool ImportBRep(char* filename); - __declspec(dllexport) void UpdateView(void); - __declspec(dllexport) void RedrawView(void); - __declspec(dllexport) void SetDegenerateModeOn(void); - __declspec(dllexport) void SetDegenerateModeOff(void); - __declspec(dllexport) void WindowFitAll(int Xmin, int Ymin, int Xmax, int Ymax); - __declspec(dllexport) void Place(int x, int y, float zoomFactor); - __declspec(dllexport) void Zoom(int x1, int y1, int x2, int y2); - __declspec(dllexport) void Pan(int x, int y); - __declspec(dllexport) void Rotation(int x, int y); - __declspec(dllexport) void StartRotation(int x, int y); - __declspec(dllexport) void Select(int x1, int y1, int x2, int y2); - __declspec(dllexport) void Select(void); - __declspec(dllexport) void MoveTo(int x, int y); - __declspec(dllexport) void ShiftSelect(int x1, int y1, int x2, int y2); - __declspec(dllexport) void ShiftSelect(void); - __declspec(dllexport) void BackgroundColor(int& r, int& g, int& b); - __declspec(dllexport) void UpdateCurrentViewer(void); - __declspec(dllexport) void FrontView(void); - __declspec(dllexport) void TopView(void); - __declspec(dllexport) void LeftView(void); - __declspec(dllexport) void BackView(void); - __declspec(dllexport) void RightView(void); - __declspec(dllexport) void BottomView(void); - __declspec(dllexport) void AxoView(void); - __declspec(dllexport) void ZoomAllView(void); - __declspec(dllexport) float Scale(void); - __declspec(dllexport) void PanGloView(void); - __declspec(dllexport) void ResetView(void); - __declspec(dllexport) void SetDisplayMode(int aMode); - __declspec(dllexport) void SetColor(int r, int g, int b); - __declspec(dllexport) void ObjectColor(int& r, int& g, int& b); - __declspec(dllexport) void SetBackgroundColor(int r, int g, int b); - __declspec(dllexport) void EraseObjects(void); - __declspec(dllexport) float GetVersion(void); - __declspec(dllexport) void SetMaterial(int theMaterial); - __declspec(dllexport) void SetTransparency(int theTrans); - __declspec(dllexport) bool ImportCsfdb(char* filename); - __declspec(dllexport) bool ImportIges(char* filename); - __declspec(dllexport) bool ImportStep(char* filename); - __declspec(dllexport) bool ExportBRep(char* filename); - __declspec(dllexport) bool ExportIges(char* filename); - __declspec(dllexport) bool ExpotStep(char* filename); - __declspec(dllexport) bool ExportStl(char* filename); - __declspec(dllexport) bool ExportVrml(char* filename); - __declspec(dllexport) bool Dump(char* filename); - __declspec(dllexport) bool IsObjectSelected(void); - __declspec(dllexport) int DisplayMode(void); - __declspec(dllexport) void CreateNewView(void* wnd); - __declspec(dllexport) bool SetAISContext(OCCViewer* Viewer); - Handle_AIS_InteractiveContext GetAISContext(void); - __declspec(dllexport) int CharToInt(char symbol); -}; diff --git a/samples/CSharp/OCC/ReadMe.txt b/samples/CSharp/OCC/ReadMe.txt deleted file mode 100755 index 1542dff05e..0000000000 --- a/samples/CSharp/OCC/ReadMe.txt +++ /dev/null @@ -1,40 +0,0 @@ -======================================================================== - DYNAMIC LINK LIBRARY : OCC Project Overview -======================================================================== - -AppWizard has created this OCC DLL for you. -This file contains a summary of what you will find in each of the files that -make up your OCC application. - - -OCC.vcproj - This is the main project file for VC++ projects generated using an Application Wizard. - It contains information about the version of Visual C++ that generated the file, and - information about the platforms, configurations, and project features selected with the - Application Wizard. - -OCC.cpp - This is the main DLL source file. - - When created, this DLL does not export any symbols. As a result, it - will not produce a .lib file when it is built. If you wish this project - to be a project dependency of some other project, you will either need to - add code to export some symbols from the DLL so that an export library - will be produced, or you can set the Ignore Input Library property to Yes - on the General propert page of the Linker folder in the project's Property - Pages dialog box. - -///////////////////////////////////////////////////////////////////////////// -Other standard files: - -StdAfx.h, StdAfx.cpp - These files are used to build a precompiled header (PCH) file - named OCC.pch and a precompiled types file named StdAfx.obj. - -///////////////////////////////////////////////////////////////////////////// -Other notes: - -AppWizard uses "TODO:" comments to indicate parts of the source code you -should add to or customize. - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/CSharp/OCC/stdafx.cpp b/samples/CSharp/OCC/stdafx.cpp deleted file mode 100755 index de3c5dc756..0000000000 --- a/samples/CSharp/OCC/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// OCC.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/samples/CSharp/OCC/stdafx.h b/samples/CSharp/OCC/stdafx.h deleted file mode 100755 index fbb417308d..0000000000 --- a/samples/CSharp/OCC/stdafx.h +++ /dev/null @@ -1,75 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -// Windows Header Files: -#include -//standard OCC types -#pragma warning( disable : 4311 ) -#pragma warning( disable : 4312 ) -#pragma warning( disable : 4267 ) -#include -#include -#include -#include -//collections -#include -#include -#include -#include -//for OCC graphic -#include -#include -#include -#include -#include -#include -//for object display -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//topology -#include -#include -//brep tools -#include -#include -#include -//geometry -#include -#include -//csfdb I/E -#include -#include -#include -#include -#include -#include -#include -#include -#include -// iges I/E -#include -#include -#include -#include -#include -//step I/E -#include -#include -//for stl export -#include -//for vrml export -#include diff --git a/samples/CSharp/OCCTProxy/OCCTProxy.cpp b/samples/CSharp/OCCTProxy/OCCTProxy.cpp new file mode 100644 index 0000000000..595d91d90c --- /dev/null +++ b/samples/CSharp/OCCTProxy/OCCTProxy.cpp @@ -0,0 +1,1100 @@ +// include required OCCT headers +#include +#include +//for OCC graphic +#include +#include +#include +#include +//for object display +#include +#include +#include +#include +//topology +#include +#include +//brep tools +#include +#include +#include +#include +//csfdb I/E +#include +#include +#include +#include +#include +// iges I/E +#include +#include +#include +#include +#include +//step I/E +#include +#include +//for stl export +#include +//for vrml export +#include +//wrapper of pure C++ classes to ref classes +#include + +// list of required OCCT libraries +#pragma comment(lib, "TKernel.lib") +#pragma comment(lib, "TKMath.lib") +#pragma comment(lib, "TKBRep.lib") +#pragma comment(lib, "PTKernel.lib") +#pragma comment(lib, "TKPShape.lib") +#pragma comment(lib, "TKShapeSchema.lib") +#pragma comment(lib, "TKXSBase.lib") +#pragma comment(lib, "TKService.lib") +#pragma comment(lib, "TKV3d.lib") +#pragma comment(lib, "TKIGES.lib") +#pragma comment(lib, "TKSTEP.lib") +#pragma comment(lib, "TKStl.lib") +#pragma comment(lib, "TKVrml.lib") + +/// +/// Proxy class encapsulating calls to OCCT C++ classes within +/// C++/CLI class visible from .Net (CSharp) +/// +public ref class OCCTProxy +{ +public: + // ============================================ + // Viewer functionality + // ============================================ + + /// + ///Initialize a viewer + /// + /// System.IntPtr that contains the window handle (HWND) of the control + bool InitViewer(System::IntPtr theWnd) + { + try + { + Handle(Aspect_DisplayConnection) aDisplayConnection; + myGraphicDriver() = Graphic3d::InitGraphicDriver (aDisplayConnection); + } + catch (Standard_Failure) + { + return false; + } + + TCollection_ExtendedString a3DName("Visu3D"); + myViewer() = new V3d_Viewer (myGraphicDriver(), a3DName.ToExtString(),"", 1000.0, + V3d_XposYnegZpos, Quantity_NOC_GRAY30, + V3d_ZBUFFER,V3d_GOURAUD,V3d_WAIT, + Standard_True, Standard_False); + + myViewer()->Init(); + myViewer()->SetDefaultLights(); + myViewer()->SetLightOn(); + myView() = myViewer()->CreateView(); + Handle(WNT_Window) aWNTWindow = new WNT_Window (reinterpret_cast (theWnd.ToPointer())); + myView()->SetWindow(aWNTWindow); + if (!aWNTWindow->IsMapped()) + { + aWNTWindow->Map(); + } + myAISContext() = new AIS_InteractiveContext( myViewer() ); + myAISContext()->UpdateCurrentViewer(); + myView()->Redraw(); + myView()->MustBeResized(); + return true; + } + + /// + /// Make dump of current view to file + /// + /// Name of dump file + bool Dump(char *theFileName) + { + if (myView().IsNull()) + { + return false; + } + myView()->Redraw(); + return myView()->Dump(theFileName) != Standard_False; + } + + /// + ///Redraw view + /// + void RedrawView(void) + { + if (!myView().IsNull()) + { + myView()->Redraw(); + } + } + + /// + ///Update view + /// + void UpdateView(void) + { + if (!myView().IsNull()) + { + myView()->MustBeResized(); + } + } + + /// + ///Set computed mode in false + /// + void SetDegenerateModeOn(void) + { + if (!myView().IsNull()) + { + myView()->SetComputedMode (Standard_False); + } + } + + /// + ///Set computed mode in true + /// + void SetDegenerateModeOff(void) + { + if (!myView().IsNull()) + { + myView()->SetComputedMode (Standard_True); + } + } + + /// + ///Fit all + /// + void WindowFitAll(int theXmin, int theYmin, int theXmax, int theYmax) + { + if (!myView().IsNull()) + { + myView()->WindowFitAll(theXmin, theYmin, theXmax, theYmax); + } + } + + /// + ///Current place of window + /// + /// Current zoom + void Place(int theX, int theY, float theZoomFactor) + { + Quantity_Factor aZoomFactor = theZoomFactor; + if (!myView().IsNull()) + { + myView()->Place(theX, theY, aZoomFactor); + } + } + + /// + ///Set Zoom + /// + void Zoom(int theX1, int theY1, int theX2, int theY2) + { + if (!myView().IsNull()) + { + myView()->Zoom(theX1, theY1, theX2, theY2); + } + } + + /// + ///Set Pan + /// + void Pan(int theX, int theY) + { + if (!myView().IsNull()) + { + myView()->Pan(theX, theY); + } + } + + /// + ///Rotation + /// + void Rotation(int theX, int theY) + { + if (!myView().IsNull()) + { + myView()->Rotation(theX, theY); + } + } + + /// + ///Start rotation + /// + void StartRotation(int theX, int theY) + { + if (!myView().IsNull()) + { + myView()->StartRotation(theX, theY); + } + } + + /// + ///Select by rectangle + /// + void Select(int theX1, int theY1, int theX2, int theY2) + { + if (!myAISContext().IsNull()) + { + myAISContext()->Select(theX1, theY1, theX2, theY2, myView()); + } + } + + /// + ///Select by click + /// + void Select(void) + { + if (!myAISContext().IsNull()) + { + myAISContext()->Select(); + } + } + + /// + ///Move view + /// + void MoveTo(int theX, int theY) + { + if ((!myAISContext().IsNull()) && (!myView().IsNull())) + { + myAISContext()->MoveTo(theX, theY, myView()); + } + } + + /// + ///Select by rectangle with pressed "Shift" key + /// + void ShiftSelect(int theX1, int theY1, int theX2, int theY2) + { + if ((!myAISContext().IsNull()) && (!myView().IsNull())) + { + myAISContext()->ShiftSelect(theX1, theY1, theX2, theY2, myView()); + } + } + + /// + ///Select by "Shift" key + /// + void ShiftSelect(void) + { + if (!myAISContext().IsNull()) + { + myAISContext()->ShiftSelect(); + } + } + + /// + ///Set background color + /// + void BackgroundColor(int& theRed, int& theGreen, int& theBlue) + { + Standard_Real R1; + Standard_Real G1; + Standard_Real B1; + if (!myView().IsNull()) + { + myView()->BackgroundColor(Quantity_TOC_RGB,R1,G1,B1); + } + theRed = (int)R1*255; + theGreen = (int)G1*255; + theBlue = (int)B1*255; + } + + /// + ///Get background color Red + /// + int GetBGColR(void) + { + int aRed, aGreen, aBlue; + BackgroundColor(aRed, aGreen, aBlue); + return aRed; + } + + /// + ///Get background color Green + /// + int GetBGColG(void) + { + int aRed, aGreen, aBlue; + BackgroundColor(aRed, aGreen, aBlue); + return aGreen; + } + + /// + ///Get background color Blue + /// + int GetBGColB(void) + { + int aRed, aGreen, aBlue; + BackgroundColor(aRed, aGreen, aBlue); + return aBlue; + } + + /// + ///Update current viewer + /// + void UpdateCurrentViewer(void) + { + if (!myAISContext().IsNull()) + { + myAISContext()->UpdateCurrentViewer(); + } + } + + /// + ///Front side + /// + void FrontView(void) + { + if (!myView().IsNull()) + { + myView()->SetProj(V3d_Xpos); + } + } + + /// + ///Top side + /// + void TopView(void) + { + if (!myView().IsNull()) + { + myView()->SetProj(V3d_Zpos); + } + } + + /// + ///Left side + /// + void LeftView(void) + { + if (!myView().IsNull()) + { + myView()->SetProj(V3d_Ypos); + } + } + + /// + ///Back side + /// + void BackView(void) + { + if (!myView().IsNull()) + { + myView()->SetProj(V3d_Xneg); + } + } + + /// + ///Right side + /// + void RightView(void) + { + if (!myView().IsNull()) + { + myView()->SetProj(V3d_Yneg); + } + } + + /// + ///Bottom side + /// + void BottomView(void) + { + if (!myView().IsNull()) + { + myView()->SetProj(V3d_Zneg); + } + } + + /// + ///Axo side + /// + void AxoView(void) + { + if (!myView().IsNull()) + { + myView()->SetProj(V3d_XposYnegZpos); + } + } + + /// + ///Scale + /// + float Scale(void) + { + if (myView().IsNull()) + { + return -1; + } + else + { + return (float)myView()->Scale(); + } + } + + /// + ///Zoom in all view + /// + void ZoomAllView(void) + { + if (!myView().IsNull()) + { + myView()->FitAll(); + myView()->ZFitAll(); + } + } + + /// + ///Reset view + /// + void Reset(void) + { + if (!myView().IsNull()) + { + myView()->Reset(); + } + } + + /// + ///Set display mode of objects + /// + /// Set current mode + void SetDisplayMode(int theMode) + { + if (myAISContext().IsNull()) + { + return; + } + AIS_DisplayMode aCurrentMode; + if (theMode == 0) + { + aCurrentMode=AIS_WireFrame; + } + else + { + aCurrentMode=AIS_Shaded; + } + + if(myAISContext()->NbCurrents()==0 || myAISContext()->NbSelected()==0) + { + myAISContext()->SetDisplayMode(aCurrentMode); + } + else + { + for(myAISContext()->InitCurrent(); myAISContext()->MoreCurrent(); myAISContext()->NextCurrent()) + { + myAISContext()->SetDisplayMode(myAISContext()->Current(), theMode, Standard_False); + } + } + myAISContext()->UpdateCurrentViewer(); + } + + /// + ///Set color + /// + void SetColor(int theR, int theG, int theB) + { + if (myAISContext().IsNull()) + { + return; + } + Quantity_Color aCol = Quantity_Color(theR/255.,theG/255.,theB/255.,Quantity_TOC_RGB); + for (;myAISContext()->MoreCurrent ();myAISContext()->NextCurrent ()) + { + myAISContext()->SetColor (myAISContext()->Current(),aCol.Name()); + } + } + + /// + ///Get object color red + /// + int GetObjColR(void) + { + int aRed, aGreen, aBlue; + ObjectColor(aRed, aGreen, aBlue); + return aRed; + } + + /// + ///Get object color green + /// + int GetObjColG(void) + { + int aRed, aGreen, aBlue; + ObjectColor(aRed, aGreen, aBlue); + return aGreen; + } + + /// + ///Get object color R/G/B + /// + void ObjectColor(int& theRed, int& theGreen, int& theBlue) + { + if (myAISContext().IsNull()) + { + return; + } + theRed=255; + theGreen=255; + theBlue=255; + Handle_AIS_InteractiveObject aCurrent ; + Quantity_Color anObjCol; + myAISContext()->InitCurrent(); + if (!myAISContext()->MoreCurrent()) + { + return; + } + aCurrent = myAISContext()->Current(); + if ( aCurrent->HasColor () ) + { + anObjCol = myAISContext()->Color(myAISContext()->Current()); + Quantity_Parameter r1, r2, r3; + anObjCol.Values(r1, r2, r3, Quantity_TOC_RGB); + theRed=(int)r1*255; + theGreen=(int)r2*255; + theBlue=(int)r3*255; + } + } + + /// + ///Get object color blue + /// + int GetObjColB(void) + { + int aRed, aGreen, aBlue; + ObjectColor(aRed, aGreen, aBlue); + return aBlue; + } + + /// + ///Set background color R/G/B + /// + void SetBackgroundColor(int theRed, int theGreen, int theBlue) + { + if (!myView().IsNull()) + { + myView()->SetBackgroundColor(Quantity_TOC_RGB, theRed/255.,theGreen/255.,theBlue/255.); + } + } + + /// + ///Erase objects + /// + void EraseObjects(void) + { + if (myAISContext().IsNull()) + { + return; + } + for(myAISContext()->InitCurrent();myAISContext()->MoreCurrent();myAISContext()->NextCurrent()) + { + myAISContext()->Erase(myAISContext()->Current(),Standard_True); + } + myAISContext()->ClearCurrents(); + } + + /// + ///Get version + /// + float GetOCCVersion(void) + { + return (float)OCC_VERSION; + } + + /// + ///set material + /// + void SetMaterial(int theMaterial) + { + if (myAISContext().IsNull()) + { + return; + } + for ( myAISContext()->InitCurrent(); myAISContext()->MoreCurrent (); myAISContext()->NextCurrent () ) + { + myAISContext()->SetMaterial( myAISContext()->Current(), (Graphic3d_NameOfMaterial)theMaterial ); + } + myAISContext()->UpdateCurrentViewer(); + } + + /// + ///set transparency + /// + void SetTransparency(int theTrans) + { + if (myAISContext().IsNull()) + { + return; + } + for( myAISContext()->InitCurrent(); myAISContext()->MoreCurrent(); myAISContext()->NextSelected() ) + { + myAISContext()->SetTransparency( myAISContext()->Current(), ((Standard_Real)theTrans) / 10.0 ); + } + } + + /// + ///Return true if object is selected + /// + bool IsObjectSelected(void) + { + if (myAISContext().IsNull()) + { + return false; + } + myAISContext()->InitCurrent(); + return myAISContext()->MoreCurrent() != Standard_False; + } + + /// + ///Return display mode + /// + int DisplayMode(void) + { + if (myAISContext().IsNull()) + { + return -1; + } + int aMode = -1; + bool OneOrMoreInShading = false; + bool OneOrMoreInWireframe = false; + for (myAISContext()->InitCurrent(); myAISContext()->MoreCurrent(); myAISContext()->NextCurrent()) + { + if ( myAISContext()->IsDisplayed( myAISContext()->Current(), 1 ) ) + { + OneOrMoreInShading = true; + } + if ( myAISContext()->IsDisplayed( myAISContext()->Current(), 0 ) ) + { + OneOrMoreInWireframe = true; + } + } + if (OneOrMoreInShading && OneOrMoreInWireframe) + { + aMode=10; + } + else if(OneOrMoreInShading) + { + aMode=1; + } + else if (OneOrMoreInWireframe) + { + aMode=0; + } + + return aMode; + } + + /// + ///Create new view + /// + /// System.IntPtr that contains the window handle (HWND) of the control + void CreateNewView(System::IntPtr theWnd) + { + if (myAISContext().IsNull()) + { + return; + } + myView() = myAISContext()->CurrentViewer()->CreateView(); + if (myGraphicDriver().IsNull()) + { + Handle(Aspect_DisplayConnection) aDisplayConnection; + myGraphicDriver() = Graphic3d::InitGraphicDriver (aDisplayConnection); + } + Handle(WNT_Window) aWNTWindow = new WNT_Window (reinterpret_cast (theWnd.ToPointer())); + myView()->SetWindow(aWNTWindow); + Standard_Integer w=100, h=100; + aWNTWindow->Size(w,h); + if (!aWNTWindow->IsMapped()) + { + aWNTWindow->Map(); + } + } + + /// + ///Set AISContext + /// + bool SetAISContext(OCCTProxy^ theViewer) + { + this->myAISContext() = theViewer->GetContext(); + if (myAISContext().IsNull()) + { + return false; + } + return true; + } + + /// + ///Get AISContext + /// + Handle_AIS_InteractiveContext GetContext(void) + { + return myAISContext(); + } + +public: + // ============================================ + // Import / export functionality + // ============================================ + + /// + ///Import BRep file + /// + /// Name of import file + bool ImportBrep(System::String^ theFileName) + { + bool isResult = false; + int aLength = theFileName->Length; + char* aFilename = new char[aLength+1]; + for(int i = 0; iToCharArray()[i]; + } + aFilename[aLength] = '\0'; + isResult = ImportBrep(aFilename); + return isResult; + } + + /// + ///Import BRep file + /// + /// Name of import file + bool ImportBrep(char* theFileName) + { + Standard_CString aFileName = (Standard_CString) theFileName; + TopoDS_Shape aShape; + BRep_Builder aBuilder; + Standard_Boolean isResult = BRepTools::Read(aShape,aFileName,aBuilder); + if (!isResult) + { + return false; + } + if(myAISContext()->HasOpenedContext()) + { + myAISContext()->CloseLocalContext(); + } + myAISContext()->Display(new AIS_Shape(aShape)); + return true; + } + + /// + ///Import Csfdb file + /// + /// Name of import file + bool ImportCsfdb(char* theFileName) + { + Standard_CString aFileName = (Standard_CString) theFileName; + if ( FSD_File::IsGoodFileType(aFileName) != Storage_VSOk ) + { + return false; + } + + FSD_File aFileDriver; + TCollection_AsciiString aName( aFileName ); + if ( aFileDriver.Open( aName, Storage_VSRead ) != Storage_VSOk ) + { + return false; + } + + Handle(ShapeSchema) aSchema = new ShapeSchema(); + Handle(Storage_Data) data = aSchema->Read( aFileDriver ); + if ( data->ErrorStatus() != Storage_VSOk ) + { + return false; + } + aFileDriver.Close(); + + Handle(Storage_HSeqOfRoot) aRoots = data->Roots(); + for ( int i = 1; i <= aRoots->Length() ; i++ ) + { + Handle(Storage_Root) aStorRoot = aRoots->Value( i ); + Handle(Standard_Persistent) aStandPersistent = aStorRoot->Object(); + Handle(PTopoDS_HShape) aPShape = Handle(PTopoDS_HShape)::DownCast(aStandPersistent); + if ( !aPShape.IsNull() ) + { + PTColStd_PersistentTransientMap aMap; + TopoDS_Shape aTShape; + MgtBRep::Translate( aPShape, aMap, aTShape, MgtBRep_WithTriangle ); + myAISContext()->Display(new AIS_Shape(aTShape)); + } + } + + return true; + } + + /// + ///Import Step file + /// + /// Name of import file + bool ImportStep(char* theFileName) + { + Standard_CString aFileName = (Standard_CString) theFileName; + STEPControl_Reader aReader; + IFSelect_ReturnStatus aStatus = aReader.ReadFile(aFileName); + if ( aStatus == IFSelect_RetDone ) + { + bool isFailsonly = false; + aReader.PrintCheckLoad( isFailsonly, IFSelect_ItemsByEntity ); + + int aNbRoot = aReader.NbRootsForTransfer(); + aReader.PrintCheckTransfer( isFailsonly, IFSelect_ItemsByEntity ); + for ( Standard_Integer n = 1; n <= aNbRoot; n++ ) + { + Standard_Boolean ok = aReader.TransferRoot( n ); + int aNbShap = aReader.NbShapes(); + if ( aNbShap > 0 ) + { + for ( int i = 1; i <= aNbShap; i++ ) + { + TopoDS_Shape aShape = aReader.Shape( i ); + myAISContext()->Display(new AIS_Shape(aShape)); + } + } + } + } + else + { + return false; + } + + return true; + } + + /// + ///Import Iges file + /// + /// Name of import file + bool ImportIges(char* theFileName) + { + Standard_CString aFileName = (Standard_CString) theFileName; + IGESControl_Reader aReader; + int aStatus = aReader.ReadFile( aFileName ); + + if ( aStatus == IFSelect_RetDone ) + { + aReader.TransferRoots(); + TopoDS_Shape aShape = aReader.OneShape(); + myAISContext()->Display(new AIS_Shape(aShape)); + } + else + { + return false; + } + + myAISContext()->UpdateCurrentViewer(); + return true; + } + + /// + ///Export BRep file + /// + /// Name of export file + bool ExportBRep(char* theFileName) + { + myAISContext()->InitCurrent(); + if (!myAISContext()->MoreCurrent()) + { + return false; + } + + Handle_AIS_InteractiveObject anIO = myAISContext()->Current(); + Handle_AIS_Shape anIS = Handle_AIS_Shape::DownCast(anIO); + return BRepTools::Write (anIS->Shape(), (Standard_CString)theFileName) != Standard_False; + } + + /// + ///Export Step file + /// + /// Name of export file + bool ExportStep(char* theFileName) + { + STEPControl_StepModelType aType = STEPControl_AsIs; + IFSelect_ReturnStatus aStatus; + STEPControl_Writer aWriter; + for ( myAISContext()->InitCurrent(); myAISContext()->MoreCurrent(); myAISContext()->NextCurrent() ) + { + Handle_AIS_InteractiveObject anIO = myAISContext()->Current(); + Handle_AIS_Shape anIS=Handle_AIS_Shape::DownCast(anIO); + TopoDS_Shape aShape = anIS->Shape(); + aStatus = aWriter.Transfer( aShape , aType ); + if ( aStatus != IFSelect_RetDone ) + { + return false; + } + } + + aStatus = aWriter.Write( (Standard_CString)theFileName ); + if ( aStatus != IFSelect_RetDone ) + { + return false; + } + + return true; + } + + /// + ///Export Iges file + /// + /// Name of export file + bool ExportIges(char* theFileName) + { + IGESControl_Controller::Init(); + IGESControl_Writer aWriter( Interface_Static::CVal( "XSTEP.iges.unit" ), + Interface_Static::IVal( "XSTEP.iges.writebrep.mode" ) ); + + for ( myAISContext()->InitCurrent(); myAISContext()->MoreCurrent(); myAISContext()->NextCurrent() ) + { + Handle_AIS_InteractiveObject anIO = myAISContext()->Current(); + Handle_AIS_Shape anIS=Handle_AIS_Shape::DownCast(anIO); + TopoDS_Shape aShape = anIS->Shape(); + aWriter.AddShape ( aShape ); + } + + aWriter.ComputeModel(); + return aWriter.Write( (Standard_CString)theFileName) != Standard_False; + } + + /// + ///Export Vrml file + /// + /// Name of export file + bool ExportVrml(char* theFileName) + { + TopoDS_Compound aRes; + BRep_Builder aBuilder; + aBuilder.MakeCompound( aRes ); + + for ( myAISContext()->InitCurrent(); myAISContext()->MoreCurrent(); myAISContext()->NextCurrent() ) + { + Handle_AIS_InteractiveObject anIO = myAISContext()->Current(); + Handle_AIS_Shape anIS=Handle_AIS_Shape::DownCast(anIO); + TopoDS_Shape aShape = anIS->Shape(); + if ( aShape.IsNull() ) + { + return false; + } + + aBuilder.Add( aRes, aShape ); + } + + VrmlAPI_Writer aWriter; + aWriter.Write( aRes, (Standard_CString)theFileName ); + + return true; + } + + /// + ///Export Stl file + /// + /// Name of export file + bool ExportStl(char* theFileName) + { + TopoDS_Compound aComp; + BRep_Builder aBuilder; + aBuilder.MakeCompound( aComp ); + + for ( myAISContext()->InitCurrent(); myAISContext()->MoreCurrent(); myAISContext()->NextCurrent() ) + { + Handle_AIS_InteractiveObject anIO = myAISContext()->Current(); + Handle_AIS_Shape anIS=Handle_AIS_Shape::DownCast(anIO); + TopoDS_Shape aShape = anIS->Shape(); + if ( aShape.IsNull() ) + { + return false; + } + aBuilder.Add( aComp, aShape ); + } + + StlAPI_Writer aWriter; + aWriter.Write( aComp, (Standard_CString)theFileName ); + return true; + } + + /// + ///Define which Import/Export function must be called + /// + /// Name of Import/Export file + /// Determines format of Import/Export file + /// Determines is Import or not + bool TranslateModel(System::String^ theFileName, int theFormat, bool theIsImport) + { + bool isResult; + int aLength = theFileName->Length; + char* aFilename = new char[aLength+1]; + for(int i = 0; iToCharArray()[i]; + } + aFilename[aLength] = '\0'; + + if (theIsImport) + { + switch(theFormat) + { + case 0: + isResult = ImportBrep(aFilename); + break; + case 1: + isResult = ImportCsfdb(aFilename); + break; + case 2: + isResult = ImportStep(aFilename); + break; + case 3: + isResult = ImportIges(aFilename); + break; + default: + isResult = false; + } + } + else + { + switch(theFormat) + { + case 0: + isResult = ExportBRep(aFilename); + break; + case 2: + isResult = ExportStep(aFilename); + break; + case 3: + isResult = ExportIges(aFilename); + break; + case 4: + isResult = ExportVrml(aFilename); + break; + case 5: + isResult = ExportStl(aFilename); + break; + case 6: + isResult = Dump(aFilename); + break; + default: + isResult = false; + } + } + return isResult; + } + + /// + ///Initialize OCCTProxy + /// + void InitOCCTProxy(void) + { + myGraphicDriver()=NULL; + myViewer()=NULL; + myView()=NULL; + myAISContext()=NULL; + } + +private: + // fields + NCollection_Haft myViewer; + NCollection_Haft myView; + NCollection_Haft myAISContext; + NCollection_Haft myGraphicDriver; +}; diff --git a/samples/CSharp/OCCTProxy/OCCTProxy.vcproj b/samples/CSharp/OCCTProxy/OCCTProxy.vcproj new file mode 100644 index 0000000000..eefb3bbf1e --- /dev/null +++ b/samples/CSharp/OCCTProxy/OCCTProxy.vcproj @@ -0,0 +1,371 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/CSharp/ReadMe.md b/samples/CSharp/ReadMe.md new file mode 100644 index 0000000000..62f2963d9a --- /dev/null +++ b/samples/CSharp/ReadMe.md @@ -0,0 +1,50 @@ +#### OCCT CSharp sample + +This sample demonstrates simple way of using OCCT libraries in .Net application +whitten using CSharp and Windows Forms or Windows Presentation Foundation (WPF). + +The connection between .Net and OCCT (C++) level is provided by proxy library, +OCCProxy, written in C++/CLI. The proxy library contains single ref class +encapsulating OCCT viewer and providing functionality to manipulate this viewer +and to import / export OCCT shapes from / to several supported formats of CAD +files (IGES, STEP, BREP). + +The sample implements two approaches for organizing user interface with C#. +Both applications provide the same functionality as the standard OCCT +Import/Export sample. +First project is called "IE_WinForms" and uses Windows Forms for GUI. +Second application is called "IE_WPF" and uses Windows Presentation Foundation. + +Note a few important details: + +- to encapsulate C++ class into a field of ref class, template class + NCollection_Haft provided by OCCT is used + +- in order to work consistently on 64-bit systems with OCCT libraries built in + 32-bit mode, C# assemblies need to have platform target explicitly set to "x86" + (in project Properties / Build) + +- this sample demonstrates indirect method of wrapping C++ to C# using manually + created proxy library. Alternative method is available, wrapping individual + OCCT classes to C# equivalents so that their full API is available to C# user + and the code can be programmed on C# level similarly to C++ one. See desciption + of OCCT C# Wrapper in Advanced Samples and Tools on OCCT web site at + http://www.opencascade.org/support/products/advsamples + +- in WPF sample, WinForms control is used to encapsulate OCC viewer since WPF + does not provide necessary interface to embed OpenGl view. Other possible + solution could be to render OpenGl scene in off-screen buffer and map it + to WPF control as image. That approach would allow using all WPF features in + control embedding OCCT viewer. + +Run msvc.bat to start MS Visual Studio for building the sample. +Note that project files are provided only for VS 2008, you can open them in +newer versions of Visual Studio using automatic converter. + +Run run_winforms.bat or run_wpf.bat to launch the corresponding sample. + +Note that all batch scripts use configuration defined in OCCT custom.bat file +as default; you can provide arguments specifying VS version, bitness, and mode +to override these settings, e.g.: + +> msvc.bat vc9 win64 Debug diff --git a/samples/CSharp/WPF/About.xaml b/samples/CSharp/WPF/About.xaml new file mode 100644 index 0000000000..59f2a05356 --- /dev/null +++ b/samples/CSharp/WPF/About.xaml @@ -0,0 +1,18 @@ + + + + diff --git a/samples/CSharp/WPF/MainWindow.xaml.cs b/samples/CSharp/WPF/MainWindow.xaml.cs new file mode 100644 index 0000000000..d2535d3208 --- /dev/null +++ b/samples/CSharp/WPF/MainWindow.xaml.cs @@ -0,0 +1,614 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.ComponentModel; +using System.Windows.Forms.Integration; + +namespace IE_WPF +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window, INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + protected void RaisePropertyChanged( string thePropertyName ) + { + if ( PropertyChanged != null ) + { + PropertyChanged( this, new PropertyChangedEventArgs( thePropertyName ) ); + } + } + + public MainWindow() + { + InitializeComponent(); + + StatusBarText = String.Empty; + IsHlrOffPushed = false; + IsHlrOnPushed = true; + IsZoomWinEnabled = true; + + #region menu operations + + CommandBinding aBind_New = new CommandBinding( IECommands.New ); + aBind_New.Executed += NewCommand_Executed; + CommandBindings.Add( aBind_New ); + + CommandBinding aBind_Close = new CommandBinding( IECommands.Close ); + aBind_Close.Executed += CloseCommand_Executed; + aBind_Close.CanExecute += CloseCommand_CanExecute; + CommandBindings.Add( aBind_Close ); + + CommandBinding aBind_Quit = new CommandBinding( IECommands.Quit ); + aBind_Quit.Executed += QuitCommand_Executed; + CommandBindings.Add( aBind_Quit ); + + CommandBinding aBind_About = new CommandBinding( IECommands.About ); + aBind_About.Executed += AboutCommand_Executed; + CommandBindings.Add( aBind_About ); + + # endregion + + PreviewKeyDown += new KeyEventHandler( OnPreviewKeyDown ); + PreviewKeyUp += new KeyEventHandler( OnPreviewKeyUp ); + } + + private String myStatusBarText; + public String StatusBarText + { + get + { + return myStatusBarText; + } + private set + { + myStatusBarText = value; + RaisePropertyChanged( "StatusBarText" ); + } + } + + private bool isHlrOffPushed; + public Boolean IsHlrOffPushed + { + get + { + return isHlrOffPushed; + } + set + { + isHlrOffPushed = value; + RaisePropertyChanged("isHlrOffPushed"); + } + } + + private bool isHlrOnPushed; + public Boolean IsHlrOnPushed + { + get + { + return isHlrOnPushed; + } + set + { + isHlrOnPushed = value; + RaisePropertyChanged("IsHlrOnPushed"); + } + } + + private bool isZoomWinEnabled; + public Boolean IsZoomWinEnabled + { + get + { + return isZoomWinEnabled; + } + set + { + isZoomWinEnabled = value; + RaisePropertyChanged("IsZoomWinEnabled"); + } + } + + private OCCViewer ActiveViewer + { + get + { + if ( !IsDocumentOpen ) + { + return null; + } + + WindowsFormsHost aHost = ( ViewPanel.SelectedContent ) as WindowsFormsHost; + if( aHost == null ) + { + return null; + } + + return aHost.Child as OCCViewer; + } + } + + public Boolean IsDocumentOpen + { + get + { + return ViewPanel.Items.Count > 0; + } + } + + private int myDocumentCounter = 1; + + private void NewCommand_Executed( object sender, ExecutedRoutedEventArgs e ) + { + WindowsFormsHost aHost = new WindowsFormsHost(); + OCCViewer aForm = new OCCViewer(); + aForm.Show(); + aHost.Child = aForm; + + TabItem aNewTab = new TabItem(); + aNewTab.Content = aHost; + aNewTab.IsSelected = true; + aNewTab.Header = "Document " + myDocumentCounter.ToString(); + myDocumentCounter++; + + ViewPanel.Items.Add( aNewTab ); + + // update XAML property + RaisePropertyChanged("IsDocumentOpen"); + } + + private void CloseCommand_Executed(object sender, ExecutedRoutedEventArgs e) + { + if ( ViewPanel.Items.Count > 0 ) + { + ViewPanel.Items.Remove( ViewPanel.SelectedItem ); + } + + // update XAML property + RaisePropertyChanged( "IsDocumentOpen" ); + } + + private void CloseCommand_CanExecute(object sender, CanExecuteRoutedEventArgs e) + { + e.CanExecute = IsDocumentOpen; + } + + private void QuitCommand_Executed( object sender, ExecutedRoutedEventArgs e ) + { + this.Close(); + } + + private void ImportBRep_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.ImportModel( ModelFormat.BREP ); + } + } + + private void ImportIges_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.ImportModel( ModelFormat.IGES ); + } + } + + private void ImportStep_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.ImportModel( ModelFormat.STEP ); + } + } + + private void ExportBRep_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.ExportModel( ModelFormat.BREP ); + } + } + + private void ExportStep_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.ExportModel( ModelFormat.STEP ); + } + } + + private void ExportIges_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.ExportModel( ModelFormat.IGES ); + } + } + + private void ExportStl_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.ExportModel( ModelFormat.STL ); + } + } + + private void ExportVrml_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.ExportModel( ModelFormat.VRML ); + } + } + + private void ExportImage_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.ExportModel( ModelFormat.IMAGE ); + } + } + + private void FitAllBtn_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.FitAll(); + } + } + + private void ZoomWindowBtn_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + IsZoomWinEnabled = false; + ActiveViewer.ZoomWindow(); + } + } + + private void DynamicZoomingBtn_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.DynamicZooming(); + } + } + + private void DynamicPanningBtn_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.DynamicPanning(); + } + } + + private void GlobalPanningBtn_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.GlobalPanning(); + } + } + + private void FrontBtn_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.FrontView(); + } + } + + private void BackBtn_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.BackView(); + } + } + + private void TopBtn_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.TopView(); + } + } + + private void BottomBtn_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.BottomView(); + } + } + + private void LeftBtn_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.LeftView(); + } + } + + private void RightBtn_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.RightView(); + } + } + + private void AxoBtn_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.AxoView(); + } + } + + private void ResetBtn_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.Reset(); + } + } + + private void DynamicRotationBtn_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.DynamicRotation(); + } + } + + private void HiddenOffBtn_Click( object sender, RoutedEventArgs e ) + { + IsHlrOffPushed = true; + IsHlrOnPushed = false; + if ( ActiveViewer != null ) + { + ActiveViewer.HiddenOff(); + } + } + + private void HiddenOnBtn_Click( object sender, RoutedEventArgs e ) + { + IsHlrOffPushed = false; + IsHlrOnPushed = true; + if (ActiveViewer != null) + { + ActiveViewer.HiddenOn(); + } + } + + private void AboutCommand_Executed( object sender, ExecutedRoutedEventArgs e ) + { + AboutDialog aDlg = new AboutDialog(); + aDlg.ShowDialog(); + } + + private void ToolBar_MouseEnter( object sender, MouseEventArgs e ) + { + StatusBarText = "Toolbar"; + } + + private void DocumentToolBar_MouseEnter(object sender, MouseEventArgs e) + { + StatusBarText = "Document toolbar"; + } + + private void ViewToolBar_MouseEnter(object sender, MouseEventArgs e) + { + StatusBarText = "View toolbar"; + } + + private void ToolBar_MouseLeave( object sender, MouseEventArgs e ) + { + StatusBarText = ""; + } + + public void OnZoomingFinished( object sender, EventArgs e ) + { + IsZoomWinEnabled = true; + } + + public bool IsWireframeEnabled + { + get + { + if ( ActiveViewer != null ) + { + return ActiveViewer.IsWireframeEnabled; + } + return false; + } + } + + private void Wireframe_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.Wireframe(); + } + } + + private void Shading_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.Shading(); + } + } + + public bool IsShadingEnabled + { + get + { + if ( ActiveViewer != null ) + { + return ActiveViewer.IsShadingEnabled; + } + return false; + } + } + + private void Color_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.Color(); + } + } + + public bool IsColorEnabled + { + get + { + if ( ActiveViewer != null ) + { + return ActiveViewer.IsColorEnabled; + } + return false; + } + } + + private void Material_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.Material(); + } + } + + public bool IsMaterialEnabled + { + get + { + if ( ActiveViewer != null ) + { + return ActiveViewer.IsMaterialEnabled; + } + return false; + } + } + + private void Transparency_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.Transparency(); + } + } + + public bool IsTransparencyEnabled + { + get + { + if ( ActiveViewer != null ) + { + return ActiveViewer.IsTransparencyEnabled; + } + return false; + } + } + + private void Delete_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.Delete(); + } + } + + public bool IsDeleteEnabled + { + get + { + if ( ActiveViewer != null ) + { + return ActiveViewer.IsDeleteEnabled; + } + return false; + } + } + + private void AvaliabiltyOfOperationToolbarChanged() + { + RaisePropertyChanged( "IsWireframeEnabled" ); + RaisePropertyChanged( "IsShadingEnabled" ); + RaisePropertyChanged( "IsTransparencyEnabled" ); + RaisePropertyChanged( "IsColorEnabled" ); + RaisePropertyChanged( "IsMaterialEnabled" ); + RaisePropertyChanged( "IsDeleteEnabled" ); + } + + public void OnAvaliabiltyOfOperationsChanged( object sender, EventArgs e ) + { + AvaliabiltyOfOperationToolbarChanged(); + } + + private void OnViewerChanged( object sender, SelectionChangedEventArgs e ) + { + if ( e.RemovedItems.Count > 0 ) + { + WindowsFormsHost aHost = ( ( e.RemovedItems[0] as TabItem).Content ) as WindowsFormsHost; + if( aHost == null ) + { + return; + } + OCCViewer aViewer = aHost.Child as OCCViewer; + if( aViewer != null ) + { + aViewer.ZoomingFinished -= new EventHandler( OnZoomingFinished ); + aViewer.AvaliabiltyOfOperationsChanged -= new EventHandler( OnAvaliabiltyOfOperationsChanged ); + } + } + + if ( e.AddedItems.Count > 0 ) + { + WindowsFormsHost aHost = ( (e.AddedItems[0] as TabItem).Content ) as WindowsFormsHost; + if ( aHost == null ) + { + return; + } + OCCViewer aViewer = aHost.Child as OCCViewer; + if ( aViewer != null ) + { + aViewer.ZoomingFinished += new EventHandler( OnZoomingFinished ); + aViewer.AvaliabiltyOfOperationsChanged += new EventHandler( OnAvaliabiltyOfOperationsChanged ); + } + } + + AvaliabiltyOfOperationToolbarChanged(); + } + + private void OnPreviewKeyDown( object sender, KeyEventArgs args ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.OnKeyDown( args.Key ); + } + } + + private void OnPreviewKeyUp( object sender, KeyEventArgs args ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.OnKeyUp(); + } + } + } +} diff --git a/samples/CSharp/WPF/MaterialDlg.xaml b/samples/CSharp/WPF/MaterialDlg.xaml new file mode 100644 index 0000000000..ef50086bee --- /dev/null +++ b/samples/CSharp/WPF/MaterialDlg.xaml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/CSharp/WPF/MaterialDlg.xaml.cs b/samples/CSharp/WPF/MaterialDlg.xaml.cs new file mode 100644 index 0000000000..0a8bebb419 --- /dev/null +++ b/samples/CSharp/WPF/MaterialDlg.xaml.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + +namespace IE_WPF +{ + public enum Material + { + Brass, + Bronze, + Copper, + Gold, + Pewter, + Plaster, + Plastic, + Silver + } + + /// + /// Interaction logic for MaterialDlg.xaml + /// + public partial class MaterialDlg : Window + { + public MaterialDlg( OCCTProxy theView ) + { + this.InitializeComponent(); + + if ( theView == null ) + { + MessageBox.Show( "Fatal Error during the graphic initialisation", "Error!" ); + } + + View = theView; + + SetInitialState(); + } + + public OCCTProxy View { get; private set; } + + private void PlasterBtn_Checked( object sender, RoutedEventArgs e ) + { + View.SetMaterial( (int)Material.Plaster ); + View.UpdateCurrentViewer(); + } + + private void BrassBtn_Checked( object sender, RoutedEventArgs e ) + { + View.SetMaterial( (int)Material.Brass ); + View.UpdateCurrentViewer(); + } + + private void BronzeBtn_Checked( object sender, RoutedEventArgs e ) + { + View.SetMaterial( (int)Material.Bronze ); + View.UpdateCurrentViewer(); + } + + private void CopperBtn_Checked( object sender, RoutedEventArgs e ) + { + View.SetMaterial( (int)Material.Copper ); + View.UpdateCurrentViewer(); + } + + private void GoldBtn_Checked( object sender, RoutedEventArgs e ) + { + View.SetMaterial( (int)Material.Gold ); + View.UpdateCurrentViewer(); + } + + private void PewterBtn_Checked( object sender, RoutedEventArgs e ) + { + View.SetMaterial( (int)Material.Pewter ); + View.UpdateCurrentViewer(); + } + + private void PlasticBtn_Checked( object sender, RoutedEventArgs e ) + { + View.SetMaterial( (int)Material.Plastic ); + View.UpdateCurrentViewer(); + } + + private void SilverBtn_Checked( object sender, RoutedEventArgs e ) + { + View.SetMaterial( (int)Material.Silver ); + View.UpdateCurrentViewer(); + } + + private void SetInitialState() + { + // TODO + } + } +} \ No newline at end of file diff --git a/samples/CSharp/WPF/OCCViewer.cs b/samples/CSharp/WPF/OCCViewer.cs new file mode 100644 index 0000000000..649b6a413b --- /dev/null +++ b/samples/CSharp/WPF/OCCViewer.cs @@ -0,0 +1,840 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace IE_WPF +{ + public enum CurrentAction3d + { + CurAction3d_Nothing, + CurAction3d_DynamicZooming, + CurAction3d_WindowZooming, + CurAction3d_DynamicPanning, + CurAction3d_GlobalPanning, + CurAction3d_DynamicRotation + } + public enum CurrentPressedKey + { + CurPressedKey_Nothing, + CurPressedKey_Ctrl, + CurPressedKey_Shift + } + public enum ModelFormat + { + BREP, + CSFDB, + STEP, + IGES, + VRML, + STL, + IMAGE + } + + public enum DisplayMode + { + Wireframe, + Shading + } + + public class OCCViewer : System.Windows.Forms.Form + { + public event EventHandler ZoomingFinished; + protected void RaiseZoomingFinished() + { + if ( ZoomingFinished != null ) + { + ZoomingFinished( this, EventArgs.Empty ); + } + } + + public event EventHandler AvaliabiltyOfOperationsChanged; + protected void RaiseAvaliabiltyOfOperationsChanged() + { + if ( AvaliabiltyOfOperationsChanged != null ) + { + AvaliabiltyOfOperationsChanged( this, EventArgs.Empty ); + } + } + + public OCCTProxy View { get; private set; } + public CurrentAction3d CurrentMode { get; private set; } + private CurrentPressedKey CurrentPressedKey { get; set; } + private bool IsRectVisible { get; set; } + public bool DegenerateMode { get; private set; } + + public bool IsWireframeEnabled { get; private set; } + public bool IsShadingEnabled { get; private set; } + public bool IsTransparencyEnabled { get; private set; } + public bool IsColorEnabled { get; private set; } + public bool IsMaterialEnabled { get; private set; } + public bool IsDeleteEnabled { get; private set; } + + private float myCurZoom;// ~ Quantity_Factor + private int myXmin; + private int myYmin; + private int myXmax; + private int myYmax; + private int myRectDownX; + private int myRectDownY; + private int myButtonDownX; + private int myButtonDownY; + + private ContextMenu Popup { get; set; } + private MenuItem ContextWireframe; + private MenuItem ContextShading; + private MenuItem ContextColor; + private MenuItem ContextMaterial; + private MenuItem ContextDelete; + private MenuItem ContextBackground; + private MenuItem ContextTransparency; + + + public OCCViewer() + { + InitializeComponent(); + + View = new OCCTProxy(); + View.InitOCCTProxy(); + if ( !View.InitViewer( this.Handle ) ) + { + MessageBox.Show( "Fatal Error during the graphic initialisation", "Error!" ); + } + + CurrentMode = CurrentAction3d.CurAction3d_Nothing; + CurrentPressedKey = CurrentPressedKey.CurPressedKey_Nothing; + IsRectVisible = false; + DegenerateMode = true; + } + + private void InitializeComponent() + { + ControlBox = false; + TopLevel = false; + + this.ImeMode = System.Windows.Forms.ImeMode.NoControl; + + SizeChanged += new System.EventHandler( OnSizeChanged ); + Paint += new System.Windows.Forms.PaintEventHandler( OnPaint ); + + MouseDown += new System.Windows.Forms.MouseEventHandler( OnMouseDown ); + MouseUp += new System.Windows.Forms.MouseEventHandler( OnMouseUp ); + MouseMove += new System.Windows.Forms.MouseEventHandler( OnMouseMove ); + + Popup = new ContextMenu(); + ContextWireframe = new MenuItem(); + ContextShading = new MenuItem(); + ContextColor = new MenuItem(); + ContextMaterial = new MenuItem(); + ContextTransparency = new MenuItem(); + ContextDelete = new MenuItem(); + ContextBackground = new MenuItem(); + + ContextWireframe.Text = "Wireframe"; + ContextShading.Text = "Shading"; + ContextColor.Text = "Color"; + ContextMaterial.Text = "Material"; + ContextTransparency.Text = "Transparency"; + ContextDelete.Text = "Delete"; + ContextBackground.Text = "Background"; + + ContextWireframe.Click += new System.EventHandler( ContextWireframe_Click ); + ContextShading.Click += new System.EventHandler( ContextShading_Click ); + ContextColor.Click += new System.EventHandler( ContextColor_Click ); + ContextMaterial.Click += new System.EventHandler( ContextMaterial_Click ); + ContextTransparency.Click += new System.EventHandler( ContextTransparency_Click ); + ContextDelete.Click += new System.EventHandler( ContextDelete_Click ); + ContextBackground.Click += new System.EventHandler( ContextBackground_Click ); + + Popup.MenuItems.AddRange( new MenuItem[] { ContextWireframe, + ContextShading, + ContextColor, + ContextMaterial, + ContextTransparency, + ContextDelete, + ContextBackground } ); + Popup.Popup += new System.EventHandler( OnPopup ); + } + + private void OnPaint(object sender, System.Windows.Forms.PaintEventArgs e) + { + View.RedrawView(); + View.UpdateView(); + } + + private void OnSizeChanged(object sender, System.EventArgs e) + { + View.UpdateView(); + } + + public void ImportModel( ModelFormat theFormat ) + { + int aFormat = 10; + OpenFileDialog anOpenDialog = new OpenFileDialog(); + string aDataDir = ( (Environment.GetEnvironmentVariable("CASROOT")) + "\\..\\data" ); + string aFilter = ""; + + switch ( theFormat ) + { + case ModelFormat.BREP: + anOpenDialog.InitialDirectory = (aDataDir + "\\occ"); + aFormat = 0; + aFilter = "BREP Files (*.brep *.rle)|*.brep; *.rle"; + break; + case ModelFormat.CSFDB: + aFormat = 1; + aFilter = "CSFDB Files (*.csfdb)|*.csfdb"; + break; + case ModelFormat.STEP: + anOpenDialog.InitialDirectory = (aDataDir + "\\step"); + aFormat = 2; + aFilter = "STEP Files (*.stp *.step)|*.stp; *.step"; + break; + case ModelFormat.IGES: + anOpenDialog.InitialDirectory = (aDataDir + "\\iges"); + aFormat = 3; + aFilter = "IGES Files (*.igs *.iges)|*.igs; *.iges"; + break; + default: + break; + } + + anOpenDialog.Filter = aFilter + "|All files (*.*)|*.*"; + if (anOpenDialog.ShowDialog() == DialogResult.OK) + { + string aFileName = anOpenDialog.FileName; + if (aFileName == "") + { + return; + } + + Cursor = System.Windows.Forms.Cursors.WaitCursor; + if ( !View.TranslateModel( aFileName, aFormat, true ) ) + { + MessageBox.Show( "Cann't read this file", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning ); + } + Cursor = System.Windows.Forms.Cursors.Default; + } + View.ZoomAllView(); + } + + public void ExportModel( ModelFormat theFormat ) + { + int aFormat = 10; + SaveFileDialog saveDialog = new SaveFileDialog(); + string aDataDir = ( (Environment.GetEnvironmentVariable("CASROOT") ) + "\\..\\data" ); + string aFilter = ""; + + switch ( theFormat ) + { + case ModelFormat.BREP: + saveDialog.InitialDirectory = ( aDataDir + "\\occ" ); + aFormat = 0; + aFilter = "BREP Files (*.brep *.rle)|*.brep; *.rle"; + break; + case ModelFormat.CSFDB: + aFormat = 1; + aFilter = "CSFDB Files (*.csfdb)|*.csfdb"; + break; + case ModelFormat.STEP: + saveDialog.InitialDirectory = ( aDataDir + "\\step" ); + aFormat = 2; + aFilter = "STEP Files (*.stp *.step)|*.step; *.stp"; + break; + case ModelFormat.IGES: + saveDialog.InitialDirectory = ( aDataDir + "\\iges" ); + aFormat = 3; + aFilter = "IGES Files (*.igs *.iges)| *.iges; *.igs"; + break; + case ModelFormat.VRML: + saveDialog.InitialDirectory = ( aDataDir + "\\vrml" ); + aFormat = 4; + aFilter = "VRML Files (*.vrml)|*.vrml"; + break; + case ModelFormat.STL: + saveDialog.InitialDirectory = ( aDataDir + "\\stl" ); + aFormat = 5; + aFilter = "STL Files (*.stl)|*.stl"; + break; + case ModelFormat.IMAGE: + saveDialog.InitialDirectory = ( aDataDir + "\\images" ); + aFormat = 6; + aFilter = "Images Files (*.bmp)|*.bmp"; + break; + default: + break; + } + + saveDialog.Filter = aFilter; + if ( saveDialog.ShowDialog() == DialogResult.OK ) + { + string aFileName = saveDialog.FileName; + if ( aFileName == "" ) + { + return; + } + + Cursor = System.Windows.Forms.Cursors.WaitCursor; + if ( !View.TranslateModel( aFileName, aFormat, false ) ) + { + MessageBox.Show( "Can not write this file", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning ); + } + Cursor = System.Windows.Forms.Cursors.Default; + } + } + + public void FitAll() + { + View.ZoomAllView(); + } + + public void ZoomWindow() + { + CurrentMode = CurrentAction3d.CurAction3d_WindowZooming; + } + + public void DynamicZooming() + { + CurrentMode = CurrentAction3d.CurAction3d_DynamicZooming; + } + + public void DynamicPanning() + { + CurrentMode = CurrentAction3d.CurAction3d_DynamicPanning; + } + + public void GlobalPanning() + { + myCurZoom = View.Scale(); + CurrentMode = CurrentAction3d.CurAction3d_GlobalPanning; + } + + public void AxoView() + { + View.AxoView(); + } + + public void FrontView() + { + View.FrontView(); + } + + public void TopView() + { + View.TopView(); + } + + public void LeftView() + { + View.LeftView(); + } + + public void BackView() + { + View.BackView(); + } + + public void RightView() + { + View.RightView(); + } + + public void Reset() + { + View.Reset(); + } + + public void BottomView() + { + View.BottomView(); + } + + public void HiddenOff() + { + View.SetDegenerateModeOff(); + DegenerateMode = false; + } + + public void HiddenOn() + { + View.SetDegenerateModeOn(); + DegenerateMode = true; + } + + public void DynamicRotation() + { + CurrentMode = CurrentAction3d.CurAction3d_DynamicRotation; + } + + public void SelectionChanged() + { + switch ( View.DisplayMode() ) + { + case -1: + IsShadingEnabled = false; + IsWireframeEnabled = false; + break; + case 0: + IsWireframeEnabled = false; + IsShadingEnabled = true; + IsTransparencyEnabled = false; + break; + case 1: + IsWireframeEnabled = true; + IsShadingEnabled = false; + IsTransparencyEnabled = true; + break; + case 10: + IsWireframeEnabled = true; + IsShadingEnabled = true; + IsTransparencyEnabled = true; + break; + default: + break; + } + + if ( View.IsObjectSelected() ) + { + IsColorEnabled = true; + IsMaterialEnabled = true; + IsDeleteEnabled = true; + } + else + { + IsColorEnabled = false; + IsMaterialEnabled = false; + IsTransparencyEnabled = false; + IsDeleteEnabled = false; + } + + RaiseAvaliabiltyOfOperationsChanged(); + } + + public void ChangeColor( bool IsObjectColor ) + { + int r, g, b; + if ( IsObjectColor ) + { + r = View.GetObjColR(); + g = View.GetObjColG(); + b = View.GetObjColB(); + } + else + { + r = View.GetBGColR(); + g = View.GetBGColG(); + b = View.GetBGColB(); + } + System.Windows.Forms.ColorDialog ColDlg = new System.Windows.Forms.ColorDialog(); + ColDlg.Color = System.Drawing.Color.FromArgb( r, g, b ); + if ( ColDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK ) + { + System.Drawing.Color c = ColDlg.Color; + r = c.R; + g = c.G; + b = c.B; + if ( IsObjectColor ) + { + View.SetColor( r, g, b ); + } + else + { + View.SetBackgroundColor( r, g, b ); + } + } + View.UpdateCurrentViewer(); + } + + public void Wireframe() + { + View.SetDisplayMode( (int)DisplayMode.Wireframe ); + View.UpdateCurrentViewer(); + + SelectionChanged(); + RaiseZoomingFinished(); + } + + public void Shading() + { + View.SetDisplayMode( (int)DisplayMode.Shading ); + View.UpdateCurrentViewer(); + + SelectionChanged(); + RaiseZoomingFinished(); + } + + public void Color() + { + ChangeColor( true ); + } + + public void Background() + { + ChangeColor( false ); + } + + public void Material() + { + MaterialDlg aDlg = new MaterialDlg( View ); + aDlg.ShowDialog(); + } + + public void Transparency() + { + TransparencyDialog dlg = new TransparencyDialog(); + dlg.View = View; + dlg.ShowDialog( this ); + } + + public void Delete() + { + View.EraseObjects(); + } + + public void OnKeyDown( System.Windows.Input.Key theKey ) + { + if ( theKey == System.Windows.Input.Key.LeftShift || + theKey == System.Windows.Input.Key.RightShift ) + { + CurrentPressedKey = CurrentPressedKey.CurPressedKey_Shift; + } + else if (theKey == System.Windows.Input.Key.LeftCtrl || + theKey == System.Windows.Input.Key.RightCtrl ) + { + CurrentPressedKey = CurrentPressedKey.CurPressedKey_Ctrl; + } + } + + public void OnKeyUp() + { + CurrentPressedKey = CurrentPressedKey.CurPressedKey_Nothing; + } + + protected void MultiDragEvent( int x, int y, int theState ) + { + if ( theState == -1 ) //mouse is down + { + myButtonDownX = x; + myButtonDownY = y; + } + else if ( theState == 1) //mouse is up + { + View.ShiftSelect( Math.Min( myButtonDownX, x ), Math.Min( myButtonDownY, y ), + Math.Max( myButtonDownX, x ), Math.Max( myButtonDownY, y ) ); + } + } + + protected void DragEvent( int x, int y, int theState ) + { + if ( theState == -1 ) //mouse is down + { + myButtonDownX = x; + myButtonDownY = y; + } + else if ( theState == 1 ) //mouse is up + { + View.Select( Math.Min( myButtonDownX, x ), Math.Min( myButtonDownY, y ), + Math.Max( myButtonDownX, x ), Math.Max( myButtonDownY, y ) ); + } + } + + private void DrawRectangle( bool draw ) + { + System.Drawing.Graphics gr = System.Drawing.Graphics.FromHwnd(Handle); + System.Drawing.Pen p = null; + if ( IsRectVisible || !draw )//erase the rect + { + int r = View.GetBGColR(); + int g = View.GetBGColG(); + int b = View.GetBGColB(); + p = new System.Drawing.Pen( System.Drawing.Color.FromArgb(r, g, b) ); + IsRectVisible = false; + View.UpdateView(); + } + else if ( draw ) + { + p = new System.Drawing.Pen( System.Drawing.Color.White ); + IsRectVisible = true; + } + if ( p == null ) + { + return; + } + int x = Math.Min( myXmin, myXmax ); + int y = Math.Min( myYmin, myYmax ); + gr.DrawRectangle( p, x, y, Math.Abs(myXmax - myXmin), Math.Abs(myYmax - myYmin) ); + myRectDownX = Math.Max( myXmin, myXmax ); + myRectDownY = Math.Max( myYmin, myYmax ); + } + + private void OnMouseDown( object sender, System.Windows.Forms.MouseEventArgs e ) + { + if ( e.Button == MouseButtons.Left ) + { + myXmin = e.X; + myXmax = e.X; + myYmin = e.Y; + myYmax = e.Y; + if ( CurrentPressedKey == CurrentPressedKey.CurPressedKey_Ctrl ) + { + // start the dinamic zooming.... + CurrentMode = CurrentAction3d.CurAction3d_DynamicZooming; + } + else + { + switch ( CurrentMode ) + { + case CurrentAction3d.CurAction3d_Nothing: + if ( CurrentPressedKey == CurrentPressedKey.CurPressedKey_Shift ) + { + MultiDragEvent( myXmax, myYmax, -1 ); + } + else + { + DragEvent( myXmax, myYmax, -1 ); + } + break; + case CurrentAction3d.CurAction3d_DynamicRotation: + if ( !DegenerateMode ) + { + View.SetDegenerateModeOn(); + } + View.StartRotation( e.X, e.Y ); + break; + case CurrentAction3d.CurAction3d_WindowZooming: + Cursor = Cursors.Hand; + break; + default: + break; + } + } + } + else if ( e.Button == MouseButtons.Right ) + { + if ( CurrentPressedKey == CurrentPressedKey.CurPressedKey_Ctrl ) + { + if ( !DegenerateMode ) + { + View.SetDegenerateModeOn(); + } + View.StartRotation( e.X, e.Y ); + } + else + { + Popup.Show( this, new System.Drawing.Point( e.X, e.Y ) ); + } + } + } + + private void OnMouseUp( object sender, System.Windows.Forms.MouseEventArgs e ) + { + if ( e.Button == MouseButtons.Left ) + { + if ( CurrentPressedKey == CurrentPressedKey.CurPressedKey_Ctrl ) + { + return; + } + switch ( CurrentMode ) + { + case CurrentAction3d.CurAction3d_Nothing: + if ( e.X == myXmin && e.Y == myYmin ) + { + myXmax = e.X; + myYmax = e.Y; + if ( CurrentPressedKey == CurrentPressedKey.CurPressedKey_Shift ) + { + View.ShiftSelect(); + } + else + { + View.Select(); + } + } + else + { + myXmax = e.X; + myYmax = e.Y; + DrawRectangle( false ); + if ( CurrentPressedKey == CurrentPressedKey.CurPressedKey_Shift ) + { + MultiDragEvent( myXmax, myYmax, 1 ); + } + else + { + DragEvent( myXmax, myYmax, 1 ); + } + } + break; + case CurrentAction3d.CurAction3d_DynamicZooming: + CurrentMode = CurrentAction3d.CurAction3d_Nothing; + break; + case CurrentAction3d.CurAction3d_WindowZooming: + myXmax = e.X; + myYmax = e.Y; + DrawRectangle( false ); + int ValZWMin = 1; + if ( Math.Abs(myXmax - myXmin) > ValZWMin && + Math.Abs(myXmax - myYmax) > ValZWMin ) + { + View.WindowFitAll( myXmin, myYmin, myXmax, myYmax ); + } + Cursor = Cursors.Arrow; + RaiseZoomingFinished(); + CurrentMode = CurrentAction3d.CurAction3d_Nothing; + break; + case CurrentAction3d.CurAction3d_DynamicPanning: + CurrentMode = CurrentAction3d.CurAction3d_Nothing; + break; + case CurrentAction3d.CurAction3d_GlobalPanning: + View.Place( e.X, e.Y, myCurZoom ); + CurrentMode = CurrentAction3d.CurAction3d_Nothing; + break; + case CurrentAction3d.CurAction3d_DynamicRotation: + CurrentMode = CurrentAction3d.CurAction3d_Nothing; + if ( !DegenerateMode ) + { + View.SetDegenerateModeOff(); + } + else + { + View.SetDegenerateModeOn(); + } + break; + default: + break; + } + } + else if ( e.Button == MouseButtons.Right ) + { + if ( !DegenerateMode ) + { + View.SetDegenerateModeOff(); + } + else + { + View.SetDegenerateModeOn(); + } + } + + SelectionChanged(); + } + + private void OnMouseMove( object sender, System.Windows.Forms.MouseEventArgs e ) + { + if ( e.Button == MouseButtons.Left ) //left button is pressed + { + if ( CurrentPressedKey == CurrentPressedKey.CurPressedKey_Ctrl ) + { + View.Zoom(myXmax, myYmax, e.X, e.Y); + myXmax = e.X; + myYmax = e.Y; + } + else + { + switch ( CurrentMode ) + { + case CurrentAction3d.CurAction3d_Nothing: + DrawRectangle( false ); + myXmax = e.X; + myYmax = e.Y; + DrawRectangle( true ); + break; + case CurrentAction3d.CurAction3d_DynamicZooming: + View.Zoom( myXmax, myYmax, e.X, e.Y ); + myXmax = e.X; + myYmax = e.Y; + break; + case CurrentAction3d.CurAction3d_WindowZooming: + DrawRectangle( false ); + myXmax = e.X; + myYmax = e.Y; + DrawRectangle( true );//add brush here + break; + case CurrentAction3d.CurAction3d_DynamicPanning: + View.Pan( e.X - myXmax, myYmax - e.Y ); + myXmax = e.X; + myYmax = e.Y; + break; + case CurrentAction3d.CurAction3d_GlobalPanning: + break; + case CurrentAction3d.CurAction3d_DynamicRotation: + View.Rotation( e.X, e.Y ); + View.RedrawView(); + break; + default: + break; + } + } + } + else if ( e.Button == MouseButtons.Middle ) //middle button is pressed + { + if ( CurrentPressedKey == CurrentPressedKey.CurPressedKey_Ctrl ) + { + View.Pan( e.X - myXmax, myYmax - e.Y ); + myXmax = e.X; + myYmax = e.Y; + } + } + else if ( e.Button == MouseButtons.Right ) //right button is pressed + { + if ( CurrentPressedKey == CurrentPressedKey.CurPressedKey_Ctrl) + { + View.Rotation( e.X, e.Y ); + } + } + else // no buttons are pressed + { + myXmax = e.X; + myYmax = e.Y; + View.MoveTo( e.X, e.Y ); + } + } + + private void OnPopup( object sender, System.EventArgs e ) + { + ContextWireframe.Enabled = IsWireframeEnabled; + ContextShading.Enabled = IsShadingEnabled; + ContextColor.Enabled = IsColorEnabled; + ContextMaterial.Enabled = IsMaterialEnabled; + ContextDelete.Enabled = IsDeleteEnabled; + ContextTransparency.Enabled = IsTransparencyEnabled; + ContextBackground.Enabled = true; + } + + private void ContextWireframe_Click( object sender, System.EventArgs e ) + { + Wireframe(); + } + + private void ContextShading_Click( object sender, System.EventArgs e ) + { + Shading(); + } + + private void ContextColor_Click( object sender, System.EventArgs e ) + { + Color(); + } + + private void ContextMaterial_Click( object sender, System.EventArgs e ) + { + Material(); + } + + private void ContextTransparency_Click( object sender, System.EventArgs e ) + { + Transparency(); + } + + private void ContextDelete_Click( object sender, System.EventArgs e ) + { + Delete(); + } + + private void ContextBackground_Click( object sender, System.EventArgs e ) + { + Background(); + } + } +} diff --git a/samples/CSharp/WPF/Properties/AssemblyInfo.cs b/samples/CSharp/WPF/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..02445ca672 --- /dev/null +++ b/samples/CSharp/WPF/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("IE")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("IE")] +[assembly: AssemblyCopyright("Copyright © 2013")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/samples/CSharp/WPF/Properties/Resources.Designer.cs b/samples/CSharp/WPF/Properties/Resources.Designer.cs new file mode 100644 index 0000000000..5855aaffdf --- /dev/null +++ b/samples/CSharp/WPF/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.5472 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace IE_WPF.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("IE_WPF.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/samples/CSharp/WPF/Properties/Resources.resx b/samples/CSharp/WPF/Properties/Resources.resx new file mode 100644 index 0000000000..af7dbebbac --- /dev/null +++ b/samples/CSharp/WPF/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/samples/CSharp/WPF/Properties/Settings.Designer.cs b/samples/CSharp/WPF/Properties/Settings.Designer.cs new file mode 100644 index 0000000000..7228f90b91 --- /dev/null +++ b/samples/CSharp/WPF/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.5472 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace IE_WPF.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/samples/CSharp/WPF/Properties/Settings.settings b/samples/CSharp/WPF/Properties/Settings.settings new file mode 100644 index 0000000000..033d7a5e9e --- /dev/null +++ b/samples/CSharp/WPF/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/samples/CSharp/WPF/Simple Styles.xaml b/samples/CSharp/WPF/Simple Styles.xaml new file mode 100644 index 0000000000..b130cea606 --- /dev/null +++ b/samples/CSharp/WPF/Simple Styles.xaml @@ -0,0 +1,1134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/CSharp/WPF/TransparencyDialog.cs b/samples/CSharp/WPF/TransparencyDialog.cs new file mode 100644 index 0000000000..0b328d5cc9 --- /dev/null +++ b/samples/CSharp/WPF/TransparencyDialog.cs @@ -0,0 +1,108 @@ +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; + +namespace IE_WPF +{ + /// + /// Summary description for TransparencyDialog. + /// + public class TransparencyDialog : System.Windows.Forms.Form + { + private System.Windows.Forms.NumericUpDown MyTransparency; + /// + /// Required designer variable. + /// + private System.ComponentModel.Container components = null; + private OCCTProxy myView; + + public TransparencyDialog() + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + // + // TODO: Add any constructor code after InitializeComponent call + // + myView = null; + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(TransparencyDialog)); + this.MyTransparency = new System.Windows.Forms.NumericUpDown(); + ((System.ComponentModel.ISupportInitialize)(this.MyTransparency)).BeginInit(); + this.SuspendLayout(); + // + // MyTransparency + // + this.MyTransparency.Location = new System.Drawing.Point(16, 16); + this.MyTransparency.Maximum = new System.Decimal(new int[] { + 10, + 0, + 0, + 0}); + this.MyTransparency.Name = "MyTransparency"; + this.MyTransparency.Size = new System.Drawing.Size(96, 20); + this.MyTransparency.TabIndex = 0; + this.MyTransparency.ValueChanged += new System.EventHandler(this.MyTransparency_ValueChanged); + // + // TransparencyDialog + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(128, 53); + this.Controls.Add(this.MyTransparency); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "TransparencyDialog"; + this.Text = "TransparencyDialog"; + ((System.ComponentModel.ISupportInitialize)(this.MyTransparency)).EndInit(); + this.ResumeLayout(false); + + } + #endregion + + private void MyTransparency_ValueChanged(object sender, System.EventArgs e) + { + if (this.myView == null) + return; + int transp = (int)this.MyTransparency.Value; + this.myView.SetTransparency(transp); + } + + public OCCTProxy View + { + set + { + this.myView = value; + } + } + + } +} diff --git a/samples/CSharp/IE/TransparencyDialog.resx b/samples/CSharp/WPF/TransparencyDialog.resx old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/TransparencyDialog.resx rename to samples/CSharp/WPF/TransparencyDialog.resx diff --git a/samples/CSharp/IE/res/MainFrame.ico b/samples/CSharp/WPF/res/MainFrame.ico old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/res/MainFrame.ico rename to samples/CSharp/WPF/res/MainFrame.ico diff --git a/samples/CSharp/IE/res/document.png b/samples/CSharp/WPF/res/document.png old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/res/document.png rename to samples/CSharp/WPF/res/document.png diff --git a/samples/CSharp/IE/res/help.png b/samples/CSharp/WPF/res/help.png old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/res/help.png rename to samples/CSharp/WPF/res/help.png diff --git a/samples/CSharp/IE/res/lamp.png b/samples/CSharp/WPF/res/lamp.png old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/res/lamp.png rename to samples/CSharp/WPF/res/lamp.png diff --git a/samples/CSharp/IE/res/new.png b/samples/CSharp/WPF/res/new.png old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/res/new.png rename to samples/CSharp/WPF/res/new.png diff --git a/samples/CSharp/IE/res/occ_logo.bmp b/samples/CSharp/WPF/res/occ_logo.bmp old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/res/occ_logo.bmp rename to samples/CSharp/WPF/res/occ_logo.bmp diff --git a/samples/CSharp/IE/res/tool_color.png b/samples/CSharp/WPF/res/tool_color.png old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/res/tool_color.png rename to samples/CSharp/WPF/res/tool_color.png diff --git a/samples/CSharp/IE/res/tool_delete.png b/samples/CSharp/WPF/res/tool_delete.png old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/res/tool_delete.png rename to samples/CSharp/WPF/res/tool_delete.png diff --git a/samples/CSharp/IE/res/tool_material.png b/samples/CSharp/WPF/res/tool_material.png old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/res/tool_material.png rename to samples/CSharp/WPF/res/tool_material.png diff --git a/samples/CSharp/IE/res/tool_shading.png b/samples/CSharp/WPF/res/tool_shading.png old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/res/tool_shading.png rename to samples/CSharp/WPF/res/tool_shading.png diff --git a/samples/CSharp/IE/res/tool_transparency.png b/samples/CSharp/WPF/res/tool_transparency.png old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/res/tool_transparency.png rename to samples/CSharp/WPF/res/tool_transparency.png diff --git a/samples/CSharp/IE/res/tool_wireframe.png b/samples/CSharp/WPF/res/tool_wireframe.png old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/res/tool_wireframe.png rename to samples/CSharp/WPF/res/tool_wireframe.png diff --git a/samples/CSharp/IE/res/view_axo.png b/samples/CSharp/WPF/res/view_axo.png old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/res/view_axo.png rename to samples/CSharp/WPF/res/view_axo.png diff --git a/samples/CSharp/IE/res/view_back.png b/samples/CSharp/WPF/res/view_back.png old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/res/view_back.png rename to samples/CSharp/WPF/res/view_back.png diff --git a/samples/CSharp/IE/res/view_bottom.png b/samples/CSharp/WPF/res/view_bottom.png old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/res/view_bottom.png rename to samples/CSharp/WPF/res/view_bottom.png diff --git a/samples/CSharp/IE/res/view_comp_off.png b/samples/CSharp/WPF/res/view_comp_off.png old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/res/view_comp_off.png rename to samples/CSharp/WPF/res/view_comp_off.png diff --git a/samples/CSharp/IE/res/view_comp_on.png b/samples/CSharp/WPF/res/view_comp_on.png old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/res/view_comp_on.png rename to samples/CSharp/WPF/res/view_comp_on.png diff --git a/samples/CSharp/IE/res/view_fitall.png b/samples/CSharp/WPF/res/view_fitall.png old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/res/view_fitall.png rename to samples/CSharp/WPF/res/view_fitall.png diff --git a/samples/CSharp/IE/res/view_fitarea.png b/samples/CSharp/WPF/res/view_fitarea.png old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/res/view_fitarea.png rename to samples/CSharp/WPF/res/view_fitarea.png diff --git a/samples/CSharp/IE/res/view_front.png b/samples/CSharp/WPF/res/view_front.png old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/res/view_front.png rename to samples/CSharp/WPF/res/view_front.png diff --git a/samples/CSharp/IE/res/view_glpan.png b/samples/CSharp/WPF/res/view_glpan.png old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/res/view_glpan.png rename to samples/CSharp/WPF/res/view_glpan.png diff --git a/samples/CSharp/IE/res/view_left.png b/samples/CSharp/WPF/res/view_left.png old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/res/view_left.png rename to samples/CSharp/WPF/res/view_left.png diff --git a/samples/CSharp/IE/res/view_pan.png b/samples/CSharp/WPF/res/view_pan.png old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/res/view_pan.png rename to samples/CSharp/WPF/res/view_pan.png diff --git a/samples/CSharp/IE/res/view_reset.png b/samples/CSharp/WPF/res/view_reset.png old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/res/view_reset.png rename to samples/CSharp/WPF/res/view_reset.png diff --git a/samples/CSharp/IE/res/view_right.png b/samples/CSharp/WPF/res/view_right.png old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/res/view_right.png rename to samples/CSharp/WPF/res/view_right.png diff --git a/samples/CSharp/IE/res/view_rotate.png b/samples/CSharp/WPF/res/view_rotate.png old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/res/view_rotate.png rename to samples/CSharp/WPF/res/view_rotate.png diff --git a/samples/CSharp/IE/res/view_top.png b/samples/CSharp/WPF/res/view_top.png old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/res/view_top.png rename to samples/CSharp/WPF/res/view_top.png diff --git a/samples/CSharp/IE/res/view_zoom.png b/samples/CSharp/WPF/res/view_zoom.png old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/res/view_zoom.png rename to samples/CSharp/WPF/res/view_zoom.png diff --git a/samples/CSharp/WinForms/AboutDialog.cs b/samples/CSharp/WinForms/AboutDialog.cs new file mode 100644 index 0000000000..73c98a726b --- /dev/null +++ b/samples/CSharp/WinForms/AboutDialog.cs @@ -0,0 +1,157 @@ +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; + +namespace IE_WinForms +{ + /// + /// Summary description for AboutDialog. + /// + public class AboutDialog : System.Windows.Forms.Form + { + private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label myVersion; + /// + /// Required designer variable. + /// + private System.ComponentModel.Container components = null; + + public AboutDialog() + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + // + // Create OCCT proxy object and get OCCT version + // + OCCTProxy t = new OCCTProxy(); + t.InitOCCTProxy(); + float version = t.GetOCCVersion(); + this.myVersion.Text = this.myVersion.Text + version; + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AboutDialog)); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.button1 = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.myVersion = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.SuspendLayout(); + // + // pictureBox1 + // + this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image"))); + this.pictureBox1.Location = new System.Drawing.Point(59, 64); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(196, 102); + this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; + this.pictureBox1.TabIndex = 0; + this.pictureBox1.TabStop = false; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(96, 248); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(128, 24); + this.button1.TabIndex = 1; + this.button1.Text = "OK"; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // label1 + // + this.label1.Location = new System.Drawing.Point(16, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(288, 24); + this.label1.TabIndex = 2; + this.label1.Text = "Import/Export Sample,"; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // myVersion + // + this.myVersion.Location = new System.Drawing.Point(16, 32); + this.myVersion.Name = "myVersion"; + this.myVersion.Size = new System.Drawing.Size(288, 16); + this.myVersion.TabIndex = 3; + this.myVersion.Text = "Open CASCADE Technology "; + this.myVersion.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label3 + // + this.label3.Location = new System.Drawing.Point(24, 168); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(280, 23); + this.label3.TabIndex = 4; + this.label3.Text = "Copyright (C) 2004-2013, Open CASCADE S.A.S"; + this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label4 + // + this.label4.Location = new System.Drawing.Point(8, 200); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(296, 24); + this.label4.TabIndex = 5; + this.label4.Text = "http://www.opencascade.com"; + this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // AboutDialog + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(312, 285); + this.ControlBox = false; + this.Controls.Add(this.label4); + this.Controls.Add(this.label3); + this.Controls.Add(this.myVersion); + this.Controls.Add(this.label1); + this.Controls.Add(this.button1); + this.Controls.Add(this.pictureBox1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "AboutDialog"; + this.Text = "About Import/Export Sample"; + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + #endregion + + private void button1_Click(object sender, System.EventArgs e) + { + this.Close(); + } + } +} diff --git a/samples/CSharp/IE/AboutDialog.resx b/samples/CSharp/WinForms/AboutDialog.resx old mode 100755 new mode 100644 similarity index 94% rename from samples/CSharp/IE/AboutDialog.resx rename to samples/CSharp/WinForms/AboutDialog.resx index 533c15ade8..0406147f1f --- a/samples/CSharp/IE/AboutDialog.resx +++ b/samples/CSharp/WinForms/AboutDialog.resx @@ -3,7 +3,7 @@ + + + + + + + + + + + + + + + + + + - + + @@ -89,24 +109,16 @@ text/microsoft-resx - 1.3 + 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - False - - - Private - - - Private - - + + Qk1W5AAAAAAAADYAAAAoAAAAwgAAAGQAAAABABgAAAAAAAAAAAAgLgAAIC4AAAAAAAAAAAAA//////// //////////////////////////////////////////////////////////////////////////////// @@ -1085,82 +1097,7 @@ ////////////////AAA= - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - (Default) - - - AboutDialog - - - False - - - 8, 8 - - - True - - - 80 - - - True - - - Private - - - False - - + AAABAAEAMDAAAAAAAACoDgAAFgAAACgAAAAwAAAAYAAAAAEACAAAAAAAgAoAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAMDcwADwyqYABAQEAAgICAAMDAwAERERABYW diff --git a/samples/CSharp/IE/App.ico b/samples/CSharp/WinForms/App.ico old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/App.ico rename to samples/CSharp/WinForms/App.ico diff --git a/samples/CSharp/IE/AssemblyInfo.cs b/samples/CSharp/WinForms/AssemblyInfo.cs old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/AssemblyInfo.cs rename to samples/CSharp/WinForms/AssemblyInfo.cs diff --git a/samples/CSharp/WinForms/Form1.cs b/samples/CSharp/WinForms/Form1.cs new file mode 100644 index 0000000000..8627c9f0b1 --- /dev/null +++ b/samples/CSharp/WinForms/Form1.cs @@ -0,0 +1,1088 @@ +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using System.Data; + +namespace IE_WinForms +{ + /// + /// Summary description for Form1. + /// + public class Form1 : System.Windows.Forms.Form + { + private System.Windows.Forms.MainMenu mainMenu1; + private System.Windows.Forms.MenuItem FileNew; + private System.Windows.Forms.MenuItem FileClose; + private System.Windows.Forms.MenuItem FileExport; + private System.Windows.Forms.MenuItem FileImport; + private System.Windows.Forms.MenuItem ImportBRep; + private System.Windows.Forms.MenuItem ExportImage; + private System.Windows.Forms.MenuItem File; + private System.Windows.Forms.MenuItem Window; + private System.Windows.Forms.ToolBarButton New; + private System.Windows.Forms.ImageList imageList1; + private System.Windows.Forms.ToolBarButton About; + private System.Windows.Forms.StatusBar myStatusBar; + private System.Windows.Forms.MenuItem ImportIges; + private System.Windows.Forms.MenuItem ImportStep; + private System.Windows.Forms.MenuItem ExportBRep; + private System.Windows.Forms.MenuItem ExportIges; + private System.Windows.Forms.MenuItem ExportStep; + private System.Windows.Forms.MenuItem ExportStl; + private System.Windows.Forms.MenuItem ExportVrml; + private System.ComponentModel.IContainer components; + private System.Windows.Forms.MenuItem menuItem1; + private System.Windows.Forms.MenuItem menuItem2; + private System.Windows.Forms.MenuItem menuItem3; + private System.Windows.Forms.MenuItem View; + private System.Windows.Forms.MenuItem Help; + private System.Windows.Forms.MenuItem HelpAbout; + private System.Windows.Forms.MenuItem ViewToolbar; + private System.Windows.Forms.MenuItem ViewStatusBar; + private System.Windows.Forms.MenuItem menuItem4; + private System.Windows.Forms.MenuItem WindowCascade; + private System.Windows.Forms.MenuItem WindowTile; + + protected IE_WinForms.ModelFormat myModelFormat; + private System.Windows.Forms.ToolBarButton wireframe; + private System.Windows.Forms.ToolBarButton shading; + private System.Windows.Forms.ToolBarButton toolBarButton1; + private System.Windows.Forms.ToolBarButton color; + private System.Windows.Forms.ToolBarButton transparency; + private System.Windows.Forms.ToolBarButton delete; + private System.Windows.Forms.ToolBarButton material; + private System.Windows.Forms.ToolBarButton ZoomAll; + private System.Windows.Forms.ToolBarButton ZoomWin; + private System.Windows.Forms.ToolBarButton ZoomProg; + private System.Windows.Forms.ToolBarButton Pan; + private System.Windows.Forms.ToolBarButton PanGlo; + private System.Windows.Forms.ToolBarButton Front; + private System.Windows.Forms.ToolBarButton Back; + private System.Windows.Forms.ToolBarButton TOP; + private System.Windows.Forms.ToolBarButton BOTTOM; + private System.Windows.Forms.ToolBarButton RIGHT; + private System.Windows.Forms.ToolBarButton LEFT; + private System.Windows.Forms.ToolBarButton Axo; + private System.Windows.Forms.ToolBarButton Rot; + private System.Windows.Forms.ToolBarButton Reset; + private System.Windows.Forms.ToolBarButton HlrOn; + private System.Windows.Forms.ToolBarButton HlrOff; + private System.Windows.Forms.ToolBar toolBarTool; + private System.Windows.Forms.ToolBar toolBarView; + protected static int myNbOfChildren; + + public Form1() + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + // + IE_WinForms.Form1.myNbOfChildren = 0; + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader(); + System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1)); + this.mainMenu1 = new System.Windows.Forms.MainMenu(); + this.File = new System.Windows.Forms.MenuItem(); + this.FileNew = new System.Windows.Forms.MenuItem(); + this.FileExport = new System.Windows.Forms.MenuItem(); + this.ImportBRep = new System.Windows.Forms.MenuItem(); + this.ImportIges = new System.Windows.Forms.MenuItem(); + this.ImportStep = new System.Windows.Forms.MenuItem(); + this.FileImport = new System.Windows.Forms.MenuItem(); + this.ExportBRep = new System.Windows.Forms.MenuItem(); + this.ExportIges = new System.Windows.Forms.MenuItem(); + this.ExportStep = new System.Windows.Forms.MenuItem(); + this.ExportStl = new System.Windows.Forms.MenuItem(); + this.ExportVrml = new System.Windows.Forms.MenuItem(); + this.menuItem3 = new System.Windows.Forms.MenuItem(); + this.ExportImage = new System.Windows.Forms.MenuItem(); + this.FileClose = new System.Windows.Forms.MenuItem(); + this.menuItem2 = new System.Windows.Forms.MenuItem(); + this.menuItem1 = new System.Windows.Forms.MenuItem(); + this.View = new System.Windows.Forms.MenuItem(); + this.ViewToolbar = new System.Windows.Forms.MenuItem(); + this.ViewStatusBar = new System.Windows.Forms.MenuItem(); + this.Window = new System.Windows.Forms.MenuItem(); + this.menuItem4 = new System.Windows.Forms.MenuItem(); + this.WindowCascade = new System.Windows.Forms.MenuItem(); + this.WindowTile = new System.Windows.Forms.MenuItem(); + this.Help = new System.Windows.Forms.MenuItem(); + this.HelpAbout = new System.Windows.Forms.MenuItem(); + this.toolBarTool = new System.Windows.Forms.ToolBar(); + this.New = new System.Windows.Forms.ToolBarButton(); + this.About = new System.Windows.Forms.ToolBarButton(); + this.toolBarButton1 = new System.Windows.Forms.ToolBarButton(); + this.wireframe = new System.Windows.Forms.ToolBarButton(); + this.shading = new System.Windows.Forms.ToolBarButton(); + this.color = new System.Windows.Forms.ToolBarButton(); + this.material = new System.Windows.Forms.ToolBarButton(); + this.transparency = new System.Windows.Forms.ToolBarButton(); + this.delete = new System.Windows.Forms.ToolBarButton(); + this.imageList1 = new System.Windows.Forms.ImageList(this.components); + this.myStatusBar = new System.Windows.Forms.StatusBar(); + this.toolBarView = new System.Windows.Forms.ToolBar(); + this.ZoomAll = new System.Windows.Forms.ToolBarButton(); + this.ZoomWin = new System.Windows.Forms.ToolBarButton(); + this.ZoomProg = new System.Windows.Forms.ToolBarButton(); + this.Pan = new System.Windows.Forms.ToolBarButton(); + this.PanGlo = new System.Windows.Forms.ToolBarButton(); + this.Front = new System.Windows.Forms.ToolBarButton(); + this.Back = new System.Windows.Forms.ToolBarButton(); + this.TOP = new System.Windows.Forms.ToolBarButton(); + this.BOTTOM = new System.Windows.Forms.ToolBarButton(); + this.LEFT = new System.Windows.Forms.ToolBarButton(); + this.RIGHT = new System.Windows.Forms.ToolBarButton(); + this.Axo = new System.Windows.Forms.ToolBarButton(); + this.Rot = new System.Windows.Forms.ToolBarButton(); + this.Reset = new System.Windows.Forms.ToolBarButton(); + this.HlrOn = new System.Windows.Forms.ToolBarButton(); + this.HlrOff = new System.Windows.Forms.ToolBarButton(); + this.SuspendLayout(); + // + // mainMenu1 + // + this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.File, + this.View, + this.Window, + this.Help}); + // + // File + // + this.File.Index = 0; + this.File.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.FileNew, + this.FileExport, + this.FileImport, + this.FileClose, + this.menuItem2, + this.menuItem1}); + this.File.Text = "&File"; + this.File.Popup += new System.EventHandler(this.File_Popup); + // + // FileNew + // + this.FileNew.Index = 0; + this.FileNew.Text = "&New"; + this.FileNew.Click += new System.EventHandler(this.menuItem2_Click); + // + // FileExport + // + this.FileExport.Index = 1; + this.FileExport.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.ImportBRep, + this.ImportIges, + this.ImportStep}); + this.FileExport.Text = "&Import"; + this.FileExport.Visible = false; + // + // ImportBRep + // + this.ImportBRep.Index = 0; + this.ImportBRep.Text = "&BRep ..."; + this.ImportBRep.Click += new System.EventHandler(this.ImportBRep_Click); + // + // ImportIges + // + this.ImportIges.Index = 1; + this.ImportIges.Text = "&Iges ..."; + this.ImportIges.Click += new System.EventHandler(this.ImportIges_Click); + // + // ImportStep + // + this.ImportStep.Index = 2; + this.ImportStep.Text = "&Step ..."; + this.ImportStep.Click += new System.EventHandler(this.ImportStep_Click); + // + // FileImport + // + this.FileImport.Index = 2; + this.FileImport.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.ExportBRep, + this.ExportIges, + this.ExportStep, + this.ExportStl, + this.ExportVrml, + this.menuItem3, + this.ExportImage}); + this.FileImport.Text = "&Export"; + this.FileImport.Visible = false; + this.FileImport.Popup += new System.EventHandler(this.FileImport_Popup); + // + // ExportBRep + // + this.ExportBRep.Enabled = false; + this.ExportBRep.Index = 0; + this.ExportBRep.Text = "&BRep ..."; + this.ExportBRep.Click += new System.EventHandler(this.ExportBRep_Click); + // + // ExportIges + // + this.ExportIges.Enabled = false; + this.ExportIges.Index = 1; + this.ExportIges.Text = "&Iges ..."; + this.ExportIges.Click += new System.EventHandler(this.ExportIges_Click); + // + // ExportStep + // + this.ExportStep.Enabled = false; + this.ExportStep.Index = 2; + this.ExportStep.Text = "&Step ..."; + this.ExportStep.Click += new System.EventHandler(this.ExportStep_Click); + // + // ExportStl + // + this.ExportStl.Enabled = false; + this.ExportStl.Index = 3; + this.ExportStl.Text = "&Stl ..."; + this.ExportStl.Click += new System.EventHandler(this.ExportStl_Click); + // + // ExportVrml + // + this.ExportVrml.Enabled = false; + this.ExportVrml.Index = 4; + this.ExportVrml.Text = "&Vrml ..."; + this.ExportVrml.Click += new System.EventHandler(this.ExportVrml_Click); + // + // menuItem3 + // + this.menuItem3.Index = 5; + this.menuItem3.Text = "-"; + // + // ExportImage + // + this.ExportImage.Index = 6; + this.ExportImage.Text = "Image ..."; + this.ExportImage.Click += new System.EventHandler(this.ExportImage_Click); + // + // FileClose + // + this.FileClose.Enabled = false; + this.FileClose.Index = 3; + this.FileClose.Text = "&Close"; + this.FileClose.Click += new System.EventHandler(this.menuItem3_Click); + // + // menuItem2 + // + this.menuItem2.Index = 4; + this.menuItem2.Text = "-"; + // + // menuItem1 + // + this.menuItem1.Index = 5; + this.menuItem1.Text = "&Quit"; + this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click); + // + // View + // + this.View.Index = 1; + this.View.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.ViewToolbar, + this.ViewStatusBar}); + this.View.Text = "&View"; + // + // ViewToolbar + // + this.ViewToolbar.Checked = true; + this.ViewToolbar.Index = 0; + this.ViewToolbar.Text = "&Toolbar"; + this.ViewToolbar.Click += new System.EventHandler(this.ViewToolbar_Click); + // + // ViewStatusBar + // + this.ViewStatusBar.Checked = true; + this.ViewStatusBar.Index = 1; + this.ViewStatusBar.Text = "&Statusbar"; + this.ViewStatusBar.Click += new System.EventHandler(this.ViewStatusBar_Click); + // + // Window + // + this.Window.Index = 2; + this.Window.MdiList = true; + this.Window.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.menuItem4, + this.WindowCascade, + this.WindowTile}); + this.Window.Text = "&Window"; + this.Window.Visible = false; + // + // menuItem4 + // + this.menuItem4.Index = 0; + this.menuItem4.Text = "&New 3d View"; + this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click); + // + // WindowCascade + // + this.WindowCascade.Index = 1; + this.WindowCascade.Text = "&Cascade"; + this.WindowCascade.Click += new System.EventHandler(this.WindowCascade_Click); + // + // WindowTile + // + this.WindowTile.Index = 2; + this.WindowTile.Text = "&Tile"; + this.WindowTile.Click += new System.EventHandler(this.WindowTile_Click); + // + // Help + // + this.Help.Index = 3; + this.Help.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.HelpAbout}); + this.Help.Text = "&Help"; + // + // HelpAbout + // + this.HelpAbout.Index = 0; + this.HelpAbout.Shortcut = System.Windows.Forms.Shortcut.F1; + this.HelpAbout.Text = "&About"; + this.HelpAbout.Click += new System.EventHandler(this.HelpAbout_Click); + // + // toolBarTool + // + this.toolBarTool.AccessibleRole = System.Windows.Forms.AccessibleRole.ToolBar; + this.toolBarTool.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] { + this.New, + this.About, + this.toolBarButton1, + this.wireframe, + this.shading, + this.color, + this.material, + this.transparency, + this.delete}); + this.toolBarTool.DropDownArrows = true; + this.toolBarTool.ImageList = this.imageList1; + this.toolBarTool.Location = new System.Drawing.Point(0, 0); + this.toolBarTool.Name = "toolBarTool"; + this.toolBarTool.ShowToolTips = true; + this.toolBarTool.Size = new System.Drawing.Size(560, 28); + this.toolBarTool.TabIndex = 1; + this.toolBarTool.Enter += new System.EventHandler(this.menuItem3_Click); + this.toolBarTool.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick); + this.toolBarTool.MouseHover += new System.EventHandler(this.toolBar1_MouseHover); + this.toolBarTool.MouseLeave += new System.EventHandler(this.toolBar1_MouseLeave); + // + // New + // + this.New.ImageIndex = 0; + this.New.ToolTipText = "New"; + this.New.Visible = ((bool)(configurationAppSettings.GetValue("New.Visible", typeof(bool)))); + // + // About + // + this.About.ImageIndex = 1; + this.About.ToolTipText = "About(F1)"; + this.About.Visible = ((bool)(configurationAppSettings.GetValue("About.Visible", typeof(bool)))); + // + // toolBarButton1 + // + this.toolBarButton1.Style = System.Windows.Forms.ToolBarButtonStyle.Separator; + // + // wireframe + // + this.wireframe.Enabled = ((bool)(configurationAppSettings.GetValue("wireframe.Enabled", typeof(bool)))); + this.wireframe.ImageIndex = 2; + this.wireframe.Pushed = ((bool)(configurationAppSettings.GetValue("wireframe.Pushed", typeof(bool)))); + this.wireframe.ToolTipText = "Wireframe"; + this.wireframe.Visible = ((bool)(configurationAppSettings.GetValue("wireframe.Visible", typeof(bool)))); + // + // shading + // + this.shading.Enabled = ((bool)(configurationAppSettings.GetValue("shading.Enabled", typeof(bool)))); + this.shading.ImageIndex = 3; + this.shading.Pushed = ((bool)(configurationAppSettings.GetValue("shading.Pushed", typeof(bool)))); + this.shading.ToolTipText = "Shading"; + this.shading.Visible = ((bool)(configurationAppSettings.GetValue("shading.Visible", typeof(bool)))); + // + // color + // + this.color.Enabled = ((bool)(configurationAppSettings.GetValue("color.Enabled", typeof(bool)))); + this.color.ImageIndex = 4; + this.color.ToolTipText = "Color"; + this.color.Visible = ((bool)(configurationAppSettings.GetValue("color.Visible", typeof(bool)))); + // + // material + // + this.material.Enabled = ((bool)(configurationAppSettings.GetValue("material.Enabled", typeof(bool)))); + this.material.ImageIndex = 5; + this.material.ToolTipText = "Material"; + this.material.Visible = ((bool)(configurationAppSettings.GetValue("material.Visible", typeof(bool)))); + // + // transparency + // + this.transparency.Enabled = ((bool)(configurationAppSettings.GetValue("transparency.Enabled", typeof(bool)))); + this.transparency.ImageIndex = 6; + this.transparency.ToolTipText = "Transparency"; + this.transparency.Visible = ((bool)(configurationAppSettings.GetValue("transparency.Visible", typeof(bool)))); + // + // delete + // + this.delete.Enabled = ((bool)(configurationAppSettings.GetValue("delete.Enabled", typeof(bool)))); + this.delete.ImageIndex = 7; + this.delete.ToolTipText = "Delete"; + this.delete.Visible = ((bool)(configurationAppSettings.GetValue("delete.Visible", typeof(bool)))); + // + // imageList1 + // + this.imageList1.ImageSize = new System.Drawing.Size(16, 16); + this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream"))); + this.imageList1.TransparentColor = System.Drawing.Color.Transparent; + // + // myStatusBar + // + this.myStatusBar.AccessibleRole = System.Windows.Forms.AccessibleRole.StatusBar; + this.myStatusBar.Location = new System.Drawing.Point(0, 363); + this.myStatusBar.Name = "myStatusBar"; + this.myStatusBar.Size = new System.Drawing.Size(560, 22); + this.myStatusBar.TabIndex = 3; + // + // toolBarView + // + this.toolBarView.AccessibleRole = System.Windows.Forms.AccessibleRole.ToolBar; + this.toolBarView.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] { + this.ZoomAll, + this.ZoomWin, + this.ZoomProg, + this.Pan, + this.PanGlo, + this.Front, + this.Back, + this.TOP, + this.BOTTOM, + this.LEFT, + this.RIGHT, + this.Axo, + this.Rot, + this.Reset, + this.HlrOn, + this.HlrOff}); + this.toolBarView.DropDownArrows = true; + this.toolBarView.ImageList = this.imageList1; + this.toolBarView.Location = new System.Drawing.Point(0, 28); + this.toolBarView.Name = "toolBarView"; + this.toolBarView.ShowToolTips = true; + this.toolBarView.Size = new System.Drawing.Size(560, 28); + this.toolBarView.TabIndex = 5; + this.toolBarView.Visible = false; + this.toolBarView.Wrappable = false; + this.toolBarView.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBarView_ButtonClick); + this.toolBarView.MouseHover += new System.EventHandler(this.toolBarView_MouseHover); + this.toolBarView.MouseLeave += new System.EventHandler(this.toolBarView_MouseLeave); + // + // ZoomAll + // + this.ZoomAll.ImageIndex = 8; + this.ZoomAll.ToolTipText = "FitAll"; + // + // ZoomWin + // + this.ZoomWin.ImageIndex = 9; + this.ZoomWin.ToolTipText = "Zoom Window"; + // + // ZoomProg + // + this.ZoomProg.ImageIndex = 10; + this.ZoomProg.ToolTipText = "Dynamic Zooming"; + // + // Pan + // + this.Pan.ImageIndex = 11; + this.Pan.ToolTipText = "Dynamic Panning"; + // + // PanGlo + // + this.PanGlo.ImageIndex = 12; + this.PanGlo.ToolTipText = "GlobalPanning"; + // + // Front + // + this.Front.ImageIndex = 13; + this.Front.ToolTipText = "Front"; + // + // Back + // + this.Back.ImageIndex = 14; + this.Back.ToolTipText = "Back"; + // + // TOP + // + this.TOP.ImageIndex = 15; + this.TOP.ToolTipText = "Top"; + // + // BOTTOM + // + this.BOTTOM.ImageIndex = 16; + this.BOTTOM.ToolTipText = "Bottom"; + // + // LEFT + // + this.LEFT.ImageIndex = 17; + this.LEFT.ToolTipText = "Left"; + // + // RIGHT + // + this.RIGHT.ImageIndex = 18; + this.RIGHT.ToolTipText = "Right"; + // + // Axo + // + this.Axo.ImageIndex = 19; + this.Axo.ToolTipText = "Axo"; + // + // Rot + // + this.Rot.ImageIndex = 20; + this.Rot.ToolTipText = "Dynamic Rotation"; + // + // Reset + // + this.Reset.ImageIndex = 21; + this.Reset.ToolTipText = "Reset"; + // + // HlrOn + // + this.HlrOn.ImageIndex = 22; + this.HlrOn.Pushed = true; + this.HlrOn.ToolTipText = "Hidden On"; + // + // HlrOff + // + this.HlrOff.ImageIndex = 23; + this.HlrOff.ToolTipText = "Hidden Off"; + // + // Form1 + // + this.AccessibleRole = System.Windows.Forms.AccessibleRole.Application; + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(560, 385); + this.Controls.Add(this.toolBarView); + this.Controls.Add(this.myStatusBar); + this.Controls.Add(this.toolBarTool); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.IsMdiContainer = true; + this.Menu = this.mainMenu1; + this.Name = "Form1"; + this.Text = "Sample Import / Export"; + this.Activated += new System.EventHandler(this.Form1_Activated); + this.ResumeLayout(false); + } + #endregion + + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.Run(new Form1()); + } + + private void menuItem2_Click(object sender, System.EventArgs e) + { + + this.Cursor = System.Windows.Forms.Cursors.WaitCursor; + this.OnNewFile(); + } + + private void menuItem3_Click(object sender, System.EventArgs e) + { + if (this.MdiChildren.Length > 0) + this.ActiveMdiChild.Close(); + + } + + private void ImportBRep_Click(object sender, System.EventArgs e) + { + Form2 curForm = (Form2)this.ActiveMdiChild; + if (curForm == null) + return; + this.myModelFormat = ModelFormat.BREP; + curForm.ImportModel(this.myModelFormat); + } + + private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e) + { + Form2 curForm = (Form2)this.ActiveMdiChild; + switch (toolBarTool.Buttons.IndexOf(e.Button)) + { + case 0: + this.Cursor = System.Windows.Forms.Cursors.WaitCursor; + this.OnNewFile(); + break; + case 1: + AboutDialog myDlg = new AboutDialog(); + myDlg.ShowDialog(this); + break; + + case 2: //just separator + break; + case 3: + if (curForm == null) + return; + curForm.SetDisplayMode(0); //wireframe + this.wireframe.Enabled = false; + this.shading.Enabled = true; + this.transparency.Enabled = false; + break; + case 4: + if (curForm == null) + return; + curForm.SetDisplayMode(1); //shading + this.shading.Enabled = false; + this.wireframe.Enabled = true; + this.transparency.Enabled = true; + break; + case 5: + if (curForm == null) + return; + curForm.ChangeColor(true); + break; + case 6: + if (curForm == null) + return; + MaterialDialog m = new MaterialDialog(); + m.View = curForm.View; + m.ShowDialog(curForm); + break; + case 7: + if (curForm == null) + return; + IE_WinForms.TransparencyDialog t = new TransparencyDialog(); + t.View = curForm.View; + t.ShowDialog(curForm); + break; + case 8: + if (curForm == null) + return; + curForm.DeleteObjects(); + break; + default: + break; + } + } + + private void toolBar1_MouseHover(object sender, System.EventArgs e) + { + this.myStatusBar.Text = "Document toolbar"; + } + + private void toolBar1_MouseLeave(object sender, System.EventArgs e) + { + this.myStatusBar.Text = ""; + } + + private void ImportCsfdb_Click(object sender, System.EventArgs e) + { + Form2 curForm = (Form2)this.ActiveMdiChild; + if (curForm == null) + return; + this.myModelFormat = IE_WinForms.ModelFormat.CSFDB; + curForm.ImportModel(this.myModelFormat); + } + + private void ImportIges_Click(object sender, System.EventArgs e) + { + Form2 curForm = (Form2)this.ActiveMdiChild; + if (curForm == null) + return; + this.myModelFormat = IE_WinForms.ModelFormat.IGES; + curForm.ImportModel(this.myModelFormat); + } + + private void ImportStep_Click(object sender, System.EventArgs e) + { + Form2 curForm = (Form2)this.ActiveMdiChild; + if (curForm == null) + return; + this.myModelFormat = IE_WinForms.ModelFormat.STEP; + curForm.ImportModel(this.myModelFormat); + } + + private void ExportBRep_Click(object sender, System.EventArgs e) + { + Form2 curForm = (Form2)this.ActiveMdiChild; + if (curForm == null) + return; + this.myModelFormat = IE_WinForms.ModelFormat.BREP; + curForm.ExportModel(this.myModelFormat); + } + + private void ExportCsfdb_Click(object sender, System.EventArgs e) + { + Form2 curForm = (Form2)this.ActiveMdiChild; + if (curForm == null) + return; + this.myModelFormat = IE_WinForms.ModelFormat.CSFDB; + curForm.ExportModel(this.myModelFormat); + } + + private void ExportIges_Click(object sender, System.EventArgs e) + { + Form2 curForm = (Form2)this.ActiveMdiChild; + if (curForm == null) + return; + this.myModelFormat = IE_WinForms.ModelFormat.IGES; + curForm.ExportModel(this.myModelFormat); + } + + private void ExportStep_Click(object sender, System.EventArgs e) + { + Form2 curForm = (Form2)this.ActiveMdiChild; + if (curForm == null) + return; + this.myModelFormat = IE_WinForms.ModelFormat.STEP; + curForm.ExportModel(this.myModelFormat); + } + + private void ExportStl_Click(object sender, System.EventArgs e) + { + Form2 curForm = (Form2)this.ActiveMdiChild; + if (curForm == null) + return; + this.myModelFormat = IE_WinForms.ModelFormat.STL; + curForm.ExportModel(this.myModelFormat); + } + + private void ExportVrml_Click(object sender, System.EventArgs e) + { + Form2 curForm = (Form2)this.ActiveMdiChild; + if (curForm == null) + return; + this.myModelFormat = IE_WinForms.ModelFormat.VRML; + curForm.ExportModel(this.myModelFormat); + } + + private void ExportImage_Click(object sender, System.EventArgs e) + { + Form2 curForm = (Form2)this.ActiveMdiChild; + if (curForm == null) + return; + this.myModelFormat = IE_WinForms.ModelFormat.IMAGE; + curForm.ExportModel(this.myModelFormat); + } + + private void HelpAbout_Click(object sender, System.EventArgs e) + { + AboutDialog myDlg = new AboutDialog(); + myDlg.ShowDialog(this); + } + + private void ViewToolbar_Click(object sender, System.EventArgs e) + { + + if (this.ViewToolbar.Checked) + { + if (this.MdiChildren.Length > 0) + { + this.New.Visible = false; + this.About.Visible = false; + } + else + this.toolBarTool.Hide(); + this.ViewToolbar.Checked = false; + } + else + { + if (this.MdiChildren.Length > 0) + { + this.New.Visible = true; + this.About.Visible = true; + } + else + this.toolBarTool.Show(); + this.ViewToolbar.Checked = true; + } + + } + + private void ViewStatusBar_Click(object sender, System.EventArgs e) + { + if (this.ViewStatusBar.Checked) + { + this.myStatusBar.Hide(); + this.ViewStatusBar.Checked = false; + } + else + { + this.myStatusBar.Show(); + this.ViewStatusBar.Checked = true; + } + } + + public void OnNewFile() + { + Form2 newForm = new Form2(); + newForm.MdiParent = this; + IE_WinForms.Form1.myNbOfChildren = IE_WinForms.Form1.myNbOfChildren + 1; + newForm.SetIndex (IE_WinForms.Form1.myNbOfChildren, 1); + newForm.Show(); + newForm.InitView(); + newForm.InitV3D(); + this.FileExport.Visible = true; + this.FileImport.Visible = true; + this.Window.Visible = true; + this.wireframe.Visible = true; + this.shading.Visible = true; + this.color.Visible = true; + this.material.Visible = true; + this.transparency.Visible = true; + this.delete.Visible = true; + this.Cursor = System.Windows.Forms.Cursors.Default; + this.toolBarView.Visible = true; + } + + private void FileImport_Popup(object sender, System.EventArgs e) + { + IE_WinForms.Form2 curForm = (IE_WinForms.Form2)this.ActiveMdiChild; + if (curForm == null) + return; + if (curForm.View.IsObjectSelected()) + { + this.ExportBRep.Enabled = true; + this.ExportIges.Enabled = true; + this.ExportStep.Enabled = true; + this.ExportVrml.Enabled = true; + this.ExportStl.Enabled = true; + } + + } + + private void menuItem1_Click(object sender, System.EventArgs e) + { + this.Close(); + } + + private void File_Popup(object sender, System.EventArgs e) + { + if (this.MdiChildren.Length > 0) + this.FileClose.Enabled = true; + else + { + this.FileClose.Enabled = false; + this.FileExport.Visible = false; + this.FileImport.Visible = false; + } + } + + private void menuItem4_Click(object sender, System.EventArgs e) + { + IE_WinForms.Form2 curForm = (IE_WinForms.Form2)this.ActiveMdiChild; + IE_WinForms.Form2 newView = new Form2(); + newView.MdiParent = this; + newView.Show(); + newView.InitView(); + newView.SetContext(curForm.View); + newView.View.CreateNewView(newView.Handle); + newView.SetNextIndex(curForm); + } + + private void WindowCascade_Click(object sender, System.EventArgs e) + { + this.LayoutMdi(System.Windows.Forms.MdiLayout.Cascade); + } + + private void WindowTile_Click(object sender, System.EventArgs e) + { + this.LayoutMdi(System.Windows.Forms.MdiLayout.TileVertical); + } + + public void SelectionChanged() + { + if (this.MdiChildren.Length == 0) + return; + IE_WinForms.Form2 curForm = (IE_WinForms.Form2)this.ActiveMdiChild; + if (curForm == null) + return; + switch (curForm.View.DisplayMode()) + { + case -1: + this.shading.Enabled = false; + this.wireframe.Enabled = false; + break; + case 0: + this.wireframe.Enabled = false; + this.shading.Enabled = true; + this.transparency.Enabled = false; + break; + case 1: + this.wireframe.Enabled = true; + this.shading.Enabled = false; + this.transparency.Enabled = true; + break; + case 10: + this.wireframe.Enabled = true; + this.shading.Enabled = true; + this.transparency.Enabled = true; + break; + default: + break; + } + bool IsSelected = curForm.View.IsObjectSelected(); + if (IsSelected) + { + this.color.Enabled = true; + this.material.Enabled = true; + this.delete.Enabled = true; + } + else + { + this.color.Enabled = false; + this.material.Enabled = false; + this.transparency.Enabled = false; + this.delete.Enabled = false; + } + if (curForm.DegenerateMode) + { + this.HlrOff.Pushed = false; + this.HlrOn.Pushed = true; + } + else + { + this.HlrOff.Pushed = true; + this.HlrOn.Pushed = false; + } + if (curForm.Mode == IE_WinForms.CurrentAction3d.CurAction3d_WindowZooming) + this.ZoomWin.Pushed = false; + + } + + public StatusBar StatusBar + { + get + { + return this.myStatusBar; + } + } + + public void OnFileClose() + { + if (this.MdiChildren.Length <= 1) + { + this.FileClose.Enabled = false; + this.Window.Visible = false; + this.wireframe.Visible = false; + this.shading.Visible = false; + this.color.Visible = false; + this.material.Visible = false; + this.transparency.Visible = false; + this.delete.Visible = false; + this.toolBarView.Visible = false; + } + } + + private void toolBarView_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e) + { + IE_WinForms.Form2 curForm = (IE_WinForms.Form2)this.ActiveMdiChild; + if (curForm == null) + return; + switch (toolBarView.Buttons.IndexOf(e.Button)) + { + case 0: + curForm.View.ZoomAllView(); + break; + case 1: + curForm.Mode = CurrentAction3d.CurAction3d_WindowZooming; + this.ZoomWin.Pushed = true; + break; + case 2: + curForm.Mode = CurrentAction3d.CurAction3d_DynamicZooming; + break; + case 3: + curForm.Mode = CurrentAction3d.CurAction3d_DynamicPanning; + break; + case 4: + curForm.Zoom = curForm.View.Scale(); + curForm.Mode = CurrentAction3d.CurAction3d_GlobalPanning; + break; + case 5: + curForm.View.FrontView(); + break; + case 6: + curForm.View.TopView(); + break; + case 7: + curForm.View.LeftView(); + break; + case 8: + curForm.View.BackView(); + break; + case 9: + curForm.View.RightView(); + break; + case 10: + curForm.View.BottomView(); + break; + case 11: + curForm.View.AxoView(); + break; + case 12: + curForm.Mode = CurrentAction3d.CurAction3d_DynamicRotation; + break; + case 13: + curForm.View.Reset(); + break; + case 14: + curForm.View.SetDegenerateModeOn(); + curForm.DegenerateMode = true; + this.HlrOff.Pushed = false; + this.HlrOn.Pushed = true; + break; + case 15: + curForm.View.SetDegenerateModeOff(); + curForm.DegenerateMode = false; + this.HlrOn.Pushed = false; + this.HlrOff.Pushed = true; + break; + default: + break; + } + } + + private void Form1_Activated(object sender, System.EventArgs e) + { + if (this.toolBarView.Visible) + this.SelectionChanged(); + } + + private void toolBarView_MouseHover(object sender, System.EventArgs e) + { + this.myStatusBar.Text = "View toolbar"; + } + + private void toolBarView_MouseLeave(object sender, System.EventArgs e) + { + this.myStatusBar.Text = ""; + } + + } + +} \ No newline at end of file diff --git a/samples/CSharp/IE/Form1.resx b/samples/CSharp/WinForms/Form1.resx old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/Form1.resx rename to samples/CSharp/WinForms/Form1.resx diff --git a/samples/CSharp/WinForms/Form2.cs b/samples/CSharp/WinForms/Form2.cs new file mode 100644 index 0000000000..b417875d5e --- /dev/null +++ b/samples/CSharp/WinForms/Form2.cs @@ -0,0 +1,952 @@ +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; + + +namespace IE_WinForms +{ + public enum CurrentAction3d + { + CurAction3d_Nothing, + CurAction3d_DynamicZooming, + CurAction3d_WindowZooming, + CurAction3d_DynamicPanning, + CurAction3d_GlobalPanning, + CurAction3d_DynamicRotation + } + public enum CurrentPressedKey + { + CurPressedKey_Nothing, + CurPressedKey_Ctrl, + CurPressedKey_Shift + } + public enum ModelFormat + { + BREP, + CSFDB, + STEP, + IGES, + VRML, + STL, + IMAGE + } + /// + /// Summary description for Form2. + /// + public class Form2 : System.Windows.Forms.Form + { + private System.ComponentModel.IContainer components; + + public Form2() + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + // + // Create OCCT proxy object + // + myOCCTProxy = new OCCTProxy(); + myCurrentMode = CurrentAction3d.CurAction3d_Nothing; + myCurrentPressedKey = CurrentPressedKey.CurPressedKey_Nothing; + myDegenerateModeIsOn = true; + IsRectVisible = false; + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form2)); + this.imageList1 = new System.Windows.Forms.ImageList(this.components); + this.myPopup = new System.Windows.Forms.ContextMenu(); + this.menuItem1 = new System.Windows.Forms.MenuItem(); + this.myPopupObject = new System.Windows.Forms.ContextMenu(); + this.ContextWireframe = new System.Windows.Forms.MenuItem(); + this.ContextShading = new System.Windows.Forms.MenuItem(); + this.ContextColor = new System.Windows.Forms.MenuItem(); + this.ContextMaterial = new System.Windows.Forms.MenuItem(); + this.ContMatBrass = new System.Windows.Forms.MenuItem(); + this.ContMenBronze = new System.Windows.Forms.MenuItem(); + this.ContMenCopper = new System.Windows.Forms.MenuItem(); + this.ContMenGold = new System.Windows.Forms.MenuItem(); + this.ContMenPewt = new System.Windows.Forms.MenuItem(); + this.ContMenPlaster = new System.Windows.Forms.MenuItem(); + this.ContMenPlastic = new System.Windows.Forms.MenuItem(); + this.ContMenSilver = new System.Windows.Forms.MenuItem(); + this.ContMenTranc = new System.Windows.Forms.MenuItem(); + this.ContMenDelete = new System.Windows.Forms.MenuItem(); + // + // imageList1 + // + this.imageList1.ImageSize = new System.Drawing.Size(16, 16); + this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream"))); + this.imageList1.TransparentColor = System.Drawing.Color.Transparent; + // + // myPopup + // + this.myPopup.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.menuItem1}); + // + // menuItem1 + // + this.menuItem1.Index = 0; + this.menuItem1.Text = "Change &Background"; + this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click); + // + // myPopupObject + // + this.myPopupObject.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.ContextWireframe, + this.ContextShading, + this.ContextColor, + this.ContextMaterial, + this.ContMenTranc, + this.ContMenDelete}); + this.myPopupObject.Popup += new System.EventHandler(this.myPopupObject_Popup); + // + // ContextWireframe + // + this.ContextWireframe.Index = 0; + this.ContextWireframe.Text = "Wireframe"; + this.ContextWireframe.Click += new System.EventHandler(this.ContextWireframe_Click); + // + // ContextShading + // + this.ContextShading.Index = 1; + this.ContextShading.Text = "Shading"; + this.ContextShading.Click += new System.EventHandler(this.ContextShading_Click); + // + // ContextColor + // + this.ContextColor.Index = 2; + this.ContextColor.Text = "Color"; + this.ContextColor.Click += new System.EventHandler(this.ContextColor_Click); + // + // ContextMaterial + // + this.ContextMaterial.Index = 3; + this.ContextMaterial.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.ContMatBrass, + this.ContMenBronze, + this.ContMenCopper, + this.ContMenGold, + this.ContMenPewt, + this.ContMenPlaster, + this.ContMenPlastic, + this.ContMenSilver}); + this.ContextMaterial.Text = "Material"; + // + // ContMatBrass + // + this.ContMatBrass.Index = 0; + this.ContMatBrass.Text = "&Brass"; + this.ContMatBrass.Click += new System.EventHandler(this.ContMatBrass_Click); + // + // ContMenBronze + // + this.ContMenBronze.Index = 1; + this.ContMenBronze.Text = "&Bronze"; + this.ContMenBronze.Click += new System.EventHandler(this.ContMenBronze_Click); + // + // ContMenCopper + // + this.ContMenCopper.Index = 2; + this.ContMenCopper.Text = "&Copper"; + this.ContMenCopper.Click += new System.EventHandler(this.ContMenCopper_Click); + // + // ContMenGold + // + this.ContMenGold.Index = 3; + this.ContMenGold.Text = "&Gold"; + this.ContMenGold.Click += new System.EventHandler(this.ContMenGold_Click); + // + // ContMenPewt + // + this.ContMenPewt.Index = 4; + this.ContMenPewt.Text = "&Pewter"; + this.ContMenPewt.Click += new System.EventHandler(this.ContMenPewt_Click); + // + // ContMenPlaster + // + this.ContMenPlaster.Index = 5; + this.ContMenPlaster.Text = "&Plaster"; + this.ContMenPlaster.Click += new System.EventHandler(this.ContMenPlaster_Click); + // + // ContMenPlastic + // + this.ContMenPlastic.Index = 6; + this.ContMenPlastic.Text = "&Plastic"; + this.ContMenPlastic.Click += new System.EventHandler(this.ContMenPlastic_Click); + // + // ContMenSilver + // + this.ContMenSilver.Index = 7; + this.ContMenSilver.Text = "&Silver"; + this.ContMenSilver.Click += new System.EventHandler(this.ContMenSilver_Click); + // + // ContMenTranc + // + this.ContMenTranc.Index = 4; + this.ContMenTranc.Text = "&Trancparency"; + this.ContMenTranc.Click += new System.EventHandler(this.ContMenTranc_Click); + // + // ContMenDelete + // + this.ContMenDelete.Index = 5; + this.ContMenDelete.Text = "&Delete"; + this.ContMenDelete.Click += new System.EventHandler(this.ContMenDelete_Click); + // + // Form2 + // + this.AccessibleRole = System.Windows.Forms.AccessibleRole.Window; + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(320, 261); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.Name = "Form2"; + this.Text = "Document"; + this.WindowState = System.Windows.Forms.FormWindowState.Maximized; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form2_KeyDown); + this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form2_MouseDown); + this.SizeChanged += new System.EventHandler(this.Form2_SizeChanged); + this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Form2_MouseUp); + this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.Form2_KeyUp); + this.Closed += new System.EventHandler(this.Form2_Closed); + this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form2_Paint); + this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form2_MouseMove); + } + #endregion + + private System.Windows.Forms.ImageList imageList1; + private System.Windows.Forms.ContextMenu myPopup; + private System.Windows.Forms.ContextMenu myPopupObject; + private System.Windows.Forms.MenuItem ContextWireframe; + private System.Windows.Forms.MenuItem ContextShading; + private System.Windows.Forms.MenuItem ContextColor; + private System.Windows.Forms.MenuItem ContextMaterial; + private System.Windows.Forms.MenuItem ContMatBrass; + private System.Windows.Forms.MenuItem ContMenBronze; + private System.Windows.Forms.MenuItem ContMenCopper; + private System.Windows.Forms.MenuItem ContMenGold; + private System.Windows.Forms.MenuItem ContMenPewt; + private System.Windows.Forms.MenuItem ContMenPlaster; + private System.Windows.Forms.MenuItem ContMenPlastic; + private System.Windows.Forms.MenuItem ContMenSilver; + private System.Windows.Forms.MenuItem ContMenTranc; + private System.Windows.Forms.MenuItem ContMenDelete; + private System.Windows.Forms.MenuItem menuItem1; + + private OCCTProxy myOCCTProxy; + private int myDocumentIndex, myViewIndex; + + public void InitV3D() + { + if (!myOCCTProxy.InitViewer(this.Handle)) + MessageBox.Show("Fatal Error during the graphic initialisation", "Error!", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + public bool ImportBRep(System.String filename) + { + return myOCCTProxy.ImportBrep(filename); + } + + private void Form2_SizeChanged(object sender, System.EventArgs e) + { + myOCCTProxy.UpdateView(); + } + + private void Form2_Paint(object sender, System.Windows.Forms.PaintEventArgs e) + { + myOCCTProxy.RedrawView(); + myOCCTProxy.UpdateView(); + } + + protected CurrentAction3d myCurrentMode; + protected CurrentPressedKey myCurrentPressedKey; + protected float myCurZoom;// ~ Quantity_Factor + protected bool myDegenerateModeIsOn; + protected int myXmin; + protected int myYmin; + protected int myXmax; + protected int myYmax; + protected int theButtonDownX; + protected int theButtonDownY; + // for erasing of rectangle + protected int theRectDownX; + protected int theRectDownY; + protected bool IsRectVisible; + + private void Form2_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) + { + switch (e.Button) + { + case MouseButtons.Left: + myXmin = e.X; myYmin = e.Y; + myXmax = e.X; myYmax = e.Y; + if (myCurrentPressedKey == CurrentPressedKey.CurPressedKey_Ctrl) + // start the dinamic zooming.... + myCurrentMode = CurrentAction3d.CurAction3d_DynamicZooming; + else + { + switch (myCurrentMode) + { + case CurrentAction3d.CurAction3d_Nothing: + if (myCurrentPressedKey == CurrentPressedKey.CurPressedKey_Shift) + MultiDragEvent(myXmax, myYmax, -1); + else + DragEvent(myXmax, myYmax, -1); + break; + case CurrentAction3d.CurAction3d_DynamicRotation: + if (!myDegenerateModeIsOn) + myOCCTProxy.SetDegenerateModeOn(); + //start the rotation + myOCCTProxy.StartRotation(e.X, e.Y); + break; + case IE_WinForms.CurrentAction3d.CurAction3d_WindowZooming: + this.Cursor = System.Windows.Forms.Cursors.Hand; + break; + default: + break; + } + } + break; + case MouseButtons.Right: + //MessageBox.Show("right mouse button is down"); + if (myCurrentPressedKey == CurrentPressedKey.CurPressedKey_Ctrl) + { + if (!myDegenerateModeIsOn) + myOCCTProxy.SetDegenerateModeOn(); + myOCCTProxy.StartRotation(e.X, e.Y); + } + else + Popup(e.X, e.Y); + break; + default: + break; + } + } + + private void Form2_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) + { + if (e.Shift) + myCurrentPressedKey = CurrentPressedKey.CurPressedKey_Shift; + else if (e.Control) + myCurrentPressedKey = CurrentPressedKey.CurPressedKey_Ctrl; + } + + private void Form2_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e) + { + myCurrentPressedKey = CurrentPressedKey.CurPressedKey_Nothing; + } + + protected void MultiDragEvent(int x, int y, int theState) + { + if (theState == -1) + { + theButtonDownX = x; + theButtonDownY = y; + } + else if (theState == 1) + myOCCTProxy.ShiftSelect(Math.Min(theButtonDownX, x), Math.Min(theButtonDownY, y), + Math.Max(theButtonDownX, x), Math.Max(theButtonDownY, y)); + } + + protected void DragEvent(int x, int y, int theState) + { + if (theState == -1) //mouse is down + { + theButtonDownX = x; + theButtonDownY = y; + } + else if (theState == 1) //mouse is up + { + myOCCTProxy.Select(Math.Min(theButtonDownX, x), Math.Min(theButtonDownY, y), + Math.Max(theButtonDownX, x), Math.Max(theButtonDownY, y)); + } + } + + protected void Popup(int x, int y) + { + System.Drawing.Point p = new Point(x, y); + if (this.myOCCTProxy.IsObjectSelected()) + this.myPopupObject.Show(this, p); + else + this.myPopup.Show(this, p); + } + + private void Form2_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) + { + switch (e.Button) + { + case MouseButtons.Left: + if (myCurrentPressedKey == CurrentPressedKey.CurPressedKey_Ctrl) + return; + switch (myCurrentMode) + { + case CurrentAction3d.CurAction3d_Nothing: + if (e.X == myXmin && e.Y == myYmin) + { + myXmax = e.X; myYmax = e.Y; + if (myCurrentPressedKey == CurrentPressedKey.CurPressedKey_Shift) + MultiInputEvent(myXmax, myYmax); + else + InputEvent(myXmax, myYmax); + } + else + { + myXmax = e.X; myYmax = e.Y; + DrawRectangle(false); + if (myCurrentPressedKey == CurrentPressedKey.CurPressedKey_Shift) + MultiDragEvent(myXmax, myYmax, 1); + else + DragEvent(myXmax, myYmax, 1); + } + break; + case CurrentAction3d.CurAction3d_DynamicZooming: + myCurrentMode = CurrentAction3d.CurAction3d_Nothing; + break; + case CurrentAction3d.CurAction3d_WindowZooming: + myXmax = e.X; myYmax = e.Y; + DrawRectangle(false); + int ValZWMin = 1; + if (Math.Abs(myXmax - myXmin) > ValZWMin && Math.Abs(myXmax - myYmax) > ValZWMin) + myOCCTProxy.WindowFitAll(myXmin, myYmin, myXmax, myYmax); + this.Cursor = System.Windows.Forms.Cursors.Default; + IE_WinForms.Form1 f = (IE_WinForms.Form1)this.ParentForm; + f.SelectionChanged(); + myCurrentMode = CurrentAction3d.CurAction3d_Nothing; + break; + case CurrentAction3d.CurAction3d_DynamicPanning: + myCurrentMode = CurrentAction3d.CurAction3d_Nothing; + break; + case CurrentAction3d.CurAction3d_GlobalPanning: + myOCCTProxy.Place(e.X, e.Y, myCurZoom); + myCurrentMode = CurrentAction3d.CurAction3d_Nothing; + break; + case CurrentAction3d.CurAction3d_DynamicRotation: + myCurrentMode = CurrentAction3d.CurAction3d_Nothing; + if (!myDegenerateModeIsOn) + { + myOCCTProxy.SetDegenerateModeOff(); + myDegenerateModeIsOn = false; + } + else + { + myOCCTProxy.SetDegenerateModeOn(); + myDegenerateModeIsOn = true; + } + break; + default: + break; + + } + break; + case MouseButtons.Right: + if (!myDegenerateModeIsOn) + { + myOCCTProxy.SetDegenerateModeOff(); + myDegenerateModeIsOn = false; + } + else + { + myOCCTProxy.SetDegenerateModeOn(); + myDegenerateModeIsOn = true; + } + break; + default: + break; + } + + IE_WinForms.Form1 parent = (IE_WinForms.Form1)this.ParentForm; + parent.SelectionChanged(); + } + + protected void MultiInputEvent(int x, int y) + { + myOCCTProxy.ShiftSelect(); + } + + protected void InputEvent(int x, int y) + { + myOCCTProxy.Select(); + } + + private void DrawRectangle(bool draw) + { + Graphics gr = Graphics.FromHwnd(this.Handle); + System.Drawing.Pen p = null; + if (this.IsRectVisible || (!draw))//erase the rect + { + int r = myOCCTProxy.GetBGColR(); + int g = myOCCTProxy.GetBGColG(); + int b = myOCCTProxy.GetBGColB(); + p = new Pen(System.Drawing.Color.FromArgb(r, g, b)); + this.IsRectVisible = false; + this.myOCCTProxy.UpdateView(); + } + else if (draw) + { + p = new Pen(System.Drawing.Color.White); + this.IsRectVisible = true; + } + if (p == null) + return; + int x = Math.Min(this.myXmin, this.myXmax); + int y = Math.Min(this.myYmin, this.myYmax); + gr.DrawRectangle(p, x, y, Math.Abs(myXmax - myXmin), Math.Abs(myYmax - myYmin)); + this.theRectDownX = Math.Max(this.myXmin, this.myXmax); + this.theRectDownY = Math.Max(this.myYmin, this.myYmax); + } + + private void Form2_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) //left button is pressed + { + if (myCurrentPressedKey == CurrentPressedKey.CurPressedKey_Ctrl) + { + myOCCTProxy.Zoom(myXmax, myYmax, e.X, e.Y); + myXmax = e.X; myYmax = e.Y; + } + else + { + switch (myCurrentMode) + { + case CurrentAction3d.CurAction3d_Nothing: + DrawRectangle(false); + myXmax = e.X; myYmax = e.Y; + DrawRectangle(true); + break; + case CurrentAction3d.CurAction3d_DynamicZooming: + myOCCTProxy.Zoom(myXmax, myYmax, e.X, e.Y); + myXmax = e.X; myYmax = e.Y; + break; + case CurrentAction3d.CurAction3d_WindowZooming: + DrawRectangle(false); + myXmax = e.X; myYmax = e.Y; + DrawRectangle(true);//add brush here + break; + case CurrentAction3d.CurAction3d_DynamicPanning: + myOCCTProxy.Pan(e.X - myXmax, myYmax - e.Y); + myXmax = e.X; myYmax = e.Y; + break; + case CurrentAction3d.CurAction3d_GlobalPanning: + break; + case CurrentAction3d.CurAction3d_DynamicRotation: + myOCCTProxy.Rotation(e.X, e.Y); + myOCCTProxy.RedrawView(); + break; + default: + break; + } + } + } // e.Button == MouseButtons.Left + else if (e.Button == MouseButtons.Middle) + { + if (myCurrentPressedKey == CurrentPressedKey.CurPressedKey_Ctrl) + { + myOCCTProxy.Pan(e.X - myXmax, myYmax - e.Y); + myXmax = e.X; myYmax = e.Y; + } + }//e.Button=MouseButtons.Middle + else if (e.Button == MouseButtons.Right) //right button is pressed + { + if (myCurrentPressedKey == CurrentPressedKey.CurPressedKey_Ctrl) + myOCCTProxy.Rotation(e.X, e.Y); + } + else // no buttons are pressed + { + myXmax = e.X; myYmax = e.Y; + if (myCurrentPressedKey == CurrentPressedKey.CurPressedKey_Shift) + MultiMoveEvent(e.X, e.Y); + else + MoveEvent(e.X, e.Y); + } + + + } + + protected void MultiMoveEvent(int x, int y) + { + myOCCTProxy.MoveTo(x, y); + } + + protected void MoveEvent(int x, int y) + { + myOCCTProxy.MoveTo(x, y); + } + + public void SetDisplayMode(int aMode) + { + myOCCTProxy.SetDisplayMode(aMode); + } + + public void ChangeColor(bool IsObjectColor) + { + int r, g, b; + if (IsObjectColor) + { + r = myOCCTProxy.GetObjColR(); + g = myOCCTProxy.GetObjColG(); + b = myOCCTProxy.GetObjColB(); + } + else + { + r = myOCCTProxy.GetBGColR(); + g = myOCCTProxy.GetBGColG(); + b = myOCCTProxy.GetBGColB(); + } + System.Windows.Forms.ColorDialog ColDlg = new ColorDialog(); + ColDlg.Color = System.Drawing.Color.FromArgb(r, g, b); + if (ColDlg.ShowDialog() == DialogResult.OK) + { + Color c = ColDlg.Color; + r = c.R; + g = c.G; + b = c.B; + if (IsObjectColor) + myOCCTProxy.SetColor(r, g, b); + else + myOCCTProxy.SetBackgroundColor(r, g, b); + } + this.myOCCTProxy.UpdateCurrentViewer(); + + } + + public void DeleteObjects() + { + myOCCTProxy.EraseObjects(); + } + public void ImportModel(IE_WinForms.ModelFormat format) + { + int theformat = 10; + System.Windows.Forms.OpenFileDialog openDialog = new OpenFileDialog(); + + string DataDir = ((Environment.GetEnvironmentVariable("CASROOT")) + "\\..\\data"); + + string filter = ""; + + switch (format) + { + case ModelFormat.BREP: + openDialog.InitialDirectory = (DataDir + "\\occ"); + theformat = 0; + filter = "BREP Files (*.brep *.rle)|*.brep; *.rle"; + break; + case ModelFormat.CSFDB: + theformat = 1; + filter = "CSFDB Files (*.csfdb)|*.csfdb"; + break; + case IE_WinForms.ModelFormat.STEP: + openDialog.InitialDirectory = (DataDir + "\\step"); + theformat = 2; + filter = "STEP Files (*.stp *.step)|*.stp; *.step"; + break; + case IE_WinForms.ModelFormat.IGES: + openDialog.InitialDirectory = (DataDir + "\\iges"); + theformat = 3; + filter = "IGES Files (*.igs *.iges)|*.igs; *.iges"; + break; + default: + break; + } + openDialog.Filter = filter + "|All files (*.*)|*.*"; + if (openDialog.ShowDialog() == DialogResult.OK) + { + string filename = openDialog.FileName; + if (filename == "") + return; + this.Cursor = System.Windows.Forms.Cursors.WaitCursor; + if (!myOCCTProxy.TranslateModel(filename, theformat, true)) + MessageBox.Show("Cann't read this file", "Error!", + MessageBoxButtons.OK, MessageBoxIcon.Warning); + this.Cursor = System.Windows.Forms.Cursors.Default; + } + this.myOCCTProxy.ZoomAllView(); + } + + public void ExportModel(ModelFormat format) + { + int theformat = 10; + System.Windows.Forms.SaveFileDialog saveDialog = new SaveFileDialog(); + string DataDir = ((Environment.GetEnvironmentVariable("CASROOT")) + "\\..\\data"); + string filter = ""; + switch (format) + { + case IE_WinForms.ModelFormat.BREP: + saveDialog.InitialDirectory = (DataDir + "\\occ"); + theformat = 0; + filter = "BREP Files (*.brep *.rle)|*.brep; *.rle"; + break; + case IE_WinForms.ModelFormat.CSFDB: + theformat = 1; + filter = "CSFDB Files (*.csfdb)|*.csfdb"; + break; + case IE_WinForms.ModelFormat.STEP: + saveDialog.InitialDirectory = (DataDir + "\\step"); + theformat = 2; + filter = "STEP Files (*.stp *.step)|*.step; *.stp"; + break; + case IE_WinForms.ModelFormat.IGES: + saveDialog.InitialDirectory = (DataDir + "\\iges"); + theformat = 3; + filter = "IGES Files (*.igs *.iges)| *.iges; *.igs"; + break; + case IE_WinForms.ModelFormat.VRML: + saveDialog.InitialDirectory = (DataDir + "\\vrml"); + theformat = 4; + filter = "VRML Files (*.vrml)|*.vrml"; + break; + case IE_WinForms.ModelFormat.STL: + saveDialog.InitialDirectory = (DataDir + "\\stl"); + theformat = 5; + filter = "STL Files (*.stl)|*.stl"; + break; + case IE_WinForms.ModelFormat.IMAGE: + saveDialog.InitialDirectory = (DataDir + "\\images"); + theformat = 6; + filter = "Images Files (*.bmp *.gif)| *.bmp; *.gif"; + break; + default: + break; + } + saveDialog.Filter = filter; + if (saveDialog.ShowDialog() == DialogResult.OK) + { + string filename = saveDialog.FileName; + if (filename == "") + return; + this.Cursor = System.Windows.Forms.Cursors.WaitCursor; + if (!myOCCTProxy.TranslateModel(filename, theformat, false)) + MessageBox.Show("Cann't write this file", "Error!", + MessageBoxButtons.OK, MessageBoxIcon.Warning); + this.Cursor = System.Windows.Forms.Cursors.Default; + } + } + + private void ContextColor_Click(object sender, System.EventArgs e) + { + this.ChangeColor(true); + } + + private void menuItem1_Click(object sender, System.EventArgs e) + { + this.myOCCTProxy.UpdateCurrentViewer(); + this.ChangeColor(false); + } + + private void ContextWireframe_Click(object sender, System.EventArgs e) + { + this.SetDisplayMode(0); + this.myOCCTProxy.UpdateCurrentViewer(); + IE_WinForms.Form1 parent = (IE_WinForms.Form1)this.ParentForm; + parent.SelectionChanged(); + } + + private void ContextShading_Click(object sender, System.EventArgs e) + { + this.SetDisplayMode(1); + this.myOCCTProxy.UpdateCurrentViewer(); + IE_WinForms.Form1 parent = (IE_WinForms.Form1)this.ParentForm; + parent.SelectionChanged(); + } + + private void ContMenTranc_Click(object sender, System.EventArgs e) + { + IE_WinForms.TransparencyDialog dlg = new TransparencyDialog(); + dlg.View = this.myOCCTProxy; + dlg.ShowDialog(this); + } + + private void ContMenDelete_Click(object sender, System.EventArgs e) + { + this.DeleteObjects(); + } + + private void ContMatBrass_Click(object sender, System.EventArgs e) + { + this.myOCCTProxy.UpdateCurrentViewer(); + this.myOCCTProxy.SetMaterial(0); + } + + private void ContMenBronze_Click(object sender, System.EventArgs e) + { + this.myOCCTProxy.UpdateCurrentViewer(); + this.myOCCTProxy.SetMaterial(1); + } + + private void ContMenCopper_Click(object sender, System.EventArgs e) + { + this.myOCCTProxy.UpdateCurrentViewer(); + this.myOCCTProxy.SetMaterial(2); + } + + private void ContMenGold_Click(object sender, System.EventArgs e) + { + this.myOCCTProxy.UpdateCurrentViewer(); + this.myOCCTProxy.SetMaterial(3); + } + + private void ContMenPewt_Click(object sender, System.EventArgs e) + { + this.myOCCTProxy.UpdateCurrentViewer(); + this.myOCCTProxy.SetMaterial(4); + } + + private void ContMenPlaster_Click(object sender, System.EventArgs e) + { + this.myOCCTProxy.UpdateCurrentViewer(); + this.myOCCTProxy.SetMaterial(5); + } + + private void ContMenPlastic_Click(object sender, System.EventArgs e) + { + this.myOCCTProxy.UpdateCurrentViewer(); + this.myOCCTProxy.SetMaterial(6); + } + + private void ContMenSilver_Click(object sender, System.EventArgs e) + { + this.myOCCTProxy.UpdateCurrentViewer(); + this.myOCCTProxy.SetMaterial(7); + } + + private void toolBar1_MouseHover(object sender, System.EventArgs e) + { + IE_WinForms.Form1 parent = (IE_WinForms.Form1)this.ParentForm; + parent.StatusBar.Text = "View toolbar"; + + } + + private void toolBar1_MouseLeave(object sender, System.EventArgs e) + { + IE_WinForms.Form1 parent = (IE_WinForms.Form1)this.ParentForm; + parent.StatusBar.Text = ""; + } + + private void myPopupObject_Popup(object sender, System.EventArgs e) + { + int mode = this.myOCCTProxy.DisplayMode(); + switch (mode) + { + case -1: + break; + case 0: + this.ContextWireframe.Enabled = false; + this.ContextShading.Enabled = true; + this.ContMenTranc.Enabled = false; + break; + case 1: + this.ContextShading.Enabled = false; + this.ContextWireframe.Enabled = true; + this.ContMenTranc.Enabled = true; + break; + case 10: + this.ContextShading.Enabled = true; ; + this.ContextWireframe.Enabled = true; + this.ContMenTranc.Enabled = true; + break; + default: + break; + + } + } + + public OCCTProxy View + { + get + { + return this.myOCCTProxy; + } + set + { + this.myOCCTProxy = value; + } + } + + public void InitView() + { + this.myOCCTProxy.InitOCCTProxy(); + } + + public void SetIndex(int documentIndex, int viewIndex) + { + this.myDocumentIndex = documentIndex; + this.myViewIndex = viewIndex; + this.Text = System.String.Format("Document {0}:{1}", documentIndex, viewIndex); + } + + public void SetNextIndex(Form2 other) + { + SetIndex(other.myDocumentIndex, other.myViewIndex + 1); + } + + public void SetContext(OCCTProxy View) + { + this.myOCCTProxy.SetAISContext(View); + } + + private void Form2_Closed(object sender, System.EventArgs e) + { + IE_WinForms.Form1 parent = (IE_WinForms.Form1)this.ParentForm; + parent.OnFileClose(); + } + + public CurrentAction3d Mode + { + get + { + return this.myCurrentMode; + } + set + { + this.myCurrentMode = value; + } + } + + public float Zoom + { + set + { + this.myCurZoom = value; + } + } + + public bool DegenerateMode + { + get + { + return this.myDegenerateModeIsOn; + } + set + { + this.myDegenerateModeIsOn = value; + } + } + + } + +} \ No newline at end of file diff --git a/samples/CSharp/IE/Form2.resx b/samples/CSharp/WinForms/Form2.resx old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/Form2.resx rename to samples/CSharp/WinForms/Form2.resx diff --git a/samples/CSharp/IE/IE.csproj b/samples/CSharp/WinForms/IE_WinForms.csproj old mode 100755 new mode 100644 similarity index 82% rename from samples/CSharp/IE/IE.csproj rename to samples/CSharp/WinForms/IE_WinForms.csproj index 160a479356..56f03f2c8c --- a/samples/CSharp/IE/IE.csproj +++ b/samples/CSharp/WinForms/IE_WinForms.csproj @@ -1,7 +1,7 @@  Local - 8.0.50727 + 9.0.30729 2.0 {B9914BB3-B886-4B41-B48D-350EBEBEFD1F} Debug @@ -9,7 +9,7 @@ App.ico - IE + IE_WinForms JScript @@ -17,7 +17,7 @@ IE50 false WinExe - IE + IE_WinForms OnBuildSuccess @@ -78,7 +78,7 @@ true - bin\x86\Debug\ + ..\win32\bind\ DEBUG;TRACE 285212672 full @@ -87,7 +87,7 @@ Off - bin\x86\Release\ + ..\win32\bin\ TRACE 285212672 true @@ -97,10 +97,31 @@ Off prompt + + true + ..\win64\bind\ + DEBUG;TRACE + 285212672 + 4096 + full + x64 + prompt + + + ..\win64\bin\ + TRACE + 285212672 + true + 4096 + x64 + Off + prompt + System + System.Data @@ -113,16 +134,6 @@ System.XML - - OCC - {DCB139CF-2190-412E-B72F-8B080CC01422} - {8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942} - - - shell - {969912D9-78E7-4AB8-B4FF-6B52B4F03991} - {8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942} - @@ -166,6 +177,12 @@ + + + {969912D9-78E7-4AB8-B4FF-6B52B4F03991} + OCCTProxy + + diff --git a/samples/CSharp/WinForms/MaterialDialog.cs b/samples/CSharp/WinForms/MaterialDialog.cs new file mode 100644 index 0000000000..7afbe47e6f --- /dev/null +++ b/samples/CSharp/WinForms/MaterialDialog.cs @@ -0,0 +1,248 @@ +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; + +namespace IE_WinForms +{ + /// + /// Summary description for MaterialDialog. + /// + public class MaterialDialog : System.Windows.Forms.Form + { + /// + /// Required designer variable. + /// + private System.ComponentModel.Container components = null; + + public MaterialDialog() + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + // + // TODO: Add any constructor code after InitializeComponent call + // + this.myView = null; + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MaterialDialog)); + this.BTN_PLASTER = new System.Windows.Forms.Button(); + this.BTN_BRASS = new System.Windows.Forms.Button(); + this.BTN_BRONZE = new System.Windows.Forms.Button(); + this.BTN_COPPER = new System.Windows.Forms.Button(); + this.BTN_GOLD = new System.Windows.Forms.Button(); + this.BTN_PEWTER = new System.Windows.Forms.Button(); + this.BTN_PLASTIC = new System.Windows.Forms.Button(); + this.BTN_SILVER = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // BTN_PLASTER + // + this.BTN_PLASTER.Location = new System.Drawing.Point(16, 8); + this.BTN_PLASTER.Name = "BTN_PLASTER"; + this.BTN_PLASTER.Size = new System.Drawing.Size(80, 24); + this.BTN_PLASTER.TabIndex = 0; + this.BTN_PLASTER.Text = "Plaster"; + this.BTN_PLASTER.Click += new System.EventHandler(this.button1_Click); + // + // BTN_BRASS + // + this.BTN_BRASS.Location = new System.Drawing.Point(16, 40); + this.BTN_BRASS.Name = "BTN_BRASS"; + this.BTN_BRASS.Size = new System.Drawing.Size(80, 24); + this.BTN_BRASS.TabIndex = 1; + this.BTN_BRASS.Text = "Brass"; + this.BTN_BRASS.Click += new System.EventHandler(this.BTN_BRASS_Click); + // + // BTN_BRONZE + // + this.BTN_BRONZE.Location = new System.Drawing.Point(16, 72); + this.BTN_BRONZE.Name = "BTN_BRONZE"; + this.BTN_BRONZE.Size = new System.Drawing.Size(80, 24); + this.BTN_BRONZE.TabIndex = 2; + this.BTN_BRONZE.Text = "Bronze"; + this.BTN_BRONZE.Click += new System.EventHandler(this.BTN_BRONZE_Click); + // + // BTN_COPPER + // + this.BTN_COPPER.Location = new System.Drawing.Point(16, 104); + this.BTN_COPPER.Name = "BTN_COPPER"; + this.BTN_COPPER.Size = new System.Drawing.Size(80, 24); + this.BTN_COPPER.TabIndex = 3; + this.BTN_COPPER.Text = "Copper"; + this.BTN_COPPER.Click += new System.EventHandler(this.BTN_COPPER_Click); + // + // BTN_GOLD + // + this.BTN_GOLD.Location = new System.Drawing.Point(16, 136); + this.BTN_GOLD.Name = "BTN_GOLD"; + this.BTN_GOLD.Size = new System.Drawing.Size(80, 24); + this.BTN_GOLD.TabIndex = 4; + this.BTN_GOLD.Text = "Gold"; + this.BTN_GOLD.Click += new System.EventHandler(this.BTN_GOLD_Click); + // + // BTN_PEWTER + // + this.BTN_PEWTER.Location = new System.Drawing.Point(16, 168); + this.BTN_PEWTER.Name = "BTN_PEWTER"; + this.BTN_PEWTER.Size = new System.Drawing.Size(80, 24); + this.BTN_PEWTER.TabIndex = 5; + this.BTN_PEWTER.Text = "Pewter"; + this.BTN_PEWTER.Click += new System.EventHandler(this.BTN_PEWTER_Click); + // + // BTN_PLASTIC + // + this.BTN_PLASTIC.Location = new System.Drawing.Point(16, 200); + this.BTN_PLASTIC.Name = "BTN_PLASTIC"; + this.BTN_PLASTIC.Size = new System.Drawing.Size(80, 24); + this.BTN_PLASTIC.TabIndex = 6; + this.BTN_PLASTIC.Text = "Plastic"; + this.BTN_PLASTIC.Click += new System.EventHandler(this.BTN_PLASTIC_Click); + // + // BTN_SILVER + // + this.BTN_SILVER.Location = new System.Drawing.Point(16, 232); + this.BTN_SILVER.Name = "BTN_SILVER"; + this.BTN_SILVER.Size = new System.Drawing.Size(80, 24); + this.BTN_SILVER.TabIndex = 7; + this.BTN_SILVER.Text = "Silver"; + this.BTN_SILVER.Click += new System.EventHandler(this.BTN_SILVER_Click); + // + // MaterialDialog + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(112, 273); + this.Controls.Add(this.BTN_SILVER); + this.Controls.Add(this.BTN_PLASTIC); + this.Controls.Add(this.BTN_PEWTER); + this.Controls.Add(this.BTN_GOLD); + this.Controls.Add(this.BTN_COPPER); + this.Controls.Add(this.BTN_BRONZE); + this.Controls.Add(this.BTN_BRASS); + this.Controls.Add(this.BTN_PLASTER); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "MaterialDialog"; + this.Text = "MaterialDialog"; + this.ResumeLayout(false); + + } + #endregion + + private System.Windows.Forms.Button BTN_PLASTER; + private System.Windows.Forms.Button BTN_BRASS; + private System.Windows.Forms.Button BTN_BRONZE; + private System.Windows.Forms.Button BTN_COPPER; + private System.Windows.Forms.Button BTN_GOLD; + private System.Windows.Forms.Button BTN_PEWTER; + private System.Windows.Forms.Button BTN_PLASTIC; + private System.Windows.Forms.Button BTN_SILVER; + + private int myMaterial; + private OCCTProxy myView; + + private void button1_Click(object sender, System.EventArgs e) + { + this.myMaterial = 5; + ChangeMaterial(); + } + + private void BTN_BRASS_Click(object sender, System.EventArgs e) + { + this.myMaterial = 0; + ChangeMaterial(); + } + + private void BTN_BRONZE_Click(object sender, System.EventArgs e) + { + this.myMaterial = 1; + ChangeMaterial(); + } + + private void BTN_COPPER_Click(object sender, System.EventArgs e) + { + this.myMaterial = 2; + ChangeMaterial(); + } + + private void BTN_GOLD_Click(object sender, System.EventArgs e) + { + this.myMaterial = 3; + ChangeMaterial(); + } + + private void BTN_PEWTER_Click(object sender, System.EventArgs e) + { + this.myMaterial = 4; + ChangeMaterial(); + } + + private void BTN_PLASTIC_Click(object sender, System.EventArgs e) + { + this.myMaterial = 6; + ChangeMaterial(); + } + + private void BTN_SILVER_Click(object sender, System.EventArgs e) + { + this.myMaterial = 7; + ChangeMaterial(); + } + + public int Material + { + get + { + return this.myMaterial; + } + set + { + this.myMaterial = value; + } + } + + public void ChangeMaterial() + { + if (myView == null) + return; + myView.SetMaterial(this.myMaterial); + + } + + public OCCTProxy View + { + set + { + this.myView = value; + } + } + + } +} diff --git a/samples/CSharp/IE/MaterialDialog.resx b/samples/CSharp/WinForms/MaterialDialog.resx old mode 100755 new mode 100644 similarity index 100% rename from samples/CSharp/IE/MaterialDialog.resx rename to samples/CSharp/WinForms/MaterialDialog.resx diff --git a/samples/CSharp/WinForms/TransparencyDialog.cs b/samples/CSharp/WinForms/TransparencyDialog.cs new file mode 100644 index 0000000000..6a61ae64db --- /dev/null +++ b/samples/CSharp/WinForms/TransparencyDialog.cs @@ -0,0 +1,108 @@ +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; + +namespace IE_WinForms +{ + /// + /// Summary description for TransparencyDialog. + /// + public class TransparencyDialog : System.Windows.Forms.Form + { + private System.Windows.Forms.NumericUpDown MyTransparency; + /// + /// Required designer variable. + /// + private System.ComponentModel.Container components = null; + private OCCTProxy myView; + + public TransparencyDialog() + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + // + // TODO: Add any constructor code after InitializeComponent call + // + myView = null; + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(TransparencyDialog)); + this.MyTransparency = new System.Windows.Forms.NumericUpDown(); + ((System.ComponentModel.ISupportInitialize)(this.MyTransparency)).BeginInit(); + this.SuspendLayout(); + // + // MyTransparency + // + this.MyTransparency.Location = new System.Drawing.Point(16, 16); + this.MyTransparency.Maximum = new System.Decimal(new int[] { + 10, + 0, + 0, + 0}); + this.MyTransparency.Name = "MyTransparency"; + this.MyTransparency.Size = new System.Drawing.Size(96, 20); + this.MyTransparency.TabIndex = 0; + this.MyTransparency.ValueChanged += new System.EventHandler(this.MyTransparency_ValueChanged); + // + // TransparencyDialog + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(128, 53); + this.Controls.Add(this.MyTransparency); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "TransparencyDialog"; + this.Text = "TransparencyDialog"; + ((System.ComponentModel.ISupportInitialize)(this.MyTransparency)).EndInit(); + this.ResumeLayout(false); + + } + #endregion + + private void MyTransparency_ValueChanged(object sender, System.EventArgs e) + { + if (this.myView == null) + return; + int transp = (int)this.MyTransparency.Value; + this.myView.SetTransparency(transp); + } + + public OCCTProxy View + { + set + { + this.myView = value; + } + } + + } +} diff --git a/samples/CSharp/WinForms/TransparencyDialog.resx b/samples/CSharp/WinForms/TransparencyDialog.resx new file mode 100644 index 0000000000..688fd72e80 --- /dev/null +++ b/samples/CSharp/WinForms/TransparencyDialog.resx @@ -0,0 +1,206 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + False + + + Private + + + Private + + + False + + + (Default) + + + False + + + False + + + 8, 8 + + + True + + + 80 + + + True + + + Private + + + TransparencyDialog + + + + AAABAAEAMDAAAAAAAACoDgAAFgAAACgAAAAwAAAAYAAAAAEACAAAAAAAgAoAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAMDcwADwyqYABAQEAAgICAAMDAwAERERABYW + FgAcHBwAIiIiACkpKQBVVVUATU1NAEJCQgA5OTkAgHz/AFBQ/wCTANYA/+zMAMbW7wDW5+cAkKmtAAAA + MwAAAGYAAACZAAAAzAAAMwAAADMzAAAzZgAAM5kAADPMAAAz/wAAZgAAAGYzAABmZgAAZpkAAGbMAABm + /wAAmQAAAJkzAACZZgAAmZkAAJnMAACZ/wAAzAAAAMwzAADMZgAAzJkAAMzMAADM/wAA/2YAAP+ZAAD/ + zAAzAAAAMwAzADMAZgAzAJkAMwDMADMA/wAzMwAAMzMzADMzZgAzM5kAMzPMADMz/wAzZgAAM2YzADNm + ZgAzZpkAM2bMADNm/wAzmQAAM5kzADOZZgAzmZkAM5nMADOZ/wAzzAAAM8wzADPMZgAzzJkAM8zMADPM + /wAz/zMAM/9mADP/mQAz/8wAM///AGYAAABmADMAZgBmAGYAmQBmAMwAZgD/AGYzAABmMzMAZjNmAGYz + mQBmM8wAZjP/AGZmAABmZjMAZmZmAGZmmQBmZswAZpkAAGaZMwBmmWYAZpmZAGaZzABmmf8AZswAAGbM + MwBmzJkAZszMAGbM/wBm/wAAZv8zAGb/mQBm/8wAzAD/AP8AzACZmQAAmTOZAJkAmQCZAMwAmQAAAJkz + MwCZAGYAmTPMAJkA/wCZZgAAmWYzAJkzZgCZZpkAmWbMAJkz/wCZmTMAmZlmAJmZmQCZmcwAmZn/AJnM + AACZzDMAZsxmAJnMmQCZzMwAmcz/AJn/AACZ/zMAmcxmAJn/mQCZ/8wAmf//AMwAAACZADMAzABmAMwA + mQDMAMwAmTMAAMwzMwDMM2YAzDOZAMwzzADMM/8AzGYAAMxmMwCZZmYAzGaZAMxmzACZZv8AzJkAAMyZ + MwDMmWYAzJmZAMyZzADMmf8AzMwAAMzMMwDMzGYAzMyZAMzMzADMzP8AzP8AAMz/MwCZ/2YAzP+ZAMz/ + zADM//8AzAAzAP8AZgD/AJkAzDMAAP8zMwD/M2YA/zOZAP8zzAD/M/8A/2YAAP9mMwDMZmYA/2aZAP9m + zADMZv8A/5kAAP+ZMwD/mWYA/5mZAP+ZzAD/mf8A/8wAAP/MMwD/zGYA/8yZAP/MzAD/zP8A//8zAMz/ + ZgD//5kA///MAGZm/wBm/2YAZv//AP9mZgD/Zv8A//9mACEApQBfX18Ad3d3AIaGhgCWlpYAy8vLALKy + sgDX19cA3d3dAOPj4wDq6uoA8fHxAPj4+ADw+/8ApKCgAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// + AAD///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABMT + ExMTExMTEyIiQiI8HTyCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALwDODg4Nzc4MQMdAAAA + AADDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOw4ODgyOCQAAAAdAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAODIyMSIAHewAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAA7DI3MSIdCwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAADEyMQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAs4JAALAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALwxJAAhAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4IgC8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAJAxJB0LAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + ALwLCx0dIh0dCwATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACx0dAB0dIiIiIiId + CxMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAvAsdAB0dIiQkAyQkIiIiHSIAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAIgMxMVhZmZqZAyQiHR0AAAAAkAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAvAsdISIDMThZWVmgvaCZWVIkIh0AAB0dIh0hCwALCwALtgAAAAAAAAAAAAAAAOwAAB0iMTEx + ODhYWZrDw8Ofn1hSJCIAHQAdACIAHSIkAwsdOAAAAADeExMTCwsLIiIkMTEyODg3MllZmprDw8PDwllS + MSQdHQAAAB0AIiQkAAAAvDi8AAAxAzExMTExMTI4Nzg4ODc4ODhZXpnDw8PDml1YNwMkIh0AAB0hIiQA + AAAAACIAAAA4ODc4Nzg4ODg4ODg4ODg4ODhZWV6avb2gmllZODcxJCIAAAAdIgMLAAAAACIAAACGE0+G + T4bs7Oy8vLy8vAAxODg4ODg4NzIyMSQdHQAAvADsCwAiJDExAAAAwjjsAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAALMSQAAAAAAAAAAAAAAAAAEyI4MQsiOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALMSQAAAAA + AAAAAAAAAAAAAAC8CwsAEwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC8AAsAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////AAD///////8AAP///////wAA//////// + AAD///////8AAP///////wAA////////AAD///////8AAP///////wAA////////AAD///////8AAP// + /////wAA//8AAH//AAD//wAAf/8AAP//4AP//wAA///4B///AAD///gP//8AAP///B///wAA///8H/// + AAD///wf//8AAP///h///wAA///8H///AAD//+AD//8AAP//wAD//wAA//4AAD//AAD//AAAB/8AAP/w + AAAAAwAA/8AAAAABAADAAAAAADgAAMAAAAAAPAAAwAAAAAA8AADAAAAAIDgAAP///j/+AQAA///+P/+D + AAD///4///8AAP///////wAA////////AAD///////8AAP///////wAA////////AAD///////8AAP// + /////wAA////////AAD///////8AAP///////wAA////////AAD///////8AAP///////wAA + + + \ No newline at end of file diff --git a/samples/CSharp/WinForms/app.config b/samples/CSharp/WinForms/app.config new file mode 100644 index 0000000000..84a1af5451 --- /dev/null +++ b/samples/CSharp/WinForms/app.config @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/CSharp/msvc.bat b/samples/CSharp/msvc.bat index 04e512ef04..ce3f0e137a 100644 --- a/samples/CSharp/msvc.bat +++ b/samples/CSharp/msvc.bat @@ -1,7 +1,7 @@ call "%~dp0..\..\env.bat" %1 %2 %3 if ["%CASDEB%"] == [""] ( - call "%~dp0..\..\msvc.bat" %VCVER% win%ARCH% "" "%~dp0IE\IE.sln" + call "%~dp0..\..\msvc.bat" %VCVER% win%ARCH% Release "%~dp0\CSharp.sln" ) else ( - call "%~dp0..\..\msvc.bat" %VCVER% win%ARCH% %CASDEB% "%~dp0IE\IE.sln" + call "%~dp0..\..\msvc.bat" %VCVER% win%ARCH% Debug "%~dp0\CSharp.sln" ) \ No newline at end of file diff --git a/samples/CSharp/run.bat b/samples/CSharp/run.bat deleted file mode 100644 index 74b7bb03e3..0000000000 --- a/samples/CSharp/run.bat +++ /dev/null @@ -1,9 +0,0 @@ -call "%~dp0..\..\env.bat" %1 %2 %3 - -set "BinDir=Debug" - -if ["%CASDEB%"] == [""] ( - set "BinDir=Release" -) - -"%~dp0IE\bin\%BinDir%\IE.exe" \ No newline at end of file diff --git a/samples/CSharp/run_winforms.bat b/samples/CSharp/run_winforms.bat new file mode 100644 index 0000000000..1c93f65d0c --- /dev/null +++ b/samples/CSharp/run_winforms.bat @@ -0,0 +1,27 @@ +@echo off + +if "%1" == "-h" ( + echo Launch WinForms sample as follows: + echo %~n0 ^[vc9^] ^[win32^|win64^] ^[Debug^|Release^] + echo By default configuration set in ..\..\custom.bat is used + echo Run %~n0 -h to get this help + exit /B +) + +call "%~dp0..\..\env.bat" %1 %2 %3 + +set "EXEC=%~dp0\win%ARCH%\bin%CASDEB%\IE_WinForms.exe" + +if not exist "%EXEC%" goto err_exe + +"%EXEC%" + +goto eof + +:err_exe +echo Executable %EXEC% not found. +echo Check that OCCT and sample are built with the selected configuration: +echo compiler=%VCVER% platform=win%ARCH% %3 +exit /B + +:eof \ No newline at end of file diff --git a/samples/CSharp/run_wpf.bat b/samples/CSharp/run_wpf.bat new file mode 100644 index 0000000000..4cbccd9163 --- /dev/null +++ b/samples/CSharp/run_wpf.bat @@ -0,0 +1,27 @@ +@echo off + +if "%1" == "-h" ( + echo Launch WPF sample as follows: + echo %~n0 ^[vc9^] ^[win32^|win64^] ^[Debug^|Release^] + echo By default configuration set in ..\..\custom.bat is used + echo Run %~n0 -h to get this help + exit /B +) + +call "%~dp0..\..\env.bat" %1 %2 %3 + +set "EXEC=%~dp0\win%ARCH%\bin%CASDEB%\IE_WPF.exe" + +if not exist "%EXEC%" goto err_exe + +"%EXEC%" + +goto eof + +:err_exe +echo Executable %EXEC% not found. +echo Check that OCCT and sample are built with the selected configuration: +echo compiler=%VCVER% platform=win%ARCH% %3 +exit /B + +:eof \ No newline at end of file diff --git a/samples/CSharp/shell/shell.cpp b/samples/CSharp/shell/shell.cpp deleted file mode 100755 index 6656492021..0000000000 --- a/samples/CSharp/shell/shell.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#include ".\shell.h" - diff --git a/samples/CSharp/shell/shell.h b/samples/CSharp/shell/shell.h deleted file mode 100755 index ed234b58ea..0000000000 --- a/samples/CSharp/shell/shell.h +++ /dev/null @@ -1,391 +0,0 @@ -#pragma once -#using -#include "OCCViewer.h" -#include "StdAfx.h" - -public ref class shell -{ - -private: - OCCViewer* myOCCViewer; -public: - - bool InitViewer(System::IntPtr wnd) - { - if (myOCCViewer != NULL) - return myOCCViewer->InitViewer(wnd.ToPointer()); - else - return false; - } - - bool ImportBrep(System::String^ filename) - { - if (myOCCViewer == NULL) - return false; - int length = filename->Length; - char * fname = new char[length+1]; - for(int i = 0; iToCharArray()[i]; - - fname[length] = '\0'; - bool res = myOCCViewer->ImportBRep(fname); - delete [] fname; - return res; - } - - void RedrawView(void) - { - if (myOCCViewer != NULL) - myOCCViewer->RedrawView(); - } - - void UpdateView(void) - { - if (myOCCViewer != NULL) - myOCCViewer->UpdateView(); - } - - void SetDegenerateModeOn(void) - { - if (myOCCViewer != NULL) - myOCCViewer->SetDegenerateModeOn(); - } - - void SetDegenerateModeOff(void) - { - if (myOCCViewer != NULL) - myOCCViewer->SetDegenerateModeOff(); - } - - void WindowFitAll(int Xmin, int Ymin, int Xmax, int Ymax) - { - if (myOCCViewer != NULL) - myOCCViewer->WindowFitAll(Xmin, Ymin, Xmax, Ymax); - } - - void Place(int x, int y, float zoomFactor) - { - if (myOCCViewer != NULL) - myOCCViewer->Place(x, y, zoomFactor); - } - - void Zoom(int x1, int y1, int x2, int y2) - { - if (myOCCViewer != NULL) - myOCCViewer->Zoom(x1, y1, x2, y2); - } - - void Pan(int x, int y) - { - if (myOCCViewer != NULL) - myOCCViewer->Pan(x, y); - } - - void Rotation(int x, int y) - { - if (myOCCViewer != NULL) - myOCCViewer->Rotation(x, y); - } - - void StartRotation(int x, int y) - { - if (myOCCViewer != NULL) - myOCCViewer->StartRotation(x, y); - } - - void Select(int x1, int y1, int x2, int y2) - { - if (myOCCViewer != NULL) - myOCCViewer->Select(x1, y1, x2, y2); - } - - void Select(void) - { - if (myOCCViewer != NULL) - myOCCViewer->Select(); - } - - void MoveTo(int x, int y) - { - if (myOCCViewer != NULL) - myOCCViewer->MoveTo(x, y); - } - - void ShiftSelect(int x1, int y1, int x2, int y2) - { - if (myOCCViewer != NULL) - myOCCViewer->ShiftSelect(x1, y1, x2, y2); - } - - void ShiftSelect(void) - { - if (myOCCViewer != NULL) - myOCCViewer->ShiftSelect(); - } - - int GetBGColR(void) - { - int r, b, g; - if (myOCCViewer != NULL) - myOCCViewer->BackgroundColor(r,g,b); - return r; - } - - int GetBGColG(void) - { - int r, b, g; - if (myOCCViewer != NULL) - myOCCViewer->BackgroundColor(r,g,b); - return g; - } - - int GetBGColB(void) - { - int r, b, g; - if (myOCCViewer != NULL) - myOCCViewer->BackgroundColor(r,g,b); - return b; - } - - void UpdateCurrentViewer(void) - { - if (myOCCViewer != NULL) - myOCCViewer->UpdateCurrentViewer(); - } - - void FrontView(void) - { - if (myOCCViewer != NULL) - myOCCViewer->FrontView(); - } - - void TopView(void) - { - if (myOCCViewer != NULL) - myOCCViewer->TopView(); - } - - void LeftView(void) - { - if (myOCCViewer != NULL) - myOCCViewer->LeftView(); - } - - void BackView(void) - { - if (myOCCViewer != NULL) - myOCCViewer->BackView(); - } - - void RightView(void) - { - if (myOCCViewer != NULL) - myOCCViewer->RightView(); - } - - void BottomView(void) - { - if (myOCCViewer != NULL) - myOCCViewer->BottomView(); - } - - void AxoView(void) - { - if (myOCCViewer != NULL) - myOCCViewer->AxoView(); - } - - float Scale(void) - { - if (myOCCViewer != NULL) - return myOCCViewer->Scale(); - else - return -1; - } - - void ZoomAllView(void) - { - if (myOCCViewer != NULL) - myOCCViewer->ZoomAllView(); - } - - void Reset(void) - { - if (myOCCViewer != NULL) - myOCCViewer->ResetView(); - } - - void SetDisplayMode(int aMode) - { - if (myOCCViewer != NULL) - myOCCViewer->SetDisplayMode(aMode); - } - - void SetColor(int r, int g, int b) - { - if (myOCCViewer != NULL) - myOCCViewer->SetColor(r, g, b); - } - - int GetObjColR(void) - { - int r, g, b; - if (myOCCViewer != NULL) - myOCCViewer->ObjectColor(r, g, b); - return r; - } - - int GetObjColG(void) - { - int r, g, b; - if (myOCCViewer != NULL) - myOCCViewer->ObjectColor(r, g, b); - return g; - } - - int GetObjColB(void) - { - int r, g, b; - if (myOCCViewer != NULL) - myOCCViewer->ObjectColor(r, g, b); - return b; - } - - void SetBackgroundColor(int r, int g, int b) - { - if (myOCCViewer != NULL) - myOCCViewer->SetBackgroundColor(r, g, b); - } - - void EraseObjects(void) - { - if (myOCCViewer != NULL) - myOCCViewer->EraseObjects(); - } - - float GetOCCVersion(void) - { - if (myOCCViewer == NULL) - return 0.0; - else - return myOCCViewer->GetVersion(); - } - - void SetMaterial(int theMaterial) - { - if (myOCCViewer != NULL) - myOCCViewer->SetMaterial(theMaterial); - } - - void SetTransparency(int TheTrans) - { - if (myOCCViewer != NULL) - myOCCViewer->SetTransparency(TheTrans); - } - - bool TranslateModel(System::String^ filename, int format, bool IsImport) - { - if (myOCCViewer == NULL) - return false; - int length = filename->Length; - char * fname = new char[length+1]; - for(int i = 0; iToCharArray()[i]; - - fname[length] = '\0'; - bool res; - if (IsImport) - { - switch(format) - { - case 0: - res=myOCCViewer->ImportBRep(fname); - break; - case 1: - res=myOCCViewer->ImportCsfdb(fname); - break; - case 2: - res=myOCCViewer->ImportStep(fname); - break; - case 3: - res=myOCCViewer->ImportIges(fname); - break; - default: - res=false; - } - } else - { - switch(format) - { - case 0: - res=myOCCViewer->ExportBRep(fname); - break; - case 2: - res=myOCCViewer->ExpotStep(fname); - break; - case 3: - res=myOCCViewer->ExportIges(fname); - break; - case 4: - res=myOCCViewer->ExportVrml(fname); - break; - case 5: - res=myOCCViewer->ExportStl(fname); - break; - case 6: - res=myOCCViewer->Dump(fname); - default: - res=false; - } - } - delete [] fname; - return res; - } - - bool IsObjectSelected(void) - { - if (myOCCViewer != NULL) - return myOCCViewer->IsObjectSelected(); - else - return false; - } - - int DisplayMode(void) - { - if (myOCCViewer != NULL) - return myOCCViewer->DisplayMode(); - else return -1; - } - - void CreateNewView(System::IntPtr wnd) - { - if (myOCCViewer != NULL) - myOCCViewer->CreateNewView(wnd.ToPointer()); - } - - bool SetAISContext(shell^ v) - { - if (myOCCViewer != NULL) - return this->myOCCViewer->SetAISContext(v->GetOCCViewer()); - else - return false; - } - - OCCViewer* GetOCCViewer(void) - { - return myOCCViewer; - } - - void InitOCCViewer(void) - { - myOCCViewer = new OCCViewer(); - } - - int CharToInt(System::String^ symbol) - { - if (myOCCViewer == NULL) - return -1; - char s = (char)symbol->ToCharArray()[0]; - return myOCCViewer->CharToInt(s); - } -}; diff --git a/samples/CSharp/shell/shell.vcproj b/samples/CSharp/shell/shell.vcproj deleted file mode 100755 index 28c3951dc4..0000000000 --- a/samples/CSharp/shell/shell.vcproj +++ /dev/null @@ -1,214 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -