예제 #1
0
 public Main()
 {
     repetierKey = Registry.CurrentUser.CreateSubKey("Software\\Repetier");
     main = this;
     generator = new GCodeGenerator();
     globalSettings = new GlobalSettings();
     conn = new PrinterConnection();
     printerSettings = new FormPrinterSettings();
     threeDSettings = new ThreeDSettings();
     InitializeComponent();
     conn.eventConnectionChange += OnPrinterConnectionChange;
     conn.eventPrinterAction += OnPrinterAction;
     conn.eventJobProgress += OnJobProgress;
     printPanel = new PrintPanel();
     printPanel.Dock = DockStyle.Fill;
     splitContainerPrinterGraphic.Panel1.Controls.Add(printPanel);
     logView = new LogView();
     logView.Dock = DockStyle.Fill;
     splitVert.Panel2.Controls.Add(logView);
     skeinforge = new Skeinforge();
     PrinterChanged(printerSettings.currentPrinterKey,true);
     printerSettings.eventPrinterChanged += PrinterChanged;
     // GCode print preview
     printPreview = new ThreeDControl();
     printPreview.Dock = DockStyle.Fill;
     splitContainerPrinterGraphic.Panel2.Controls.Add(printPreview);
     printPreview.SetEditor(false);
     printPreview.AutoUpdateable = true;
     printVisual = new GCodeVisual(conn.analyzer);
     printPreview.models.AddLast(printVisual);
     basicTitle = Text;
 }
예제 #2
0
 // This method will be called when the thread is started.
 public void DoWork()
 {
     RepetierEditor ed = Main.main.editor;
     
     Stopwatch sw = new Stopwatch();
     sw.Start();
     visual = new GCodeVisual();
     switch (ed.ShowMode)
     {
         case 0:
             visual.minLayer = 0;
             visual.maxLayer = 999999;
             break;
         case 1:
             visual.minLayer = visual.maxLayer = ed.ShowMinLayer;
             break;
         case 2:
             visual.minLayer = ed.ShowMinLayer;
             visual.maxLayer = ed.ShowMaxLayer;
             break;
     }
     visual.parseGCodeShortArray(Main.main.previewArray, true);
     Main.main.previewArray = null;
     visual.Reduce();
     //visual.stats();
     Main.main.newVisual = visual;
     Main.main.jobPreviewThreadFinished = true;
     Main.main.previewThread = null;
     sw.Stop();
     //Main.conn.log("Update time:" + sw.ElapsedMilliseconds, false, 3);
 }
예제 #3
0
 // This method will be called when the thread is started.
 public void DoWork()
 {
     RepetierEditor ed = Main.main.editor;
     string text = ed.getContent(1) + ed.getContent(0) + ed.getContent(2);
     visual = new GCodeVisual();
     visual.ParseText(text, true);
     visual.Reduce();
     //visual.stats();
     Main.main.newVisual = visual;
     Main.main.jobPreviewThreadFinished = true;
     Main.main.previewThread = null;
 }
예제 #4
0
 // This method will be called when the thread is started.
 public void DoWork()
 {
     RepetierEditor ed = Main.main.editor;
     string text = ed.getContent(1) + ed.getContent(0) + ed.getContent(2);
     Stopwatch sw = new Stopwatch();
     sw.Start();
     visual = new GCodeVisual();
     visual.ParseText(text, true);
     visual.Reduce();
     //visual.stats();
     Main.main.newVisual = visual;
     Main.main.jobPreviewThreadFinished = true;
     Main.main.previewThread = null;
     sw.Stop();
     //Main.conn.log("Update time:" + sw.ElapsedMilliseconds, false, 3);
 }
예제 #5
0
        private void timer_Tick(object sender, EventArgs e)
        {
            if (newVisual != null)
            {
                jobPreview.models.RemoveLast();
                jobVisual.Clear();
                jobVisual = newVisual;
                jobPreview.models.AddLast(jobVisual);
                jobPreview.UpdateChanges();
                newVisual = null;
                editor.toolUpdating.Text = "";
                editor.UpdateLayerInfo();
                editor.MaxLayer = editor.getContentArray(0).Last<GCodeShort>().layer;
            }
            if (recalcJobPreview && jobPreviewThreadFinished)
            {
                previewArray = new List<GCodeShort>();
                previewArray.AddRange(((RepetierEditor.Content)editor.toolFile.Items[1]).textArray);
                previewArray.AddRange(((RepetierEditor.Content)editor.toolFile.Items[0]).textArray);
                previewArray.AddRange(((RepetierEditor.Content)editor.toolFile.Items[2]).textArray);
                recalcJobPreview = false;
                jobPreviewThreadFinished = false;
                JobUpdater workerObject = new JobUpdater();
                editor.toolUpdating.Text = "Updating ...";
                previewThread = new Thread(workerObject.DoWork);
                previewThread.Start();

            }
            if (refreshCounter > 0)
            {
                if (--refreshCounter == 0)
                {
                    Invalidate();
                }
            }
        }
