Beispiel #1
0
        /// <summary>
        /// Gets all object aliases
        /// </summary>
        /// <param name="baseObject">Base object</param>
        /// <param name="o">object</param>
        /// <param name="list">List of aliases</param>
        /// <param name="type">Type of alias</param>
        public static void GetAllObjectAliases(IAssociatedObject baseObject, object o, List <string> list, object type)
        {
            IAssociatedObject ass = o as IAssociatedObject;
            IObjectLabel      l   = ass.Object as IObjectLabel;

            GetAllAliases(baseObject, l, list, type);
        }
Beispiel #2
0
        /// <summary>
        /// Checks whether str has prefix of component name
        /// </summary>
        /// <param name="ao">Relative object</param>
        /// <param name="obj">Object</param>
        /// <param name="str">String to check</param>
        /// <returns>The component and null otherwise</returns>
        static public INamedComponent PrefixComponent(IAssociatedObject ao, object obj, string str)
        {
            if (!(obj is IAssociatedObject))
            {
                return(null);
            }
            IAssociatedObject ass = obj as IAssociatedObject;

            if (!(ass.Object is INamedComponent))
            {
                return(null);
            }
            INamedComponent c = ass.Object as INamedComponent;
            int             n = str.LastIndexOf(".");
            string          s = str.Substring(0, n);

            if (s.Equals(ao.GetRelativeName(ass)))
            {
                return(c);
            }
            else
            {
                return(null);
            }
        }
Beispiel #3
0
 private void GetObjectsPrivate(IAssociatedObject ao, IList <ICategoryObject> objects, IList <ICategoryArrow> arrows)
 {
     {
         if (ao is ICategoryObject)
         {
             objects.Add(ao as ICategoryObject);
         }
         if (ao is ICategoryArrow)
         {
             arrows.Add(ao as ICategoryArrow);
         }
         if (ao is IChildrenObject)
         {
             IChildrenObject     co  = ao as IChildrenObject;
             IAssociatedObject[] ass = co.Children;
             if (ass != null)
             {
                 foreach (IAssociatedObject asso in ass)
                 {
                     if (asso != null)
                     {
                         GetObjects(asso, objects, arrows);
                     }
                 }
             }
         }
     }
 }
Beispiel #4
0
        private FormFieldShape(FieldConsumer3D consumer)
            : this()
        {
            IAssociatedObject ao = consumer as IAssociatedObject;

            Set(ao.Object as IObjectLabel);
        }
 /// <summary>
 /// Gets interface
 /// </summary>
 /// <typeparam name="T">Type</typeparam>
 /// <param name="obj">Object</param>
 /// <returns>Interface</returns>
 public static T GetInterface <T>(this IAssociatedObject obj) where T : class
 {
     if (obj is T)
     {
         return(obj as T);
     }
     if (obj is IChildrenObject)
     {
         IChildrenObject     co = obj as IChildrenObject;
         IAssociatedObject[] ch = co.Children;
         if (ch != null)
         {
             foreach (IAssociatedObject ob in ch)
             {
                 if (ob != null)
                 {
                     T o = GetInterface <T>(ob);
                     if (o != null)
                     {
                         return(o);
                     }
                 }
             }
         }
     }
     return(null);
 }
Beispiel #6
0
        /// <summary>
        /// The operation that performs after arrows setting
        /// </summary>
        public void PostSetArrow()
        {
            //aliases = new IAliasName[aliasNames.Count];
            int i = 0;
            List <IAliasName> lan = new List <IAliasName>();

            foreach (string s in aliasNames)
            {
                IAliasName[] arr = this.FindAllAliasName(s, false);
                lan.AddRange(arr);
            }
            aliases = lan.ToArray();
            int nmea = 0;

            for (i = 0; i < measurementsNames.Count; i++)
            {
                string name = measurementsNames[i] as string;
                int    n    = name.LastIndexOf(".");
                string m    = name.Substring(0, n);
                foreach (IMeasurements meas in measurements)
                {
                    IAssociatedObject ao = meas as IAssociatedObject;
                    //INamedComponent nc = ao.Object as INamedComponent;
                    if (!m.Equals(this.GetRelativeName(ao)))
                    {
                        continue;
                    }
                    string suff = name.Substring(n + 1);
                    for (int j = 0; j < meas.Count; j++)
                    {
                        IMeasurement mea = meas[j];
                        if (!mea.Name.Equals(suff))
                        {
                            continue;
                        }
                        measurementsDitcionary[nmea] = mea;
                        ++nmea;
                    }
                }
            }
            for (i = 0; i < selectionNames.Count; i++)
            {
                string sn = selectionNames[i] as string;
                foreach (IStructuredSelectionCollection s in selections)
                {
                    IAssociatedObject ao = s as IAssociatedObject;
                    //INamedComponent nc = ao.Object as INamedComponent;
                    string name = this.GetRelativeName(ao);                    //nc.Name;
                    for (int j = 0; j < s.Count; j++)
                    {
                        if (!sn.Equals(name + "." + s[j].Name))
                        {
                            continue;
                        }
                        selectedSelections[i] = s[j];
                    }
                }
            }
            Init();
        }
        private void Process(List <object> l, List <RelativeMeasurements> rm, IPosition position,
                             List <object> ladd, int priority, string reason)
        {
            Action <object> act = (object obj) => { };

            if (position == null)
            {
                return;
            }
            IDataConsumer c = position.GetLabelObject <IDataConsumer>();

            if (c != null)
            {
                if (c is IAssociatedObject)
                {
                    IAssociatedObject ao = c as IAssociatedObject;
                    object            o  = ao.Object;
                    if (!ladd.Contains(o))
                    {
                        ladd.Add(o);
                    }
                }
                CreateDataConsumerCollection(c, ladd, act, priority, reason);
            }
            Process(l, rm, position.Parent, ladd, priority, reason);
        }
