How draw a circle arc into a srcreendisplay

2158
4
08-03-2011 06:28 AM
eddixoncastillo
New Contributor
What's wrog with this code?.....
IPoint from = arcPoints["from"] as IPoint;
IPoint to = arcPoints["to"] as IPoint;
IPoint thru = arcPoints["thru"] as IPoint;
ICircularArc circularArcThreePoint = new CircularArcClass();
IConstructCircularArc construtionCircularArc = circularArcThreePoint as IConstructCircularArc;
construtionCircularArc.ConstructThreePoints(from, thru, to, true);
IScreenDisplay screenDisplay = m_mapControl.ActiveView.ScreenDisplay;
ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
ESRI.ArcGIS.Display.ISymbol symbol = simpleFillSymbol as ESRI.ArcGIS.Display.ISymbol;
ESRI.ArcGIS.Display.IRubberBand rubberBand = new ESRI.ArcGIS.Display.RubberPolygonClass();
screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache);
ISegment pSeg;
ISegmentCollection polyline;
pSeg = circularArcThreePoint as ISegment;
polyline = new PolylineClass();
polyline.AddSegment(pSeg);
screenDisplay.DrawPolyline(polyline as IGeometry);
screenDisplay.FinishDrawing();


A try draw an arc circle, and then store in a new feature, but throw the following exception:
COMException was unhandled by user code
0 Kudos
4 Replies
DubravkoAntonic
New Contributor III
You need to specify screenDisplay.SetSymbol before Draw method.
But you didn't specified your symbol line and color.
Here is DrawPolyline snippet from help ISymbol Desktop SDK

IScreenDisplay screenDisplay = activeView.ScreenDisplay;     // Constant   
screenDisplay.StartDrawing(screenDisplay.hDC,
(System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit Cast
ESRI.ArcGIS.Display.IRgbColor rgbColor = new ESRI.ArcGIS.Display.RgbColorClass();
rgbColor.Red = 255;    
ESRI.ArcGIS.Display.IColor color = rgbColor; 
// Implicit Cast   
ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbolClass();   simpleLineSymbol.Color = color;    
ESRI.ArcGIS.Display.ISymbol symbol = (ESRI.ArcGIS.Display.ISymbol)simpleLineSymbol;
// Explicit Cast   
ESRI.ArcGIS.Display.IRubberBand rubberBand = new ESRI.ArcGIS.Display.RubberLineClass();
ESRI.ArcGIS.Geometry.IGeometry geometry = rubberBand.TrackNew(screenDisplay, symbol);
screenDisplay.SetSymbol(symbol);
screenDisplay.DrawPolyline(geometry);   
screenDisplay.FinishDrawing(); 
Hope it helps
0 Kudos
eddixoncastillo
New Contributor
don't work !!!!
Especifically i have to draw circles ( or arc circles)...

here my code:
IScreenDisplay screenDisplay = activeView.ScreenDisplay;
screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache);
ESRI.ArcGIS.Display.IRgbColor rgbColor = new ESRI.ArcGIS.Display.RgbColorClass();
rgbColor.Red = 255;
ESRI.ArcGIS.Display.IColor color = rgbColor; // Implicit Cast
ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbolClass();
simpleLineSymbol.Color = color;
ESRI.ArcGIS.Display.ISymbol symbol = (ESRI.ArcGIS.Display.ISymbol)simpleLineSymbol; 
ESRI.ArcGIS.Display.IRubberBand rubberBand = new ESRI.ArcGIS.Display.RubberCircleClass();
IGeometry circulo1;
circulo1 = rubberBand.TrackNew(screenDisplay, symbol);
screenDisplay.SetSymbol(symbol);
screenDisplay.DrawPolygon(circulo1);
screenDisplay.FinishDrawing();
0 Kudos
DubravkoAntonic
New Contributor III
Yes it works:), I tried it and it does draw. Put the code in the event OmMouseDown and it will draw rubberband segments on each mouseDown

I wrote this one and it also works in  the same OnMouseDown. Just uncomment DrawPolyline or DrawPolygon and change something to get what you need.

public void DrawSomethingElse(IPoint pPoint)
        {[INDENT]             try
            {[INDENT]                 IPoint a = new PointClass();
                IPoint b = new PointClass();
                a.PutCoords(pPoint.X + 100, pPoint.Y + 100);
                b.PutCoords(pPoint.X - 100, pPoint.Y + 100);

                IScreenDisplay screenDisplay = Extension.ActiveView.ScreenDisplay;     // Constant  
                screenDisplay.StartDrawing(screenDisplay.hDC,
                (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit Cast
                IRgbColor rgbColor = new ESRI.ArcGIS.Display.RgbColorClass();
                rgbColor.Red = 255;
                IColor color = rgbColor;

                ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();
                simpleLineSymbol.Color = color;
                simpleLineSymbol.Width = 3;

                ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass();
                simpleMarkerSymbol.Color = color;


                ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
                simpleFillSymbol.Color = color;

                ICircularArc circularArcThreePoint = new CircularArcClass();
                IConstructCircularArc construtionCircularArc = circularArcThreePoint as IConstructCircularArc;
                construtionCircularArc.ConstructThreePoints(a, pPoint, b, true);


                object missing = Type.Missing;
                ISymbol symbol = (ESRI.ArcGIS.Display.ISymbol)simpleMarkerSymbol;

                // point
                screenDisplay.SetSymbol(symbol);
                screenDisplay.DrawPoint(a);
                screenDisplay.DrawPoint(b);
                screenDisplay.DrawPoint(pPoint);

                // polygon
                ISegment pSegment = circularArcThreePoint as ISegment;
                ISegmentCollection pSegColl = new PolygonClass();
                pSegColl.AddSegment(pSegment, ref missing, ref missing);
                IGeometry pGeometry = pSegColl as IGeometry;               
                symbol = (ESRI.ArcGIS.Display.ISymbol)simpleFillSymbol;
                screenDisplay.SetSymbol(symbol);
                //screenDisplay.DrawPolygon(pGeometry);

                // poyline
                ISegment pLineSegment = circularArcThreePoint as ISegment;
                ISegmentCollection pLineSegColl = new PolylineClass();
                pLineSegColl.AddSegment(pLineSegment, ref missing, ref missing);
                IGeometry pPolylineGeometry = pLineSegColl as IGeometry;               
                symbol = (ESRI.ArcGIS.Display.ISymbol)simpleLineSymbol;
                screenDisplay.SetSymbol(symbol);
                //screenDisplay.DrawPolyline(pPolylineGeometry);

                screenDisplay.FinishDrawing();
[/INDENT]}
            catch (Exception ex)
            {[INDENT]                 MessageBox.Show(ex.Message);
[/INDENT]}
[/INDENT]}

Hope this will be helpful

regards Dubravko Antoni�?
0 Kudos
eddixoncastillo
New Contributor
Thank you!!!! It's usefulll
0 Kudos