1

固定表示領域を持つ Plotcube と、このビューを復元するダブルクリック ハンドラーが必要です。そのために、ILPlotcude からクラスを派生させ、そのコンストラクターに制限を設定するための次のコードを配置しました。

:
float max = 1000f;
Limits.YMax = max;
Limits.XMax = max;
Limits.ZMax = max;
Limits.YMin = -max;
Limits.XMin = -max;
Limits.ZMin = -max;
AspectRatioMode = AspectRatioMode.MaintainRatios;
:

上記のコードと回転をリセットする追加の行を使用して、このクラスに doubleClick-handler もインストールしました。

:
if (args.Cancel) return;
if (!args.DirectionUp) return;
Rotation = Matrix4.Identity;
float max = 1000f;
Limits.YMax = max;
Limits.XMax = max;
Limits.ZMax = max;
Limits.YMin = -max;
Limits.XMin = -max;
Limits.ZMin = -max;
AspectRatioMode = AspectRatioMode.MaintainRatios;

args.Refresh = true;
args.Cancel = true;
:

ハンドラは実行されますが、何も起こりません。テスト目的で、(関数呼び出し reset () の代わりに) 基本クラス ILPlotCube の関数 OnMouseDoubleClick に同じコードを直接入れました。これは期待どおりに機能しますが、最終的な解決策にはなりません。

誰かがアイデアを持っていますか、何が問題なのですか?

4

1 に答える 1

0

マウス イベント ハンドラーは、通常、グローバルシーンに登録されます。各パネル/ドライバーは、後でレンダリングするために、そのシーンの独自の同期コピーを作成します。ユーザーは、回転、パンなどのために同期コピーを操作します。イベント ハンドラーを起動するのは、同期コピーです。

ただし、カスタム イベント ハンドラーはグローバル シーンに登録されているため、ハンドラー関数はグローバル シーン内のノード オブジェクトで実行されます。senderしたがって、シーン ノード オブジェクトにアクセスするには、イベント ハンドラによって提供されるオブジェクトを常に使用する必要があります。

この例では、共通 (グローバル) シーンに含まれる最初のプロット キューブ オブジェクトにマウス ハンドラーを登録します。ハンドラーは、シーンをカスタム ビューにリセットします。

ilPanel1.Scene.First<ILPlotCube>().MouseDoubleClick += (s,a) => {

    // we need the true target of the event. This may differs from 'this'!
    var plotcube = s as ILPlotCube;

    // The event sender is modified: 
    plotcube.Rotation = Matrix4.Identity;
    float max = 1000f;
    plotcube.Limits.YMax = max;
    plotcube.Limits.XMax = max;
    plotcube.Limits.ZMax = max;
    plotcube.Limits.YMin = -max;
    plotcube.Limits.XMin = -max;
    plotcube.Limits.ZMin = -max;
    plotcube.AspectRatioMode = AspectRatioMode.MaintainRatios;

    // disable the default double click handler which would reset the scene
    a.Cancel = true;
    // trigger a redraw of the scene
    a.Refresh = true;
};

ハンドラー内では、 によってシーン オブジェクトへの参照を取得できますilPanel.Scene.First<ILPlotCube>()...。ただし、代わりに、s発生したイベントのターゲットであるによって提供されるオブジェクトを取得します。これは、プロット キューブの同期バージョン (レンダリングに使用されるバージョン) に対応します。代わりにこれを使用すると、変更が適切に表示されます。

于 2014-02-11T10:42:57.250 に答える