예제 #6
0
        public Main()
        {
            executeHostCall = new executeHostCommandDelegate(this.executeHostCommand);
            repetierKey = Registry.CurrentUser.CreateSubKey("SOFTWARE\\Repetier");
            repetierKey.SetValue("installPath", Application.StartupPath);
            if (Path.DirectorySeparatorChar != '\\' && IsRunningOnMac())
                IsMac = true;
            /*String[] parms = Environment.GetCommandLineArgs();
            string lastcom = "";
            foreach (string s in parms)
            {
                if (lastcom == "-home")
                {
                    repetierKey.SetValue("installPath",s);
                    lastcom = "";
                    continue;
                }
                if (s == "-macosx") IsMac = true;
                lastcom = s;
            }*/
            main = this;
            generator = new GCodeGenerator();
            globalSettings = new GlobalSettings();
            conn = new PrinterConnection();
            printerSettings = new FormPrinterSettings();
            conn.analyzer.start();
            threeDSettings = new ThreeDSettings();
            InitializeComponent();
            updateShowFilament();
            RegMemory.RestoreWindowPos("mainWindow", this);
            if (WindowState == FormWindowState.Maximized)
                Application.DoEvents();
            splitLog.SplitterDistance = RegMemory.GetInt("logSplitterDistance", splitLog.SplitterDistance);
            if (IsMono)
            {
                if (!IsMac)
                {
                    splitContainerPrinterGraphic.SplitterDistance += 52;
                    foreach (ToolStripItem m in menu.Items)
                    {
                        m.Text = m.Text.Replace("&", null);
                    }
                }
                if (IsMac)
                {
                    /*Application.Events.Quit += delegate (object sender, ApplicationEventArgs e) {
                        Application.Quit ();
                        e.Handled = true;
                    };
 
                    ApplicationEvents.Reopen += delegate (object sender, ApplicationEventArgs e) {
                        WindowState = FormWindowState.Normal;
                        e.Handled = true;
                    };*/

                    MinimumSize = new Size(500, 640);
                    tab.MinimumSize = new Size(500, 500);
                    splitLog.Panel1MinSize = 520;
                    splitLog.Panel2MinSize = 100;
                    splitLog.IsSplitterFixed = true;
                    splitJob.IsSplitterFixed = true;
                    //splitContainerPrinterGraphic.SplitterDistance -= 52;
                    splitLog.SplitterDistance = splitLog.Height - 100;
                }
            }
            toolShowLog.Checked = RegMemory.GetBool("logShow", true);
            conn.eventConnectionChange += OnPrinterConnectionChange;
            conn.eventPrinterAction += OnPrinterAction;
            conn.eventJobProgress += OnJobProgress;
            printPanel = new PrintPanel();
            printPanel.Dock = DockStyle.Fill;
            splitContainerPrinterGraphic.Panel1.Controls.Add(printPanel);
            printerSettings.formToCon();
            logView = new LogView();
            logView.Dock = DockStyle.Fill;
            splitLog.Panel2.Controls.Add(logView);
            skeinforge = new Skeinforge();
            PrinterChanged(printerSettings.currentPrinterKey, true);
            printerSettings.eventPrinterChanged += PrinterChanged;
            // GCode print preview
            printPreview = new ThreeDControl();
            printPreview.Dock = DockStyle.Fill;
            splitContainerPrinterGraphic.Panel2.Controls.Add(printPreview);
            printPreview.SetEditor(false);
            printPreview.AutoUpdateable = true;
            printVisual = new GCodeVisual(conn.analyzer);
            printVisual.liveView = true;
            printPreview.models.AddLast(printVisual);
            basicTitle = Text;
            jobPreview = new ThreeDControl();
            jobPreview.Dock = DockStyle.Fill;
            splitJob.Panel2.Controls.Add(jobPreview);
            jobPreview.SetEditor(false);
            jobPreview.models.AddLast(jobVisual);
            editor.contentChangedEvent += JobPreview;
            editor.commands = new Commands();
            editor.commands.Read("default", "en");
            UpdateHistory();
            UpdateConnections();
            Main.slic3r = new Slic3r();
            slicer = new Slicer();
            if (IsMac)
            {
                tabGCode.Controls.Remove(splitJob);
                tabPrint.Controls.Remove(splitContainerPrinterGraphic);
            }
            toolShowLog_CheckedChanged(null, null);
            updateShowFilament();
        }