Beispiel #8
0
        /// <summary>
        /// Creates transformer of associated object
        /// </summary>
        /// <param name="tr">Initial transformer</param>
        /// <param name="obj">The object</param>
        /// <returns>The transformer</returns>
        static public Action <double[]> CreateTransformer(Action <double[]> tr, IAssociatedObject obj)
        {
            if (!(obj is IChildrenObject))
            {
                return(tr);
            }
            IChildrenObject ch = obj as IChildrenObject;

            IAssociatedObject[]       ao = ch.Children;
            List <Action <double[]> > l  = new List <Action <double[]> >();

            foreach (IAssociatedObject ob in ao)
            {
                if (!(ob is IVectorTransformer))
                {
                    continue;
                }
                IVectorTransformer t  = ob as IVectorTransformer;
                Action <double[]>  tv = t.Transformer;
                if (tv != null)
                {
                    l.Add(tv);
                }
            }
            if (l.Count == 0)
            {
                return(tr);
            }
            Action <double[]> trv = Sum(l.ToArray());
            Action <double[]> tvr = tr + trv;

            return(tvr);
        }
        /// <summary>
        /// Gets additional feature
        /// </summary>
        /// <typeparam name="T">Feature type</typeparam>
        /// <param name="factory">User interface factory</param>
        /// <param name="obj">Obj</param>
        /// <returns>Feature</returns>
        static public object GetAdditionalFeature <T>(this IUIFactory factory, IAssociatedObject obj)
        {
            IUIFactory f = factory;
            IUIFactory p = factory.Parent;

            if (p != null)
            {
                f = p;
            }
            if (obj == null)
            {
                return(null);
            }
            if (obj is T)
            {
                return(f.GetAdditionalFeature <T>((T)obj));
            }
            if (obj is IChildrenObject) // If object has children
            {
                IAssociatedObject[] ao = (obj as IChildrenObject).Children;
                foreach (IAssociatedObject aa in ao) // Searches additional feature among children
                {
                    object ob = GetAdditionalFeature <T>(f, aa);
                    if (ob != null)
                    {
                        return(ob);
                    }
                }
            }
            return(null);
        }
Beispiel #10
0
        /// <summary>
        /// Sets measures to consumer
        /// </summary>
        /// <param name="consumer">The consumer</param>
        /// <param name="measures">Names of measures</param>
        /// <param name="measuresData">Measures</param>
        public static void SetMeasurements(IDataConsumer consumer, List <string> measures, List <IMeasurement> measuresData)
        {
            measuresData.Clear();
            IAssociatedObject ac = consumer as IAssociatedObject;

            foreach (string ms in measures)
            {
                for (int i = 0; i < consumer.Count; i++)
                {
                    IMeasurements     m  = consumer[i];
                    IAssociatedObject ao = m as IAssociatedObject;
                    string            on = ac.GetRelativeName(ao) + ".";

                    for (int j = 0; j < m.Count; j++)
                    {
                        IMeasurement mea = m[j];
                        string       s   = on + mea.Name;
                        if (s.Equals(ms))
                        {
                            measuresData.Add(mea);
                        }
                    }
                }
            }
        }
