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 >
Wrap
C/C++ Source or Header
|
1996-07-10
|
27KB
|
1,048 lines
/* Project medit
Project Team DoGA
Copyright (c) 1995. All Rights Reserved.
サブシステム: medit.exe Application
ファイル: meditapp.cpp
作成者: Taka2
概要
====
meditApp (TApplication) のインプリメンテーション用のソースファイル
*/
#include <owl\owlpch.h>
#pragma hdrstop
#include <owl\inputdia.h>
#include <owl\statusba.h>
#include "meditapp.h"
#include "mdtabtdl.h" // 「プログラムについて」ダイアログボックスの定義
#include "winframe.h"
#include "display.h"
#include "anim.h"
#include "motion.h"
#include "files.h"
#include "drange.h"
#include "dslider.h"
#include "fxg.h"
#include "rendexec.h"
#include "log.h"
#include "suflib.h"
#include "syscolor.h"
#include "bmpopen.h"
#include "dselreso.h"
//
// ヘルプファイルの作成
//
//const char HelpFileName[] = "medit.hlp";
//{{meditApp Implementation}}
//
// アプリケーションが処理するすべてのメッセージ/コマンドに対する応答テーブルを作成する
//
DEFINE_RESPONSE_TABLE1(meditApp, TApplication)
//{{meditAppRSP_TBL_BEGIN}}
EV_COMMAND(CM_FILENEW, CmFileNew), EV_COMMAND_ENABLE(CM_FILENEW, CmFileNewEnable),
EV_COMMAND(CM_FILEOPEN, CmFileOpen),
EV_COMMAND(CM_HELPCONTENTS, CmHelpContents),
EV_COMMAND(CM_HELPABOUT, CmHelpAbout),
EV_COMMAND(CM_FILESAVE, CmFileSave), EV_COMMAND_ENABLE(CM_FILESAVE, CmFileSaveEnable),
EV_COMMAND(CM_FILESAVEAS, CmFileSaveAs), EV_COMMAND_ENABLE(CM_FILESAVEAS, CmFileSaveAs),
EV_COMMAND(CM_EDIT_DELETE, CmEditDelete), EV_COMMAND_ENABLE(CM_EDIT_DELETE, CmEditDeleteEnable),
EV_COMMAND(CM_EDIT_DUP, CmEditDup), EV_COMMAND_ENABLE(CM_EDIT_DUP, CmEditDupEnable),
EV_COMMAND(CM_EDIT_EXCHANGE, CmEditExchange), EV_COMMAND_ENABLE(CM_EDIT_EXCHANGE, CmEditExchangeEnable),
EV_COMMAND(CM_EDIT_FORWARD, CmEditForward), EV_COMMAND_ENABLE(CM_EDIT_FORWARD, CmEditForwardEnable),
EV_COMMAND(CM_EDIT_MAXFRAME, CmEditMaxFrame), EV_COMMAND_ENABLE(CM_EDIT_MAXFRAME, CmEditMaxFrameEnable),
EV_COMMAND(CM_MECHA_ADD_FIX, CmMechaAddFix), EV_COMMAND_ENABLE(CM_MECHA_ADD_FIX, CmMechaAddFixEnable),
EV_COMMAND(CM_MECHA_ADD_MOVE, CmMechaAddMove), EV_COMMAND_ENABLE(CM_MECHA_ADD_MOVE, CmMechaAddMoveEnable),
EV_COMMAND(CM_MECHA_RANGE, CmMechaRange), EV_COMMAND_ENABLE(CM_MECHA_RANGE, CmMechaRangeEnable),
EV_COMMAND(CM_CAMERA_ADD_END, CmCameraAddEnd), EV_COMMAND_ENABLE(CM_CAMERA_ADD_END, CmCameraAddEndEnable),
EV_COMMAND(CM_CAMERA_DELETE_END, CmCameraDeleteEnd), EV_COMMAND_ENABLE(CM_CAMERA_DELETE_END, CmCameraDeleteEndEnable),
EV_COMMAND(CM_CAMERA_RANGE, CmCameraRange), EV_COMMAND_ENABLE(CM_CAMERA_RANGE, CmCameraRangeEnable),
EV_COMMAND(CM_CAMERA_TARGET_RANGE, CmTargetRange), EV_COMMAND_ENABLE(CM_CAMERA_TARGET_RANGE, CmTargetRangeEnable),
EV_COMMAND(CM_CAMERA_LIGHT, CmCameraLight), EV_COMMAND_ENABLE(CM_CAMERA_LIGHT, CmCameraLightEnable),
EV_COMMAND(CM_DISP_FXGA, CmDispFxga), EV_COMMAND_ENABLE(CM_DISP_FXGA, CmDispFxgaEnable),
EV_COMMAND(CM_DISP_REND, CmDispRend), EV_COMMAND_ENABLE(CM_DISP_REND, CmDispRendEnable),
EV_COMMAND(CM_DISP_RENDRESO, CmDispRendReso), EV_COMMAND_ENABLE(CM_DISP_RENDRESO, CmDispRendResoEnable),
EV_COMMAND(CM_DISP_WIREVIEW, CmDispWireview), EV_COMMAND_ENABLE(CM_DISP_WIREVIEW, CmDispWireviewEnable),
EV_COMMAND(CM_DISP_HIDDENREMOVE, CmDispHidenRemove), EV_COMMAND_ENABLE(CM_DISP_HIDDENREMOVE, CmDispHiddenRemoveEnable),
EV_COMMAND(CM_DISP_SIMPLE, CmDispSimple), EV_COMMAND_ENABLE(CM_DISP_SIMPLE, CmDispSimpleEnable),
EV_COMMAND(CM_DISP_ZOOM, CmDispZoom), EV_COMMAND_ENABLE(CM_DISP_ZOOM, CmDispZoomEnable),
EV_COMMAND(CM_DISP_SCALEDOWN, CmDispScaleDown), EV_COMMAND_ENABLE(CM_DISP_SCALEDOWN, CmDispScaleDownEnable),
EV_COMMAND(CM_DISP_SCALEUP, CmDispScaleUp), EV_COMMAND_ENABLE(CM_DISP_SCALEUP, CmDispScaleUpEnable),
EV_COMMAND(CM_DISP_MESH, CmDispMesh), EV_COMMAND_ENABLE(CM_DISP_MESH, CmDispMeshEnable),
EV_COMMAND(CM_DISP_MESHSPACE, CmDispMeshSpace), EV_COMMAND_ENABLE(CM_DISP_MESHSPACE, CmDispMeshSpaceEnable),
EV_COMMAND(CM_MODE_GRID, CmModeGrid), EV_COMMAND_ENABLE(CM_MODE_GRID, CmModeGridEnable),
EV_COMMAND(CM_MODE_GRIDSPACE, CmModeGridSpace), EV_COMMAND_ENABLE(CM_MODE_GRIDSPACE, CmModeGridSpaceEnable),
EV_COMMAND(CM_MODE_ROTSPACE, CmModeRotSpace), EV_COMMAND_ENABLE(CM_MODE_ROTSPACE, CmModeRotSpaceEnable),
EV_COMMAND(CM_MODE_SCALESPACE, CmModeScaleSpace), EV_COMMAND_ENABLE(CM_MODE_SCALESPACE, CmModeScaleSpaceEnable),
//{{meditAppRSP_TBL_END}}
END_RESPONSE_TABLE;
//////////////////////////////////////////////////////////
// meditApp
// =====
//
meditApp::meditApp () : TApplication("Motion Editor")
{
execonce = FALSE;
// HelpState = FALSE;
// ContextHelp = FALSE;
// HelpCursor = 0;
// 「開く」と「名前を付けて保存」ダイアログボックスに共通の,ファイルフラグとフィルタ。ファイル名と
// ディレクトリは,メンバー関数 CmFileOpen と CmFileSaveAs で計算される
// FileData.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
// FileData.SetFilter("すべてのファイル (*.*)|*.*|");
// INSERT>> コンストラクタ用のコードはここに
}
meditApp::~meditApp ()
{
// INSERT>> デストラクタ用のコードはここに
}
BOOL meditApp::CanClose ()
{
BOOL result = TApplication::CanClose();
//
// ヘルプエンジンを使っていた場合には,それをクローズする
//
if (result && anim->HelpState)
anim->WinHelp(HELP_QUIT, 0L);
static char *title = "REND for Windows";
HWND hRend;
if ((hRend = FindWindow(NULL, title)) != NULL) {
::SendMessage(hRend, WM_CLOSE, 0, 0);
}
return result;
}
//////////////////////////////////////////////////////////
// meditApp
// =====
// アプリケーションの初期化
//
void meditApp::InitMainWindow ()
{
TWinFrame *client = new TWinFrame(0);
anim = client->anim;
// TFrameWindow *frame = new TFrameWindow(0, GetName(), client, TRUE);
TDecoratedFrame *frame = new TDecoratedFrame(0, GetName(), client, TRUE);
int screenX = GetSystemMetrics(SM_CXSCREEN);
int screenY = GetSystemMetrics(SM_CYSCREEN);
if (screenX <= 800) {
frame->Attr.W = screenX - 20;
frame->Attr.H = screenY - 60;
} else {
frame->Attr.W = 800;
frame->Attr.H = 600;
}
// SDIDecFrame *frame = new SDIDecFrame(0, GetName(), client, FALSE);
nCmdShow = nCmdShow != SW_SHOWMINIMIZED ? SW_SHOWNORMAL : nCmdShow;
//
// このアプリケーションに,アイコンを設定する
//
frame->SetIcon(this, IDI_SDIAPPLICATION);
//
// ウィンドウに対応したメニューと,テーブルに対応したアクセラレータのテーブル
//
#if 0
switch (fxgaflag) {
case PREVIEW_FXGA:
frame->AssignMenu(SDI_MENU);
break;
case PREVIEW_REND:
frame->AssignMenu(SDI_MENU_REND);
break;
case PREVIEW_BOTH:
frame->AssignMenu(SDI_MENU_BOTH);
break;
}
#endif
frame->AssignMenu(SDI_MENU);
//
// アクセラレータテーブルへの関連付け
//
frame->Attr.AccelTable = SDI_MENU;
frame->Insert(*anim->InitStatusBar(), TDecoratedFrame::Bottom);
SetMainWindow(frame);
}
//////////////////////////////////////////////////////////
// meditApp
// ===========
// 「ファイル」メニューの「新規作成」コマンド
void meditApp::CmFileNew ()
{
// TEditFile *client = TYPESAFE_DOWNCAST(GetMainWindow()->GetClientWindow(), TEditFile); // フレーム用のクライアントウィンドウ
// client->NewFile();
if (anim->Frame->CanClose()) {
anim->NewFile();
}
}
void meditApp::CmFileNewEnable (TCommandEnabler &tce)
{
// tce.Enable(anim->motion != NULL || anim->editflag > 0);
tce.Enable(TRUE);
}
//////////////////////////////////////////////////////////
// meditApp
// ===========
// 「ファイル」メニューの「開く」コマンド
void meditApp::CmFileOpen ()
{
//
// 標準の「開く」ダイアログボックスを表示し,ファイル名を選ぶ
//
if (anim->Frame->CanClose()) {
#if 0
TOpenSaveDialog::TData FileData(
OFN_FILEMUSTEXIST | OFN_HIDEREADONLY,
"フレームファイル(*.frm)|*.frm|",
0, anim->filedir, "FRM");
if (TFileOpenDialog(anim->Frame, FileData).Execute() == IDOK) {
anim->ReadFile(FileData.FileName);
}
#else
char fname[256];
if (FileOpenDialogWithBMP(anim->Frame, fname,
OFN_FILEMUSTEXIST | OFN_HIDEREADONLY,
"フレームファイル(*.frm)|*.frm|",
0, anim->filedir, "FRM") == IDOK) {
anim->ReadFile(fname);
}
#endif
}
}
#if 0
void meditApp::OpenFile (const char *fileName)
{
if (fileName)
lstrcpy(FileData.FileName, fileName);
TEditFile *client = TYPESAFE_DOWNCAST(GetMainWindow()->GetClientWindow(), TEditFile); // フレーム用のクライアントウィンドウ
client->ReplaceWith(FileData.FileName);
}
#endif
//////////////////////////////////////////////////////////
// meditApp
// =====
// 「ファイル」メニューの「閉じる」コマンド
void meditApp::CmFileClose ()
{
CmFileNew();
}
//////////////////////////////////////////////////////////
// meditApp
// =====
// 「ヘルプ」メニューの,「内容」コマンド
void meditApp::CmHelpContents ()
{
//
// ヘルプの内容のテーブルを表示する
//
anim->WinHelp(HELP_CONTENTS, 0L);
}
//////////////////////////////////////////////////////////
// meditApp
// =====
// 「ヘルプ」メニューの「ヘルプの使い方」コマンド
void meditApp::CmHelpUsing ()
{
//
// ウィンドウズのヘルプファイルの内容を表示する
//
anim->WinHelp(HELP_HELPONHELP, 0L);
}
//////////////////////////////////////////////////////////
// meditApp
// ===========
// 「ヘルプ」メニューの「medit.exe について」コマンド
void meditApp::CmHelpAbout ()
{
//
// モーダルダイアログを表示する
//
meditAboutDlg(MainWindow).Execute();
}
BOOL meditApp::ProcessAppMsg (MSG& msg)
{
if (msg.message == WM_COMMAND) {
#if 0
if (ContextHelp || (GetKeyState(VK_F1) < 0)) {
ContextHelp = FALSE;
anim->WinHelp(HELP_CONTEXT, msg.wParam);
return TRUE;
}
#endif
} else
switch (msg.message) {
case WM_KEYDOWN:
if (msg.wParam == VK_F1) {
#if 0
// もし Shift/F1 キーであれば,ヘルプカーソルをセットし,モーダルヘルプ状態に遷移する
if (::GetKeyState(VK_SHIFT) < 0) {
ContextHelp = TRUE;
HelpCursor = ::LoadCursor(GetMainWindow()->GetModule()->GetInstance(), MAKEINTRESOURCE(IDC_HELPCURSOR));
::SetCursor(HelpCursor);
return TRUE; // メッセージは「食べて」しまう
} else {
// もしシフトなしの F1 キーであれば,ヘルプのメインインデックスを表示する
anim->WinHelp(HELP_INDEX, 0L);
return TRUE; // メッセージは「食べて」しまう
}
#else
anim->WinHelp(HELP_INDEX, 0L);
return TRUE;
#endif
#if 0
} else {
if (ContextHelp && (msg.wParam == VK_ESCAPE)) {
if (HelpCursor)
::DestroyCursor(HelpCursor);
ContextHelp = FALSE;
HelpCursor = 0;
GetMainWindow()->SetCursor(0, IDC_ARROW);
return TRUE; // メッセージは「食べて」しまう
}
#endif
}
break;
case WM_MOUSEMOVE:
case WM_NCMOUSEMOVE:
#if 0
if (ContextHelp) {
::SetCursor(HelpCursor);
return TRUE; // メッセージは「食べて」しまう
}
#endif
break;
case WM_INITMENU:
#if 0
if (ContextHelp) {
::SetCursor(HelpCursor);
return TRUE; // メッセージは「食べて」しまう
}
#endif
break;
case WM_ENTERIDLE:
#if 0
if (msg.wParam == MSGF_MENU)
if (GetKeyState(VK_F1) < 0) {
ContextHelp = TRUE;
GetMainWindow()->PostMessage(WM_KEYDOWN, VK_RETURN, 0L);
return TRUE; // メッセージは「食べて」しまう
}
#endif
break;
default:
;
}; // switch の終わり
// 通常の処理を続ける
return TApplication::ProcessAppMsg(msg);
}
int OwlMain (int , char* [])
{
meditApp App;
int result;
FileInit();
Object::UsePoly();
result = App.Run();
return result;
}
void meditApp::CmFileSave ()
{
// INSERT>> 追加コードはここに
anim->WriteFile();
}
void meditApp::CmFileSaveEnable (TCommandEnabler &tce)
{
if (anim->opstat == OpPlay || anim->opstat == OpSelZoom) {
anim->OpModeDefault();
}
tce.Enable(anim->opstat == OpDefault &&anim->filename[0] != '\0');
}
void meditApp::CmFileSaveAs ()
{
// INSERT>> 追加コードはここに
#if 0
TOpenSaveDialog::TData FileData(
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
"フレームファイル(*.frm)|*.frm|",
0, anim->filedir, "FRM");
if (TFileSaveDialog(GetMainWindow(), FileData).Execute() == IDOK) {
anim->WriteFile(FileData.FileName);
}
#else
char fname[256];
if (FileSaveDialogWithBMP(GetMainWindow(), fname,
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
"フレームファイル(*.frm)|*.frm|",
0, anim->filedir, "FRM") == IDOK) {
anim->WriteFile(fname);
}
#endif
}
void meditApp::CmFileSaveAs (TCommandEnabler &tce)
{
tce.Enable(anim->opstat == OpDefault);
}
void meditApp::CmEditDelete ()
{
anim->DeleteMotion(anim->select);
}
void meditApp::CmEditDeleteEnable (TCommandEnabler &tce)
{
if (anim->opstat == OpPlay || anim->opstat == OpSelZoom) {
anim->OpModeDefault();
}
tce.Enable(anim->opstat == OpDefault && anim->select != NULL && anim->select != anim->camera && anim->select != anim->camera->target);
}
void meditApp::CmEditDup ()
{
anim->CopyMotion(anim->select);
}
void meditApp::CmEditDupEnable (TCommandEnabler &tce)
{
tce.Enable(anim->opstat == OpDefault && anim->select != NULL && anim->select != anim->camera && anim->select != anim->camera->target);
}
void meditApp::CmEditExchange ()
{
char fname[256];
if (anim->GetMechaName(fname)) {
anim->ExchangeMechanic(fname);
}
}
void meditApp::CmEditExchangeEnable (TCommandEnabler &tce)
{
tce.Enable(anim->opstat == OpDefault && anim->select != NULL && anim->select != anim->camera && anim->select != anim->camera->target);
}
void meditApp::CmEditForward ()
{
if (anim->select != NULL && anim->select->motiondata != NULL) {
MotionData *m = anim->select->motiondata;
if (m->dirtype == DirForward) {
Vector v1, v2, v3;
anim->select->motiondata->GetPosition(1.0, v1, v2, v3);
anim->select->motiondata->rotation[1] = v2;
anim->select->motiondata->dirtype = DirLinear;
} else {
anim->select->SetForward();
}
anim->CalcPoints(anim->select);
anim->Redraw();
}
}
void meditApp::CmEditForwardEnable (TCommandEnabler &tce)
{
tce.Enable(anim->opstat == OpDefault && anim->select != NULL && anim->select->motiondata != NULL && anim->select != anim->camera && anim->select != anim->camera->target);
tce.SetCheck(anim->select != NULL && anim->select->motiondata != NULL && anim->select->motiondata->dirtype == DirForward);
}
void meditApp::CmEditMaxFrame ()
{
char str[16];
sprintf(str, "%d", anim->maxframe);
TInputDialog dialog(MainWindow, "総フレーム数変更", "総フレーム数を入力してください", str, 16);
if (dialog.Execute() == IDOK) {
int n = atoi(str);
if (BEGIN < n && n < 1000) {
anim->ExpandFrame(n);
}
}
}
void meditApp::CmEditMaxFrameEnable (TCommandEnabler &tce)
{
tce.Enable(anim->opstat == OpDefault);
}
void meditApp::CmMechaAddFix ()
{
char fname[256];
if (anim->GetMechaName(fname)) {
anim->AddMechanicFix(fname);
}
}
void meditApp::CmMechaAddFixEnable (TCommandEnabler &tce)
{
if (anim->opstat == OpPlay || anim->opstat == OpSelZoom) {
anim->OpModeDefault();
}
tce.Enable(anim->opstat == OpDefault);
}
void meditApp::CmMechaAddMove ()
{
char fname[256];
if (anim->GetMechaName(fname)) {
anim->AddMechanicMove(fname);
}
}
void meditApp::CmMechaAddMoveEnable (TCommandEnabler &tce)
{
tce.Enable(anim->opstat == OpDefault);
}
void meditApp::CmMechaRange ()
{
if (anim->select == NULL || anim->maxframe == BEGIN) {
return;
}
char *m;
if (anim->select->motiondata != NULL) {
m = "メカの移動速度・出現/消失時刻を設定します";
} else {
m = "メカの出現/消失時刻を設定します";
}
TDRange dialog(GetMainWindow(), anim, anim->select, m);
if (dialog.Execute() == IDOK) {
if (anim->selectframe < anim->select->beginframe) {
anim->SelectFrame(anim->select->beginframe);
} else if (anim->selectframe > anim->select->endframe) {
anim->SelectFrame(anim->select->endframe);
}
anim->editflag++;
anim->select->GetPosition(anim->selectframe);
anim->CalcPoints(anim->select);
anim->Redraw();
}
}
void meditApp::CmMechaRangeEnable (TCommandEnabler &tce)
{
tce.Enable(anim->opstat == OpDefault
&& anim->select != NULL
&& anim->select != anim->camera
&& anim->select != anim->camera->target);
}
void meditApp::CmCameraAddEnd ()
{
Matrix m = Matrix::m_rot(anim->camera->rotation);
Vector v0 = (anim->TopView->Attr.H/3/anim->displayscale) * m.v[1];
anim->editflag++;
anim->camera->ChangeMove(v0);
anim->camera->target->ChangeMove(v0);
anim->CalcPoints(anim->camera);
anim->CalcViewAll();
anim->SelectMotion(anim->camera);
anim->Redraw();
}
void meditApp::CmCameraAddEndEnable (TCommandEnabler &tce)
{
if (anim->opstat == OpPlay || anim->opstat == OpSelZoom) {
anim->OpModeDefault();
}
tce.Enable(anim->opstat == OpDefault && anim->camera->motiondata == NULL);
}
void meditApp::CmCameraDeleteEnd ()
{
anim->editflag++;
anim->camera->target->ChangeFix();
anim->camera->ChangeFix();
anim->camera->GetPosition(anim->selectframe);
anim->CalcPoints(anim->camera);
anim->CalcViewAll();
anim->SelectMotion(anim->camera);
anim->Redraw();
}
void meditApp::CmCameraDeleteEndEnable (TCommandEnabler &tce)
{
tce.Enable(anim->opstat == OpDefault && anim->camera->motiondata != NULL);
}
void meditApp::CmCameraRange ()
{
if (anim->select != anim->camera) {
anim->SelectMotion(anim->camera);
}
TDRange dialog(GetMainWindow(), anim, anim->select, "カメラの移動速度を設定します");
if (dialog.Execute() == IDOK) {
anim->camera->GetPosition(anim->selectframe);
anim->CalcPoints(anim->camera);
anim->CalcViewAll();
anim->editflag++;
anim->Redraw();
}
}
void meditApp::CmCameraRangeEnable (TCommandEnabler &tce)
{
tce.Enable(anim->opstat == OpDefault && anim->camera->motiondata != NULL);
}
void meditApp::CmTargetRange ()
{
if (anim->select != anim->camera->target) {
anim->SelectMotion(anim->camera->target);
}
TDRange dialog(GetMainWindow(), anim, anim->select, "ターゲットの移動速度を設定します");
if (dialog.Execute() == IDOK) {
anim->camera->GetPosition(anim->selectframe);
anim->CalcPoints(anim->camera);
anim->CalcViewAll();
anim->editflag++;
anim->Redraw();
}
}
void meditApp::CmTargetRangeEnable (TCommandEnabler &tce)
{
tce.Enable(anim->opstat == OpDefault && anim->camera->motiondata != NULL);
}
void meditApp::CmCameraLight ()
{
anim->OpModeLight();
}
void meditApp::CmCameraLightEnable (TCommandEnabler &tce)
{
tce.Enable(anim->opstat == OpDefault);
}
void meditApp::CmDispFxga ()
{
static char *title ="FXGA モーション表示";
static char *title2 ="FXGA 初期化";
if (FindWindow(NULL, title) != NULL
|| FindWindow(NULL, title2) != NULL) {
GetMainWindow()->MessageBox("現在実行中です", title, MB_OK);
} else {
FXGA_ShowMotion(anim->motion, anim->camera, anim->light);
anim->statusbar->SetText("I:再生 II:順コマ送り III:逆コマ送り VI:頭出し");
}
}
void meditApp::CmDispFxgaEnable (TCommandEnabler &tce)
{
if (anim->opstat == OpPlay || anim->opstat == OpSelZoom) {
anim->OpModeDefault();
}
tce.Enable(anim->opstat == OpDefault && anim->motion != NULL);
}
void meditApp::CmDispWireview ()
{
// INSERT>> 追加コードはここに
static char *title = "WireView - _TEMP.FRM";
HWND hWire;
if (anim->motion != NULL) {
if ((hWire= FindWindow(NULL, title)) != NULL) {
::SendMessage(hWire, WM_CLOSE, 0, 0);
}
WireView(anim->motion, anim->camera, anim->light);
}
}
void meditApp::CmDispWireviewEnable (TCommandEnabler &tce)
{
if (anim->opstat == OpPlay || anim->opstat == OpSelZoom) {
anim->OpModeDefault();
}
tce.Enable(anim->opstat == OpDefault && anim->motion != NULL);
}
void meditApp::CmDispRend ()
{
// INSERT>> 追加コードはここに
static char *title = "REND for Windows";
HWND hRend;
if (anim->motion != NULL) {
if ((hRend= FindWindow(NULL, title)) != NULL) {
::SendMessage(hRend, WM_CLOSE, 0, 0);
}
RendNowMotion(anim->motion, anim->camera, anim->light, anim->selectframe);
}
}
void meditApp::CmDispRendEnable (TCommandEnabler &tce)
{
// INSERT>> 追加コードはここに
tce.Enable(anim->opstat == OpDefault && anim->motion != NULL);
}
void meditApp::CmDispRendReso ()
{
// INSERT>> 追加コードはここに
char opt[1024], *s, *d;
int w=320, h=240;
strcpy(opt, rendoption.c_str());
for (s = d = opt; *s; ) {
if ((*s == '-' || *s == '/') && (s[1] == 'c' || s[1] == 'C')) {
s+=2;
w = atoi(s);
while (*s && isdigit(*s)) s++;
if (*s) {
s++;
if (isdigit(*s)) {
h = atoi(s);
}
while(*s && !isspace(*s)) s++;
if (*s) s++;
}
} else {
*d++ = *s++;
}
}
while (d > opt && isspace(d[-1])) d--;
*d = '\0';
TDSelReso dialog(MainWindow, w, h);
if (dialog.Execute() == IDOK) {
w = dialog.selwidth;
h = dialog.selheight;
sprintf(opt+strlen(opt), " -c%d:%d:%d:%d", w, h, w, h);
rendoption = opt;
FileWriteRendOption();
}
}
void meditApp::CmDispRendResoEnable (TCommandEnabler &tce)
{
// INSERT>> 追加コードはここに
tce.Enable(anim->opstat == OpDefault);
}
void meditApp::CmDispHidenRemove ()
{
// INSERT>> 追加コードはここに
anim->hiddenremove = !anim->hiddenremove;
anim->BuildWireFrame(anim->selectframe);
anim->Redraw(SelPers);
}
void meditApp::CmDispHiddenRemoveEnable (TCommandEnabler &tce)
{
// INSERT>> 追加コードはここに
tce.SetCheck(anim->hiddenremove);
}
void meditApp::CmDispSimple ()
{
if (anim->drawmode == DrawWire) {
anim->SetDrawMode(DrawPlane);
} else {
anim->SetDrawMode(DrawWire);
}
}
void meditApp::CmDispSimpleEnable (TCommandEnabler &tce)
{
tce.Enable(anim->opstat == OpDefault);
tce.SetCheck(anim->drawmode == DrawPlane);
}
void meditApp::CmDispZoom ()
{
anim->OpModeZoom();
}
void meditApp::CmDispZoomEnable (TCommandEnabler &tce)
{
tce.Enable(anim->opstat == OpDefault);
tce.SetCheck(anim->zoomflag != FALSE);
}
void meditApp::CmDispScaleDown ()
{
anim->ScaleDown();
}
void meditApp::CmDispScaleDownEnable (TCommandEnabler &tce)
{
tce.Enable(anim->opstat == OpDefault && anim->zoomflag == FALSE && anim->ScaleDownLimitCheck());
}
void meditApp::CmDispScaleUp ()
{
anim->ScaleUp();
}
void meditApp::CmDispScaleUpEnable (TCommandEnabler &tce)
{
tce.Enable(anim->opstat == OpDefault && anim->zoomflag == FALSE && anim->ScaleUpLimitCheck());
}
void meditApp::CmDispMesh ()
{
anim->meshflag = ! anim->meshflag;
anim->Redraw();
}
void meditApp::CmDispMeshEnable (TCommandEnabler &tce)
{
tce.Enable(anim->opstat == OpDefault);
tce.SetCheck(anim->meshflag != FALSE);
}
void meditApp::CmDispMeshSpace ()
{
char *buf[] = {"250", "500", "1000", "2500", "5000", "10000", NULL};
int pos;
for (pos = 0; buf[pos] != NULL; pos++) {
if (anim->meshspacing == atoi(buf[pos])) {
break;
}
}
if (buf[pos] == NULL) pos = 5;
TDSliderInput dialog(MainWindow, "メッシュ間隔設定", "メッシュの間隔を設定してください", buf, pos);
if (dialog.Execute() == IDOK) {
anim->meshspacing = atoi(buf[pos]);
anim->Redraw();
}
}
void meditApp::CmDispMeshSpaceEnable (TCommandEnabler &tce)
{
tce.Enable(anim->opstat == OpDefault);
}
void meditApp::CmModeGrid ()
{
anim->gridflag = ! anim->gridflag;
}
void meditApp::CmModeGridEnable (TCommandEnabler &tce)
{
if (anim->opstat == OpPlay || anim->opstat == OpSelZoom) {
anim->OpModeDefault();
}
tce.Enable(anim->opstat == OpDefault);
tce.SetCheck(anim->gridflag != FALSE);
}
void meditApp::CmModeGridSpace ()
{
char *buf[] = {"50", "100", "250", "500", "1000", "2500", NULL};
int pos;
for (pos = 0; buf[pos] != NULL; pos++) {
if (anim->gridspacing == atoi(buf[pos])) {
break;
}
}
if (buf[pos] == NULL) pos = 1;
TDSliderInput dialog(MainWindow, "移動グリッド量設定", "位置設定の最小単位を設定してください", buf, pos);
if (dialog.Execute() == IDOK) {
anim->gridspacing = atoi(buf[pos]);
}
}
void meditApp::CmModeGridSpaceEnable (TCommandEnabler &tce)
{
tce.Enable(anim->opstat == OpDefault);
}
void meditApp::CmModeRotSpace ()
{
char *buf[] = {"2", "5", "10", "15", "20", "30", "45",NULL};
int pos;
for (pos = 0; buf[pos] != NULL; pos++) {
if (anim->rotspacing == atoi(buf[pos])) {
break;
}
}
if (buf[pos] == NULL) pos = 5;
TDSliderInput dialog(MainWindow, "回転グリッド量設定", "回転角度の最小単位を設定してください", buf, pos);
if (dialog.Execute() == IDOK) {
anim->rotspacing = atoi(buf[pos]);
}
}
void meditApp::CmModeRotSpaceEnable (TCommandEnabler &tce)
{
tce.Enable(anim->opstat == OpDefault);
}
void meditApp::CmModeScaleSpace ()
{
char *buf[] = {"0.05", "0.1", "0.2", "0.5", NULL};
int pos;
for (pos = 0; buf[pos] != NULL; pos++) {
if (anim->scalespacing == (int)(atof(buf[pos]) * scalespacingfactor)) {
break;
}
}
if (buf[pos] == NULL) pos = 1;
TDSliderInput dialog(MainWindow, "拡大グリッド量設定", "拡大倍率の最少単位を設定してください", buf, pos);
if (dialog.Execute() == IDOK) {
anim->scalespacing = atof(buf[pos]) * scalespacingfactor;
}
}
void meditApp::CmModeScaleSpaceEnable (TCommandEnabler &tce)
{
tce.Enable(anim->opstat == OpDefault);
}
BOOL meditApp::IdleAction (long idleCount)
{
BOOL result;
result = TApplication::IdleAction(idleCount);
// INSERT>> 追加のコードはここに
if (execonce != FALSE) {
return result;
}
execonce = TRUE;
TWindow *client = GetMainWindow()->GetClientWindow();
TClientDC dc(*client);
InitSysColor(dc);
TMenu menu(GetMainWindow()->GetMenu());
TMenu submenu(menu.GetSubMenu(4));
if (fxgaflag == PREVIEW_FXGA) {
submenu.RemoveMenu(CM_DISP_REND, MF_BYCOMMAND);
submenu.RemoveMenu(CM_DISP_RENDRESO, MF_BYCOMMAND);
} else if (fxgaflag == PREVIEW_REND) {
submenu.RemoveMenu(CM_DISP_FXGA, MF_BYCOMMAND);
}
return result;
}