home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 March
/
VPR9703A.ISO
/
VPR_DATA
/
DOGA
/
SOURCES
/
PASM.LZH
/
DINPUT.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1996-07-12
|
4KB
|
152 lines
/* Project partsasm
Project Team DoGA
Copyright (c) 1995. All Rights Reserved.
サブシステム: partsasm.apx Application
ファイル: dinput.cpp
作成者: Taka2
概要
====
TDDirectInput (TDialog) のインプリメンテーション用のソースファイル
*/
#include <owl\owlpch.h>
#pragma hdrstop
#include <stdio.h>
#include <owl\edit.h>
#include "dinput.h"
#include "matrix.h"
#include "design.h"
#include "parts.h"
#include "syscolor.h"
//
// このアプリケーションで処理するすべてのメッセージ/コマンドの
// 応答テーブルを作成する
//
DEFINE_RESPONSE_TABLE1(TDDirectInput, TDialog)
//{{TDDirectInputRSP_TBL_BEGIN}}
EV_BN_CLICKED(IDOK, CmOK),
//{{TDDirectInputRSP_TBL_END}}
END_RESPONSE_TABLE;
//{{TDDirectInput Implementation}}
TDDirectInput::TDDirectInput (TWindow* parent, DesignData *d, int initialpos, TResId resId, TModule* module):
TDialog(parent, resId, module)
{
// INSERT>> コンストラクタ用のコードはここに
m1 = new TStatic(this, IDC_DIRECT_M1);
m2 = new TStatic(this, IDC_DIRECT_M2);
m3 = new TStatic(this, IDC_DIRECT_M3);
px = new TEdit(this, IDC_DIRECT_PX);
py = new TEdit(this, IDC_DIRECT_PY);
pz = new TEdit(this, IDC_DIRECT_PZ);
rx = new TEdit(this, IDC_DIRECT_RX);
ry = new TEdit(this, IDC_DIRECT_RY);
rz = new TEdit(this, IDC_DIRECT_RZ);
sx = new TEdit(this, IDC_DIRECT_SX);
sy = new TEdit(this, IDC_DIRECT_SY);
sz = new TEdit(this, IDC_DIRECT_SZ);
designdata = d;
ipos = initialpos;
}
TDDirectInput::~TDDirectInput ()
{
Destroy();
// INSERT>> デストラクタ用のコードはここに
}
void TDDirectInput::SetupWindow ()
{
TDialog::SetupWindow();
// INSERT>> 追加のコードはここに
if (designdata->select != NULL) {
Parts *p = designdata->select;
char str[16];
sprintf(str, "%5.0lf", p->position.x); px->SetText(str);
sprintf(str, "%5.0lf", p->position.y); py->SetText(str);
sprintf(str, "%5.0lf", p->position.z); pz->SetText(str);
if (designdata->select == designdata->camera) {
Vector& t = designdata->camera->target;
sprintf(str, "%5.0lf", t.x); rx->SetText(str);
sprintf(str, "%5.0lf", t.y); ry->SetText(str);
sprintf(str, "%5.0lf", t.z); rz->SetText(str);
m1->SetText("カメラ");
m2->SetText("ターゲット");
m3->Show(SW_HIDE);
sx->Show(SW_HIDE);
sy->Show(SW_HIDE);
sz->Show(SW_HIDE);
} else {
sprintf(str, "%4.0lf", rad(p->rotation.x)); rx->SetText(str);
sprintf(str, "%4.0lf", rad(p->rotation.y)); ry->SetText(str);
sprintf(str, "%4.0lf", rad(p->rotation.z)); rz->SetText(str);
sprintf(str, "%5.3lf", p->scale.x); sx->SetText(str);
sprintf(str, "%5.3lf", p->scale.y); sy->SetText(str);
sprintf(str, "%5.3lf", p->scale.z); sz->SetText(str);
if (designdata->select == designdata->combined) {
sy->Show(SW_HIDE);
sz->Show(SW_HIDE);
}
}
}
}
static void limit(Vector& v)
{
if (v.x > limitdim) v.x = limitdim;
if (v.x < -limitdim) v.x = -limitdim;
if (v.y > limitdim) v.y = limitdim;
if (v.y < -limitdim) v.y = -limitdim;
if (v.z > limitdim) v.z = limitdim;
if (v.z < -limitdim) v.z = -limitdim;
}
void TDDirectInput::CmOK ()
{
// INSERT>> 追加コードはここに
char str[16];
Parts *p = designdata->select;
if (p != NULL) {
px->GetText(str,16); p->position.x = atof(str);
py->GetText(str,16); p->position.y = atof(str);
pz->GetText(str,16); p->position.z = atof(str);
limit(p->position);
if (designdata->select == designdata->camera) {
Vector& t = designdata->camera->target;
rx->GetText(str,16); t.x = atof(str);
ry->GetText(str,16); t.y = atof(str);
rz->GetText(str,16); t.z = atof(str);
limit(t);
} else {
rx->GetText(str,16); p->rotation.x = deg(atof(str));
ry->GetText(str,16); p->rotation.y = deg(atof(str));
rz->GetText(str,16); p->rotation.z = deg(atof(str));
p->rotation = Matrix::m_rot(p->rotation).GetRotation();
sx->GetText(str,16); p->scale.x = atof(str);
sy->GetText(str,16); p->scale.y = atof(str);
sz->GetText(str,16); p->scale.z = atof(str);
if (designdata->select == designdata->combined) {
p->scale.y = p->scale.z = p->scale.x;
}
}
}
CloseWindow(IDOK);
}