Beispiel #11
0
 /// <summary>
 /// Gets objects and arrows of associated object
 /// </summary>
 /// <param name="ao">The associated object</param>
 /// <param name="objects">Objects</param>
 /// <param name="arrows">Arrows</param>
 protected virtual void GetObjects(IAssociatedObject ao, IList <ICategoryObject> objects, IList <ICategoryArrow> arrows)
 {
     if (ao is IObjectContainer)
     {
         IObjectContainer     oc = ao as IObjectContainer;
         IDesktop             d  = oc.Desktop;
         IEnumerable <object> c  = d.AllComponents;
         foreach (object o in c)
         {
             if (o is IObjectLabel)
             {
                 IObjectLabel ol = o as IObjectLabel;
                 GetObjects(ol.Object, objects, arrows);
             }
             if (o is IArrowLabel)
             {
                 IArrowLabel al = o as IArrowLabel;
                 GetObjects(al.Arrow, objects, arrows);
             }
         }
     }
     else
     {
         GetObjectsPrivate(ao, objects, arrows);
     }
 }
Beispiel #12
0
        /// <summary>
        /// Finds measure by name
        /// </summary>
        /// <param name="name">Measure name</param>
        /// <returns>The measure</returns>
        protected IMeasurement Find(string name)
        {
            int n = name.LastIndexOf(".");

            if (n < 0)
            {
                return(null);
            }
            string cn   = name.Substring(0, n);
            string suff = name.Substring(n + 1);

            for (int i = 0; i < mea.Count; i++)
            {
                IMeasurements     m  = mea[i];
                IAssociatedObject ao = m as IAssociatedObject;
                string            na = this.GetRelativeName(ao);
                if (cn.Equals(na))
                {
                    for (int j = 0; j < m.Count; j++)
                    {
                        IMeasurement ms = m[j];
                        if (suff.Equals(ms.Name))
                        {
                            return(ms);
                        }
                    }
                }
            }
            return(null);
        }
Beispiel #13
0
        /// <summary>
        /// Creates collection of components
        /// </summary>
        /// <param name="consumer">Data consumer</param>
        /// <param name="list">List of objects</param>
        /// <param name="action">Additional acton</param>
        /// <param name="priority">Priority</param>
        /// <param name="reason">Reason</param>
        /// <returns>Collection of components</returns>
        protected void CreateDataConsumerCollection(IDataConsumer consumer, List <object> list,
                                                    Action <object> action, int priority, string reason)
        {
            IList <object> ll = consumer.GetDependentObjects();

            foreach (object o in ll)
            {
                if (o is INamedComponent)
                {
                    action(o);
                    if (!list.Contains(o))
                    {
                        list.Add(o);
                    }
                    continue;
                }
                if (o is IAssociatedObject)
                {
                    IAssociatedObject ao = o as IAssociatedObject;
                    object            ob = ao.Object;
                    action(ob);
                    if (ob is INamedComponent)
                    {
                        if (!list.Contains(ob))
                        {
                            list.Add(ob);
                        }
                        continue;
                    }
                }
            }
        }
Beispiel #14
0
 /// <summary>
 /// Creates Mesurements
 /// </summary>
 protected void CreateMesurements()
 {
     isLoaded = true;
     measurements.Clear();
     Dictionary<string, IMeasurement> d = this.GetAllMeasurementsByName((double)0);
     List<string> l = new List<string>(d.Keys);
     l.Sort();
     medians = new double[l.Count];
     condition = null;
     IAssociatedObject ass = this;
     if (ass.Object != null)
     {
         condition = this.FindMeasurement(conditionName, true);
     }
     Dictionary<string, IMeasurement> dp = new Dictionary<string, IMeasurement>();
     int i = 0;
     list = new List<double>[l.Count];
     input = new IMeasurement[l.Count];
     foreach (string key in d.Keys)
     {
         int[] p = new int[] { i };
         string k = key.Replace('.', '_').Replace('/', '_');
         IMeasurement m = new Measurement(
             () => 
             {
                 return medians[p[0]];
             }, 
             k);
         measurements.Add(m);
         list[i] = new List<double>();
         input[i] = d[key];
         ++i;
      }
 }
Beispiel #15
0
 /// <summary>
 /// Accepts arguments
 /// </summary>
 private void AcceptArguments()
 {
     foreach (IMeasurements measurements in this.measurements)
     {
         IAssociatedObject cont = measurements as IAssociatedObject;
         INamedComponent   c    = cont.Object as INamedComponent;
         string            name = c.Name;
         for (int i = 0; i < measurements.Count; i++)
         {
             IMeasurement measure = measurements[i];
             string       p       = name + "." + measure.Name;
             for (int j = 0; j < 2; j++)
             {
                 if (arguments[j].Equals(p))
                 {
                     input[j] = measure;
                     break;
                 }
             }
         }
     }
     hasDerivation = true;
     for (int i = 0; i < input.Length; i++)
     {
         IDerivation der = input[i] as IDerivation;
         if (der == null)
         {
             hasDerivation = false;
             break;
         }
     }
 }
