home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 March / VPR9703A.ISO / VPR_DATA / DOGA / SOURCES / MEDIT.LZH / MEDITAPP.CPP < prev    next >
C/C++ Source or Header  |  1996-07-10  |  27KB  |  1,048 lines

  1. /*  Project medit
  2.     Project Team DoGA
  3.     Copyright (c) 1995. All Rights Reserved.
  4.  
  5.     サブシステム:    medit.exe Application
  6.     ファイル:        meditapp.cpp
  7.     作成者:          Taka2
  8.  
  9.  
  10.     概要
  11.     ====
  12.     meditApp (TApplication) のインプリメンテーション用のソースファイル
  13. */
  14.  
  15.  
  16. #include <owl\owlpch.h>
  17. #pragma hdrstop
  18.  
  19. #include <owl\inputdia.h>
  20. #include <owl\statusba.h>
  21. #include "meditapp.h"
  22. #include "mdtabtdl.h"                        // 「プログラムについて」ダイアログボックスの定義
  23. #include "winframe.h"
  24. #include "display.h"
  25. #include "anim.h"
  26. #include "motion.h"
  27. #include "files.h"
  28. #include "drange.h"
  29. #include "dslider.h"
  30. #include "fxg.h"
  31. #include "rendexec.h"
  32. #include "log.h"
  33. #include "suflib.h"
  34. #include "syscolor.h"
  35. #include "bmpopen.h"
  36. #include "dselreso.h"
  37. //
  38. // ヘルプファイルの作成
  39. //
  40. //const char HelpFileName[] = "medit.hlp";
  41.  
  42.  
  43. //{{meditApp Implementation}}
  44.  
  45.  
  46. //
  47. // アプリケーションが処理するすべてのメッセージ/コマンドに対する応答テーブルを作成する
  48. //
  49. DEFINE_RESPONSE_TABLE1(meditApp, TApplication)
  50. //{{meditAppRSP_TBL_BEGIN}}
  51.     EV_COMMAND(CM_FILENEW, CmFileNew),                               EV_COMMAND_ENABLE(CM_FILENEW, CmFileNewEnable),
  52.     EV_COMMAND(CM_FILEOPEN, CmFileOpen),
  53.     EV_COMMAND(CM_HELPCONTENTS, CmHelpContents),
  54.     EV_COMMAND(CM_HELPABOUT, CmHelpAbout),
  55.     EV_COMMAND(CM_FILESAVE, CmFileSave),                               EV_COMMAND_ENABLE(CM_FILESAVE, CmFileSaveEnable),
  56.     EV_COMMAND(CM_FILESAVEAS, CmFileSaveAs),                        EV_COMMAND_ENABLE(CM_FILESAVEAS, CmFileSaveAs),
  57.     EV_COMMAND(CM_EDIT_DELETE, CmEditDelete),                       EV_COMMAND_ENABLE(CM_EDIT_DELETE, CmEditDeleteEnable),
  58.     EV_COMMAND(CM_EDIT_DUP, CmEditDup),                             EV_COMMAND_ENABLE(CM_EDIT_DUP, CmEditDupEnable),
  59.     EV_COMMAND(CM_EDIT_EXCHANGE, CmEditExchange),                   EV_COMMAND_ENABLE(CM_EDIT_EXCHANGE, CmEditExchangeEnable),
  60.     EV_COMMAND(CM_EDIT_FORWARD, CmEditForward),                     EV_COMMAND_ENABLE(CM_EDIT_FORWARD, CmEditForwardEnable),
  61.     EV_COMMAND(CM_EDIT_MAXFRAME, CmEditMaxFrame),                   EV_COMMAND_ENABLE(CM_EDIT_MAXFRAME, CmEditMaxFrameEnable),
  62.     EV_COMMAND(CM_MECHA_ADD_FIX, CmMechaAddFix),                    EV_COMMAND_ENABLE(CM_MECHA_ADD_FIX, CmMechaAddFixEnable),
  63.     EV_COMMAND(CM_MECHA_ADD_MOVE, CmMechaAddMove),                  EV_COMMAND_ENABLE(CM_MECHA_ADD_MOVE, CmMechaAddMoveEnable),
  64.     EV_COMMAND(CM_MECHA_RANGE, CmMechaRange),                       EV_COMMAND_ENABLE(CM_MECHA_RANGE, CmMechaRangeEnable),
  65.     EV_COMMAND(CM_CAMERA_ADD_END, CmCameraAddEnd),                  EV_COMMAND_ENABLE(CM_CAMERA_ADD_END, CmCameraAddEndEnable),
  66.     EV_COMMAND(CM_CAMERA_DELETE_END, CmCameraDeleteEnd),            EV_COMMAND_ENABLE(CM_CAMERA_DELETE_END, CmCameraDeleteEndEnable),
  67.     EV_COMMAND(CM_CAMERA_RANGE, CmCameraRange),                     EV_COMMAND_ENABLE(CM_CAMERA_RANGE, CmCameraRangeEnable),
  68.     EV_COMMAND(CM_CAMERA_TARGET_RANGE, CmTargetRange),              EV_COMMAND_ENABLE(CM_CAMERA_TARGET_RANGE, CmTargetRangeEnable),
  69.     EV_COMMAND(CM_CAMERA_LIGHT, CmCameraLight),                     EV_COMMAND_ENABLE(CM_CAMERA_LIGHT, CmCameraLightEnable),
  70.     EV_COMMAND(CM_DISP_FXGA, CmDispFxga),                           EV_COMMAND_ENABLE(CM_DISP_FXGA, CmDispFxgaEnable),
  71.     EV_COMMAND(CM_DISP_REND, CmDispRend),                           EV_COMMAND_ENABLE(CM_DISP_REND, CmDispRendEnable),
  72.     EV_COMMAND(CM_DISP_RENDRESO, CmDispRendReso),                      EV_COMMAND_ENABLE(CM_DISP_RENDRESO, CmDispRendResoEnable),
  73.     EV_COMMAND(CM_DISP_WIREVIEW, CmDispWireview),                   EV_COMMAND_ENABLE(CM_DISP_WIREVIEW, CmDispWireviewEnable),
  74.     EV_COMMAND(CM_DISP_HIDDENREMOVE, CmDispHidenRemove),            EV_COMMAND_ENABLE(CM_DISP_HIDDENREMOVE, CmDispHiddenRemoveEnable),
  75.     EV_COMMAND(CM_DISP_SIMPLE, CmDispSimple),                       EV_COMMAND_ENABLE(CM_DISP_SIMPLE, CmDispSimpleEnable),
  76.     EV_COMMAND(CM_DISP_ZOOM, CmDispZoom),                           EV_COMMAND_ENABLE(CM_DISP_ZOOM, CmDispZoomEnable),
  77.     EV_COMMAND(CM_DISP_SCALEDOWN, CmDispScaleDown),                 EV_COMMAND_ENABLE(CM_DISP_SCALEDOWN, CmDispScaleDownEnable),
  78.     EV_COMMAND(CM_DISP_SCALEUP, CmDispScaleUp),                     EV_COMMAND_ENABLE(CM_DISP_SCALEUP, CmDispScaleUpEnable),
  79.     EV_COMMAND(CM_DISP_MESH, CmDispMesh),                           EV_COMMAND_ENABLE(CM_DISP_MESH, CmDispMeshEnable),
  80.     EV_COMMAND(CM_DISP_MESHSPACE, CmDispMeshSpace),                 EV_COMMAND_ENABLE(CM_DISP_MESHSPACE, CmDispMeshSpaceEnable),
  81.     EV_COMMAND(CM_MODE_GRID, CmModeGrid),                           EV_COMMAND_ENABLE(CM_MODE_GRID, CmModeGridEnable),
  82.     EV_COMMAND(CM_MODE_GRIDSPACE, CmModeGridSpace),                 EV_COMMAND_ENABLE(CM_MODE_GRIDSPACE, CmModeGridSpaceEnable),
  83.     EV_COMMAND(CM_MODE_ROTSPACE, CmModeRotSpace),                   EV_COMMAND_ENABLE(CM_MODE_ROTSPACE, CmModeRotSpaceEnable),
  84.     EV_COMMAND(CM_MODE_SCALESPACE, CmModeScaleSpace),               EV_COMMAND_ENABLE(CM_MODE_SCALESPACE, CmModeScaleSpaceEnable),
  85.     //{{meditAppRSP_TBL_END}}
  86. END_RESPONSE_TABLE;
  87.  
  88.  
  89.  
  90.  
  91. //////////////////////////////////////////////////////////
  92. // meditApp
  93. // =====
  94. //
  95. meditApp::meditApp () : TApplication("Motion Editor")
  96. {
  97.     execonce = FALSE;
  98. //    HelpState = FALSE;
  99. //    ContextHelp = FALSE;
  100. //    HelpCursor = 0;
  101.  
  102.     // 「開く」と「名前を付けて保存」ダイアログボックスに共通の,ファイルフラグとフィルタ。ファイル名と
  103.     // ディレクトリは,メンバー関数 CmFileOpen と CmFileSaveAs で計算される
  104. //    FileData.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
  105. //    FileData.SetFilter("すべてのファイル (*.*)|*.*|");
  106.  
  107.     // INSERT>> コンストラクタ用のコードはここに
  108.  
  109. }
  110.  
  111.  
  112. meditApp::~meditApp ()
  113. {
  114.     // INSERT>> デストラクタ用のコードはここに
  115.  
  116. }
  117.  
  118.  
  119. BOOL meditApp::CanClose ()
  120. {
  121.     BOOL result = TApplication::CanClose();
  122.  
  123.     //
  124.     // ヘルプエンジンを使っていた場合には,それをクローズする
  125.     //
  126.     if (result && anim->HelpState)
  127.         anim->WinHelp(HELP_QUIT, 0L);
  128.  
  129.     static char *title = "REND for Windows";
  130.     HWND hRend;
  131.     if ((hRend = FindWindow(NULL, title)) != NULL) {
  132.         ::SendMessage(hRend, WM_CLOSE, 0, 0);
  133.     }
  134.  
  135.     return result;
  136. }
  137.  
  138.  
  139. //////////////////////////////////////////////////////////
  140. // meditApp
  141. // =====
  142. // アプリケーションの初期化
  143. //
  144. void meditApp::InitMainWindow ()
  145. {
  146.     TWinFrame *client = new TWinFrame(0);
  147.  
  148.     anim = client->anim;
  149.  
  150. //    TFrameWindow *frame = new TFrameWindow(0, GetName(), client, TRUE);
  151.     TDecoratedFrame *frame = new TDecoratedFrame(0, GetName(), client, TRUE);
  152.  
  153.     int screenX = GetSystemMetrics(SM_CXSCREEN);
  154.     int screenY = GetSystemMetrics(SM_CYSCREEN);
  155.     if (screenX <= 800) {
  156.         frame->Attr.W = screenX - 20;
  157.         frame->Attr.H = screenY - 60;
  158.     } else {
  159.         frame->Attr.W = 800;
  160.         frame->Attr.H = 600;
  161.     }
  162. //    SDIDecFrame *frame = new SDIDecFrame(0, GetName(), client, FALSE);
  163.  
  164.  
  165.     nCmdShow = nCmdShow != SW_SHOWMINIMIZED ? SW_SHOWNORMAL : nCmdShow;
  166.  
  167.     //
  168.     // このアプリケーションに,アイコンを設定する
  169.     //
  170.     frame->SetIcon(this, IDI_SDIAPPLICATION);
  171.  
  172.     //
  173.     // ウィンドウに対応したメニューと,テーブルに対応したアクセラレータのテーブル
  174.     //
  175. #if 0
  176.     switch (fxgaflag) {
  177.     case PREVIEW_FXGA:
  178.         frame->AssignMenu(SDI_MENU);
  179.         break;
  180.     case PREVIEW_REND:
  181.         frame->AssignMenu(SDI_MENU_REND);
  182.         break;
  183.     case PREVIEW_BOTH:
  184.         frame->AssignMenu(SDI_MENU_BOTH);
  185.         break;
  186.     }
  187. #endif
  188.     frame->AssignMenu(SDI_MENU);
  189.  
  190.     //
  191.     // アクセラレータテーブルへの関連付け
  192.     //
  193.     frame->Attr.AccelTable = SDI_MENU;
  194.  
  195.     frame->Insert(*anim->InitStatusBar(), TDecoratedFrame::Bottom);
  196.  
  197.     SetMainWindow(frame);
  198.  
  199. }
  200.  
  201.  
  202. //////////////////////////////////////////////////////////
  203. // meditApp
  204. // ===========
  205. // 「ファイル」メニューの「新規作成」コマンド
  206. void meditApp::CmFileNew ()
  207. {
  208. //    TEditFile *client = TYPESAFE_DOWNCAST(GetMainWindow()->GetClientWindow(), TEditFile);     // フレーム用のクライアントウィンドウ
  209. //    client->NewFile();
  210.  
  211.     if (anim->Frame->CanClose()) {
  212.         anim->NewFile();
  213.     }
  214.  
  215. }
  216.  
  217. void meditApp::CmFileNewEnable (TCommandEnabler &tce)
  218. {
  219. //    tce.Enable(anim->motion != NULL || anim->editflag > 0);
  220.     tce.Enable(TRUE);
  221. }
  222.  
  223.  
  224. //////////////////////////////////////////////////////////
  225. // meditApp
  226. // ===========
  227. // 「ファイル」メニューの「開く」コマンド
  228. void meditApp::CmFileOpen ()
  229. {
  230.     //
  231.     // 標準の「開く」ダイアログボックスを表示し,ファイル名を選ぶ
  232.     //
  233.     if (anim->Frame->CanClose()) {
  234. #if 0
  235.         TOpenSaveDialog::TData FileData(
  236.                             OFN_FILEMUSTEXIST | OFN_HIDEREADONLY,
  237.                             "フレームファイル(*.frm)|*.frm|",
  238.                             0, anim->filedir, "FRM");
  239.         if (TFileOpenDialog(anim->Frame, FileData).Execute() == IDOK) {
  240.             anim->ReadFile(FileData.FileName);
  241.         }
  242. #else
  243.         char fname[256];
  244.         if (FileOpenDialogWithBMP(anim->Frame, fname,
  245.                             OFN_FILEMUSTEXIST | OFN_HIDEREADONLY,
  246.                             "フレームファイル(*.frm)|*.frm|",
  247.                             0, anim->filedir, "FRM") == IDOK) {
  248.             anim->ReadFile(fname);
  249.         }
  250. #endif
  251.     }
  252. }
  253.  
  254.  
  255. #if 0
  256. void meditApp::OpenFile (const char *fileName)
  257. {
  258.     if (fileName)
  259.         lstrcpy(FileData.FileName, fileName);
  260.  
  261.     TEditFile *client = TYPESAFE_DOWNCAST(GetMainWindow()->GetClientWindow(), TEditFile);     // フレーム用のクライアントウィンドウ
  262.     client->ReplaceWith(FileData.FileName);
  263. }
  264. #endif
  265.  
  266.  
  267. //////////////////////////////////////////////////////////
  268. // meditApp
  269. // =====
  270. // 「ファイル」メニューの「閉じる」コマンド
  271. void meditApp::CmFileClose ()
  272. {
  273.     CmFileNew();
  274. }
  275.  
  276. //////////////////////////////////////////////////////////
  277. // meditApp
  278. // =====
  279. // 「ヘルプ」メニューの,「内容」コマンド
  280. void meditApp::CmHelpContents ()
  281. {
  282.     //
  283.     // ヘルプの内容のテーブルを表示する
  284.     //
  285.     anim->WinHelp(HELP_CONTENTS, 0L);
  286. }
  287.  
  288.  
  289. //////////////////////////////////////////////////////////
  290. // meditApp
  291. // =====
  292. // 「ヘルプ」メニューの「ヘルプの使い方」コマンド
  293. void meditApp::CmHelpUsing ()
  294. {
  295.     //
  296.     // ウィンドウズのヘルプファイルの内容を表示する
  297.     //
  298.     anim->WinHelp(HELP_HELPONHELP, 0L);
  299. }
  300.  
  301.  
  302. //////////////////////////////////////////////////////////
  303. // meditApp
  304. // ===========
  305. // 「ヘルプ」メニューの「medit.exe について」コマンド
  306. void meditApp::CmHelpAbout ()
  307. {
  308.     //
  309.     // モーダルダイアログを表示する
  310.     //
  311.     meditAboutDlg(MainWindow).Execute();
  312. }
  313.  
  314.  
  315. BOOL meditApp::ProcessAppMsg (MSG& msg)
  316. {
  317.     if (msg.message == WM_COMMAND) {
  318. #if 0
  319.         if (ContextHelp || (GetKeyState(VK_F1) < 0)) {
  320.             ContextHelp = FALSE;
  321.             anim->WinHelp(HELP_CONTEXT, msg.wParam);
  322.             return TRUE;
  323.         }
  324. #endif
  325.     } else
  326.         switch (msg.message) {
  327.         case WM_KEYDOWN:
  328.             if (msg.wParam == VK_F1) {
  329. #if 0
  330.                 // もし Shift/F1 キーであれば,ヘルプカーソルをセットし,モーダルヘルプ状態に遷移する
  331.  
  332.                 if (::GetKeyState(VK_SHIFT) < 0) {
  333.                     ContextHelp = TRUE;
  334.                     HelpCursor = ::LoadCursor(GetMainWindow()->GetModule()->GetInstance(), MAKEINTRESOURCE(IDC_HELPCURSOR));
  335.                     ::SetCursor(HelpCursor);
  336.                     return TRUE;        // メッセージは「食べて」しまう
  337.                 } else {
  338.                     // もしシフトなしの F1 キーであれば,ヘルプのメインインデックスを表示する
  339.                     anim->WinHelp(HELP_INDEX, 0L);
  340.                     return TRUE;        // メッセージは「食べて」しまう
  341.                 }
  342. #else
  343.                 anim->WinHelp(HELP_INDEX, 0L);
  344.                 return TRUE;
  345. #endif
  346. #if 0
  347.             } else {
  348.                 if (ContextHelp && (msg.wParam == VK_ESCAPE)) {
  349.                     if (HelpCursor)
  350.                         ::DestroyCursor(HelpCursor);
  351.                     ContextHelp = FALSE;
  352.                     HelpCursor = 0;
  353.                     GetMainWindow()->SetCursor(0, IDC_ARROW);
  354.                     return TRUE;    // メッセージは「食べて」しまう
  355.                 }
  356. #endif
  357.             }
  358.             break;
  359.  
  360.         case WM_MOUSEMOVE:
  361.         case WM_NCMOUSEMOVE:
  362. #if 0
  363.             if (ContextHelp) {
  364.                 ::SetCursor(HelpCursor);
  365.                 return TRUE;        // メッセージは「食べて」しまう
  366.             }
  367. #endif
  368.             break;
  369.  
  370.         case WM_INITMENU:
  371. #if 0
  372.             if (ContextHelp) {
  373.                 ::SetCursor(HelpCursor);
  374.                 return TRUE;        // メッセージは「食べて」しまう
  375.             }
  376. #endif
  377.             break;
  378.  
  379.         case WM_ENTERIDLE:
  380. #if 0
  381.             if (msg.wParam == MSGF_MENU)
  382.                 if (GetKeyState(VK_F1) < 0) {
  383.                 ContextHelp = TRUE;
  384.                 GetMainWindow()->PostMessage(WM_KEYDOWN, VK_RETURN, 0L);
  385.                 return TRUE;       // メッセージは「食べて」しまう
  386.             }
  387. #endif
  388.             break;
  389.  
  390.         default:
  391.             ;
  392.         };  // switch の終わり
  393.  
  394.     // 通常の処理を続ける
  395.     return TApplication::ProcessAppMsg(msg);
  396. }
  397.  
  398.  
  399. int OwlMain (int , char* [])
  400. {
  401.     meditApp     App;
  402.     int             result;
  403.  
  404.     FileInit();
  405.  
  406.     Object::UsePoly();
  407.  
  408.     result = App.Run();
  409.  
  410.     return result;
  411. }
  412.  
  413. void meditApp::CmFileSave ()
  414. {
  415.     // INSERT>> 追加コードはここに
  416.  
  417.     anim->WriteFile();
  418. }
  419.  
  420.  
  421. void meditApp::CmFileSaveEnable (TCommandEnabler &tce)
  422. {
  423.     if (anim->opstat == OpPlay || anim->opstat == OpSelZoom) {
  424.         anim->OpModeDefault();
  425.     }
  426.     tce.Enable(anim->opstat == OpDefault &&anim->filename[0] != '\0');
  427. }
  428.  
  429.  
  430. void meditApp::CmFileSaveAs ()
  431. {
  432.     // INSERT>> 追加コードはここに
  433.  
  434. #if 0
  435.     TOpenSaveDialog::TData FileData(
  436.                             OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
  437.                             "フレームファイル(*.frm)|*.frm|",
  438.                             0, anim->filedir, "FRM");
  439.     if (TFileSaveDialog(GetMainWindow(), FileData).Execute() == IDOK) {
  440.         anim->WriteFile(FileData.FileName);
  441.     }
  442. #else
  443.     char fname[256];
  444.     if (FileSaveDialogWithBMP(GetMainWindow(), fname,
  445.                             OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
  446.                             "フレームファイル(*.frm)|*.frm|",
  447.                             0, anim->filedir, "FRM") == IDOK) {
  448.         anim->WriteFile(fname);
  449.     }
  450. #endif
  451.  
  452. }
  453. void meditApp::CmFileSaveAs (TCommandEnabler &tce)
  454. {
  455.     tce.Enable(anim->opstat == OpDefault);
  456. }
  457.  
  458.  
  459.  
  460.  
  461. void meditApp::CmEditDelete ()
  462. {
  463.     anim->DeleteMotion(anim->select);
  464. }
  465.  
  466.  
  467. void meditApp::CmEditDeleteEnable (TCommandEnabler &tce)
  468. {
  469.     if (anim->opstat == OpPlay || anim->opstat == OpSelZoom) {
  470.         anim->OpModeDefault();
  471.     }
  472.     tce.Enable(anim->opstat == OpDefault && anim->select != NULL && anim->select != anim->camera && anim->select != anim->camera->target);
  473. }
  474.  
  475.  
  476. void meditApp::CmEditDup ()
  477. {
  478.     anim->CopyMotion(anim->select);
  479. }
  480.  
  481.  
  482. void meditApp::CmEditDupEnable (TCommandEnabler &tce)
  483. {
  484.     tce.Enable(anim->opstat == OpDefault && anim->select != NULL && anim->select != anim->camera && anim->select != anim->camera->target);
  485. }
  486.  
  487.  
  488. void meditApp::CmEditExchange ()
  489. {
  490.     char fname[256];
  491.     if (anim->GetMechaName(fname)) {
  492.         anim->ExchangeMechanic(fname);
  493.     }
  494. }
  495.  
  496.  
  497. void meditApp::CmEditExchangeEnable (TCommandEnabler &tce)
  498. {
  499.     tce.Enable(anim->opstat == OpDefault && anim->select != NULL && anim->select != anim->camera && anim->select != anim->camera->target);
  500. }
  501.  
  502.  
  503. void meditApp::CmEditForward ()
  504. {
  505.     if (anim->select != NULL && anim->select->motiondata != NULL) {
  506.         MotionData *m = anim->select->motiondata;
  507.         if (m->dirtype == DirForward) {
  508.             Vector v1, v2, v3;
  509.             anim->select->motiondata->GetPosition(1.0, v1, v2, v3);
  510.             anim->select->motiondata->rotation[1] = v2;
  511.             anim->select->motiondata->dirtype = DirLinear;
  512.         } else {
  513.             anim->select->SetForward();
  514.         }
  515.         anim->CalcPoints(anim->select);
  516.         anim->Redraw();
  517.     }
  518. }
  519.  
  520.  
  521. void meditApp::CmEditForwardEnable (TCommandEnabler &tce)
  522. {
  523.     tce.Enable(anim->opstat == OpDefault && anim->select != NULL && anim->select->motiondata != NULL && anim->select != anim->camera && anim->select != anim->camera->target);
  524.     tce.SetCheck(anim->select != NULL && anim->select->motiondata != NULL && anim->select->motiondata->dirtype == DirForward);
  525. }
  526.  
  527.  
  528. void meditApp::CmEditMaxFrame ()
  529. {
  530.     char str[16];
  531.     sprintf(str, "%d", anim->maxframe);
  532.     TInputDialog dialog(MainWindow, "総フレーム数変更", "総フレーム数を入力してください", str, 16);
  533.     if (dialog.Execute() == IDOK) {
  534.         int n = atoi(str);
  535.         if (BEGIN < n && n < 1000) {
  536.             anim->ExpandFrame(n);
  537.         }
  538.     }
  539. }
  540.  
  541.  
  542. void meditApp::CmEditMaxFrameEnable (TCommandEnabler &tce)
  543. {
  544.     tce.Enable(anim->opstat == OpDefault);
  545. }
  546.  
  547.  
  548. void meditApp::CmMechaAddFix ()
  549. {
  550.     char fname[256];
  551.     if (anim->GetMechaName(fname)) {
  552.         anim->AddMechanicFix(fname);
  553.     }
  554. }
  555.  
  556.  
  557. void meditApp::CmMechaAddFixEnable (TCommandEnabler &tce)
  558. {
  559.     if (anim->opstat == OpPlay || anim->opstat == OpSelZoom) {
  560.         anim->OpModeDefault();
  561.     }
  562.     tce.Enable(anim->opstat == OpDefault);
  563. }
  564.  
  565.  
  566. void meditApp::CmMechaAddMove ()
  567. {
  568.     char fname[256];
  569.     if (anim->GetMechaName(fname)) {
  570.         anim->AddMechanicMove(fname);
  571.     }
  572. }
  573.  
  574.  
  575. void meditApp::CmMechaAddMoveEnable (TCommandEnabler &tce)
  576. {
  577.     tce.Enable(anim->opstat == OpDefault);
  578. }
  579.  
  580.  
  581. void meditApp::CmMechaRange ()
  582. {
  583.     if (anim->select == NULL || anim->maxframe == BEGIN) {
  584.         return;
  585.     }
  586.     char *m;
  587.     if (anim->select->motiondata != NULL) {
  588.         m = "メカの移動速度・出現/消失時刻を設定します";
  589.     } else {
  590.         m = "メカの出現/消失時刻を設定します";
  591.     }
  592.     TDRange dialog(GetMainWindow(), anim, anim->select, m);
  593.     if (dialog.Execute() == IDOK) {
  594.         if (anim->selectframe < anim->select->beginframe) {
  595.             anim->SelectFrame(anim->select->beginframe);
  596.         } else if (anim->selectframe > anim->select->endframe) {
  597.             anim->SelectFrame(anim->select->endframe);
  598.         }
  599.         anim->editflag++;
  600.         anim->select->GetPosition(anim->selectframe);
  601.         anim->CalcPoints(anim->select);
  602.         anim->Redraw();
  603.     }
  604. }
  605.  
  606.  
  607. void meditApp::CmMechaRangeEnable (TCommandEnabler &tce)
  608. {
  609.     tce.Enable(anim->opstat == OpDefault
  610.             && anim->select != NULL
  611.             && anim->select != anim->camera
  612.             && anim->select != anim->camera->target);
  613. }
  614.  
  615.  
  616. void meditApp::CmCameraAddEnd ()
  617. {
  618.     Matrix m = Matrix::m_rot(anim->camera->rotation);
  619.     Vector v0 = (anim->TopView->Attr.H/3/anim->displayscale) * m.v[1];
  620.     anim->editflag++;
  621.     anim->camera->ChangeMove(v0);
  622.     anim->camera->target->ChangeMove(v0);
  623.     anim->CalcPoints(anim->camera);
  624.     anim->CalcViewAll();
  625.     anim->SelectMotion(anim->camera);
  626.     anim->Redraw();
  627. }
  628.  
  629.  
  630. void meditApp::CmCameraAddEndEnable (TCommandEnabler &tce)
  631. {
  632.     if (anim->opstat == OpPlay || anim->opstat == OpSelZoom) {
  633.         anim->OpModeDefault();
  634.     }
  635.     tce.Enable(anim->opstat == OpDefault && anim->camera->motiondata == NULL);
  636. }
  637.  
  638.  
  639. void meditApp::CmCameraDeleteEnd ()
  640. {
  641.     anim->editflag++;
  642.     anim->camera->target->ChangeFix();
  643.     anim->camera->ChangeFix();
  644.     anim->camera->GetPosition(anim->selectframe);
  645.     anim->CalcPoints(anim->camera);
  646.     anim->CalcViewAll();
  647.     anim->SelectMotion(anim->camera);
  648.     anim->Redraw();
  649. }
  650.  
  651.  
  652. void meditApp::CmCameraDeleteEndEnable (TCommandEnabler &tce)
  653. {
  654.     tce.Enable(anim->opstat == OpDefault && anim->camera->motiondata != NULL);
  655. }
  656.  
  657.  
  658. void meditApp::CmCameraRange ()
  659. {
  660.     if (anim->select != anim->camera) {
  661.         anim->SelectMotion(anim->camera);
  662.     }
  663.     TDRange dialog(GetMainWindow(), anim, anim->select, "カメラの移動速度を設定します");
  664.     if (dialog.Execute() == IDOK) {
  665.         anim->camera->GetPosition(anim->selectframe);
  666.         anim->CalcPoints(anim->camera);
  667.         anim->CalcViewAll();
  668.         anim->editflag++;
  669.         anim->Redraw();
  670.     }
  671. }
  672.  
  673.  
  674. void meditApp::CmCameraRangeEnable (TCommandEnabler &tce)
  675. {
  676.     tce.Enable(anim->opstat == OpDefault && anim->camera->motiondata != NULL);
  677. }
  678.  
  679. void meditApp::CmTargetRange ()
  680. {
  681.     if (anim->select != anim->camera->target) {
  682.         anim->SelectMotion(anim->camera->target);
  683.     }
  684.     TDRange dialog(GetMainWindow(), anim, anim->select, "ターゲットの移動速度を設定します");
  685.     if (dialog.Execute() == IDOK) {
  686.         anim->camera->GetPosition(anim->selectframe);
  687.         anim->CalcPoints(anim->camera);
  688.         anim->CalcViewAll();
  689.         anim->editflag++;
  690.         anim->Redraw();
  691.     }
  692. }
  693.  
  694.  
  695. void meditApp::CmTargetRangeEnable (TCommandEnabler &tce)
  696. {
  697.     tce.Enable(anim->opstat == OpDefault && anim->camera->motiondata != NULL);
  698. }
  699.  
  700. void meditApp::CmCameraLight ()
  701. {
  702.     anim->OpModeLight();
  703. }
  704.  
  705.  
  706. void meditApp::CmCameraLightEnable (TCommandEnabler &tce)
  707. {
  708.     tce.Enable(anim->opstat == OpDefault);
  709. }
  710.  
  711.  
  712. void meditApp::CmDispFxga ()
  713. {
  714.     static char *title        ="FXGA モーション表示";
  715.     static char *title2        ="FXGA 初期化";
  716.     if (FindWindow(NULL, title) != NULL
  717.      || FindWindow(NULL, title2) != NULL) {
  718.         GetMainWindow()->MessageBox("現在実行中です", title, MB_OK);
  719.     } else {
  720.         FXGA_ShowMotion(anim->motion, anim->camera, anim->light);
  721.         anim->statusbar->SetText("I:再生 II:順コマ送り III:逆コマ送り  VI:頭出し");
  722.     }
  723. }
  724.  
  725.  
  726. void meditApp::CmDispFxgaEnable (TCommandEnabler &tce)
  727. {
  728.     if (anim->opstat == OpPlay || anim->opstat == OpSelZoom) {
  729.         anim->OpModeDefault();
  730.     }
  731.     tce.Enable(anim->opstat == OpDefault && anim->motion != NULL);
  732. }
  733.  
  734. void meditApp::CmDispWireview ()
  735. {
  736.     // INSERT>> 追加コードはここに
  737.     static char *title = "WireView - _TEMP.FRM";
  738.     HWND hWire;
  739.     if (anim->motion != NULL) {
  740.         if ((hWire= FindWindow(NULL, title)) != NULL) {
  741.             ::SendMessage(hWire, WM_CLOSE, 0, 0);
  742.         }
  743.         WireView(anim->motion, anim->camera, anim->light);
  744.     }
  745. }
  746.  
  747.  
  748. void meditApp::CmDispWireviewEnable (TCommandEnabler &tce)
  749. {
  750.     if (anim->opstat == OpPlay || anim->opstat == OpSelZoom) {
  751.         anim->OpModeDefault();
  752.     }
  753.     tce.Enable(anim->opstat == OpDefault && anim->motion != NULL);
  754. }
  755.  
  756. void meditApp::CmDispRend ()
  757. {
  758.     // INSERT>> 追加コードはここに
  759.  
  760.     static char *title = "REND for Windows";
  761.     HWND hRend;
  762.     if (anim->motion != NULL) {
  763.         if ((hRend= FindWindow(NULL, title)) != NULL) {
  764.             ::SendMessage(hRend, WM_CLOSE, 0, 0);
  765.         }
  766.         RendNowMotion(anim->motion, anim->camera, anim->light, anim->selectframe);
  767.     }
  768. }
  769.  
  770.  
  771. void meditApp::CmDispRendEnable (TCommandEnabler &tce)
  772. {
  773.     // INSERT>> 追加コードはここに
  774.     tce.Enable(anim->opstat == OpDefault && anim->motion != NULL);
  775.  
  776. }
  777.  
  778. void meditApp::CmDispRendReso ()
  779. {
  780.     // INSERT>> 追加コードはここに
  781.     char opt[1024], *s, *d;
  782.     int w=320, h=240;
  783.     strcpy(opt, rendoption.c_str());
  784.     for (s = d = opt; *s; ) {
  785.         if ((*s == '-' || *s == '/') && (s[1] == 'c' || s[1] == 'C')) {
  786.             s+=2;
  787.             w = atoi(s);
  788.             while (*s && isdigit(*s)) s++;
  789.             if (*s) {
  790.                 s++;
  791.                 if (isdigit(*s)) {
  792.                     h = atoi(s);
  793.                 }
  794.                 while(*s && !isspace(*s)) s++;
  795.                 if (*s) s++;
  796.             }
  797.         } else {
  798.             *d++ = *s++;
  799.         }
  800.     }
  801.     while (d > opt  && isspace(d[-1])) d--;
  802.     *d = '\0';
  803.     TDSelReso dialog(MainWindow, w, h);
  804.     if (dialog.Execute() == IDOK) {
  805.         w = dialog.selwidth;
  806.         h = dialog.selheight;
  807.         sprintf(opt+strlen(opt), " -c%d:%d:%d:%d", w, h, w, h);
  808.         rendoption = opt;
  809.         FileWriteRendOption();
  810.     }
  811.  
  812. }
  813.  
  814.  
  815. void meditApp::CmDispRendResoEnable (TCommandEnabler &tce)
  816. {
  817.     // INSERT>> 追加コードはここに
  818.     tce.Enable(anim->opstat == OpDefault);
  819. }
  820.  
  821. void meditApp::CmDispHidenRemove ()
  822. {
  823.     // INSERT>> 追加コードはここに
  824.     anim->hiddenremove = !anim->hiddenremove;
  825.     anim->BuildWireFrame(anim->selectframe);
  826.     anim->Redraw(SelPers);
  827. }
  828.  
  829.  
  830. void meditApp::CmDispHiddenRemoveEnable (TCommandEnabler &tce)
  831. {
  832.     // INSERT>> 追加コードはここに
  833.     tce.SetCheck(anim->hiddenremove);
  834. }
  835.  
  836. void meditApp::CmDispSimple ()
  837. {
  838.     if (anim->drawmode == DrawWire) {
  839.         anim->SetDrawMode(DrawPlane);
  840.     } else {
  841.         anim->SetDrawMode(DrawWire);
  842.     }
  843. }
  844.  
  845.  
  846. void meditApp::CmDispSimpleEnable (TCommandEnabler &tce)
  847. {
  848.     tce.Enable(anim->opstat == OpDefault);
  849.     tce.SetCheck(anim->drawmode == DrawPlane);
  850. }
  851.  
  852.  
  853. void meditApp::CmDispZoom ()
  854. {
  855.     anim->OpModeZoom();
  856. }
  857.  
  858.  
  859. void meditApp::CmDispZoomEnable (TCommandEnabler &tce)
  860. {
  861.     tce.Enable(anim->opstat == OpDefault);
  862.     tce.SetCheck(anim->zoomflag != FALSE);
  863. }
  864.  
  865.  
  866. void meditApp::CmDispScaleDown ()
  867. {
  868.     anim->ScaleDown();
  869. }
  870.  
  871.  
  872. void meditApp::CmDispScaleDownEnable (TCommandEnabler &tce)
  873. {
  874.     tce.Enable(anim->opstat == OpDefault && anim->zoomflag == FALSE && anim->ScaleDownLimitCheck());
  875. }
  876.  
  877.  
  878. void meditApp::CmDispScaleUp ()
  879. {
  880.     anim->ScaleUp();
  881. }
  882.  
  883.  
  884. void meditApp::CmDispScaleUpEnable (TCommandEnabler &tce)
  885. {
  886.     tce.Enable(anim->opstat == OpDefault && anim->zoomflag == FALSE && anim->ScaleUpLimitCheck());
  887. }
  888.  
  889.  
  890. void meditApp::CmDispMesh ()
  891. {
  892.     anim->meshflag = ! anim->meshflag;
  893.     anim->Redraw();
  894. }
  895.  
  896.  
  897. void meditApp::CmDispMeshEnable (TCommandEnabler &tce)
  898. {
  899.     tce.Enable(anim->opstat == OpDefault);
  900.     tce.SetCheck(anim->meshflag != FALSE);
  901. }
  902.  
  903.  
  904. void meditApp::CmDispMeshSpace ()
  905. {
  906.     char *buf[] = {"250", "500", "1000", "2500", "5000", "10000", NULL};
  907.     int pos;
  908.     for (pos = 0; buf[pos] != NULL; pos++) {
  909.         if (anim->meshspacing == atoi(buf[pos])) {
  910.             break;
  911.         }
  912.     }
  913.     if (buf[pos] == NULL) pos = 5;
  914.     TDSliderInput dialog(MainWindow, "メッシュ間隔設定", "メッシュの間隔を設定してください", buf, pos);
  915.     if (dialog.Execute() == IDOK) {
  916.         anim->meshspacing = atoi(buf[pos]);
  917.         anim->Redraw();
  918.     }
  919. }
  920.  
  921.  
  922. void meditApp::CmDispMeshSpaceEnable (TCommandEnabler &tce)
  923. {
  924.     tce.Enable(anim->opstat == OpDefault);
  925. }
  926.  
  927.  
  928. void meditApp::CmModeGrid ()
  929. {
  930.     anim->gridflag = ! anim->gridflag;
  931. }
  932.  
  933.  
  934. void meditApp::CmModeGridEnable (TCommandEnabler &tce)
  935. {
  936.     if (anim->opstat == OpPlay || anim->opstat == OpSelZoom) {
  937.         anim->OpModeDefault();
  938.     }
  939.     tce.Enable(anim->opstat == OpDefault);
  940.     tce.SetCheck(anim->gridflag != FALSE);
  941. }
  942.  
  943.  
  944. void meditApp::CmModeGridSpace ()
  945. {
  946.     char *buf[] = {"50", "100", "250", "500", "1000", "2500", NULL};
  947.     int pos;
  948.     for (pos = 0; buf[pos] != NULL; pos++) {
  949.         if (anim->gridspacing == atoi(buf[pos])) {
  950.             break;
  951.         }
  952.     }
  953.     if (buf[pos] == NULL) pos = 1;
  954.     TDSliderInput dialog(MainWindow, "移動グリッド量設定", "位置設定の最小単位を設定してください", buf, pos);
  955.     if (dialog.Execute() == IDOK) {
  956.         anim->gridspacing = atoi(buf[pos]);
  957.     }
  958. }
  959.  
  960.  
  961. void meditApp::CmModeGridSpaceEnable (TCommandEnabler &tce)
  962. {
  963.     tce.Enable(anim->opstat == OpDefault);
  964. }
  965.  
  966.  
  967. void meditApp::CmModeRotSpace ()
  968. {
  969.     char *buf[] = {"2", "5", "10", "15", "20", "30", "45",NULL};
  970.     int pos;
  971.     for (pos = 0; buf[pos] != NULL; pos++) {
  972.         if (anim->rotspacing == atoi(buf[pos])) {
  973.             break;
  974.         }
  975.     }
  976.     if (buf[pos] == NULL) pos = 5;
  977.     TDSliderInput dialog(MainWindow, "回転グリッド量設定", "回転角度の最小単位を設定してください", buf, pos);
  978.     if (dialog.Execute() == IDOK) {
  979.         anim->rotspacing = atoi(buf[pos]);
  980.     }
  981.  
  982. }
  983.  
  984.  
  985. void meditApp::CmModeRotSpaceEnable (TCommandEnabler &tce)
  986. {
  987.     tce.Enable(anim->opstat == OpDefault);
  988. }
  989.  
  990.  
  991. void meditApp::CmModeScaleSpace ()
  992. {
  993.     char *buf[] = {"0.05", "0.1", "0.2", "0.5", NULL};
  994.     int pos;
  995.     for (pos = 0; buf[pos] != NULL; pos++) {
  996.         if (anim->scalespacing == (int)(atof(buf[pos]) * scalespacingfactor)) {
  997.             break;
  998.         }
  999.     }
  1000.     if (buf[pos] == NULL) pos = 1;
  1001.     TDSliderInput dialog(MainWindow, "拡大グリッド量設定", "拡大倍率の最少単位を設定してください", buf, pos);
  1002.     if (dialog.Execute() == IDOK) {
  1003.         anim->scalespacing = atof(buf[pos]) * scalespacingfactor;
  1004.     }
  1005. }
  1006.  
  1007.  
  1008. void meditApp::CmModeScaleSpaceEnable (TCommandEnabler &tce)
  1009. {
  1010.     tce.Enable(anim->opstat == OpDefault);
  1011. }
  1012.  
  1013.  
  1014.  
  1015.  
  1016.  
  1017. BOOL meditApp::IdleAction (long idleCount)
  1018. {
  1019.     BOOL result;
  1020.  
  1021.     result = TApplication::IdleAction(idleCount);
  1022.  
  1023.     // INSERT>> 追加のコードはここに
  1024.  
  1025.     if (execonce != FALSE) {
  1026.         return result;
  1027.     }
  1028.     execonce = TRUE;
  1029.  
  1030.     TWindow *client = GetMainWindow()->GetClientWindow();
  1031.     TClientDC dc(*client);
  1032.     InitSysColor(dc);
  1033.  
  1034.  
  1035.     TMenu menu(GetMainWindow()->GetMenu());
  1036.     TMenu submenu(menu.GetSubMenu(4));
  1037.     if (fxgaflag == PREVIEW_FXGA) {
  1038.         submenu.RemoveMenu(CM_DISP_REND, MF_BYCOMMAND);
  1039.         submenu.RemoveMenu(CM_DISP_RENDRESO, MF_BYCOMMAND);
  1040.     } else if (fxgaflag == PREVIEW_REND) {
  1041.         submenu.RemoveMenu(CM_DISP_FXGA, MF_BYCOMMAND);
  1042.     }
  1043.  
  1044.     return result;
  1045. }
  1046.  
  1047.  
  1048.