Exemple #1
0
 public HSCPanel(HSComponent nOwner)
 {
     owner = nOwner;
     InitializeComponent();
     UpdateViewButton.Checked = HSComponent.UpdateView;
     delayBox.Text = HSComponent.delay.ToString();
 }
Exemple #2
0
 // Auto loop all.
 public void autoLoop()
 {
     attr.Panel.Message("Checking all Components.");
     ResetAllData();
     // Case 1:  There is only on HS component in the document.
     //          Use that as a starting point.
     if (HoopSnakes.Count == 1)
     {
         ActiveComponent = HoopSnakes[0];
     }
     // Case 2:  There are more components.
     //          Attempt to find a "starting point" for the
     //          loop structure by checking if there is a component
     //          with no inputs in trigger.
     else
     {
         foreach (HSComponent h in HoopSnakes)
         {
             if (h.Params.Input[3].SourceCount == 0)
             {
                 h.OldComponent  = ActiveComponent;
                 ActiveComponent = h;
             }
         }
     }
     Loop();
 }
Exemple #3
0
 public HSCPanel(HSComponent nOwner)
 {
     owner = nOwner;
     InitializeComponent();
     UpdateViewButton.Checked = HSComponent.UpdateView;
     delayBox.Text            = HSComponent.delay.ToString();
 }
Exemple #4
0
 // Start.
 public void Start()
 {
     // Prepare this component for looping.
     if (resetCounterOnLoop)
     {
         ResetStepCounter();
     }
     ActiveComponent = this;
     OldComponent    = null;
     // Start looping.
     Loop();
 }
Exemple #5
0
 private void StepButton_Click(object sender, EventArgs e)
 {
     try
     {
         HSComponent c = (HSComponent)HSCombo.SelectedItem;
         c.Step();
     }
     catch
     {
         Message("Error while stepping.");
     }
 }
Exemple #6
0
 public HSAttributes(IGH_Component nComponent)
     : base(nComponent)
 {
     m_owner = (HSComponent)nComponent; 
 }
Exemple #7
0
 public HSAttributes(IGH_Component nComponent)
     : base(nComponent)
 {
     m_owner = (HSComponent)nComponent;
 }
Exemple #8
0
 public HSTriggerParam(HSComponent nOwner)
     : base(new GH_InstanceDescription("Trigger", "T*", "Is input unchanged?", "Params", "Primitive"))
 {
     this.m_owner     = nOwner;
     this.WireDisplay = GH_ParamWireDisplay.faint;
 }
Exemple #9
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();
        }
Exemple #10
0
 // Start.
 public void Start()
 {
     // Prepare this component for looping.
     if (resetCounterOnLoop) ResetStepCounter();
     ActiveComponent = this;
     OldComponent = null;
     // Start looping.
     Loop();
 }
Exemple #11
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();
        }
Exemple #12
0
 // Auto loop all. 
 public void autoLoop()
 {
     attr.Panel.Message("Checking all Components.");
     ResetAllData();
     // Case 1:  There is only on HS component in the document.
     //          Use that as a starting point.
     if (HoopSnakes.Count == 1)
     {
         ActiveComponent = HoopSnakes[0];
     }
     // Case 2:  There are more components.
     //          Attempt to find a "starting point" for the
     //          loop structure by checking if there is a component
     //          with no inputs in trigger.
     else
     {
         foreach (HSComponent h in HoopSnakes)
         {
             if (h.Params.Input[3].SourceCount == 0)
             {
                 h.OldComponent = ActiveComponent;
                 ActiveComponent = h;
             }
         }
     }
     Loop();
 }
Exemple #13
0
 public HSBoolParam(HSComponent nOwner)
     : base(new GH_InstanceDescription("Termination Condition", "B*", "Accepts either a boolean or number. \n If the boolean is false, or the current\n iterations count is equal or more than\n the input, the loop will stop.", "Params", "Primitive"))
 {
     this.m_owner = nOwner;
 }
Exemple #14
0
 public HSDataParam(HSComponent nOwner, GH_Param <IGH_Goo> nParam)
     : base(new GH_InstanceDescription("Data", "D*", "Represents a collection of generic data", "Params", "Primitive"))
 {
     this.m_owner = nOwner;
     this.m_param = nParam;
 }