Beispiel #16
0
 /// <summary>
 /// Gets Differential Equation Solver from object
 /// </summary>
 /// <param name="obj"></param>
 /// <returns></returns>
 public override IDifferentialEquationSolver GetDifferentialEquationSolver(object obj)
 {
     if (obj is IAssociatedObject)
     {
         IAssociatedObject ao  = obj as IAssociatedObject;
         AggregableWrapper agg =
             ao.GetObject <AggregableWrapper>();
         if (agg != null)
         {
             if (agg.Aggregate.Parent == null)
             {
                 return(GetEquation(agg));
             }
         }
     }
     if (obj is DataPerformer.Portable.MeasurementsWrapper)
     {
         DataPerformer.Portable.MeasurementsWrapper m = obj as DataPerformer.Portable.MeasurementsWrapper;
         for (int i = 0; i < m.Count; i++)
         {
             if (m[i] is AggregableWrapper)
             {
                 AggregableWrapper agg =
                     m[i] as AggregableWrapper;
                 if (agg.Aggregate.Parent == null)
                 {
                     return(GetEquation(agg));
                 }
             }
         }
     }
     return(null);
 }
Beispiel #17
0
 internal PanelConsumer(IDataConsumer consumer, Dictionary <string, string> selected, object vars)
 {
     this.consumer = consumer;
     obj           = consumer as IAssociatedObject;
     this.selected = selected;
     this.vars     = vars;
     Init();
 }
Beispiel #18
0
 IPhysicalField IFieldFactory.GetField(IFieldConsumer consumer, object obj)
 {
     if (obj is IAssociatedObject)
     {
         IAssociatedObject ao = obj as IAssociatedObject;
         object            o  = ao.GetObject <PhysicalField.Interfaces.IPhysicalField>();
     }
     return(null);
 }
Beispiel #19
0
 IFieldConsumer IFieldFactory.GetConsumer(object obj)
 {
     if (obj is IAssociatedObject)
     {
         IAssociatedObject ao = obj as IAssociatedObject;
         return(ao.GetObject <IFieldConsumer>());
     }
     return(null);
 }
        /// <summary>
        /// Gets names of providers
        /// </summary>
        /// <param name="consumer">Consumer</param>
        /// <returns>Names of providers</returns>
        public static IEnumerable <string> GetProviders(this IBitmapConsumer consumer)
        {
            IAssociatedObject ao = consumer as IAssociatedObject;

            foreach (IBitmapProvider p in consumer.Providers)
            {
                yield return(ao.GetRelativeName(p as IAssociatedObject));
            }
        }
 IAggregableMechanicalObject IAggregableMechanicalFactory.GetObject(object obj)
 {
     if (obj is IAssociatedObject)
     {
         IAssociatedObject ao = obj as IAssociatedObject;
         return(ao.GetObject <IAggregableMechanicalObject>());
     }
     return(null);
 }
Beispiel #22
0
        /// <summary>
        /// Gets all measurements of one dimension real array
        /// </summary>
        /// <param name="ao">Associated object</param>
        /// <returns>Names of measurements</returns>
        public static string[] GetOneDimensionRealArrays(this IAssociatedObject ao)
        {
            INamedComponent nc = null;

            if (ao is INamedComponent)
            {
                nc = ao as INamedComponent;
            }
            else
            {
                nc = ao.Object as INamedComponent;
            }
            IDesktop desktop = nc.Root.Desktop;

            if (desktop == null)
            {
                desktop = nc.Desktop;
            }
            if (desktop == null)
            {
                return(new string[0]);
            }
            List <string> l = new List <string>();

            desktop.ForEach <IMeasurements>((IMeasurements m) =>
            {
                IAssociatedObject aob = m as IAssociatedObject;
                INamedComponent ncm   = aob.Object as INamedComponent;
                string nm             = ncm.GetName(desktop);
                for (int i = 0; i < m.Count; i++)
                {
                    IMeasurement mea = m[i];
                    if (mea == null)
                    {
                        continue;
                    }
                    object t = mea.Type;
                    if (!(t is ArrayReturnType))
                    {
                        continue;
                    }
                    ArrayReturnType art = t as ArrayReturnType;
                    Double a            = 0;
                    if (!art.ElementType.Equals(a))
                    {
                        continue;
                    }
                    if (art.Dimension.Length != 1)
                    {
                        continue;
                    }
                    l.Add(nm + "." + mea.Name);
                }
            });
            return(l.ToArray());
        }
