コード例 #1
0
        public RevitVisualizationManager(DynamoModel dynamoModel) : base(dynamoModel)
        {
            if (dynamoModel.Context == Context.VASARI_2014 ||
                dynamoModel.Context == Context.REVIT_2015)
            {
                AlternateDrawingContextAvailable = true;
                DrawToAlternateContext           = false;

                AlternateContextName = dynamoModel.Context;

                RequestAlternateContextClear += CleanupVisualizations;
                dynamoModel.CleaningUp       += CleanupVisualizations;
            }
            else
            {
                AlternateDrawingContextAvailable = false;
            }
        }
コード例 #2
0
        public override void Cleanup()
        {
            try
            {
                preloader = null;
                DynamoSelection.Instance.ClearSelection();

                if (this.CurrentDynamoModel != null)
                {
                    this.CurrentDynamoModel.ShutDown(false);
                    this.CurrentDynamoModel = null;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }

            base.Cleanup();
        }
コード例 #3
0
        public VisualizationManager(DynamoModel model)
        {
            dynamoModel = model;

            dynamoModel.WorkspaceClearing += Pause;
            dynamoModel.WorkspaceCleared  += ClearVisualizations;

            dynamoModel.WorkspaceAdded   += WorkspaceAdded;
            dynamoModel.WorkspaceRemoved += WorkspaceRemoved;

            dynamoModel.DeletionStarted  += Pause;
            dynamoModel.DeletionComplete += UnPauseAndUpdate;

            dynamoModel.CleaningUp += Clear;

            dynamoModel.EvaluationCompleted += Update;
            dynamoModel.RequestsRedraw      += Update;

            UnPause(this, EventArgs.Empty);
        }
コード例 #4
0
        public VisualizationManager(DynamoModel dynamoModel)
        {
            MaxTesselationDivisions = 128;

            this.dynamoModel = dynamoModel;
            renderManager    = new RenderManager(this, dynamoModel);
            //octree = new Octree.OctreeSearch.Octree(10000,-10000,10000,-10000,10000,-10000,10000000);

            dynamoModel.WorkspaceClearing += Pause;
            dynamoModel.WorkspaceCleared  += UnPauseAndUpdate;

            dynamoModel.NodeAdded   += NodeAdded;
            dynamoModel.NodeDeleted += NodeDeleted;

            dynamoModel.DeletionStarted  += Pause;
            dynamoModel.DeletionComplete += UnPauseAndUpdate;

            dynamoModel.CleaningUp += Clear;

            UnPause(this, EventArgs.Empty);
        }
コード例 #5
0
        protected virtual void StartDynamo(IPreferences settings = null)
        {
            var assemblyPath = Assembly.GetExecutingAssembly().Location;

            preloader = new Preloader(Path.GetDirectoryName(assemblyPath));
            preloader.Preload();

            var preloadedLibraries = new List <string>();

            GetLibrariesToPreload(preloadedLibraries);

            if (preloadedLibraries.Any())
            {
                // Only when any library needs preloading will a path resolver be
                // created, otherwise DynamoModel gets created without preloading
                // any library.
                //

                var pathResolverParams = new TestPathResolverParams()
                {
                    UserDataRootFolder   = GetUserUserDataRootFolder(),
                    CommonDataRootFolder = GetCommonDataRootFolder()
                };

                pathResolver = new TestPathResolver(pathResolverParams);
                foreach (var preloadedLibrary in preloadedLibraries.Distinct())
                {
                    pathResolver.AddPreloadLibraryPath(preloadedLibrary);
                }
            }

            this.CurrentDynamoModel = DynamoModel.Start(
                new DynamoModel.DefaultStartConfiguration()
            {
                PathResolver        = pathResolver,
                StartInTestMode     = true,
                GeometryFactoryPath = preloader.GeometryFactoryPath,
                Preferences         = settings
            });
        }
コード例 #6
0
        public override void Cleanup()
        {
            try
            {
                preloader = null;
                DynamoSelection.Instance.ClearSelection();

                if (CurrentDynamoModel != null)
                {
                    CurrentDynamoModel.ShutDown(false);
                    CurrentDynamoModel = null;
                }

                PathManager.BuiltinPackagesDirectory = originalBuiltinPackagesDirectory;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }

            base.Cleanup();
        }
コード例 #7
0
 private void CleanupVisualizations(DynamoModel model)
 {
     CleanupVisualizations();
 }
コード例 #8
0
 private void Clear(DynamoModel dynamoModel)
 {
     Pause(this, EventArgs.Empty);
     Cleanup();
 }
コード例 #9
0
        /// <summary>
        ///     Class constructor
        /// </summary>
        public DynamoController(string context, IUpdateManager updateManager,
                                IWatchHandler watchHandler, IPreferences preferences)
        {
            DebugSettings = new DebugSettings();

            IsCrashing = false;

            dynSettings.Controller = this;

            Context = context;

            //Start heartbeat reporting
            InstrumentationLogger.Start();

            PreferenceSettings = preferences;
            ((PreferenceSettings)PreferenceSettings).PropertyChanged += PreferenceSettings_PropertyChanged;

            SIUnit.LengthUnit   = PreferenceSettings.LengthUnit;
            SIUnit.AreaUnit     = PreferenceSettings.AreaUnit;
            SIUnit.VolumeUnit   = PreferenceSettings.VolumeUnit;
            SIUnit.NumberFormat = PreferenceSettings.NumberFormat;

            UpdateManager = updateManager;
            UpdateManager.UpdateDownloaded  += updateManager_UpdateDownloaded;
            UpdateManager.ShutdownRequested += updateManager_ShutdownRequested;
            UpdateManager.CheckForProductUpdate(new UpdateRequest(new Uri(Configurations.UpdateDownloadLocation), dynSettings.DynamoLogger, UpdateManager.UpdateDataAvailable));

            WatchHandler = watchHandler;

            //create the model
            DynamoModel = new DynamoModel();
            DynamoModel.AddHomeWorkspace();
            DynamoModel.CurrentWorkspace   = DynamoModel.HomeSpace;
            DynamoModel.CurrentWorkspace.X = 0;
            DynamoModel.CurrentWorkspace.Y = 0;

            // custom node loader
            string directory   = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string pluginsPath = Path.Combine(directory, "definitions");

            CustomNodeManager = new CustomNodeManager(pluginsPath);

            SearchViewModel = new SearchViewModel();

            dynSettings.PackageLoader = new PackageLoader();

            dynSettings.PackageLoader.DoCachedPackageUninstalls();
            dynSettings.PackageLoader.LoadPackages();

            DisposeLogic.IsShuttingDown = false;

            EngineController = new EngineController(this);

            //This is necessary to avoid a race condition by causing a thread join
            //inside the vm exec
            //TODO(Luke): Push this into a resync call with the engine controller
            ResetEngine();

            dynSettings.DynamoLogger.Log(String.Format(
                                             "Dynamo -- Build {0}",
                                             Assembly.GetExecutingAssembly().GetName().Version));

            DynamoLoader.ClearCachedAssemblies();
            DynamoLoader.LoadNodeModels();

            MigrationManager.Instance.MigrationTargets.Add(typeof(WorkspaceMigrations));

            Runner = new DynamoRunner();
        }
コード例 #10
0
 private void Clear(DynamoModel dynamoModel)
 {
     Pause(this, EventArgs.Empty);
     QueueRenderTask();
 }
コード例 #11
0
ファイル: DynamoRunner.cs プロジェクト: Sean-Nguyen/Dynamo
 /// <summary>
 ///     Class constructor
 /// </summary>
 /// <param name="dynamoModel"> The parent DynamoModel object</param>
 /// <param name="fschemeEnv"> The enviro.  Should be able to get rid of this. </param>
 public DynamoRunner(DynamoModel dynamoModel, ExecutionEnvironment fschemeEnv)
 {
     this.DynamoModel = dynamoModel;
     this.FSchemeEnv  = fschemeEnv;
 }
コード例 #12
0
 public WorkspaceMigrations(DynamoModel dynamoModel)
 {
     this.dynamoModel = dynamoModel;
 }
コード例 #13
0
ファイル: DynamoRunner.cs プロジェクト: romeo08437/Dynamo
 /// <summary>
 ///     Class constructor
 /// </summary>
 /// <param name="dynamoModel"> The parent DynamoModel object</param>
 /// <param name="fschemeEnv"> The enviro.  Should be able to get rid of this. </param>
 public DynamoRunner(DynamoModel dynamoModel, ExecutionEnvironment fschemeEnv)
 {
     this.DynamoModel = dynamoModel;
     this.FSchemeEnv = fschemeEnv;
 }
コード例 #14
0
        /// <summary>
        /// Compiles this custom node definition, updating all UI instances to match
        /// inputs and outputs and registering new definition with the EngineController.
        /// </summary>
        public void Compile(DynamoModel dynamoModel, EngineController controller)
        {
            // If we are loading dyf file, dont compile it until all nodes are loaded
            // otherwise some intermediate function defintions will be created.
            // TODO: This is a hack, in reality we should be preventing this from being called at the Workspace.RequestSync() level --SJE
            if (IsBeingLoaded || IsProxy)
            {
                return;
            }

            #region Outputs and Inputs and UI updating

            #region Find outputs

            // Find output elements for the node
            List <Output> outputs = WorkspaceModel.Nodes.OfType <Output>().ToList();

            var topMost = new List <Tuple <int, NodeModel> >();

            List <string> outNames;

            // if we found output nodes, add select their inputs
            // these will serve as the function output
            if (outputs.Any())
            {
                topMost.AddRange(
                    outputs.Where(x => x.HasInput(0)).Select(x => Tuple.Create(0, x as NodeModel)));
                outNames = outputs.Select(x => x.Symbol).ToList();
            }
            else
            {
                outNames = new List <string>();

                // if there are no explicitly defined output nodes
                // get the top most nodes and set THEM as the output
                IEnumerable <NodeModel> topMostNodes = WorkspaceModel.GetTopMostNodes();

                var rtnPorts =
                    //Grab multiple returns from each node
                    topMostNodes.SelectMany(
                        topNode =>
                        //If the node is a recursive instance...
                        topNode is Function && (topNode as Function).Definition == this
                        // infinity output
                                ? new[] { new { portIndex = 0, node = topNode, name = "∞" } }
                        // otherwise, grab all ports with connected outputs and package necessary info
                                : topNode.OutPortData
                        .Select(
                            (port, i) =>
                            new { portIndex = i, node = topNode, name = port.NickName })
                        .Where(x => !topNode.HasOutput(x.portIndex)));

                foreach (var rtnAndIndex in rtnPorts.Select((rtn, i) => new { rtn, idx = i }))
                {
                    topMost.Add(Tuple.Create(rtnAndIndex.rtn.portIndex, rtnAndIndex.rtn.node));
                    outNames.Add(rtnAndIndex.rtn.name ?? rtnAndIndex.idx.ToString());
                }
            }

            var nameDict = new Dictionary <string, int>();
            foreach (var name in outNames)
            {
                if (nameDict.ContainsKey(name))
                {
                    nameDict[name]++;
                }
                else
                {
                    nameDict[name] = 0;
                }
            }

            nameDict = nameDict.Where(x => x.Value != 0).ToDictionary(x => x.Key, x => x.Value);

            outNames.Reverse();

            var keys = new List <string>();
            foreach (var name in outNames)
            {
                int amt;
                if (nameDict.TryGetValue(name, out amt))
                {
                    nameDict[name] = amt - 1;
                    keys.Add(name == "" ? amt + ">" : name + amt);
                }
                else
                {
                    keys.Add(name);
                }
            }

            keys.Reverse();

            ReturnKeys = keys;

            #endregion

            //Find function entry point, and then compile
            var inputNodes = WorkspaceModel.Nodes.OfType <Symbol>().ToList();
            var parameters = inputNodes.Select(x => string.IsNullOrEmpty(x.InputSymbol) ? x.AstIdentifierForPreview.Value: x.InputSymbol);
            Parameters = inputNodes.Select(x => x.InputSymbol);

            //Update existing function nodes which point to this function to match its changes
            var customNodeInstances = dynamoModel.AllNodes
                                      .OfType <Function>()
                                      .Where(el => el.Definition != null && el.Definition == this);

            foreach (var node in customNodeInstances)
            {
                node.ResyncWithDefinition();
            }

            //Call OnSave for all saved elements
            foreach (var node in WorkspaceModel.Nodes)
            {
                node.OnSave();
            }

            #endregion

            var outputNodes = topMost.Select((x) =>
            {
                var n = x.Item2.GetAstIdentifierForOutputIndex(x.Item1);
                return(n as AssociativeNode);
            });

#if ENABLE_DYNAMO_SCHEDULER
            var initParams = new CompileCustomNodeParams()
            {
                EngineController = controller,
                Definition       = this,
                Nodes            = WorkspaceModel.Nodes.Where(x => !(x is Symbol)),
                Parameters       = parameters,
                Outputs          = outputNodes
            };

            // Schedule the compilation of CustomNodeDefinition, we are
            // not interested in when it will be completed, so no callback.
            var scheduler = dynamoModel.Scheduler;
            var task      = new CompileCustomNodeAsyncTask(scheduler);
            if (task.Initialize(initParams))
            {
                scheduler.ScheduleForExecution(task);
            }
#else
            controller.GenerateGraphSyncDataForCustomNode(
                this,
                WorkspaceModel.Nodes.Where(x => !(x is Symbol)),
                outputNodes,
                parameters);
#endif

            // Not update graph until Run
            // if (success)
            //    controller.UpdateGraph();
        }