Esempio n. 1
0
        public void showScene(AnomalyController anomalyController)
        {
            if (!shown)
            {
                anomalyController.SceneController.setSceneDefinition(sceneFileInterface.getFileObject());

                SimObjectManagerDefinition simObjectManager = new SimObjectManagerDefinition();
                anomalyController.SimObjectController.setSceneManagerDefintion(simObjectManager);

                commonShowScene(anomalyController);
            }
        }
Esempio n. 2
0
        public void createCurrentProject()
        {
            anomalyController.ResourceController.clearResources();
            if (currentProject != null)
            {
                currentProject.showScene(anomalyController);
            }
            else //Create an empty scene
            {
                SimSceneDefinition sceneDefinition = new SimSceneDefinition();
                anomalyController.SceneController.setSceneDefinition(sceneDefinition);

                SimObjectManagerDefinition simObjectManager = new SimObjectManagerDefinition();
                anomalyController.SimObjectController.setSceneManagerDefintion(simObjectManager);
            }
            anomalyController.ResourceController.applyToScene();
        }
Esempio n. 3
0
 internal void buildInstance(SimObjectManagerDefinition simObjectManagerDefinition)
 {
     if (instance != null)
     {
         if (!simObjectManagerDefinition.hasSimObject(instance.Definition.Name))
         {
             simObjectManagerDefinition.addSimObject(instance.Definition);
         }
         else
         {
             Log.Error("Could not create SimObject {0} because an instance with that name already exists.", instance.Name);
         }
     }
     else
     {
         Log.Error("Could not create SimObject {0} because the instance definition could not be loaded.", instance.Name);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Load the SimObject instances from the given XML stream into the
 /// given SimObjectManagerDefinition.
 /// </summary>
 /// <param name="xmlReader">The XML stream to read instances from.</param>
 /// <param name="objectManager">The SimObjectManagerDefinition to fill with the new instances.</param>
 public void loadInstances(XmlReader xmlReader, SimObjectManagerDefinition objectManager)
 {
     while (xmlReader.Read())
     {
         if (xmlReader.NodeType == XmlNodeType.Element)
         {
             if (xmlReader.Name.Equals(SIMOBJECT_ELEMENT))
             {
                 String templatePath          = xmlReader.GetAttribute(TEMPLATE_ATTRIBUTE);
                 SimObjectDefinition template = null;//= templateController.getTemplateFromPath(templatePath);
                 if (template != null)
                 {
                     if (!objectManager.hasSimObject(template.Name))
                     {
                         SimObjectDefinition instance = copySaver.copyObject(template) as SimObjectDefinition;
                         while (!(xmlReader.Name == SIMOBJECT_ELEMENT && xmlReader.NodeType == XmlNodeType.EndElement) && xmlReader.Read())
                         {
                             if (xmlReader.NodeType == XmlNodeType.Element)
                             {
                                 if (xmlReader.Name == ROTATION_ELEMENT)
                                 {
                                     instance.Rotation = readRotation(xmlReader);
                                 }
                                 else if (xmlReader.Name == LOCATION_ELEMENT)
                                 {
                                     instance.Translation = readTranslation(xmlReader);
                                 }
                             }
                         }
                         objectManager.addSimObject(instance);
                     }
                     else
                     {
                         Log.Default.sendMessage("The SimObjectManager already has an instance named {0}. Skipping this instance.", LogLevel.Warning, "Editor", template.Name);
                     }
                 }
                 else
                 {
                     Log.Default.sendMessage("Could not find template {0}. Skipping this instance.", LogLevel.Warning, "Editor", templatePath);
                 }
             }
         }
     }
 }
 /// <summary>
 /// Set the SimObjectManagerDefintion to be used by this controller.
 /// This will add the definitions to the UI but will not create the
 /// instances. That will happen when the scene is loaded on the
 /// callback.
 /// </summary>
 /// <param name="definition">The SimObjectManagerDefinition to use.</param>
 public void setSceneManagerDefintion(SimObjectManagerDefinition definition)
 {
     controller.SelectionController.clearSelection();
     simObjectManagerDefiniton = definition;
 }