Beispiel #23
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="length">The length</param>
        public FormLength(ILength length)
            : this()
        {
            this.length = length;
            IAssociatedObject ao = length as IAssociatedObject;

            label = ao.Object as IObjectLabel;
            UpdateFormUI();
            textBoxLength.Text = length.Length + "";
        }
Beispiel #24
0
        /// <summary>
        /// Gets associated control
        /// </summary>
        /// <param name="obj">Prototype</param>
        /// <returns>The control</returns>
        public static Control GetControl(this IAssociatedObject obj)
        {
            INamedComponent nc = obj.GetNamedComponent();

            if (nc is Control)
            {
                return(nc as Control);
            }
            return(null);
        }
        /// <summary>
        /// Try to get object of predefined type
        /// </summary>
        /// <typeparam name="T">The type</typeparam>
        /// <param name="obj">The prototype</param>
        /// <param name="message">The exception message</param>
        /// <returns>The object of predefined type</returns>
        public static T GetObject <T>(this IAssociatedObject obj, string message) where T : class
        {
            T a = GetObject <T>(obj);

            if (a != null)
            {
                return(a);
            }
            throw new Exception(message);
        }
Beispiel #26
0
        public FormDeformed(IPosition p, IVisible v)
            : this()
        {
            userControlDeformed.Set(p, v);
            IAssociatedObject ao = p as IAssociatedObject;

            label = ao.Object as IObjectLabel;

            UpdateFormUI();
        }
Beispiel #27
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="obj">Base object</param>
 /// <param name="measurements">Measurements</param>
 /// <param name="vars">Variables</param>
 /// <param name="selected">Selected measurements</param>
 public PanelMeasurements(IAssociatedObject obj,
                          IMeasurements measurements, object vars, Dictionary <string, string> selected)
 {
     this.obj          = obj;
     this.measurements = measurements;
     this.selected     = selected;
     init();
     Vars     = vars;
     Selected = selected;
 }
Beispiel #28
0
        /// <summary>
        /// The post load operation
        /// </summary>
        public override bool PostLoad()
        {
            //return base.PostLoad();
            if (!isLoaded)
            {
                return(false);
            }
            if (isPostLoaded)
            {
                return(true);
            }
            desktop.SetObjectNames();
            PureObjectLabel.SetLabels(desktop.Objects);
            PureArrowLabel.SetLabels(desktop.Arrows);
            IEnumerable <IArrowLabel> arrows = desktop.Arrows;
//            SetParents(desktop);
            IEnumerable <object> components = desktop.Components;

            foreach (INamedComponent nc in components)
            {
                nc.Desktop = desktop;
                //nc.Parent = Object as INamedComponent;
                if (nc is IObjectLabel)
                {
                    IObjectLabel ol = nc as IObjectLabel;
                    if (ol.Object is IObjectContainer)
                    {
                        IObjectContainer oc = ol.Object as IObjectContainer;
                        bool             b  = oc.PostLoad();
                        if (!b)
                        {
                            return(false);
                        }
                    }
                }
            }
            foreach (IArrowLabel arrow in arrows)
            {
                arrow.Desktop = desktop;
                ICategoryObject source = arrow.Arrow.Source;
                if (source == null)
                {
                    arrow.Arrow.Source = arrow.Source.Object;
                }
                ICategoryObject target = arrow.Arrow.Target;
                if (target == null)
                {
                    arrow.Arrow.Target = arrow.Target.Object;
                }
                IAssociatedObject ass = arrow.Arrow as IAssociatedObject;
                ass.Object = arrow;
            }
            return(true);
        }
 /// <summary>
 /// Finds object
 /// </summary>
 /// <typeparam name="T">Object type</typeparam>
 /// <param name="obj">Object</param>
 /// <returns>Found object</returns>
 public static T Find <T>(this IAssociatedObject obj) where T : class
 {
     if (findObject != null)
     {
         object f = findObject[typeof(T), obj];
         if (f != null)
         {
             return(f as T);
         }
     }
     return(null);
 }
Beispiel #30
0
        /// <summary>
        /// Post operation
        /// </summary>
        public override void Post()
        {
            uc.Writer = writer;
            IAssociatedObject ao = this.Object;
            object            o  = ao.Object;

            if (o is UserControlLabel)
            {
                UserControlLabel ucl = o as UserControlLabel;
                ucl.SetImage(Properties.Resources.SeverEvent.ToBitmap());
            }
        }