Ejemplo n.º 1
0
        /// <summary>
        /// The event sequence on changing value of data at other plugin.
        /// </summary>
        /// <param name="modelID">The model ID before value change.</param>
        /// <param name="oldKey">The ID before value change.</param>
        /// <param name="type">The data type before value change.</param>
        /// <param name="eo">Changed value of object.</param>
        public void DataChanged(string modelID, string oldKey, string type, EcellObject eo)
        {
            // Select Canvas
            if (m_canvas == null)
                return;

            // Reset unreached flag.
            m_unreachedFlag = false;

            if (type.Equals(EcellObject.MODEL))
            {
                EcellModel model = (EcellModel)eo;
                m_layerView.ResetLayers(model.Layers);
                m_canvas.RefreshEdges();
                m_animCon.SetAnimationSettings((XmlElement)model.Animations);
            }

            PPathwayObject obj;
            // If case SystemSize
            if (type == Constants.xpathVariable)
            {
                if (eo.LocalID == "SIZE")
                {
                    obj = m_canvas.Systems[eo.ParentSystemID];
                    ((EcellSystem)obj.EcellObject).SizeInVolume = (double)eo.GetEcellValue("Value");
                    obj.Refresh();
                }
            }

            // Select changed object.
            obj = m_canvas.GetObject(oldKey, type);
            if (obj != null)
            {
                // Change data.
                if (!obj.Setting.Name.Equals(eo.Layout.Figure))
                    obj.Setting = m_csManager.GetSetting(eo.Type, eo.Layout.Figure);
                obj.EcellObject = eo;
                m_canvas.DataChanged(oldKey, eo.Key, obj);
            }

            // Update Animation.
            if (IsAnimation)
                m_animCon.SetAnimation();
        }
Ejemplo n.º 2
0
        private static void createSystem(EcellObject anEml, Model aSBMLModel)
        {
            if ( anEml.LocalID == "SBMLParameter" || anEml.LocalID == "SBMLRule" )
                return;

            // create Compartment object
            Compartment aCompartment = aSBMLModel.createCompartment();

            // set ID ROOT System and Other System
            string aCompartmentID = "";
            if (anEml.LocalID == "/")
                aCompartmentID = "default"; // Root system
            else
                aCompartmentID = anEml.LocalID;
            //  aCompartmentID = "default" + anEml.Key.Replace( "/", "__" );

            ID_Namespace.Add( aCompartmentID );

            if (aSBMLModel.getLevel() == 1)
                aCompartment.setName( aCompartmentID );
            else if (aSBMLModel.getLevel() == 2)
                aCompartment.setId( aCompartmentID );

            foreach(EcellObject child in anEml.Children)
            {
                if (!(child is EcellVariable))
                    continue;
                // set Size and constant of Compartment
                if( child.LocalID == "SIZE" )
                {
                    double size = ((EcellSystem)anEml).SizeInVolume;
                    aCompartment.setSize(size);

                    EcellValue value = anEml.GetEcellValue("Fixed");
                    if(value != null)
                        aCompartment.setConstant(System.Convert.ToBoolean((int)value));
                }
                // set Dimensions of Compartment
                else if( child.LocalID == "Dimensions" )
                {
                    int dimension = (int)child.GetEcellValue("Value");
                    aCompartment.setSpatialDimensions(dimension);
                }
            }
            // set Outside element of Compartment
            if( anEml.ParentSystemID == "/" && anEml.LocalID != "")
            {
                aCompartment.setOutside( "default" );
            }
            else if (!string.IsNullOrEmpty(anEml.ParentSystemID))
            {
                aCompartment.setOutside(
                    getCurrentCompartment( anEml.ParentSystemID ));
            }
        }