예제 #7
0
        public Main()
        {
            executeHostCall = new executeHostCommandDelegate(this.executeHostCommand);
            repetierKey = Custom.BaseKey; // Registry.CurrentUser.CreateSubKey("SOFTWARE\\Repetier");
            repetierKey.SetValue("installPath", Application.StartupPath);
            if (Path.DirectorySeparatorChar != '\\' && IsRunningOnMac())
                IsMac = true;
            /*String[] parms = Environment.GetCommandLineArgs();
            string lastcom = "";
            foreach (string s in parms)
            {
                if (lastcom == "-home")
                {
                    repetierKey.SetValue("installPath",s);
                    lastcom = "";
                    continue;
                }
                if (s == "-macosx") IsMac = true;
                lastcom = s;
            }*/
            main = this;
            generator = new GCodeGenerator();
            globalSettings = new GlobalSettings();
            conn = new PrinterConnection();
            printerSettings = new FormPrinterSettings();
            conn.analyzer.start();
            threeDSettings = new ThreeDSettings();
            InitializeComponent();
            updateShowFilament();
            RegMemory.RestoreWindowPos("mainWindow", this);
            if (WindowState == FormWindowState.Maximized)
                Application.DoEvents();
            splitLog.SplitterDistance = RegMemory.GetInt("logSplitterDistance", splitLog.SplitterDistance);
            splitInfoEdit.SplitterDistance = RegMemory.GetInt("infoEditSplitterDistance", Width-470);
            if (IsMono)
            {
                if (!IsMac)
                {
                    foreach (ToolStripItem m in menu.Items)
                    {
                        m.Text = m.Text.Replace("&", null);
                    }
                }
                if (IsMac)
                {
                    /*Application.Events.Quit += delegate (object sender, ApplicationEventArgs e) {
                        Application.Quit ();
                        e.Handled = true;
                    };
 
                    ApplicationEvents.Reopen += delegate (object sender, ApplicationEventArgs e) {
                        WindowState = FormWindowState.Normal;
                        e.Handled = true;
                    };*/

                    MinimumSize = new Size(500, 640);
                    tab.MinimumSize = new Size(500, 500);
                    splitLog.Panel1MinSize = 520;
                    splitLog.Panel2MinSize = 100;
                    splitLog.IsSplitterFixed = true;
                    //splitContainerPrinterGraphic.SplitterDistance -= 52;
                    splitLog.SplitterDistance = splitLog.Height - 100;
                }
            }
            slicerToolStripMenuItem.Visible = false;
            splitLog.Panel2Collapsed = !RegMemory.GetBool("logShow", true);
            conn.eventConnectionChange += OnPrinterConnectionChange;
            conn.eventPrinterAction += OnPrinterAction;
            conn.eventJobProgress += OnJobProgress;
            printPanel = new PrintPanel();
            printPanel.Dock = DockStyle.Fill;
            tabPrint.Controls.Add(printPanel);
            printerSettings.formToCon();
            logView = new LogView();
            logView.Dock = DockStyle.Fill;
            splitLog.Panel2.Controls.Add(logView);
            skeinforge = new Skeinforge();
            PrinterChanged(printerSettings.currentPrinterKey, true);
            printerSettings.eventPrinterChanged += PrinterChanged;
            // GCode print preview
            threedview = new ThreeDControl();
            threedview.Dock = DockStyle.Fill;
            tabPage3DView.Controls.Add(threedview);

            printPreview = new ThreeDView();
           // printPreview.Dock = DockStyle.Fill;
          //  splitContainerPrinterGraphic.Panel2.Controls.Add(printPreview);
            printPreview.SetEditor(false);
            printPreview.autoupdateable = true;
            printVisual = new GCodeVisual(conn.analyzer);
            printVisual.liveView = true;
            printPreview.models.AddLast(printVisual);
            basicTitle = Text;
            jobPreview = new ThreeDView();
         //   jobPreview.Dock = DockStyle.Fill;
         //   splitJob.Panel2.Controls.Add(jobPreview);
            jobPreview.SetEditor(false);
            jobPreview.models.AddLast(jobVisual);
            editor.contentChangedEvent += JobPreview;
            editor.commands = new Commands();
            editor.commands.Read("default", "en");
            UpdateHistory();
            UpdateConnections();
            Main.slic3r = new Slic3r();
            slicer = new Slicer();
            //toolShowLog_CheckedChanged(null, null);
            updateShowFilament();
            assign3DView();
            history = new TemperatureHistory();
            tempView = new TemperatureView();
            tempView.Dock = DockStyle.Fill;
            tabPageTemp.Controls.Add(tempView);
            if (IsMono)
                showWorkdirectoryToolStripMenuItem.Visible = false;
            new SoundConfig();
            stlComposer1.buttonSlice.Text = "Slice with " + slicer.SlicerName;

            // Customizations

            if(Custom.GetBool("removeTestgenerator",false)) {
                internalSlicingParameterToolStripMenuItem.Visible = false;
                testCaseGeneratorToolStripMenuItem.Visible = false;
            }
            string titleAdd = Custom.GetString("titleAddition", "");
            if (titleAdd.Length > 0)
            {
                int p = basicTitle.IndexOf(' ');
                basicTitle = basicTitle.Substring(0, p) + titleAdd + basicTitle.Substring(p);
                Text = basicTitle;
            }
            slicerPanel.UpdateSelection();
        }
