Beispiel #1
0
        public override void DocumentContextChanged(Grasshopper.Kernel.GH_Document document, Grasshopper.Kernel.GH_DocumentContext context)
        {
            base.DocumentContextChanged(document, context);
            if (context == Grasshopper.Kernel.GH_DocumentContext.Loaded)
            {
                //Rhino.RhinoDoc.ReplaceRhinoObject += RhinoDoc_ReplaceRhinoObject;

                timer          = new System.Windows.Forms.Timer();
                timer.Tick    += timer_Tick;
                timer.Enabled  = false;
                timer.Interval = 1;

                // register evens

                keyboardHook.KeyDown     = new RamGecTools.KeyboardHook.KeyboardHookCallback(keyboardHook_KeyDown);
                keyboardHook.KeyUp       = new RamGecTools.KeyboardHook.KeyboardHookCallback(keyboardHook_KeyUp);
                keyboardHook._activate   = new RamGecTools.KeyboardHook.activate(activate);
                keyboardHook._deactivate = new RamGecTools.KeyboardHook.deactivate(deactivate);
                keyboardHook.Uninstall();

                keyboardHook.Install();
                full = new mikity.visualize.fullScreen(DEV);
                full.deactivate();
                full.Show();
                full.resetGo();
                full.drift1();
                full.renewPlot(Drift1);
                full.onRF();
                if (!DEV)
                {
                    full.onNorm();
                    _normalize = true;
                }
                else
                {
                    full.offNorm();
                    _normalize = false;
                }
                full.onGeo();
                full.offVN();
                full.offIF();
            }
            if (context == Grasshopper.Kernel.GH_DocumentContext.Unloaded)
            {
                keyboardHook.Uninstall();
                keyboardHook.KeyDown -= new RamGecTools.KeyboardHook.KeyboardHookCallback(keyboardHook_KeyDown);
                keyboardHook.KeyUp   -= new RamGecTools.KeyboardHook.KeyboardHookCallback(keyboardHook_KeyUp);
                if (full != null)
                {
                    full.Close();
                    full = null;
                }
            }
        }
Beispiel #2
0
        bool keyboardHook_KeyUp(RamGecTools.KeyboardHook.VKeys key)
        {
            if (DEV)
            {
                if (key == RamGecTools.KeyboardHook.VKeys.KEY_F)
                {
                    for (int i = 0; i < FriedChiken.nParticles; i++)
                    {
                        FriedChiken.x[i * 3 + 0] += (rand.NextDouble() - 0.5) * 50d;
                        FriedChiken.x[i * 3 + 1] += (rand.NextDouble() - 0.5) * 50d;
                        FriedChiken.x[i * 3 + 2] += (rand.NextDouble() - 0.5) * 50d;
                    }
                    return(true);
                }

                if (key == RamGecTools.KeyboardHook.VKeys.KEY_E)
                {
                    if (_IF)
                    {
                        _IF = false;
                        full.offIF();
                    }
                    else
                    {
                        _IF = true;
                        full.onIF();
                    }
                    return(true);
                }
                if (key == RamGecTools.KeyboardHook.VKeys.KEY_R)
                {
                    if (_RP)
                    {
                        _RP = false;
                        full.offRF();
                    }
                    else
                    {
                        _RP = true;
                        full.onRF();
                    }
                    return(true);
                }

                if (key == RamGecTools.KeyboardHook.VKeys.KEY_N)
                {
                    if (_normalize)
                    {
                        _normalize = false;
                        full.offNorm();
                    }
                    else
                    {
                        _normalize = true;
                        full.onNorm();
                    }
                    return(true);
                }

                if (key == RamGecTools.KeyboardHook.VKeys.KEY_H)
                {
                    if (_geodesic)
                    {
                        _geodesic = false;
                        full.offGeo();
                    }
                    else
                    {
                        _geodesic = true;
                        full.onGeo();
                    }
                    return(true);
                }

                if (key == RamGecTools.KeyboardHook.VKeys.KEY_A)
                {
                    if (_drift1)
                    {
                        _drift1 = false;
                        _drift2 = true;
                        _drift3 = false;
                        full.drift2();
                        full.renewPlot(Drift2);
                    }
                    else if (_drift2)
                    {
                        _drift1 = false;
                        _drift2 = false;
                        _drift3 = true;
                        full.drift3();
                        full.renewPlot(Drift3);
                    }
                    else if (_drift3)
                    {
                        _drift1 = false;
                        _drift2 = false;
                        _drift3 = false;
                        full.drift0();
                        full.renewPlot(Drift0);
                    }
                    else
                    {
                        _drift1 = true;
                        _drift2 = false;
                        _drift3 = false;
                        full.drift1();
                        full.renewPlot(Drift1);
                    }
                    return(true);
                }
            }

            if (key == RamGecTools.KeyboardHook.VKeys.ESCAPE)
            {
                full.resetGo();
                full.clearNorm();
                _go           = false;
                timer.Enabled = false;
                if (t != 0 && refX != null)
                {
                    t = 0;
                    for (int i = 0; i < FriedChiken.x.rawData.Length; i++)
                    {
                        FriedChiken.x.rawData[i] = refX[i];
                    }
                    FriedChiken.Tick(t); //要素アップデート、勾配の計算
                    FriedChiken.Tack(t); //マスク等後処理
                    refX = null;
                }
                ExpireSolution(true);
                return(true);
            }
            if (key == RamGecTools.KeyboardHook.VKeys.KEY_G)
            {
                if (_go)
                {
                    full.pauseGo();

                    _go           = false;
                    timer.Enabled = false;
                }
                else
                {
                    full.onGo();

                    _go           = true;
                    timer.Enabled = true;
                }
                return(true);
            }
            if (key == RamGecTools.KeyboardHook.VKeys.KEY_T)
            {
                if (_VN)
                {
                    _VN = false;
                    full.offVN();
                }
                else
                {
                    _VN = true;
                    full.onVN();
                }
                return(true);
            }
            return(false);
        }