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"; }
/// <summary> /// The constractor of GOM_Point_Value /// </summary> /// <param name="point">The point referred to</param> /// <param name="type">The type of this node (x/y)</param> public GOM_Point_Value(GOM_Point point, ValueType type) { m_point = point; m_type = type; m_values= new GOM_Values(); if ((type != ValueType.X_Value) && (type != ValueType.Y_Value)) { m_type = ValueType.Error_Value; throw new ArgumentException("Invalid type"); } }
public void Insert(int index, GOM_Point point) { rgPoints.Insert(index, point); }
/// <summary> /// Add a point into the list /// </summary> /// <param name="point">The point being stored</param> public void Add(GOM_Point point) { rgPoints.Add(point); }
/// <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_Filling_Rectangle /// </summary> /// <param name="leftTop">The top left corner of the rectangle</param> /// <param name="righgDown">The right down corner of the rectangle</param> /// <param name="style">The filling style to fill the rectangle</param> public GOM_Filling_Rectangle(GOM_Point leftTop, GOM_Point righgDown, GOM_Style_Filling style) { m_points = new GOM_Points(); m_points.Add(leftTop); m_points.Add(righgDown); m_style = style; }
public GOM_Object_LinkNode() { m_boundingBox = new System.Drawing.RectangleF(0, 0, 0, 0); m_id = Guid.NewGuid().ToString("D");; m_xOffset = 0; m_yOffset = 0; m_rotation = 0; m_point = new GOM_Point(); m_point.id = GOM_Special_Point_Name.LINKNODE_POINT; m_point.Connectable = true; m_point.Controllable = false; }
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; }
/// <summary> /// Initialize the graphic object according to a given template /// </summary> /// <param name="template"></param> public void InitializeFromTemplate(GOM_Template template) { //Initialize property this.m_template = template; this.extConnect = template.extConnect; this.extRotate = template.extRotate; this.extScale = template.extScale; this.keepAspectRatio = template.keepAspectRatio; //Clear up existing data this.rgPoints.Clear(); this.rgFillings.Clear(); this.rgDrawings.Clear(); this.rgEditingModes.Clear(); this.rgDrawingStyles.Clear(); this.rgFillingStyles.Clear(); //Initialize editing mode for (int i = 0; i < template.rgEditingModes.Count; i++) { this.rgEditingModes.Add(template.rgEditingModes[i]); } //Initialize drawing styles for (int i = 0; i < template.rgDrawingStyles.Count; i++) { GOM_Style_Drawing style; style = new GOM_Style_Drawing(); style.id = template.rgDrawingStyles[i].id; style.drawingStyle = (System.Drawing.Pen)template.rgDrawingStyles[i].drawingStyle.Clone(); this.rgDrawingStyles.Add(style); } //Initialize filling styles for (int i = 0; i < template.rgFillingStyles.Count; i++) { GOM_Style_Filling style; style = new GOM_Style_Filling(); style.id = template.rgFillingStyles[i].id; style.fillingStyle = (System.Drawing.Brush)template.rgFillingStyles[i].fillingStyle.Clone(); this.rgFillingStyles.Add(style); } //Initialize basic properties of points for (int i = 0; i < template.rgPoints.Count; i++) { GOM_Point pt; pt = new GOM_Point(); pt.id = template.rgPoints[i].id; pt.x = template.rgPoints[i].x; pt.y = template.rgPoints[i].y; pt.Connectable = template.rgPoints[i].Connectable; pt.Controllable = template.rgPoints[i].Controllable; this.rgPoints.Add(pt); } //Initialize drawing operations for (int i = 0; i < template.rgDrawings.Count; i++) { rgDrawings.Add(CloneDrawing(template.rgDrawings[i])); } //Initialize filling operations for (int i = 0; i < template.rgFillings.Count; i++) { rgFillings.Add(CloneFilling(template.rgFillings[i])); } //Initialize constraints of points for (int i = 0; i < template.rgPoints.Count; i++) { for (int j = 0; j < template.rgPoints[i].Constraints.Count; j++) { GOM_Constraint_Set constraintSet; constraintSet = new GOM_Constraint_Set(); for (int k = 0; k < template.rgPoints[i].Constraints[j].Count; k++) { constraintSet.Add(CloneConstraint(template.rgPoints[i].Constraints[j][k])); } rgPoints[i].Constraints.Add(constraintSet); } } CalculateBoundingBox(); //from template #region new_modified if (template.var_list != null) { var_list = template.var_list.clone(); } if (template.res_list != null) { res_list = template.res_list.clone(); } #endregion }
private GOM_Points LoadPointsFromXML(System.Xml.XmlNode node) { GOM_Points points = new GOM_Points(); for( int i=0; i<node.ChildNodes.Count; i++ ) { if ( string.Compare(node.ChildNodes[i].Name,GOM_TAGS.POINT,true) == 0 ) { GOM_Point pt = new GOM_Point(); pt.LoadFromXML(node.ChildNodes[i], null); points.Add(pt); } } return points; }
public GOM_Object_Group() { m_id = Guid.NewGuid().ToString("D"); m_xOffset = 0; m_yOffset = 0; m_rotation = 0; m_boundingBox = new System.Drawing.RectangleF(); rgObjects = new GOM_Objects(); GOM_Constraint_Set constraintSet; m_Top_Connector = new GOM_Point(); m_Top_Connector.id = GOM_Special_Point_Name.TOP_CONNECTOR; m_Top_Connector.Connectable = true; m_Bottom_Connector = new GOM_Point(); m_Bottom_Connector.id = GOM_Special_Point_Name.BOTTOM_CONNECTOR; m_Bottom_Connector.Connectable = true; m_Left_Connector = new GOM_Point(); m_Left_Connector.id = GOM_Special_Point_Name.LEFT_CONNECTOR; m_Left_Connector.Connectable = true; m_Right_Connector = new GOM_Point(); m_Right_Connector.id = GOM_Special_Point_Name.RIGHT_CONNECTOR; m_Right_Connector.Connectable = true; m_SE_Resize_Point = new GOM_Point(); m_SE_Resize_Point.id = GOM_Special_Point_Name.SE_RESIZING_POINT; constraintSet = new GOM_Constraint_Set(); constraintSet.EditingMode = "default"; constraintSet.Add(new GOM_Resizing_SE_Constraint(this, m_SE_Resize_Point)); m_SE_Resize_Point.Constraints.Add(constraintSet); m_NW_Resize_Point = new GOM_Point(); m_NW_Resize_Point.id = GOM_Special_Point_Name.NW_RESIZING_POINT; constraintSet = new GOM_Constraint_Set(); constraintSet.EditingMode = "default"; constraintSet.Add(new GOM_Resizing_NW_Constraint(this, m_NW_Resize_Point)); m_NW_Resize_Point.Constraints.Add(constraintSet); m_SW_Resize_Point = new GOM_Point(); m_SW_Resize_Point.id = GOM_Special_Point_Name.SW_RESIZING_POINT; constraintSet = new GOM_Constraint_Set(); constraintSet.EditingMode = "default"; constraintSet.Add(new GOM_Resizing_SW_Constraint(this, m_SW_Resize_Point)); m_SW_Resize_Point.Constraints.Add(constraintSet); m_NE_Resize_Point = new GOM_Point(); m_NE_Resize_Point.id = GOM_Special_Point_Name.NE_RESIZING_POINT; constraintSet = new GOM_Constraint_Set(); constraintSet.EditingMode = "default"; constraintSet.Add(new GOM_Resizing_NE_Constraint(this, m_NE_Resize_Point)); m_NE_Resize_Point.Constraints.Add(constraintSet); m_Rotation_Point = new GOM_Point(); m_Rotation_Point.id = GOM_Special_Point_Name.ROTATION_POINT; constraintSet = new GOM_Constraint_Set(); constraintSet.EditingMode = "default"; constraintSet.Add(new GOM_Rotation_Constraint(this, m_Rotation_Point)); m_Rotation_Point.Constraints.Add(constraintSet); }
/// <summary> /// The constructor of GOM_Object_Primitive /// </summary> public GOM_Object_Primitive() { m_id = Guid.NewGuid().ToString("D"); m_xOffset = 0; m_yOffset = 0; m_rotation = 0; m_template = null; GOM_Constraint_Set constraintSet; m_boundingBox = new System.Drawing.RectangleF(0, 0, 0, 0); m_Top_Connector = new GOM_Point(); m_Top_Connector.id = GOM_Special_Point_Name.TOP_CONNECTOR; m_Top_Connector.Connectable = true; m_Bottom_Connector = new GOM_Point(); m_Bottom_Connector.id = GOM_Special_Point_Name.BOTTOM_CONNECTOR; m_Bottom_Connector.Connectable = true; m_Left_Connector = new GOM_Point(); m_Left_Connector.id = GOM_Special_Point_Name.LEFT_CONNECTOR; m_Left_Connector.Connectable = true; m_Right_Connector = new GOM_Point(); m_Right_Connector.id = GOM_Special_Point_Name.RIGHT_CONNECTOR; m_Right_Connector.Connectable = true; m_SE_Resize_Point = new GOM_Point(); m_SE_Resize_Point.id = GOM_Special_Point_Name.SE_RESIZING_POINT; constraintSet = new GOM_Constraint_Set(); constraintSet.EditingMode = "default"; constraintSet.Add(new GOM_Resizing_SE_Constraint(this, m_SE_Resize_Point)); m_SE_Resize_Point.Constraints.Add(constraintSet); m_NW_Resize_Point = new GOM_Point(); m_NW_Resize_Point.id = GOM_Special_Point_Name.NW_RESIZING_POINT; constraintSet = new GOM_Constraint_Set(); constraintSet.EditingMode = "default"; constraintSet.Add(new GOM_Resizing_NW_Constraint(this, m_NW_Resize_Point)); m_NW_Resize_Point.Constraints.Add(constraintSet); m_SW_Resize_Point = new GOM_Point(); m_SW_Resize_Point.id = GOM_Special_Point_Name.SW_RESIZING_POINT; constraintSet = new GOM_Constraint_Set(); constraintSet.EditingMode = "default"; constraintSet.Add(new GOM_Resizing_SW_Constraint(this, m_SW_Resize_Point)); m_SW_Resize_Point.Constraints.Add(constraintSet); m_NE_Resize_Point = new GOM_Point(); m_NE_Resize_Point.id = GOM_Special_Point_Name.NE_RESIZING_POINT; constraintSet = new GOM_Constraint_Set(); constraintSet.EditingMode = "default"; constraintSet.Add(new GOM_Resizing_NE_Constraint(this, m_NE_Resize_Point)); m_NE_Resize_Point.Constraints.Add(constraintSet); m_Rotation_Point = new GOM_Point(); m_Rotation_Point.id = GOM_Special_Point_Name.ROTATION_POINT; constraintSet = new GOM_Constraint_Set(); constraintSet.EditingMode = "default"; constraintSet.Add(new GOM_Rotation_Constraint(this, m_Rotation_Point)); m_Rotation_Point.Constraints.Add(constraintSet); innerText = ""; font = new System.Drawing.Font("Tahoma", 10); fontColor = System.Drawing.Color.Black; extScale = false; extRotate = false; extConnect = false; keepAspectRatio = false; rgPoints = new GOM_Points(); rgDrawings = new GOM_Drawings(); rgFillings = new GOM_Fillings(); rgEditingModes = new GOM_Strings(); rgDrawingStyles = new GOM_Drawing_Styles(); rgFillingStyles = new GOM_Filling_Styles(); }
/// <summary> /// Add a key point into this polyline link. /// </summary> /// <param name="x">X coordinate of the key point.</param> /// <param name="y">Y coordinate of the key point.</param> /// <param name="rgObjs">GOM object collection.</param> public void AddKeyPoint(float x, float y, GOM_Objects rgObjs) { if ( m_linkingStyle != GOM_Linking_Style.Polyline ) { return; } System.Drawing.Drawing2D.Matrix matrix; System.Drawing.PointF[] rgPts, rgAllPts; System.Drawing.PointF startPt, endPt; startPt = StartPointInCanvas(rgObjs); endPt = EndPointInCanvas(rgObjs); rgPts = new System.Drawing.PointF[2]; rgAllPts = new System.Drawing.PointF[m_keyPts.Count+2]; rgAllPts[0].X = startPt.X; rgAllPts[0].Y = startPt.Y; for(int i=0; i<m_keyPts.Count; i++) { rgAllPts[1+i].X = m_keyPts[i].x; rgAllPts[1+i].Y = m_keyPts[i].y; } rgAllPts[rgAllPts.Length-1].X = endPt.X; rgAllPts[rgAllPts.Length-1].Y = endPt.Y; for(int i=0; i<(rgAllPts.Length-1); i++) { rgPts[0].X = rgAllPts[i+1].X; rgPts[0].Y = rgAllPts[i+1].Y; rgPts[1].X = x; rgPts[1].Y = y; matrix = new System.Drawing.Drawing2D.Matrix(); matrix.Translate(-rgAllPts[i].X, -rgAllPts[i].Y); matrix.TransformPoints(rgPts); float angle = (float)(System.Math.Atan2(rgAllPts[i+1].Y - rgAllPts[i].Y, rgAllPts[i+1].X - rgAllPts[i].X) / System.Math.PI) * 180; matrix.Reset(); matrix.Rotate(-angle); matrix.TransformPoints(rgPts); if ((Math.Abs(rgPts[1].Y) < 2) && (-2 < rgPts[1].X) && (rgPts[1].X < rgPts[0].X + 2)) { GOM_Point point = new GOM_Point(); point.x = x; point.y = y; m_keyPts.Insert(i, point); return; } } }
public static bool IsPointOnLink(GOM_Point pt, GOM_Link link, GOM_Objects rgObjs) { return link.IsPointOnLink(pt.x, pt.y, rgObjs); }
/// <summary> /// The constructor of GOM_Drawing_Arc /// </summary> /// <param name="leftTop">The left top corner of the bounding box of the ellipse which the arc belongs to</param> /// <param name="rightDown">The right down corner of the bounding box of the ellipse which the arc belongs to</param> /// <param name="startPoint">The start-point of the arc</param> /// <param name="endPoint">The end-point of the arc</param> /// <param name="style">The drawing style of the arc</param> public GOM_Drawing_Arc(GOM_Point leftTop, GOM_Point rightDown, GOM_Point startPoint, GOM_Point endPoint, GOM_Style_Drawing style, float rotateAngle) { m_points = new GOM_Points(); m_points.Add(leftTop); m_points.Add(rightDown); m_points.Add(startPoint); m_points.Add(endPoint); m_style = style; m_rotateAngle = rotateAngle; }
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); }
/// <summary> /// The constructor of GOM_Drawing_Line /// </summary> /// <param name="startPoint">The start-point of the line</param> /// <param name="endPoint">The end-point of the line</param> /// <param name="style">The drawing style of line</param> public GOM_Drawing_Line(GOM_Point startPoint, GOM_Point endPoint, GOM_Style_Drawing style) { m_points = new GOM_Points(); m_points.Add(startPoint); m_points.Add(endPoint); m_style = style; }
/// <summary> /// The constructor of GOM_Filling_Pie /// </summary> /// <param name="leftTop">The top left corner of the bounding box of the ellipse which the pie belongs to</param> /// <param name="rightDown">The right down corner of the bounding box of the ellipse which the pie belongs to</param> /// <param name="startPoint">The start-point of the pie</param> /// <param name="endPoint">The end-point of the pie</param> /// <param name="style">The filling style to fill the pie</param> public GOM_Filling_Pie(GOM_Point leftTop, GOM_Point rightDown, GOM_Point startPoint, GOM_Point endPoint, GOM_Style_Filling style) { m_points = new GOM_Points(); m_points.Add(leftTop); m_points.Add(rightDown); m_points.Add(startPoint); m_points.Add(endPoint); m_style = style; }
/// <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; }
/// <summary> /// Add a point to current template and load all properties except the constraints /// </summary> /// <param name="node">The XML node that represents the point</param> private void LoadPointFromXML(System.Xml.XmlNode node) { GOMLib.GOM_Point pt; if (System.String.Compare(node.Name, GOM_TAGS.POINT, true) == 0) { pt = new GOM_Point(); pt.LoadFromXML( node, new GOM_ResourceArrays(rgPoints) ); rgPoints.Add(pt); } }
/// <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); } } }