Sds setcallbackfunc

提供:GizmoLabs - だいたい CAD LISP なサイト
構文
int sds_setcallbackfunc (int [int flag, void *arg1, void *arg2, void *arg3]);


機能
IntelliCADコマンドからのコールバックを遮って、指定した機能に送る。
引数
  • flag : コールバックの種類。
  • *arg1 : コールバックの内容による。
  • *arg2 : コールバックの内容による。
  • *arg3 : コールバックの内容による。
戻り値
それぞれ。


サンプル
erase コマンドをトラップする関数 cbfunc を作成した場合のサンプル
以下のように指定してロードする。
sds_setcallbackfunc(cbfunc);
ロード以降は、IntelliCADからのコールバックは、cbfunc を通過することになる。
erase コマンドが実行された時の処理の例は以下のようになる。
int cbfunc(int flag,void *arg1,void *arg2,void *arg3)
{
  int res = RTNORM;
  switch (flag) {
    // Command Start/End.
    case SDS_CBCMDBEGIN:
      // SDS_CBCMDBEGIN は arg1="command name" cast as (char *)
      // Callback return  RTERROR will cause command to not be called.
      // コマンドが呼び出されない場合、コールバックは RTERROR を返すはずである。
      // 例えば、erase コマンドを動かなくしてユーザーが図形を
      // 消すことを防ぎたければ、以下のコードのようになる:
      if (!stricmp(arg1, "erase"))
        res = RTERROR;
        break;
    case default:
      break;
  }
  return res;
}
上記のコメントが示すように、erase コマンドの実行で RTERROR のコールバックが返る事で、IntelliCAD からの erase コマンド実行をトラップして異なるアクション(RTERRORを返す)になったことがわかる。


コールバックフラグの種類(IJCAD7のSDS.Hから抜粋)
// コマンド Start/End.
SDS_CBCMDBEGIN        0  // arg1="command name"     cast as (char *)
                         // Callback return  RTERROR will cause command to not be called.
SDS_CBCMDEND          1  // arg1="command name"     cast as (char *)
                         // Return code does not matter.

// マウスの移動とボタン.
SDS_CBMOUSEMOVE       2  // arg1=X pixel  arg2=Y pixel
SDS_CBLBUTTONDN       3  // arg1=X pixel  arg2=Y pixel
SDS_CBLBUTTONUP       4  // arg1=X pixel  arg2=Y pixel
SDS_CBLBUTTONDBLCLK   5  // arg1=X pixel  arg2=Y pixel
SDS_CBRBUTTONDN       6  // arg1=X pixel  arg2=Y pixel
SDS_CBRBUTTONUP       7  // arg1=X pixel  arg2=Y pixel
                         // Callback return  RTERROR will cause point to be ignored.
                         // Cast arg1 and arg2 as (int*)

// 選択セットの座標変換
SDS_CBXFORMSS         8  // arg1=Selection set (ok to modify) cast as (sds_name)
                         // arg2=Transformation Matrix (ok to modify) cast as (sds_matrix)
                         // Callback return RTERROR will stop the transformation.

// Undo/Redo.
SDS_CBENTUNDO         9  // arg1=Entname (ok to modify)    cast as (sds_name), arg2 below defines on undo type
                         // Callback return RTERROR will stop UNDO for this ent.
SDS_CBENTREDO        10  // arg1=Entname (ok to modify)     cast as (sds_name), arg2 below defines on undo type
                         // Callback return RTERROR will stop REDO for this ent.
/ Undo/Redo: 成功した場合
SDS_CBENTUNDONE      44  // arg1 = ename, cast as (sds_namep), arg2 below defines on undo type, arg3 is NULL
SDS_CBENTREDONE      45  // arg1 = ename, cast as (sds_namep), arg2 below defines on redo type, arg3 is NULL

// Undo/Redo constants - Passed back as arg2 parameter so the user can tell what action is being undone.
SDS_ADD_NOTICE        1
SDS_MODIFY_NOTICE    2
SDS_DELETE_NOTICE    3

// Palette Change.
SDS_CBPALETTECHG     11  // arg1=HPALETTE cast as (HPALETTE)

// ファイルの開く/閉じる/新規/保存
SDS_CBOPENDOC        12  // arg1=file name, cast as (char *)
SDS_CBNEWDOC         13  // (all args NULL)
SDS_CBCLOSEDOC       14  // arg1=file name, cast as (char *)
SDS_CBSAVEDOC        15  // arg1= new file name, cast as (char *)
                         // arg2= old file name, cast as (char *)

// !!! See new callback SDS_CBDOCCHG below for better MDI control
// Doc/View change (when the user activates a new MDI window).
SDS_CBVIEWDOCCHG     16  // arg1=file name, cast as (char *)
                         // arg2=current window HWND, cast as (HWND)

// ドキュメントの変更
SDS_CBENTDEL         17  // arg1=Entname to be deleted (or undeleted), cast as (sds_name)
                         // Callback return RTERROR will stop sds_entdel() for this ent.
SDS_CBENTMAKE        18  // arg1=Entname of new entity, cast as (sds_name)
SDS_CBENTMOD         19  // arg1=Entname of modified entity, cast as (sds_name)

