Ejemplo n.º 1
0
        public GOM_Link(GOM_Interface_Graphic_Object startObj, GOM_Point startPt, GOM_Interface_Graphic_Object endObj, GOM_Point endPt, GOM_Style_Drawing drawingStyle, GOM_Linking_Style linkingStyle, GOM_Terminal_Style startStyle, GOM_Terminal_Style endStyle)
        {
            m_startObj		= startObj;
            m_endObj		= endObj;
            m_startPt		= startPt;
            m_endPt			= endPt;
            m_startStyle	= startStyle;
            m_endStyle		= endStyle;
            m_drawingStyle	= drawingStyle;
            m_linkingStyle	= linkingStyle;
            m_keyPts		= new GOM_Points();

            m_drawingStyle.id = "default";
        }
Ejemplo n.º 2
0
 public static GOM_Link CreateLink(GOM_Interface_Graphic_Object startObj, GOM_Point startPt, GOM_Interface_Graphic_Object endObj, GOM_Point endPt, GOM_Points keyPoints)
 {
     GOM_Style_Drawing drawing = new GOMLib.GOM_Style_Drawing();
     drawing.drawingStyle.Color = System.Drawing.Color.Gray;
     GOM_Link link = new GOMLib.GOM_Link(startObj, startPt,
         endObj, endPt,
         drawing,
         GOMLib.GOM_Linking_Style.Line,
         GOMLib.GOM_Terminal_Style.None,
         GOMLib.GOM_Terminal_Style.None);
     if ( keyPoints!=null && keyPoints.Count>0 )
     {
         link.m_linkingStyle = GOMLib.GOM_Linking_Style.Polyline;
         link.m_keyPts = keyPoints;
     }
     return link;
 }
Ejemplo n.º 3
0
 public static GOM_Link CreateLink(GOM_Interface_Graphic_Object startObj, GOM_Point startPt, GOM_Interface_Graphic_Object endObj, GOM_Point endPt)
 {
     return CreateLink(startObj, startPt, endObj, endPt, null);
 }