예제 #8
0
        public Main()
        {
            executeHostCall = new executeHostCommandDelegate(this.executeHostCommand);
            repetierKey = Custom.BaseKey; // Registry.CurrentUser.CreateSubKey("SOFTWARE\\Repetier");
            repetierKey.SetValue("installPath", Application.StartupPath);
            if (Path.DirectorySeparatorChar != '\\' && IsRunningOnMac())
                IsMac = true;
            /*String[] parms = Environment.GetCommandLineArgs();
            string lastcom = "";
            foreach (string s in parms)
            {
                if (lastcom == "-home")
                {
                    repetierKey.SetValue("installPath",s);
                    lastcom = "";
                    continue;
                }
                if (s == "-macosx") IsMac = true;
                lastcom = s;
            }*/
            main = this;
            SplashScreen.run();
            trans = new Trans(Application.StartupPath + Path.DirectorySeparatorChar + "data" + Path.DirectorySeparatorChar + "translations");
            SwitchButton.imageOffset = RegMemory.GetInt("onOffImageOffset", 0);
            generator = new GCodeGenerator();
            globalSettings = new GlobalSettings();
            conn = new PrinterConnection();
            printerSettings = new FormPrinterSettings();
            printerModel = new PrinterModel();
            conn.analyzer.start(true);
            threeDSettings = new ThreeDSettings();
            InitializeComponent();
            tdSettings.DataSource = threeDSettings;
            tdSettings_DataMemberChanged(null, null);
            editor = new RepetierEditor();
            editor.Dock = DockStyle.Fill;
            tabGCode.Controls.Add(editor);
            updateShowFilament();
            RegMemory.RestoreWindowPos("mainWindow", this);
            if (WindowState == FormWindowState.Maximized)
                Application.DoEvents();
            splitLog.SplitterDistance = RegMemory.GetInt("logSplitterDistance", splitLog.SplitterDistance);
            splitInfoEdit.SplitterDistance = RegMemory.GetInt("infoEditSplitterDistance", Width-470);
            if (IsMono)
            {
                if (!IsMac)
                {
                    foreach (ToolStripItem m in menu.Items)
                    {
                        m.Text = m.Text.Replace("&", null);
                    }
                }
                if (IsMac)
                {
                    /*Application.Events.Quit += delegate (object sender, ApplicationEventArgs e) {
                        Application.Quit ();
                        e.Handled = true;
                    };
 
                    ApplicationEvents.Reopen += delegate (object sender, ApplicationEventArgs e) {
                        WindowState = FormWindowState.Normal;
                        e.Handled = true;
                    };*/

                    MinimumSize = new Size(500, 640);
                    tab.MinimumSize = new Size(500, 500);
                    splitLog.Panel1MinSize = 520;
                    splitLog.Panel2MinSize = 100;
                    splitLog.IsSplitterFixed = true;
                    //splitContainerPrinterGraphic.SplitterDistance -= 52;
                    splitLog.SplitterDistance = splitLog.Height - 100;
                }
            }
            slicerToolStripMenuItem.Visible = false;
            splitLog.Panel2Collapsed = !RegMemory.GetBool("logShow", true);
            splitPrinterId.Panel1Collapsed = !RegMemory.GetBool("printerIdShow", false);
            conn.eventConnectionChange += OnPrinterConnectionChange;
            conn.eventPrinterAction += OnPrinterAction;
            conn.eventJobProgress += OnJobProgress;
            objectPlacement = new STLComposer();
            objectPlacement.Dock = DockStyle.Fill;
            tabModel.Controls.Add(objectPlacement);
            printPanel = new PrintPanel();
            printPanel.Dock = DockStyle.Fill;
            tabPrint.Controls.Add(printPanel);
            printerSettings.formToCon();
            logView = new LogView();
            logView.Dock = DockStyle.Fill;
            splitLog.Panel2.Controls.Add(logView);
            skeinforge = new Skeinforge();
            PrinterChanged(printerSettings.currentPrinterKey, true);
            printerSettings.eventPrinterChanged += PrinterChanged;
            // GCode print preview
            threedview = new ThreeDControl();
            threedview.Dock = DockStyle.Fill;
            tabPage3DView.Controls.Add(threedview);

            printPreview = new ThreeDView();
           // printPreview.Dock = DockStyle.Fill;
          //  splitContainerPrinterGraphic.Panel2.Controls.Add(printPreview);
            printPreview.SetEditor(false);
            printPreview.autoupdateable = true;
            printVisual = new GCodeVisual(conn.analyzer);
            printVisual.liveView = true;
            printPreview.models.AddLast(printVisual);
            basicTitle = Text;
            jobPreview = new ThreeDView();
         //   jobPreview.Dock = DockStyle.Fill;
         //   splitJob.Panel2.Controls.Add(jobPreview);
            jobPreview.SetEditor(false);
            jobPreview.models.AddLast(jobVisual);
            editor.contentChangedEvent += JobPreview;
            editor.commands = new Commands();
            editor.commands.Read("default", "en");
            UpdateHistory();
            UpdateConnections();
            Main.slic3r = new Slic3r();
            slicer = new Slicer();
            //toolShowLog_CheckedChanged(null, null);
            updateShowFilament();
            assign3DView();
            history = new TemperatureHistory();
            tempView = new TemperatureView();
            tempView.Dock = DockStyle.Fill;
            tabPageTemp.Controls.Add(tempView);
            if (IsMono)
            {
                showWorkdirectoryToolStripMenuItem.Visible = false;
                toolStrip.Height = 56;
            }
            new SoundConfig();
            //stlComposer1.buttonSlice.Text = Trans.T1("L_SLICE_WITH", slicer.SlicerName);

            // Customizations

            if(Custom.GetBool("removeTestgenerator",false)) {
                internalSlicingParameterToolStripMenuItem.Visible = false;
                testCaseGeneratorToolStripMenuItem.Visible = false;
            }
            string titleAdd = Custom.GetString("titleAddition", "");
            string titlePrefix = Custom.GetString("titlePrefix", "");
            if (titleAdd.Length > 0 || titlePrefix.Length>0)
            {
                int p = basicTitle.IndexOf(' ');
                basicTitle = titlePrefix+basicTitle.Substring(0, p) + titleAdd + basicTitle.Substring(p);
                Text = basicTitle;
            }
            slicerPanel.UpdateSelection();
            if (Custom.GetBool("removeUpdates", false))
                checkForUpdatesToolStripMenuItem.Visible = false;
            else
                RHUpdater.checkForUpdates(true);
            UpdateToolbarSize();
            // Add languages
            foreach (Translation t in trans.translations.Values)
            {
                ToolStripMenuItem item = new ToolStripMenuItem(t.language,null, languageSelected);
                item.Tag = t;
                languageToolStripMenuItem.DropDownItems.Add(item);
            }
            languageChanged += translate;
            translate();
            if (Custom.GetBool("removeSkeinforge", false))
            {
                Main.slicer.ActiveSlicer = Slicer.SlicerID.Slic3r;
            }
            if (Custom.GetBool("extraSupportButton", false))
            {
                supportToolStripMenuItem.Text = Custom.GetString("extraSupportText", "Support");
            }
            else
            {
                toolStripAskSeperator.Visible = false;
                supportToolStripMenuItem.Visible = false;
            }
            if (Custom.GetString("extraLink1Title", "").Length>0)
            {
                extraUrl1ToolStripMenuItem.Text = Custom.GetString("extraLink1Title", "");
                toolStripAskSeperator.Visible = true;
            }
            else extraUrl1ToolStripMenuItem.Visible = false;
            if (Custom.GetString("extraLink2Title", "").Length > 0)
            {
                extraUrl2ToolStripMenuItem.Text = Custom.GetString("extraLink2Title", "");
                toolStripAskSeperator.Visible = true;
            }
            else extraUrl2ToolStripMenuItem.Visible = false;
            if (Custom.GetString("extraLink3Title", "").Length > 0)
            {
                extraUrl3ToolStripMenuItem.Text = Custom.GetString("extraLink3Title", "");
                toolStripAskSeperator.Visible = true;
            }
            else extraUrl3ToolStripMenuItem.Visible = false;
            if (Custom.GetString("extraLink4Title", "").Length > 0)
            {
                extraUrl4ToolStripMenuItem.Text = Custom.GetString("extraLink4Title", "");
                toolStripAskSeperator.Visible = true;
            }
            else extraUrl4ToolStripMenuItem.Visible = false;
            if (Custom.GetString("extraLink5Title", "").Length > 0)
            {
                extraUrl5ToolStripMenuItem.Text = Custom.GetString("extraLink5Title", "");
                toolStripAskSeperator.Visible = true;
            }
            else extraUrl5ToolStripMenuItem.Visible = false;
            string supportImage = Custom.GetString("extraSupportToolbarImage", "");
            if (supportImage.Length > 0 && File.Exists(Application.StartupPath + Path.DirectorySeparatorChar + supportImage))
            {
                toolStripButtonSupport.Image = Image.FromFile(Application.StartupPath + Path.DirectorySeparatorChar + Custom.GetString("extraSupportToolbarImage", ""));
                toolStripButtonSupport.Text = Custom.GetString("extraSupportText", "Support");
            }
            else
            {
                toolStripButtonSupport.Visible = false;
            }
            toolAction.Text = Trans.T("L_IDLE");
            toolConnection.Text = Trans.T("L_DISCONNECTED");
            updateTravelMoves();
            printerIdLabel.Text = printerSettings.comboPrinter.Text;
            this.AllowDrop = true;
            this.DragEnter += new DragEventHandler(Form1_DragEnter);
            this.DragDrop += new DragEventHandler(Form1_DragDrop);
            extensions.ExtensionManager.Initalize();
            if (conn.connector != null)
                conn.connector.Activate();
            //TestTopoTriangle triTests = new TestTopoTriangle();
            //triTests.RunTests();

            //everything done.  Now look at command line
            ProcessCommandLine();
            snapshotToolStripMenuItem.Visible = false;
            setImportUnits(RegMemory.GetDouble("importScaleFactor", importScaleFactor));

        }
