YouTube | Facebook | X(Twitter) | RSS

回転フィードバック

2016/9/1 (木)

#region Overridden Class Methods
 
/// <summary>
/// Occurs when this tool is created
/// </summary>
/// <param name="hook">Instance of the application</param>
public override void OnCreate(object hook)
{
    if (m_hookHelper == null)
        m_hookHelper = new HookHelperClass();
 
    m_hookHelper.Hook = hook;
 
    // TODO:  Add Tool1.OnCreate implementation
}
 
/// <summary>
/// Occurs when this tool is clicked
/// </summary>
public override void OnClick()
{
    // TODO: Add Tool1.OnClick implementation
    m_pRotateTracker = new EngineRotateTrackerClass();  //Desktopの場合はRotateTrackerClass
}
 
public override void OnMouseDown(int Button, int Shift, int X, int Y)
{
    // TODO:  Add Tool1.OnMouseDown implementation
    IGraphicsContainerSelect pGraContSel = (IGraphicsContainerSelect)m_hookHelper.ActiveView.GraphicsContainer;
 
    //Get the document's active Graphics Container
    IScreenDisplay pScreenDisplay = m_hookHelper.ActiveView.ScreenDisplay;
 
    //****** Set screen display of the tracker
    m_pRotateTracker.Display = pScreenDisplay;
 
    //****** Set origin of the rotation, add geometry
    m_pRotateTracker.ClearGeometry();
 
    m_pSelElem = pGraContSel.SelectedElements.Next();
    IGeometry pGeom = m_pSelElem.Geometry;
 
    m_pRotateTracker.Origin = pGeom.Envelope.LowerLeft;
    m_pRotateTracker.AddGeometry(pGeom);
 
    if (m_pRotateTracker != null)
    {
        m_pRotateTracker.OnMouseDown();
    }
}
 
public override void OnMouseMove(int Button, int Shift, int X, int Y)
{
    // TODO:  Add Tool1.OnMouseMove implementation
    if (m_pRotateTracker != null)
    {
        IScreenDisplay pScreenDisplay = m_hookHelper.ActiveView.ScreenDisplay;
        IPoint pPoint = pScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
 
        m_pRotateTracker.OnMouseMove(pPoint);
    }
}
 
public override void OnMouseUp(int Button, int Shift, int X, int Y)
{
    // TODO:  Add Tool1.OnMouseUp implementation
    if (m_pRotateTracker != null)
    {
        bool bChanged = m_pRotateTracker.OnMouseUp();
        if (!bChanged)
        {
            return;
        }
 
        ITransform2D pTransform2D = (ITransform2D)m_pSelElem;
        pTransform2D.Rotate(m_pRotateTracker.Origin, m_pRotateTracker.Angle);
 
        IGraphicsContainer pGraphicsContainer = m_hookHelper.ActiveView.GraphicsContainer;
        pGraphicsContainer.UpdateElement(m_pSelElem);
        m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
    }
}
#endregion
  • この記事を書いた人

羽田 康祐

伊達と酔狂のGISエンジニア。GIS上級技術者、Esri認定インストラクター、CompTIA CTT+ Classroom Trainer、潜水士、PADIダイブマスター、四アマ。WordPress は 2.1 からのユーザーで歴だけは長い。 代表著書『"地図リテラシー入門―地図の正しい読み方・描き方がわかる』 GIS を使った自己紹介はこちら。ESRIジャパン(株)所属、元青山学院大学非常勤講師を兼務。日本地図学会第31期常任委員。発言は個人の見解です。

-プログラミング, ArcGIS
-,