Ejemplo n.º 4
0
        public static void ScaleObject(GOM_Interface_Graphic_Object obj, float maxWidth, float maxHeight)
        {
            float	ratio;

            ratio = System.Math.Min(maxWidth / obj.width, maxHeight / obj.height);

            obj.width		*= ratio;
            obj.height	*= ratio;
        }
 /// <summary>
 /// The constructor of GOM_Rotation_Constraint
 /// </summary>
 /// <param name="obj">The graphic object to be resized</param>
 /// <param name="pt">The south east resizing point</param>
 public GOM_Rotation_Constraint(GOM_Interface_Graphic_Object obj, GOM_Point pt)
 {
     m_obj	= obj;
     m_pt	= pt;
 }
 /// <summary>
 /// The constructor of GOM_Resizing_SW_Constraint
 /// </summary>
 /// <param name="obj">The graphic object to be resized</param>
 /// <param name="pt">The south east resizing point</param>
 public GOM_Resizing_SW_Constraint(GOM_Interface_Graphic_Object obj, GOM_Point pt)
 {
     m_obj	= obj;
     m_pt	= pt;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Add a graphic object into the list
 /// </summary>
 /// <param name="val">The graphic object being stored</param>
 public void Add(GOM_Interface_Graphic_Object val)
 {
     rgObject.Add(val);
 }
Ejemplo n.º 8
0
 public void Remove(GOM_Interface_Graphic_Object val)
 {
     rgObject.Remove(val);
 }
Ejemplo n.º 9
0
 public void Insert(GOM_Interface_Graphic_Object val, int idx)
 {
     rgObject.Insert(idx, val);
 }
Ejemplo n.º 10
0
 public bool Contains(GOM_Interface_Graphic_Object val)
 {
     return rgObject.Contains(val);
 }
Ejemplo n.º 11
0
        private bool CalculatePointLocation(ref System.Drawing.PointF pt, GOM_Interface_Graphic_Object obj, GOM_Objects rgObjs)
        {
            bool bTranslated = false;

            for (int i = 0; i < rgObjs.Count; i++)
            {
                if (rgObjs[i].Equals(obj))
                {
                    bTranslated = true;
                }
                else if (rgObjs[i] is GOM_Object_Group)
                {
                    bTranslated |= CalculatePointLocation(ref pt, obj, ((GOM_Object_Group)rgObjs[i]).rgObjects);
                }

                if (bTranslated)
                {
                    pt = rgObjs[i].PointToCanvas(pt);
                    break;
                }
            }

            return bTranslated;
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Load the link from XmlNode.
        /// </summary>
        /// <param name="node">The XmlNode.</param>
        /// <param name="resources">GOM resource.</param>
        public void LoadFromXML(System.Xml.XmlNode node, GOM_ResourceArrays resources)
        {
            GOM_Utility.VerifyXmlNode(node, GOM_TAGS.CONNECTION);

            for( int i=0; i<node.Attributes.Count; i++ )
            {
            //				if ( string.Compare(node.Attributes[i].Name,GOM_TAGS.DRAWING_STYLE) == 0 )
            //				{
            //					this.m_drawingStyle = resources.DrawingStyles[node.Attributes[i].Value];
            //				}
                if ( string.Compare(node.Attributes[i].Name,GOM_TAGS.LINKING_STYLE) == 0 )
                {
                    this.m_linkingStyle = ConvertStringToLinkingStyle(node.Attributes[i].Value);
                }
            }

            GOM_Utility.VerifyXmlNode(node.ChildNodes[0], GOM_TAGS.POINT);
            GOM_Utility.VerifyXmlNode(node.ChildNodes[1], GOM_TAGS.POINT);
            // 1st pass
            //   objectID
            for( int i=0; i<node.ChildNodes[0].Attributes.Count; i++ )
            {
                if ( string.Compare(node.ChildNodes[0].Attributes[i].Name, GOM_TAGS.OBJECTID) == 0 )
                {
                    this.m_startObj = GOM_Utility.RecursiveFindObject(node.ChildNodes[0].Attributes[i].Value, resources.Objects);
                }
            }
            for( int i=0; i<node.ChildNodes[1].Attributes.Count; i++ )
            {
                if ( string.Compare(node.ChildNodes[1].Attributes[i].Name, GOM_TAGS.OBJECTID) == 0 )
                {
                    this.m_endObj = GOM_Utility.RecursiveFindObject(node.ChildNodes[1].Attributes[i].Value, resources.Objects);
                }
            }
            if ( m_startObj==null || m_endObj==null )
            {
                throw new System.Xml.XmlException("Missing points in the connection.");
            }

            //			if ( !(m_startObj is GOM_Object_Primitive) || !(m_endObj is GOM_Object_Primitive) )
            //			{
            //				throw new System.Xml.XmlException("Terminal points' objects are not all primitives.");
            //			}

            // 2nd pass
            //   pointID
            //   terminalStyle
            for( int i=0; i<node.ChildNodes[0].Attributes.Count; i++ )
            {
                if ( string.Compare(node.ChildNodes[0].Attributes[i].Name, GOM_TAGS.POINTID) == 0 )
                {
                    this.m_startPt = m_startObj.GetPointByName(node.ChildNodes[0].Attributes[i].Value);
                }
                if ( string.Compare(node.ChildNodes[0].Attributes[i].Name, GOM_TAGS.TERMINAL_STYLE) == 0 )
                {
                    this.m_startStyle = ConvertStringToTerminalStyle(node.ChildNodes[0].Attributes[i].Value);
                }
            }
            for( int i=0; i<node.ChildNodes[1].Attributes.Count; i++ )
            {
                if ( string.Compare(node.ChildNodes[1].Attributes[i].Name, GOM_TAGS.POINTID) == 0 )
                {
                    this.m_endPt = m_endObj.GetPointByName(node.ChildNodes[1].Attributes[i].Value);
                }
                if ( string.Compare(node.ChildNodes[1].Attributes[i].Name, GOM_TAGS.TERMINAL_STYLE) == 0 )
                {
                    this.m_endStyle = ConvertStringToTerminalStyle(node.ChildNodes[1].Attributes[i].Value);
                }
            }

            if ( m_startPt==null || m_endPt==null )
            {
                throw new System.Xml.XmlException("Cannot find find terminal points.");
            }

            // Drawing style
            this.m_drawingStyle.LoadFromXML( node.ChildNodes[2], resources );

            // Key points
            GOM_Utility.VerifyXmlNode(node.ChildNodes[3], GOM_TAGS.KEYPOINTS);
            for(int i=0; i<node.ChildNodes[3].ChildNodes.Count; i++ )
            {
                if ( string.Compare(node.ChildNodes[3].ChildNodes[i].Name, GOM_TAGS.POINT, true) == 0 )
                {
                    GOM_Point keyPoint = new GOM_Point();
                    for(int j=0; j<node.ChildNodes[3].ChildNodes[i].Attributes.Count; j++ )
                    {
                        if ( string.Compare(node.ChildNodes[3].ChildNodes[i].Attributes[j].Name, GOM_TAGS.X, true) == 0 )
                        {
                            keyPoint.x = float.Parse(node.ChildNodes[3].ChildNodes[i].Attributes[j].Value);
                        }
                        if ( string.Compare(node.ChildNodes[3].ChildNodes[i].Attributes[j].Name, GOM_TAGS.Y, true) == 0 )
                        {
                            keyPoint.y = float.Parse(node.ChildNodes[3].ChildNodes[i].Attributes[j].Value);
                        }
                    }
                    m_keyPts.Add(keyPoint);
                }
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Indicates whether this link is linked with an specilized object.
        /// </summary>
        /// <param name="obj">The object.</param>
        /// <returns>Whether this link is linked with an specilized object.</returns>
        public bool LinkWith(GOM_Interface_Graphic_Object obj)
        {
            if (m_startObj.Equals(obj) || m_endObj.Equals(obj))
            {
                return true;
            }
            else if (obj is GOM_Object_Group)
            {
                GOM_Object_Group objGroup = ((GOM_Object_Group)obj);

                for (int i = 0; i < objGroup.rgObjects.Count; i++)
                {
                    if (LinkWith(objGroup.rgObjects[i]))
                    {
                        return true;
                    }
                }
            }

            return false;
        }