Example #1
0
        //
        // Performs a complete loop of ALL the components,
        // in their correct sequence, depending on their
        // connectivity.
        //
        public void Loop()
        {
            attr.Panel.loopMode();
            if (!updateView)
            {
                Rhino.Display.RhinoView.EnableDrawing = false;
            }
            attr.Panel.Message("Starting Loop.");
            int steps = 0;

            // Reset all broken components
            foreach (HSComponent h in HoopSnakes)
            {
                if (h.Params.Output[0].VolatileData.IsEmpty)
                {
                    h.ResetData();
                }
            }
            while (ActiveComponent != null && !stop)
            {
                // 1.
                // If an active HoopSnake exists:
                //    If it is still within the loop step it.
                //    Otherwise for the active HoopSnake:
                //       Am I done?
                //       If yes:
                //       1. give control back to the old guy (or null).
                //       2. Reset OldComponent to null.
                if (ActiveComponent != null)
                {
                    if (ActiveComponent.ShouldLoopContinue)
                    {
                        ActiveComponent.Step();
                        steps++;
                    }
                    else
                    {
                        ActiveComponent.lStep++;
                        ActiveComponent.ExpireSolution(true);
                        if (ActiveComponent.OldComponent == null)
                        {
                            attr.Panel.Message("dot", ActiveComponent.NickName, "End of Local Loop.");
                            ActiveComponent = null;
                        }
                        else
                        {
                            HSComponent c = ActiveComponent.OldComponent;
                            attr.Panel.Message("up", ActiveComponent.NickName, "End of Local Loop. Switching to \"" + c.NickName + "\"");
                            ActiveComponent.OldComponent = null;
                            ActiveComponent = c;
                        }
                    }
                }

                // 2.
                // Foreach HoopSnake do:
                // IF my T* input has changed I am in charge!
                // If somebody else was in charge, store him
                // in OldComponent.
                foreach (HSComponent h in HoopSnakes)
                {
                    if (!h.T.same(true) && ActiveComponent != h)
                    {
                        // Messages
                        if (ActiveComponent != null)
                        {
                            attr.Panel.Message("down", ActiveComponent.NickName, "Switching to \"" + h.NickName + "\"");
                        }
                        else
                        {
                            attr.Panel.Message("forward", "", "Switching to \"" + h.NickName + "\"");
                        }

                        h.OldComponent  = ActiveComponent;
                        ActiveComponent = h;
                        h.ResetData();
                        if (h.resetCounterOnLoop)
                        {
                            h.ResetStepCounter();
                        }

                        //Message
                        attr.Panel.Message("dot", ActiveComponent.NickName, "Starting Local Loop.");
                    }
                }
                if (delay > 0)
                {
                    Thread.Sleep(delay);
                }
            }
            attr.Panel.Message("End of Loop.");
            attr.Panel.Message("Total solutions: " + steps.ToString());

            attr.Panel.defaultMode();
            stop = false;
            Rhino.Display.RhinoView.EnableDrawing = true;
            Rhino.RhinoDoc.ActiveDoc.Views.Redraw();
        }
Example #2
0
 private void resetCounterToolStripMenuItem_Click(object sender, EventArgs e)
 {
     owner.ResetStepCounter();
     owner.ExpireSolution(true);
 }