YouTube | Facebook | Twitter  Feed

回転フィードバック

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

関連記事

  • この記事を書いた人

羽田 康祐

Esri認定インストラクター、GIS上級技術者、測量士補、潜水士。GISy / GISc とその関連分野である地理学・地図学について日々の出来事で学んだ記憶を記録するためにブログを書いています。行動原理は伊達と酔狂。好きな地形は圏谷。好きな地図投影法はパースクインカンシャル図法。呉市生まれ広島市出身。GIS を使った自己紹介はこちら

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

© 2020 WINGFIELD since1981