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 >
C/C++ Source or Header  |  1996-07-12  |  4KB  |  152 lines

  1. /*  Project partsasm
  2.     Project Team DoGA
  3.     Copyright (c) 1995. All Rights Reserved.
  4.  
  5.     サブシステム:    partsasm.apx Application
  6.     ファイル:        dinput.cpp
  7.     作成者:          Taka2
  8.  
  9.  
  10.     概要
  11.     ====
  12.     TDDirectInput (TDialog) のインプリメンテーション用のソースファイル
  13. */
  14.  
  15. #include <owl\owlpch.h>
  16. #pragma hdrstop
  17.  
  18. #include <stdio.h>
  19. #include <owl\edit.h>
  20. #include "dinput.h"
  21. #include "matrix.h"
  22. #include "design.h"
  23. #include "parts.h"
  24. #include "syscolor.h"
  25.  
  26. //
  27. // このアプリケーションで処理するすべてのメッセージ/コマンドの
  28. // 応答テーブルを作成する
  29. //
  30. DEFINE_RESPONSE_TABLE1(TDDirectInput, TDialog)
  31. //{{TDDirectInputRSP_TBL_BEGIN}}
  32.     EV_BN_CLICKED(IDOK, CmOK),
  33. //{{TDDirectInputRSP_TBL_END}}
  34. END_RESPONSE_TABLE;
  35.  
  36.  
  37. //{{TDDirectInput Implementation}}
  38.  
  39. TDDirectInput::TDDirectInput (TWindow* parent, DesignData *d, int initialpos, TResId resId, TModule* module):
  40.     TDialog(parent, resId, module)
  41. {
  42.     // INSERT>> コンストラクタ用のコードはここに
  43.  
  44.     m1 = new TStatic(this, IDC_DIRECT_M1);
  45.     m2 = new TStatic(this, IDC_DIRECT_M2);
  46.     m3 = new TStatic(this, IDC_DIRECT_M3);
  47.     px = new TEdit(this, IDC_DIRECT_PX);
  48.     py = new TEdit(this, IDC_DIRECT_PY);
  49.     pz = new TEdit(this, IDC_DIRECT_PZ);
  50.     rx = new TEdit(this, IDC_DIRECT_RX);
  51.     ry = new TEdit(this, IDC_DIRECT_RY);
  52.     rz = new TEdit(this, IDC_DIRECT_RZ);
  53.     sx = new TEdit(this, IDC_DIRECT_SX);
  54.     sy = new TEdit(this, IDC_DIRECT_SY);
  55.     sz = new TEdit(this, IDC_DIRECT_SZ);
  56.  
  57.     designdata = d;
  58.     ipos = initialpos;
  59. }
  60.  
  61.  
  62. TDDirectInput::~TDDirectInput ()
  63. {
  64.     Destroy();
  65.  
  66.     // INSERT>> デストラクタ用のコードはここに
  67.  
  68. }
  69.  
  70.  
  71. void TDDirectInput::SetupWindow ()
  72. {
  73.     TDialog::SetupWindow();
  74.  
  75.     // INSERT>> 追加のコードはここに
  76.  
  77.     if (designdata->select != NULL) {
  78.         Parts *p = designdata->select;
  79.         char str[16];
  80.         sprintf(str, "%5.0lf", p->position.x);        px->SetText(str);
  81.         sprintf(str, "%5.0lf", p->position.y);        py->SetText(str);
  82.         sprintf(str, "%5.0lf", p->position.z);        pz->SetText(str);
  83.         if (designdata->select == designdata->camera) {
  84.             Vector& t = designdata->camera->target;
  85.             sprintf(str, "%5.0lf", t.x);        rx->SetText(str);
  86.             sprintf(str, "%5.0lf", t.y);        ry->SetText(str);
  87.             sprintf(str, "%5.0lf", t.z);        rz->SetText(str);
  88.             m1->SetText("カメラ");
  89.             m2->SetText("ターゲット");
  90.             m3->Show(SW_HIDE);
  91.             sx->Show(SW_HIDE);
  92.             sy->Show(SW_HIDE);
  93.             sz->Show(SW_HIDE);
  94.         } else {
  95.             sprintf(str, "%4.0lf", rad(p->rotation.x));    rx->SetText(str);
  96.             sprintf(str, "%4.0lf", rad(p->rotation.y));    ry->SetText(str);
  97.             sprintf(str, "%4.0lf", rad(p->rotation.z));    rz->SetText(str);
  98.             sprintf(str, "%5.3lf", p->scale.x);            sx->SetText(str);
  99.             sprintf(str, "%5.3lf", p->scale.y);            sy->SetText(str);
  100.             sprintf(str, "%5.3lf", p->scale.z);            sz->SetText(str);
  101.             if (designdata->select == designdata->combined) {
  102.                 sy->Show(SW_HIDE);
  103.                 sz->Show(SW_HIDE);
  104.             }
  105.         }
  106.     }
  107. }
  108.  
  109. static void limit(Vector& v)
  110. {
  111.     if (v.x >  limitdim) v.x =  limitdim;
  112.     if (v.x < -limitdim) v.x = -limitdim;
  113.     if (v.y >  limitdim) v.y =  limitdim;
  114.     if (v.y < -limitdim) v.y = -limitdim;
  115.     if (v.z >  limitdim) v.z =  limitdim;
  116.     if (v.z < -limitdim) v.z = -limitdim;
  117. }
  118.  
  119. void TDDirectInput::CmOK ()
  120. {
  121.     // INSERT>> 追加コードはここに
  122.     char str[16];
  123.     Parts *p = designdata->select;
  124.  
  125.     if (p != NULL) {
  126.         px->GetText(str,16); p->position.x = atof(str);
  127.         py->GetText(str,16); p->position.y = atof(str);
  128.         pz->GetText(str,16); p->position.z = atof(str);
  129.         limit(p->position);
  130.         if (designdata->select == designdata->camera) {
  131.             Vector& t = designdata->camera->target;
  132.             rx->GetText(str,16); t.x = atof(str);
  133.             ry->GetText(str,16); t.y = atof(str);
  134.             rz->GetText(str,16); t.z = atof(str);
  135.             limit(t);
  136.         } else {
  137.             rx->GetText(str,16); p->rotation.x = deg(atof(str));
  138.             ry->GetText(str,16); p->rotation.y = deg(atof(str));
  139.             rz->GetText(str,16); p->rotation.z = deg(atof(str));
  140.             p->rotation = Matrix::m_rot(p->rotation).GetRotation();
  141.             sx->GetText(str,16); p->scale.x    = atof(str);
  142.             sy->GetText(str,16); p->scale.y    = atof(str);
  143.             sz->GetText(str,16); p->scale.z    = atof(str);
  144.             if (designdata->select == designdata->combined) {
  145.                 p->scale.y = p->scale.z = p->scale.x;
  146.             }
  147.         }
  148.     }
  149.     CloseWindow(IDOK);
  150. }
  151.  
  152.