本文整理汇总了C#中PolylineClass.AddSegment方法的典型用法代码示例。如果您正苦于以下问题:C# PolylineClass.AddSegment方法的具体用法?C# PolylineClass.AddSegment怎么用?C# PolylineClass.AddSegment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PolylineClass
的用法示例。
在下文中一共展示了PolylineClass.AddSegment方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnMouseDown
public override void OnMouseDown(int Button, int Shift, int X, int Y)
{
if (Button == 2)
return;
IPoint pt = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
pt = GIS.GraphicEdit.SnapSetting.getSnapPoint(pt);
IGraphicsContainer graphicContainer = m_hookHelper.ActiveView.GraphicsContainer;
IEnvelope pEnvBounds = null;
//��ȡ��һ�ι켣�ߵķ�Χ,�Ա�ȷ��ˢ�·�Χ
try
{
if (m_TracePolygon != null)
{
m_TracePolygon.QueryEnvelope(pEnvBounds);
pEnvBounds.Expand(4, 4, true); //���ο�����������4��(����2������),Ŀ����Ϊ�˱�֤�г����ˢ������
}
else
pEnvBounds = m_hookHelper.ActiveView.Extent;
}
catch
{
pEnvBounds = m_hookHelper.ActiveView.Extent;
}
#region �������
if (m_NewPolygonFeedback == null)
{
//�Ƴ�element
RemoveElements();
//ˢ��
m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
Application.DoEvents();
m_NewPolygonFeedback = new NewPolygonFeedbackClass();
//�����ȵõ�symbol,������symbol
ISimpleLineSymbol simpleLineSymbol = m_NewPolygonFeedback.Symbol as ISimpleLineSymbol;
simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
simpleLineSymbol.Width = 2;
simpleLineSymbol.Color = TransColorToAEColor(Color.Blue);
m_simpleFillSymbol.Outline = simpleLineSymbol;
m_NewPolygonFeedback.Display = m_hookHelper.ActiveView.ScreenDisplay;
m_NewPolygonFeedback.Start(pt);
}
else
{
m_NewPolygonFeedback.AddPoint(pt);
}
if (m_ptCollection == null)
{
m_ptCollection = new PolylineClass();
}
//��¼�ڵ�
object obj = Type.Missing;
m_ptCollection.AddPoint(pt, ref obj, ref obj);
#endregion
#region ���ƽ��
try
{
IElement vertexElement = createElement_x(pt);
//
graphicContainer = m_hookHelper.ActiveView as IGraphicsContainer;
//g.AddElement(vertexElement, 0);
//g.MoveElementToGroup(vertexElement, m_VertexElement);
m_VertexElement.AddElement(vertexElement);
//ˢ��
m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, vertexElement, pEnvBounds);
}
catch
{ }
#endregion
try
{
if (m_ptCollection.PointCount >= 2)
{
IPoint fromPt = m_ptCollection.get_Point(m_ptCollection.PointCount - 2); //�����ڶ�����
IPoint toPt = m_ptCollection.get_Point(m_ptCollection.PointCount - 1); //����һ����
ILine line = new LineClass();
line.PutCoords(fromPt, toPt);
#region ���ƹ켣��
try
{
object missing = Type.Missing;
ISegmentCollection segColl = new PolylineClass();
segColl.AddSegment(line as ISegment, ref missing, ref missing);
IPolyline polyline = new PolylineClass();
//.........这里部分代码省略.........
示例2: OnSketchFinished
private void OnSketchFinished()
{
ConfigUtil.type = "gas";
IFeature pFeat = null;
ISegmentCollection pSegColl = null;
IEnumSegment pESeg = null;
ISegment testSegment = null;
ISegmentCollection segColTest = null;
object Missing = null;
try
{
// Send a shift-tab to hide the construction toolbar
try
{
m_editor.StartOperation();
}
catch
{
m_editor.AbortOperation();
m_editor.StartOperation();
}
bool twoPoint = false;
(ArcMap.Application.Document as IMxDocument).FocusMap.ClearSelection();
List<IFeature> pLstFeat = null;
if (Control.ModifierKeys == Keys.Control)
{
twoPoint = CreateLineWithEndPoints.CreatePoints(ArcMap.Application, ConfigUtil.GetLinePointAtEndsConfig(), m_edSketch.Geometry as IPolyline, (IFeatureLayer)m_editor.CurrentTemplate.Layer, false, out pLstFeat);
}
else
{
twoPoint = CreateLineWithEndPoints.CreatePoints(ArcMap.Application, ConfigUtil.GetLinePointAtEndsConfig(), m_edSketch.Geometry as IPolyline, (IFeatureLayer)m_editor.CurrentTemplate.Layer, true, out pLstFeat);
}
if (twoPoint)
{
pSegColl = (ISegmentCollection)m_edSketch.Geometry;
pESeg = pSegColl.EnumSegments;
pESeg.Reset();
int partIndex = 0;
int segmentIndex = 0;
pESeg.Next(out testSegment, ref partIndex, ref segmentIndex);
while (testSegment != null)
{
segColTest = new PolylineClass();
Missing = Type.Missing;
segColTest.AddSegment(testSegment, ref Missing, ref Missing);
pFeat = Globals.CreateFeature(segColTest as IGeometry, m_editor.CurrentTemplate, m_editor, ArcMap.Application, false, false, true);
pFeat.Store();
pESeg.Next(out testSegment, ref partIndex, ref segmentIndex);
}
}
else
{
pFeat = Globals.CreateFeature(m_edSketch.Geometry, m_editor.CurrentTemplate, m_editor, ArcMap.Application, false, false, true);
pFeat.Store();
}
foreach (IFeature pFt in pLstFeat)
{
pFt.Store();
}
pLstFeat = null;
m_editor.StopOperation("Create line with points");
}
catch { }
finally
{
pFeat = null;
pSegColl = null;
pESeg = null;
testSegment = null;
segColTest = null;
Missing = null;
}
}
示例3: OnMouseUp
private void OnMouseUp()
{
if (m_lMouseDownCount != 2 ) return;
if (m_pEllipticArc == null) return;
m_lMouseDownCount = 0;
ISegmentCollection pSegColl=null;
if (m_pEllipticArc.Envelope.Width > 0.001 && m_pEllipticArc.Envelope.Height > 0.001)
{
m_pCurrentLayer = DataEditCommon.g_pLayer;
IFeatureLayer featureLayer = m_pCurrentLayer as IFeatureLayer;
if (featureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline) //������Ҫ��
{
IPolyline pPolyline;
pSegColl = new PolylineClass();
pSegColl.AddSegment(m_pEllipticArc as ISegment);
pPolyline = pSegColl as IPolyline;
IFeature pFeature = DataEditCommon.CreateUndoRedoFeature(featureLayer, pPolyline);
m_hookHelper.FocusMap.SelectFeature(m_pCurrentLayer, pFeature);
m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics | esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewBackground, null, null);
}
if (featureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon) //������Ҫ��
{
IPolygon pPolygon;
pSegColl = new PolygonClass();
pSegColl.AddSegment(m_pEllipticArc as ISegment);
pPolygon = pSegColl as IPolygon;
IFeature pFeature = DataEditCommon.CreateUndoRedoFeature(featureLayer, pPolygon);
m_hookHelper.FocusMap.SelectFeature(m_pCurrentLayer, pFeature);
m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics | esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewBackground, null, null);
}
//�ֲ�ˢ��
IInvalidArea pInvalidArea = new InvalidAreaClass();
pInvalidArea.Add(pSegColl);
pInvalidArea.Display = m_hookHelper.ActiveView.ScreenDisplay;
pInvalidArea.Invalidate((short)esriScreenCache.esriAllScreenCaches);
m_bCreated = true;
}
}
示例4: OnMouseDown
public override void OnMouseDown(int Button, int Shift, int X, int Y)
{
// �Ҽ�����
if (Button == 2) return;
if (m_pDongshiFeatureLayer == null)
return;
m_pPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
m_pPoint = GIS.GraphicEdit.SnapSetting.getSnapPoint(m_pPoint);
double angle = -1;
string layerName = LayerNames.LAYER_ALIAS_MR_TUNNEL_FD; //���
pFeatLayer = drawSpecialCom.GetFeatureLayerByName(layerName);
IFeature pFeature = null;
TestExistPointFeature(m_hookHelper, m_pPoint, pFeatLayer, ref pFeature);
if (pFeature == null)
{
MessageBox.Show(@"�������û�����������ѡ��һ���������", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
//IPoint hightPoint= Snapping(m_pPoint, pFeatLayer, pFeature);
//if (hightPoint.IsEmpty)
//{
// MessageBox.Show("��ȡ����߽�ʧ�ܣ�������ѡ��", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
// return;
//}
IProximityOperator proximityOperator = (IProximityOperator)pFeature.Shape;
IPoint mousePoint = proximityOperator.ReturnNearestPoint(m_pPoint, esriSegmentExtension.esriNoExtension);
IProximityOperator proximityOperator2 = (IProximityOperator)mousePoint;
ISegmentCollection segmentCollection = (ISegmentCollection)pFeature.Shape;
for (int i = 0; i < segmentCollection.SegmentCount; i++)
{
ISegmentCollection geometryCollection = new PolylineClass();
ISegment segment = segmentCollection.get_Segment(i);
geometryCollection.AddSegment(segment);
geometryCollection.SegmentsChanged();
var distance = proximityOperator2.ReturnDistance((IGeometry)geometryCollection);
if (distance < 0.0001)
{
angle = ((ILine)segment).Angle;
break;
}
}
if (angle == -1)
{
MessageBox.Show(@"��ȡ����߽�ʧ�ܣ�������ѡ��", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
//�õ���Ӧ������
string hdid = pFeature.get_Value(pFeature.Fields.FindField(GIS_Const.FIELD_HDID)).ToString();
string bid = pFeature.get_Value(pFeature.Fields.FindField(GIS_Const.FIELD_BID)).ToString();
FormCaveSizeInput frmCaveSize = new FormCaveSizeInput();
frmCaveSize.ShowDialog();
if (frmCaveSize.DialogResult == DialogResult.OK)
{
//������ȷ��������ҵij��Ϳ�
double Width = frmCaveSize.CaveWidth;
double Height = frmCaveSize.CaveHeight;
PointClass p0 = RectanglePoint(mousePoint, angle, Width);
PointClass p1 = RectanglePoint(mousePoint, angle + Math.PI, Width);
PointClass p2 = RectanglePoint2(p0, angle + 90 * Math.PI / 180, Height);
PointClass p3 = RectanglePoint2(p1, angle + 90 * Math.PI / 180, Height);
//��������
CreateDongShi(p0, p2, p3, p1, hdid, bid);
}
}
示例5: DrawJldc
//.........这里部分代码省略.........
//IPolyline polyline = newLine as IPolyline;
//DataEditCommon.ZMValue(pFeature, polyline); //zwy 20140526 add
//pFeature.Shape = polyline;
////2.1断层标注(DCBZ)
//string strMC = this.txtFaultageName.Text;//断层名称
//string strLC = this.txtGap.Text;//落差
//string strQJ = this.txtAngle.Text;//倾角
//string strDCBZ = strMC + " " + "H=" + strLC + "m" + " " + "<" + strQJ + "°";
////断层标注字段赋值(该字段值保持在图层属性中)
//int index = featureLayer.FeatureClass.Fields.FindField("FAULTAGE_NAME");
//pFeature.set_Value(index, strDCBZ);
////要素ID字段赋值(对应属性表中BindingID)
//int iFieldID = pFeature.Fields.FindField(GIS_Const.FIELD_BID);
//pFeature.Value[iFieldID] = faultage.bid.ToString();
//pFeature.Store();
//DataEditCommon.g_CurWorkspaceEdit.StopEditOperation();
//DataEditCommon.g_CurWorkspaceEdit.StopEditing(true);
////2.2给生成的断层赋符号
//int ID = pFeature.OID;
//string path = Application.StartupPath + @"\symbol.ServerStyle";//【这里用到了自己定义的符号库】
////默认为正断层(符号)
//string sGalleryClassName = "123";
//string symbolName = "123"; ;
//if (this.rbtnFrontFaultage.Checked)//正断层
//{
// sGalleryClassName = "123";
// symbolName = "123";
//}
//else if (this.rbtnOppositeFaultage.Checked)//逆断层
//{
// sGalleryClassName = "1234";
// symbolName = "1234";
//}
//ILineSymbol lineSymbol = GetSymbol(path, sGalleryClassName, symbolName);
//ILayer layer = featureLayer as ILayer;
//SpecialLineRenderer(layer, ID, lineSymbol);
//AddAnnotate(layer, GIS_Const.FILE_DCBZ);
////缩放到新增的线要素,并高亮该要素
//GIS.Common.DataEditCommon.g_pMyMapCtrl.ActiveView.Extent = pFeature.Shape.Envelope;
//GIS.Common.DataEditCommon.g_pMyMapCtrl.ActiveView.Extent.Expand(1.5, 1.5, true);
//GIS.Common.DataEditCommon.g_pMyMapCtrl.Map.SelectFeature(featureLayer, pFeature);
//GIS.Common.DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewAll, null, null);
var pLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.DEFALUT_EXPOSE_FAULTAGE);
var featureLayer = (IFeatureLayer)pLayer;
if (pLayer == null)
{
MessageBox.Show(@"未找到揭露断层图层,无法绘制揭露断层图元。");
return;
}
//2.生成要素(要根据中心点获取起止点)
//中心点
IPoint centrePt = new PointClass();
centrePt.X = faultage.coordinate_x;
centrePt.Y = faultage.coordinate_y;
centrePt.Z = faultage.coordinate_z;
var trend = faultage.trend; //走向
var length = faultage.length / 2; //默认长度为20,左右各10
//计算起止点
IPoint fromPt = new PointClass();
IPoint toPt = new PointClass();
CalculateEndpoints(centrePt, trend, length, ref fromPt, ref toPt);
ILine line = new LineClass();
line.PutCoords(fromPt, toPt);
var missing = Type.Missing;
var segment = (ISegment)line;
ISegmentCollection newLine = new PolylineClass();
newLine.AddSegment(segment, ref missing, ref missing);
var polyline = (IPolyline)newLine;
var list = new List<ziduan>
{
new ziduan("bid", faultage.bid),
new ziduan("FAULTAGE_NAME", faultage.name),
new ziduan("addtime", DateTime.Now.ToString(CultureInfo.InvariantCulture)),
new ziduan("GAP", faultage.gap),
new ziduan("ANGLE", faultage.angle.ToString(CultureInfo.InvariantCulture)),
new ziduan("TREND", faultage.trend.ToString(CultureInfo.InvariantCulture)),
new ziduan("SEPARATION", faultage.separation),
new ziduan("type", faultage.type)
};
var pfeature = DataEditCommon.CreateNewFeature(featureLayer, polyline, list);
if (pfeature == null) return;
MyMapHelp.Jump(polyline);
DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(
(esriViewDrawPhase)34, null, null);
}
示例6: DrawArc
private void DrawArc(IEllipticArc pEllipArc)
{
if (pEllipArc == null) return;
try
{
ISegmentCollection pSegColl;
IPolyline pPolyline;
pSegColl = new PolylineClass();
pSegColl.AddSegment(pEllipArc as ISegment);
pPolyline = pSegColl as IPolyline;
IRgbColor pColor = new RgbColor();
pColor.Red = 0;
pColor.Green = 0;
pColor.Blue = 0;
m_LineSym = new SimpleLineSymbol();
m_LineSym.Color = pColor;
m_LineSym.Width = 1;
m_LineSym.Style = esriSimpleLineStyle.esriSLSSolid;
ISymbol pSym = m_LineSym as ISymbol;
pSym.ROP2 = esriRasterOpCode.esriROPNotXOrPen;
m_pEnvFeedback.Symbol = pSym;
m_hookHelper.ActiveView.ScreenDisplay.StartDrawing(m_hookHelper.ActiveView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
m_hookHelper.ActiveView.ScreenDisplay.SetSymbol(pSym);
m_hookHelper.ActiveView.ScreenDisplay.DrawPolyline(pPolyline);
m_hookHelper.ActiveView.ScreenDisplay.FinishDrawing();
}
catch (Exception)
{
return;
}
}
示例7: theForm_BoxChange
private void theForm_BoxChange(object sender, EventArgs e)
{
bool bNeedRefresh = false;
ISDUTExtension theExt = this.Extension;
IGraphicsContainer theGCont = util.GraphicsHelper.get_GraphicsContainer(theExt.FocusMap);
ui.CreateWellsiteBoxForm theForm = (ui.CreateWellsiteBoxForm)sender;
IPolygon theBox = null;
if (double.IsNaN(theForm.Orientation) == false && double.IsNaN(theForm.BoxSize) == false)
{
theBox = this.CreateBox(this._Wellsite, theForm.Orientation, theForm.BoxSize, theForm.SizeUnits);
theBox.Project(theExt.FocusMap.SpatialReference);
}
// Clear existing feedback
if (this._Feedback != null)
{
theGCont.DeleteElement(this._Feedback);
this._Feedback = null;
bNeedRefresh = true;
}
// Create new graphic
if (theBox != null)
{
object theMissing = Type.Missing;
IElement theBoxE = new PolygonElementClass();
theBoxE.Geometry = theBox;
((IFillShapeElement)theBoxE).Symbol = util.GraphicsHelper.get_SimplePolygonSymbol(
util.GraphicsHelper.get_RgbColor(0, 0, 0), esriSimpleFillStyle.esriSFSHollow,
util.GraphicsHelper.get_SimpleLineSymbol(
util.GraphicsHelper.get_RgbColor(0, 0, 0), 2.0, esriSimpleLineStyle.esriSLSSolid));
ILine theLine = new LineClass();
theLine.PutCoords(this._Wellsite, theBox.FromPoint);
ISegmentCollection theSegColl = new PolylineClass();
theSegColl.AddSegment((ISegment)theLine, ref theMissing, ref theMissing);
IElement theLineE = new LineElementClass();
theLineE.Geometry = (IGeometry)theSegColl;
IGroupElement theGroupE = new GroupElementClass();
theGroupE.AddElement(theBoxE);
theGroupE.AddElement(theLineE);
this._Feedback = (IElement)theGroupE;
theGCont.AddElement(this._Feedback, 0);
bNeedRefresh = true;
}
// Refresh the graphics in the map
if (bNeedRefresh)
{
IActiveView theAV = (IActiveView)theExt.FocusMap;
theAV.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, theAV.Extent);
}
}
示例8: GetIntersectionPoint
/// <summary>
/// 延长
/// </summary>
/// <param name="player">当前操作图层</param>
/// <param name="pMap">当前操作地图</param>
private void GetIntersectionPoint(ILayer player, IMap pMap)
{
IEnumFeature pEnumFeature = pMap.FeatureSelection as IEnumFeature;
IFeature selectFeature = pEnumFeature.Next();
IPolyline extendline = selectFeature.Shape as IPolyline;
IFeature selectFeature2 = pEnumFeature.Next();
IPolyline intersectionline = selectFeature2.Shape as IPolyline;
IActiveView maprefr = (IActiveView)pMap;
IFeatureLayer pfeaturelayer = (IFeatureLayer)player;
IFeatureClass pfeatureclass = pfeaturelayer.FeatureClass;
IDataset pDataset = (IDataset)pfeaturelayer.FeatureClass;
IWorkspaceEdit pWorkspaceEdit = (IWorkspaceEdit)pDataset.Workspace;
IFeature addfeature = pfeatureclass.CreateFeature();
//IPolyline pline = addfeature.Shape as IPolyline;
IGeometry pGeometry;
IPoint pPointFrom = new PointClass();
IPoint pPointTo = new PointClass();
ILine pLine = new LineClass();
pLine.PutCoords(pPointFrom, pPointTo);
//IPolyline pline = new PointClass();
double X1 = extendline.ToPoint.X;
double Y1 = extendline.ToPoint.Y;
double X2 = extendline.FromPoint.X;
double Y2 = extendline.FromPoint.Y;
double a1 = Y2 - Y1;
double b1 = X1 - X2;
double c1 = X1 * Y2 - X2 * Y1;
double x1 = intersectionline.ToPoint.X;
double y1 = intersectionline.ToPoint.Y;
double x2 = intersectionline.FromPoint.X;
double y2 = intersectionline.FromPoint.Y;
double a2 = y2 - y1;
double b2 = x1 - x2;
double c2 = x1 * y2 - x2 * y1;
double isparallline = a1 * b2 - a2 * b1;
double getpx = (c1 * b2 - c2 * b1) / isparallline;
double getpy = (a1 * c2 - a2 * c1) / isparallline;
pWorkspaceEdit.StartEditOperation();
//pline.ToPoint.X = getpx;
//pline.ToPoint.Y = getpy;
//pline.FromPoint = extendline.ToPoint;
pPointFrom.X = getpx;
pPointFrom.Y = getpy;
pPointTo = extendline.ToPoint;
pLine.PutCoords(pPointFrom, pPointTo);
ISegmentCollection psegmentcollection = new PolylineClass();
object oMissing = Type.Missing;
psegmentcollection.AddSegment((ISegment)pLine, oMissing, oMissing);
//pline = (IGeometry)psegmentcollection;
pGeometry = psegmentcollection as IGeometry;
addfeature.Shape = pGeometry;
addfeature.Store();
pWorkspaceEdit.StopEditOperation();
maprefr.Refresh();
}
示例9: DrawCircleFeature
/// <summary>
/// ���ݻ��Ƶ�Բ�δ���Ҫ��
/// </summary>
/// <params name="pLayer"></params>
/// <params name="pCircuArc"></params>
/// <params name="pScreenDisplay"></params>
private void DrawCircleFeature(ILayer pLayer, ICircularArc pCircuArc, IScreenDisplay pScreenDisplay)
{
if (pLayer == null) return;
ISegmentCollection pSegmentCollection = null;
if (pLayer is IFeatureLayer)
{
IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
if (pFeatureClass != null)
{
IPolyline pPolyline = null;
IPolygon pPolygon = null;
if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
{
pSegmentCollection = new PolylineClass();
pSegmentCollection.AddSegment(pCircuArc as ISegment);
pPolyline = pSegmentCollection as IPolyline;
}
else if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
{
pSegmentCollection = new PolygonClass();
pSegmentCollection.AddSegment(pCircuArc as ISegment);
pPolygon = pSegmentCollection as IPolygon;
}
else
return;
IFeature pFeature = null;
if (pPolyline != null)
pFeature = DataEditCommon.CreateUndoRedoFeature(pFeatureLayer, pPolyline);
else if (pPolygon != null)
pFeature = DataEditCommon.CreateUndoRedoFeature(pFeatureLayer, pPolygon);
else
return;
m_hookHelper.FocusMap.SelectFeature(m_pCurrentLayer, pFeature);
m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics | esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewBackground, null, null);
}
}
}
示例10: GetRotationUsingConnectedEdges
// Uses Geometric Network to find connected edges which determine desired rotation of point
public Nullable<double> GetRotationUsingConnectedEdges(IFeature inFeature)
{
Nullable<double> rotationAngle = null;
if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPoint)
{
try
{
double diameter = 0;
List<double> angles = new List<double>();
List<double> diameters = new List<double>();
List<Boolean> flipDirections = new List<Boolean>();
IPoint pnt = (ESRI.ArcGIS.Geometry.IPoint)inFeature.Shape;
INetworkFeature netFeat = (INetworkFeature)inFeature;
ISimpleJunctionFeature simpleJunctionFeature = (ISimpleJunctionFeature)netFeat;
INetworkClass netClass = (INetworkClass)inFeature.Class;
IGeometricNetwork geomNetwork = (IGeometricNetwork)netClass.GeometricNetwork;
INetwork network = (INetwork)geomNetwork.Network;
INetElements netElements = (INetElements)network;
IFeatureClass fc;
IFeature feat;
IGeometry geometry;
IPolyline polyline;
ISegmentCollection segmentCollection;
ISegmentCollection segColTest;
ISegment testSegment;
IEnumSegment enumSegment;
System.Object edgeWeight;
Boolean edgeOrient;
int partIndex = 0;
int segmentIndex = 0;
int edgesCount;
int edgeEID;
int classId; int userId; int subId;
int posField; double angle;
object Missing = Type.Missing;
IPoint toPoint;
ITopologicalOperator topoOp;
IPolygon poly;
IRelationalOperator relOp;
IForwardStarGEN forwardStar = (IForwardStarGEN)network.CreateForwardStar(false, null, null, null, null);
forwardStar.FindAdjacent(0, simpleJunctionFeature.EID, out edgesCount);
for (int i = 0; i < edgesCount; i++)
{
forwardStar.QueryAdjacentEdge(i, out edgeEID, out edgeOrient, out edgeWeight);
geometry = geomNetwork.get_GeometryForEdgeEID(edgeEID);
polyline = (IPolyline5)geometry;
//Special case for reducer
if (m_useDiameter & (edgesCount == 2))
{
netElements.QueryIDs(edgeEID, esriElementType.esriETEdge, out classId, out userId, out subId);
fc = GetFeatureClassByClassId(classId, geomNetwork);
feat = fc.GetFeature(userId);
posField = GetFieldPosition(m_diameterFieldName, feat);
if (posField > -1)
{
diameter = (double)feat.get_Value(posField);
}
}
//given line and point, return angles of all touching segments
segmentCollection = (ISegmentCollection)polyline;
enumSegment = (IEnumSegment)segmentCollection.EnumSegments;
enumSegment.Next(out testSegment, ref partIndex, ref segmentIndex);
while (testSegment != null)
{
angle = GetAngleOfSegment(testSegment);
toPoint = testSegment.ToPoint;
topoOp = toPoint as ITopologicalOperator;
poly = topoOp.Buffer(0.01) as IPolygon;
//ML: 20090617 Added test for segment touching point to be rotated
segColTest = new PolylineClass();
segColTest.AddSegment(testSegment, ref Missing, ref Missing);
relOp = segColTest as IRelationalOperator;
if (relOp.Touches(pnt))
{
relOp = poly as IRelationalOperator;
flipDirections.Add(relOp.Contains(pnt));
diameters.Add(diameter);
angles.Add(angle);
}
enumSegment.Next(out testSegment, ref partIndex, ref segmentIndex);
}
///end of possible function returning list of angles
}
//.........这里部分代码省略.........
示例11: OnMouseUp
public override void OnMouseUp(int Button, int Shift, int X, int Y)
{
if (Button != 1)
return;
if (m_lMouseDownCount > 2)
{
m_lMouseDownCount = 0;
ISegmentCollection pSegColl=null;
IFeatureLayer featureLayer = m_pCurrentLayer as IFeatureLayer;
if (featureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline) //������Ҫ��
{
IPolyline pPolyline;
pSegColl = new PolylineClass();
pSegColl.AddSegment(m_pCircleArc as ISegment);
pPolyline = pSegColl as IPolyline;
if (pPolyline.Length < 0.001)
return;
IFeature pFeature = DataEditCommon.CreateUndoRedoFeature(featureLayer, pPolyline);
m_hookHelper.FocusMap.SelectFeature(m_pCurrentLayer, pFeature);
m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics | esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewBackground, null, null);
}
else //������Ҫ��
{
IPolygon pPolygon;
pSegColl = new PolygonClass();
pSegColl.AddSegment(m_pCircleArc as ISegment);
pPolygon = pSegColl as IPolygon;
pPolygon.Close();
if (pPolygon.Length < 0.001)
return;
IFeature pFeature = DataEditCommon.CreateUndoRedoFeature(featureLayer, pPolygon);
m_hookHelper.FocusMap.SelectFeature(m_pCurrentLayer, pFeature);
m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics | esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewBackground, null, null);
}
//�ֲ�ˢ��
//IInvalidArea pInvalidArea = new InvalidAreaClass();
//pInvalidArea.Add(pSegColl);
//pInvalidArea.Display = m_hookHelper.ActiveView.ScreenDisplay;
//pInvalidArea.Invalidate((short)esriScreenCache.esriAllScreenCaches);
m_bCreated = true;
}
}