예제 #9
0
        private void timer_Tick(object sender, EventArgs e)
        {
            if (conn.connector.IsJobRunning())
            {
                PreventSleepmode();
            }
            if (newVisual != null)
            {
                jobPreview.models.RemoveLast();
                jobVisual.Clear();
                jobVisual = newVisual;
                jobPreview.models.AddLast(jobVisual);
                threedview.UpdateChanges();
                newVisual = null;
                editor.toolUpdating.Text = "";
                if (Main.main.gcodePrintingTime > 0)
                {
                    Main.main.editor.printingTime = Main.main.gcodePrintingTime;
                    int sec = (int)(Main.main.editor.printingTime * (1 + 0.01 * Main.conn.addPrintingTime));
                    int hours = sec / 3600;
                    sec -= 3600 * hours;
                    int min = sec / 60;
                    sec -= min * 60;
                    StringBuilder s = new StringBuilder();
                    if (hours > 0)
                        s.Append(Trans.T1("L_TIME_H:", hours.ToString())); //"h:");
                    if (min > 0 || hours > 0)
                        s.Append(Trans.T1("L_TIME_M:", min.ToString()));
                    s.Append(Trans.T1("L_TIME_S", sec.ToString()));
                    Main.main.editor.toolPrintingTime.Text = Trans.T1("L_PRINTING_TIME:", s.ToString());
                }

                editor.UpdateLayerInfo();
                editor.MaxLayer = editor.getContentArray(0).Last<GCodeShort>().layer;
            }
            if (recalcJobPreview && jobPreviewThreadFinished)
            {
                previewArray0 = new List<GCodeShort>();
                previewArray1 = new List<GCodeShort>();
                previewArray2 = new List<GCodeShort>();
                previewArray0.AddRange(((RepetierEditor.Content)editor.toolFile.Items[1]).textArray);
                previewArray1.AddRange(((RepetierEditor.Content)editor.toolFile.Items[0]).textArray);
                previewArray2.AddRange(((RepetierEditor.Content)editor.toolFile.Items[2]).textArray);
                recalcJobPreview = false;
                jobPreviewThreadFinished = false;
                JobUpdater workerObject = new JobUpdater();
                editor.toolUpdating.Text = Trans.T("L_UPDATING..."); // "Updating ...";
                previewThread = new Thread(workerObject.DoWork);
                previewThread.Start();

            }
            if (refreshCounter > 0)
            {
                if (--refreshCounter == 0)
                {
                    Invalidate();
                }
            }
        }
