![]() |
Xsc
|
public class XscObjEx : XscObj
The XscObjEx type exposes the following members.
Name | Description | |
---|---|---|
![]() | XscObjEx | XscObjEx 객체를 생성하고 데이터 멤버를 초기화한다. 기본 생성자. 클래스를 확인하기 위한 클래스 이름(XscObj의 GetTypeName 함수의 역할)을 지정하여 생성한다. |
Name | Description | |
---|---|---|
![]() | Draw | Render 호출시 객체를 그린다. Persepctive 모드. (Overrides XscObjDraw(NXDrawArgs, XscAttrSet)) |
![]() | OrthoDraw | OrthoRender 호출히 객체를 그린다. Ortho 모드. (Overrides XscObjOrthoDraw(NXDrawArgs, XscAttrSet)) |
class LineObj : XscObjEx { protected Pixoneer.NXDL.XGeoPoint[] gpPos = null; protected System.Drawing.Color lineColor = System.Drawing.Color.Red; // XscObj를 상속받고 클래스의 타입을 "MyLineObj"롤 설정하는 생성자 public MyLineObj() : base("MyLineObj") { } public void SetPosition(Pixoneer.NXDL.XGeoPoint pos1, Pixoneer.NXDL.XGeoPoint pos2, Pixoneer.NXDL.XGeoPoint pos3) { if (gpPos == null) { gpPos = new Pixoneer.NXDL.XGeoPoint[3]; } gpPos[0] = pos1; gpPos[1] = pos2; gpPos[2] = pos3; double minLon = Pixoneer.NXDL.XDataRange.MAX_REAL64, minLat = Pixoneer.NXDL.XDataRange.MAX_REAL64; double maxLon = Pixoneer.NXDL.XDataRange.MIN_REAL64, maxLat = Pixoneer.NXDL.XDataRange.MIN_REAL64; for (int i = 0; i < 3; i++) { if (gpPos[i] == null) continue; minLon = (gpPos[i].lond < minLon) ? gpPos[i].lond : minLon; minLat = (gpPos[i].latd < minLat) ? gpPos[i].latd : minLat; maxLon = (gpPos[i].lond > maxLon) ? gpPos[i].lond : maxLon; maxLat = (gpPos[i].latd > maxLat) ? gpPos[i].latd : maxLat; } this.SetRange(Pixoneer.NXDL.XGeoPoint.FromDegree(minLon, minLat, 0.0), Pixoneer.NXDL.XGeoPoint.FromDegree(maxLon, maxLat, 0.0)); Random rand = new Random(); int r = rand.Next(256); int g = rand.Next(256); int b = rand.Next(256); this.lineColor = System.Drawing.Color.FromArgb(r, g, b); } // XscObj의 Draw 함수를 오버라이드하여 정의 public override bool Draw(NXDrawArgs Args, XscAttrSet AttrSet) { if (gpPos == null) return false; if (Args == null) return false; if (Args.Graphics == null) return false; if (Args.Type != eDrawArgsType.Planet2D) return false; Pixoneer.NXDL.NXPlanet.NXPlanetDrawArgs planetDrawArgs = (Pixoneer.NXDL.NXPlanet.NXPlanetDrawArgs)Args; if (planetDrawArgs.ViewArea == null) return false; Args.Graphics.glDisable(XGraphics.GL_DEPTH_TEST); Args.Graphics.glColor(lineColor); Args.Graphics.glLineWidth(1.0); Pixoneer.NXDL.XVertex3d pt1 = planetDrawArgs.ViewArea.GeographicToWorld(gpPos[0]); Pixoneer.NXDL.XVertex3d pt2 = planetDrawArgs.ViewArea.GeographicToWorld(gpPos[1]); Pixoneer.NXDL.XVertex3d pt3 = planetDrawArgs.ViewArea.GeographicToWorld(gpPos[2]); Args.Graphics.glBegin(XGraphics.GL_LINE_STRIP); Args.Graphics.glVertex3d(pt1 - planetDrawArgs.WOS); Args.Graphics.glVertex3d(pt2 - planetDrawArgs.WOS); Args.Graphics.glVertex3d(pt3 - planetDrawArgs.WOS); Args.Graphics.glEnd(); Args.Graphics.glLineWidth(1.0); Args.Graphics.glColor3d(1.0, 1.0, 1.0); return true; } } ... // MyLineObj 객체를 생성하여 PlanetLayerSceneDispaly에 추가 XScene scene2D = nxPlanetLayerSceneDisplay2D.GetScene(); MyLineObj newObj = new MyLineObj(); MyLineObj.ObjID = sc2D1.GetNextID(); MyLineObj.Name = newObj.ObjID.ToString(); XGeoPoint gpPos1 = Pixoneer.NXDL.XGeoPoint.FromDegree(125.0, 33.0, 0.0); XGeoPoint gpPos2 = Pixoneer.NXDL.XGeoPoint.FromDegree(127.0, 38.0, 0.0); XGeoPoint gpPos3 = Pixoneer.NXDL.XGeoPoint.FromDegree(126.0, 32.0, 0.0); newObj.SetPosition(gpPos1, gpPos2, gpPos3); scene2D.AddNode(newObj.ObjID, newObj); scene2D.CalcRange();