// システム変数変更
SDS_CBVARCHANGE      43  // arg1 = name of sysvar, cast as (char*); arg2 & arg3 are NULL

// グリップ編集
SDS_CBGRIPEDITBEG    20  // arg1=Entname being edited, cast as (sds_name)
                         // arg2=Point being edited, cast as (sds_point)
                         // Callback return RTERROR will stop grip edit.
SDS_CBGRIPEDITEND    21  // arg1=Entname of entity that was edited, cast as (sds_name)
                         // arg2=Point being edited, cast as (sds_point)

SDS_CBVIEWCHANGE     22  // arg1=type of paint
                         // 1=redraw, 2=shade, 3=hide, 4=view change (zoom, vpoint, etc.) 5=regen
                         //
// Mouse movements and Mouse buttons returning current UCS cordinates
// Callback return  RTERROR will cause point to be ignored.
SDS_CBMOUSEMOVEUCS      23  // arg1=X coord  arg2=Y coord arg3=Z coord
SDS_CBLBUTTONDNUCS      24  // arg1=X coord  arg2=Y coord arg3=Z coord
SDS_CBLBUTTONUPUCS      25  // arg1=X coord  arg2=Y coord arg3=Z coord
SDS_CBLBUTTONDBLCLKUCS  26  // arg1=X coord  arg2=Y coord arg3=Z coord
SDS_CBRBUTTONDNUCS      27  // arg1=X coord  arg2=Y coord arg3=Z coord
SDS_CBRBUTTONUPUCS      28  // arg1=X coord  arg2=Y coord arg3=Z coord
                            // Cast arg1 and arg2 as (int*)

// Callbacks associated with painting and dragging
SDS_CBBEGINPAINT        29  // no arguments
SDS_CBENDPAINT          30  // no arguments
SDS_CBENDMOUSEMOVE      31  // arg1=X coord  arg2=Y coord arg3 = is Dragging flag
                            // Cast arg1 and arg2 as (int*) cast arg3 as bool

// ファイル変更 (ユーザが新しい MDIウィンドウをアクティブにした時)
SDS_CBDOCCHG            32  // arg1=new file name, cast as (char *)
                            // arg2=new window, cast as HWND
                            // arg3=old window, cast as HWND

// Callbacks associated with cloning
SDS_CBBEGINCLONE        33  // arg1=selection set of the entities to be processed by sds-apps

SDS_CBENDCLONE          34  // arg1=selection set of the entities the cloning was performed from
                            // arg2=selection set of created objects or entity name of created block
                            // arg3=mode(0 - arg2=selection set, 1 - agr2=block entity name)

// Mouse movements and Mouse buttons.
SDS_CBMBUTTONDN         35  // arg1=X pixel  arg2=Y pixel // SystemMetrix(Maeda)
SDS_CBMBUTTONUP         36  // arg1=X pixel  arg2=Y pixel // SystemMetrix(Maeda)
SDS_CBMBUTTONDNUCS      37  // arg1=X coord  arg2=Y coord arg3=Z coord // SystemMetrix(Maeda)
SDS_CBMBUTTONUPUCS      38  // arg1=X coord  arg2=Y coord arg3=Z coord // SystemMetrix(Maeda)
SDS_CBMBUTTONDBLCLK     39  // arg1=X pixel  arg2=Y pixel // SystemMetrix(Maeda)
SDS_CBMBUTTONDBLCLKUCS  40  // arg1=X coord  arg2=Y coord arg3=Z coord // SystemMetrix(Maeda)
SDS_CBRBUTTONDBLCLK     41  // arg1=X pixel  arg2=Y pixel // SystemMetrix(Maeda)
SDS_CBRBUTTONDBLCLKUCS  42  // arg1=X coord  arg2=Y coord arg3=Z coord // SystemMetrix(Maeda)
                            // Cast arg1 and arg2 and arg3 as (double)

SDS_CBKEYDOWN           47  // arg1=virtual key code arg2=status flags     // SystemMetrix(Maeda)
SDS_CBKEYUP             48  // arg1=virtual key code arg2=status flags     // SystemMetrix(Maeda)
SDS_CBCHAR              49  // arg1=virtual key code arg2=status flags     // SystemMetrix(Maeda)

SDS_CBGETPOINT          50  // arg1-arg3=ucs point for getpoint function   // IntelliJapan(Mimura) 2006/12/26

// 'current selection set changed' callback notification
SDS_CBSSCHANGE          46  // arg1 is a changing type (add, del, free: see defines below), cast as int;
                            // arg2 is an entity if it's added or deleted, cast as sds_namep;
                            //arg3 is NULL

// The following callback gives third-party apps access to the display buffer for the purposes
// of adding their own image data as a background
SDS_CBFRAMEBUFFER       98  // arg2 is the struct HDCInfo that contains the frame buffer info

SDS_CB_SSMOD            0   // ss is changed somehow, e.g. several ents were added to it and/or other ones were deleted from;
                            // note, neither SDS_CB_SSADD nor SDS_CB_SSDEL are sent if SDS_CB_SSMOD is sent
SDS_CB_SSADD            1
SDS_CB_SSDEL            2
SDS_CB_SSFREE           3   // Cast arg1 and arg2 as (UINT)                // SystemMetrix(Maeda)