예제 #10
0
        private void timer_Tick(object sender, EventArgs e)
        {
            if (newVisual != null)
            {
                jobPreview.models.RemoveLast();
                jobVisual.Clear();
                jobVisual = newVisual;
                jobPreview.models.AddLast(jobVisual);
                jobPreview.UpdateChanges();
                newVisual = null;
                editor.toolUpdating.Text = "";
            }
            if (recalcJobPreview && jobPreviewThreadFinished)
            {
                recalcJobPreview = false;
                jobPreviewThreadFinished = false;
                JobUpdater workerObject = new JobUpdater();
                editor.toolUpdating.Text = "Updating ...";
                previewThread = new Thread(workerObject.DoWork);
                previewThread.Start();

            }
            if (refreshCounter > 0)
            {
                if (--refreshCounter == 0)
                {
                    Invalidate();
                }
            }
        }
예제 #11
0
        private void RedrawCurrentCheckpoint()
        {
            if (checkpoints.GetCurrent() != null && checkBoxPreviewCheckpoint.Checked)
            {
                Stopwatch sw = new Stopwatch();
                sw.Start();

                GCodeVisual gcodeVisual = new GCodeVisual();
                gcodeVisual.showSelection = true;
                gcodeVisual.minLayer = 0;
                gcodeVisual.maxLayer = 999999;
                Main.main.checkpointsView = new ThreeDView();
                Main.main.checkpointsView.editor = false;
                Main.main.checkpointsView.models.AddLast(gcodeVisual);
                Main.main.assign3DView();

                gcodeVisual.parseGCodeShortArray(ToGCodeShortArray(checkpoints.GetCurrent().GetCodeAlreadyExecuted()), false, 0);

                gcodeVisual.Reduce();

                sw.Stop();
            }
        }
예제 #12
0
        public void UpdateVBO(bool buffer)
        {
            if (pointsCount < 2)
            {
                return;
            }
            if (hasBuf)
            {
                GL.DeleteBuffers(3, buf);
            }
            hasBuf = false;
            int   method = Main.threeDSettings.filamentVisualization;
            float h = Main.threeDSettings.layerHeight;
            float wfac = Main.threeDSettings.widthOverHeight;
            float w = h * wfac;
            bool  fixedH = Main.threeDSettings.useLayerHeight;
            float dfac = (float)(Math.PI * Main.threeDSettings.filamentDiameter * Main.threeDSettings.filamentDiameter * 0.25 / wfac);
            int   nv = 8 * (method - 1), i;

            if (method == 1)
            {
                nv = 4;
            }
            if (method == 0)
            {
                nv = 1;
            }
            int n = nv * (method == 0 ? 1 : 2) * (pointsCount - pointsLists.Count);

            //if (method != 0) positions = new float[n * 3]; else positions = new float[3 * pointsCount];
            //if (method != 0) normals = new float[n * 3]; else normals = null;
            if (method != 0)
            {
                positions = new float[pointsCount * nv * 3];
            }
            else
            {
                positions = new float[3 * pointsCount];
            }
            if (method != 0)
            {
                normals = new float[pointsCount * nv * 3];
            }
            else
            {
                normals = null;
            }
            if (method != 0)
            {
                elements = new int[(pointsCount - pointsLists.Count) * nv * 4 + pointsLists.Count * (nv - 2) * 4];
            }
            else
            {
                elements = new int[n * 2];
            }
            int pos  = 0;
            int npos = 0;
            int vpos = 0;

            if (method > 0)
            {
                float   alpha, dalpha = (float)Math.PI * 2f / nv;
                float[] dir     = new float[3];
                float[] dirs    = new float[3];
                float[] diru    = new float[3];
                float[] norm    = new float[3];
                float[] lastdir = new float[3];
                float[] actdir  = new float[3];
                float   laste   = 0;
                float   dh      = 0.5f * h;
                float   dw      = 0.5f * w;
                bool    first   = true;
                Vector3 last    = new Vector3();
                w *= 0.5f;
                int nv2 = 2 * nv;
                foreach (LinkedList <GCodePoint> points in pointsLists)
                {
                    if (points.Count < 2)
                    {
                        continue;
                    }
                    first = true;
                    LinkedListNode <GCodePoint> ptNode = points.First;
                    while (ptNode != null)
                    {
                        GCodePoint pt  = ptNode.Value;
                        GCodePoint ptn = null;
                        if (ptNode.Next != null)
                        {
                            ptn = ptNode.Next.Value;
                        }
                        ptNode = ptNode.Next;
                        Vector3 v = pt.p;
                        if (first)
                        {
                            last       = v;
                            laste      = pt.e;
                            lastdir[0] = actdir[0] = ptn.p.X - v.X;
                            lastdir[1] = actdir[1] = ptn.p.Y - v.Y;
                            lastdir[2] = actdir[2] = ptn.p.Z - v.Z;
                            GCodeVisual.normalize(ref lastdir);
                            // first = false;
                            // continue;
                        }
                        else
                        {
                            bool isLast = pt == points.Last.Value;
                            if (isLast)
                            {
                                actdir[0] = v.X - last.X;
                                actdir[1] = v.Y - last.Y;
                                actdir[2] = v.Z - last.Z;
                            }
                            else
                            {
                                actdir[0] = ptn.p.X - v.X;
                                actdir[1] = ptn.p.Y - v.Y;
                                actdir[2] = ptn.p.Z - v.Z;
                            }
                        }
                        if (!fixedH)
                        {
                            float dist = (float)Math.Sqrt(actdir[0] * actdir[0] + actdir[1] * actdir[1] + actdir[2] * actdir[2]);
                            if (dist > 0)
                            {
                                h  = (float)Math.Sqrt((pt.e - laste) * dfac / dist);
                                w  = h * wfac;
                                dh = 0.5f * h;
                                dw = 0.5f * w;
                            }
                        }
                        GCodeVisual.normalize(ref actdir);
                        dir[0] = actdir[0] + lastdir[0];
                        dir[1] = actdir[1] + lastdir[1];
                        dir[2] = actdir[2] + lastdir[2];
                        GCodeVisual.normalize(ref dir);
                        float zoomw = dir[0] * lastdir[0] + dir[1] * lastdir[1] + dir[2] * lastdir[2];
                        lastdir[0] = actdir[0];
                        lastdir[1] = actdir[1];
                        lastdir[2] = actdir[2];
                        dirs[0]    = -dir[1];
                        dirs[1]    = dir[0];
                        dirs[2]    = dir[2];
                        diru[0]    = diru[1] = 0;
                        diru[2]    = 1;
                        alpha      = 0;
                        float c, s;
                        int   b = vpos / 3 - nv;
                        for (i = 0; i < nv; i++)
                        {
                            c       = (float)Math.Cos(alpha) * dh;
                            s       = (float)Math.Sin(alpha) * dw / zoomw;
                            norm[0] = (float)(s * dirs[0] + c * diru[0]);
                            norm[1] = (float)(s * dirs[1] + c * diru[1]);
                            norm[2] = (float)(s * dirs[2] + c * diru[2]);
                            GCodeVisual.normalize(ref norm);
                            if (!first)
                            {
                                elements[pos++] = b + (i + 1) % nv;      //2
                                elements[pos++] = b + i;                 //1
                                elements[pos++] = b + i + nv;            //4
                                elements[pos++] = b + (i + 1) % nv + nv; //3
                            }
                            normals[npos++]   = norm[0];
                            normals[npos++]   = norm[1];
                            normals[npos++]   = norm[2];
                            positions[vpos++] = v.X + s * dirs[0] + c * diru[0];
                            positions[vpos++] = v.Y + s * dirs[1] + c * diru[1];
                            positions[vpos++] = v.Z - dh + s * dirs[2] + c * diru[2];
                            alpha            += dalpha;
                        }
                        if (first || ptNode == null) // Draw cap
                        {
                            b = vpos / 3 - nv;
                            int nn = (nv - 2) / 2;
                            for (i = 0; i < nn; i++)
                            {
                                if (first)
                                {
                                    elements[pos++] = b + i;
                                    elements[pos++] = b + i + 1;
                                    elements[pos++] = b + nv - i - 2;
                                    elements[pos++] = b + nv - i - 1;
                                }
                                else
                                {
                                    elements[pos++] = b + nv - i - 1;
                                    elements[pos++] = b + nv - i - 2;
                                    elements[pos++] = b + i + 1;
                                    elements[pos++] = b + i;
                                }
                            }
                        }
                        last  = v;
                        laste = pt.e;
                        first = false;
                    }
                }
                if (buffer)
                {
                    GL.GenBuffers(3, buf);
                    GL.BindBuffer(BufferTarget.ArrayBuffer, buf[0]);
                    GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(positions.Length * sizeof(float)), positions, BufferUsageHint.StaticDraw);
                    GL.BindBuffer(BufferTarget.ArrayBuffer, buf[1]);
                    GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(normals.Length * sizeof(float)), normals, BufferUsageHint.StaticDraw);
                    GL.BindBuffer(BufferTarget.ElementArrayBuffer, buf[2]);
                    GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)(elements.Length * sizeof(int)), elements, BufferUsageHint.StaticDraw);
                    // GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
                    hasBuf = true;
                }
            }
            else
            {
                // Draw edges
                bool first = true;
                foreach (LinkedList <GCodePoint> points in pointsLists)
                {
                    first = true;
                    foreach (GCodePoint pt in points)
                    {
                        Vector3 v = pt.p;
                        positions[vpos++] = v.X;
                        positions[vpos++] = v.Y;
                        positions[vpos++] = v.Z;

                        if (!first)
                        {
                            elements[pos]     = pos / 2;
                            elements[pos + 1] = pos / 2 + 1;
                            pos += 2;
                        }
                        first = false;
                    }
                }
                if (buffer)
                {
                    GL.GenBuffers(3, buf);
                    GL.BindBuffer(BufferTarget.ArrayBuffer, buf[0]);
                    GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(positions.Length * sizeof(float)), positions, BufferUsageHint.StaticDraw);
                    GL.BindBuffer(BufferTarget.ElementArrayBuffer, buf[2]);
                    GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)(elements.Length * sizeof(int)), elements, BufferUsageHint.StaticDraw);
                    hasBuf = true;
                }
            }
            drawMethod = method;
        }
예제 #13
0
        public void UpdateVBO()
        {
            if (points.Count < 2)
            {
                return;
            }
            if (elements != null)
            {
                GL.DeleteBuffers(3, buf);
            }
            int   method = Main.threeDSettings.filamentVisualization;
            float h = Main.threeDSettings.layerHeight;
            float w = h * Main.threeDSettings.widthOverHeight;
            int   nv = 8 * (method - 1), i;

            if (method == 1)
            {
                nv = 4;
            }
            if (method == 0)
            {
                nv = 1;
            }
            int n = nv * (method == 0 ? 1 : 2) * (points.Count - 1);

            if (method != 0)
            {
                positions = new float[n * 3];
            }
            else
            {
                positions = new float[3 * points.Count];
            }
            if (method != 0)
            {
                normals = new float[n * 3];
            }
            else
            {
                normals = null;
            }
            if (method != 0)
            {
                elements = new int[(points.Count - 1) * nv * 4];
            }
            else
            {
                elements = new int[n * 2];
            }
            int pos  = 0;
            int npos = 0;
            int vpos = 0;

            if (method > 0)
            {
                float   alpha, dalpha = (float)Math.PI * 2f / nv;
                float[] dir   = new float[3];
                float[] dirs  = new float[3];
                float[] diru  = new float[3];
                float[] norm  = new float[3];
                float   dh    = 0.5f * h;
                float   dw    = 0.5f * w;
                bool    first = true;
                Vector3 last  = new Vector3();
                w *= 0.5f;
                int nv2 = 2 * nv;
                foreach (Vector3 v in points)
                {
                    if (first)
                    {
                        last  = v;
                        first = false;
                        continue;
                    }
                    bool isLast = v == points.Last.Value;
                    dir[0] = v.X - last.X;
                    dir[1] = v.Y - last.Y;
                    dir[2] = v.Z - last.Z;
                    GCodeVisual.normalize(ref dir);
                    dirs[0] = -dir[1];
                    dirs[1] = dir[0];
                    dirs[2] = dir[2];
                    diru[0] = diru[1] = 0;
                    diru[2] = 1;
                    alpha   = 0;
                    float c, s;
                    int   b = vpos / 3;
                    for (i = 0; i < nv; i++)
                    {
                        c       = (float)Math.Cos(alpha) * dh;
                        s       = (float)Math.Sin(alpha) * dw;
                        norm[0] = (float)(s * dirs[0] + c * diru[0]);
                        norm[1] = (float)(s * dirs[1] + c * diru[1]);
                        norm[2] = (float)(s * dirs[2] + c * diru[2]);
                        GCodeVisual.normalize(ref norm);
                        elements[pos++]   = b + i * 2;                   //1
                        elements[pos++]   = b + (i * 2 + nv2 - 2) % nv2; //2
                        elements[pos++]   = b + (i * 2 + nv2 - 1) % nv2; //3
                        elements[pos++]   = b + (i * 2 + 1);             //4
                        normals[npos++]   = norm[0];
                        normals[npos++]   = norm[1];
                        normals[npos++]   = norm[2];
                        normals[npos++]   = norm[0];
                        normals[npos++]   = norm[1];
                        normals[npos++]   = norm[2];
                        positions[vpos++] = last.X + s * dirs[0] + c * diru[0];
                        positions[vpos++] = last.Y + s * dirs[1] + c * diru[1];
                        positions[vpos++] = last.Z - dh + s * dirs[2] + c * diru[2];
                        positions[vpos++] = v.X + s * dirs[0] + c * diru[0];
                        positions[vpos++] = v.Y + s * dirs[1] + c * diru[1];
                        positions[vpos++] = v.Z - dh + s * dirs[2] + c * diru[2];
                        alpha            += dalpha;
                    }
                    last = v;
                }
                GL.GenBuffers(3, buf);
                GL.BindBuffer(BufferTarget.ArrayBuffer, buf[0]);
                GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(positions.Length * sizeof(float)), positions, BufferUsageHint.StaticDraw);
                GL.BindBuffer(BufferTarget.ArrayBuffer, buf[1]);
                GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(normals.Length * sizeof(float)), normals, BufferUsageHint.StaticDraw);
                GL.BindBuffer(BufferTarget.ElementArrayBuffer, buf[2]);
                GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)(elements.Length * sizeof(int)), elements, BufferUsageHint.StaticDraw);
            }
            else
            {
                // Draw edges
                bool first = true;
                foreach (Vector3 v in points)
                {
                    positions[vpos++] = v.X;
                    positions[vpos++] = v.Y;
                    positions[vpos++] = v.Z;

                    if (!first)
                    {
                        elements[pos]     = pos / 2;
                        elements[pos + 1] = pos / 2 + 1;
                        pos += 2;
                    }
                    first = false;
                }
                GL.GenBuffers(3, buf);
                GL.BindBuffer(BufferTarget.ArrayBuffer, buf[0]);
                GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(positions.Length * sizeof(float)), positions, BufferUsageHint.StaticDraw);
                GL.BindBuffer(BufferTarget.ElementArrayBuffer, buf[2]);
                GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)(elements.Length * sizeof(int)), elements, BufferUsageHint.StaticDraw);
            }
            drawMethod = method;
        }