home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 March / VPR9703A.ISO / VPR_DATA / DOGA / SOURCES / PASM.LZH / WINFRAME.CPP < prev    next >
C/C++ Source or Header  |  1996-07-10  |  20KB  |  638 lines

  1. /*  Project partsasm
  2.     Project Team DoGA
  3.     Copyright (c) 1995. All Rights Reserved.
  4.  
  5.     サブシステム:    partsasm.apx Application
  6.     ファイル:        winframe.cpp
  7.     作成者:          Taka2
  8.  
  9.  
  10.     概要
  11.     ====
  12.     TWinFrame (TWindow) のインプリメンテーション用のソースファイル
  13. */
  14.  
  15. #include <owl\owlpch.h>
  16. #pragma hdrstop
  17.  
  18. #include <owl\opensave.h>
  19. #include <owl\scrollba.h>
  20. #include <owl\button.h>
  21.  
  22. #include "winframe.h"
  23. #include "matrix.h"
  24. #include "design.h"
  25. #include "display.h"
  26. #include "pers.h"
  27. #include "status.h"
  28. #include "parts.h"
  29. #include "bmpbtn.h"
  30. #include "syscolor.h"
  31. #include "bmpopen.h"
  32.  
  33. #include "log.h"
  34.  
  35.  
  36. //
  37. // このアプリケーションで処理するすべてのメッセージ/コマンドの
  38. // 応答テーブルを作成する
  39. //
  40. DEFINE_RESPONSE_TABLE1(TWinFrame, TWindow)
  41. //{{TWinFrameRSP_TBL_BEGIN}}
  42.     EV_WM_KEYDOWN,
  43.     EV_CHILD_NOTIFY_ALL_CODES(ID_SCROLL_X, EvScrollX),
  44.     EV_CHILD_NOTIFY_ALL_CODES(ID_SCROLL_Y, EvScrollY),
  45.     EV_CHILD_NOTIFY_ALL_CODES(ID_SCROLL_Z, EvScrollZ),
  46.     EV_WM_PALETTECHANGED,
  47.     EV_WM_SIZE,
  48.     EV_BN_CLICKED(BUTTON_ZOOM, EvButtonZoom),
  49.     EV_BN_CLICKED(BUTTON_OK, EvButtonOk),
  50.     EV_BN_CLICKED(BUTTON_CANCEL, EvButtonCancel),
  51.  
  52.     EV_WM_TIMER,
  53. //{{TWinFrameRSP_TBL_END}}
  54. END_RESPONSE_TABLE;
  55.  
  56.  
  57. //{{TWinFrame Implementation}}
  58.  
  59. const int barwidth_org = 16;
  60. //const int scrollunit = 50;
  61. //const int scrolllimit = 20;
  62. const int buttonsize_org = 24;
  63.  
  64. const double camerarot = 20.0;
  65. const double targetrot = 5.0;
  66. const double cameramove = 300;
  67.  
  68. TWinFrame::TWinFrame (TWindow* parent, const char far* title, TModule* module):
  69.     TWindow(parent, title, module)
  70. {
  71.     // INSERT>> コンストラクタ用のコードはここに
  72.  
  73.     SetBkgndColor(TColor::LtGray);
  74.  
  75.     int screenX = GetSystemMetrics(SM_CXSCREEN);
  76.     int screenY = GetSystemMetrics(SM_CYSCREEN);
  77.  
  78.     int barwidth = barwidth_org;
  79.     int buttonsize = buttonsize_org;
  80.  
  81.     if (Attr.W < 700 || Attr.H < 500) {
  82.         barwidth = 12;
  83.         buttonsize = 16;
  84.     }
  85.  
  86.     int widthX, widthY, widthZ, viewW, viewH;
  87.     if (screenX <= 800) {
  88.         Attr.W = screenX - 20;
  89.         Attr.H = screenY - 60;
  90.         Attr.X = 10;
  91.         Attr.Y = 10;
  92.     } else {
  93.         Attr.W = 800;
  94.         Attr.H = 600;
  95.     }
  96.  
  97.     widthY = (Attr.H - barwidth) / 2;
  98.     widthZ = Attr.H - barwidth - widthY;
  99.     viewH = widthY + barwidth-1;
  100. //    viewH = widthY;
  101.     viewW = viewH * 4 / 3;
  102.     widthX = Attr.W - barwidth - viewW - buttonsize;
  103.  
  104. //    TScrollBar *bar;
  105.  
  106.     designdata = new DesignData();
  107.  
  108.     designdata->Frame = this;
  109.  
  110.     designdata->TopView   = new TWinDisplay(this, designdata, SelXY,                 0,                 0, widthX, widthY);
  111.     designdata->SideView  = new TWinDisplay(this, designdata, SelZX,                 0, widthY + barwidth, widthX, widthZ);
  112.     designdata->FrontView = new TWinDisplay(this, designdata, SelYZ, widthX + barwidth, widthY + barwidth, widthY, widthZ);
  113.     designdata->PersView  = new TWinPers(this, designdata, widthX+barwidth, 0, viewW, viewH);
  114.  
  115.     designdata->Status = new TWinStatus(this, designdata, widthX + barwidth + widthY+1, widthY + barwidth, Attr.W - widthX - barwidth - widthY, widthZ);
  116.  
  117.     designdata->scrollX = new TScrollBar(this, ID_SCROLL_X,      0, widthY         ,   widthX, barwidth, TRUE);
  118.     designdata->scrollY = new TScrollBar(this, ID_SCROLL_Y, widthX,               0, barwidth,   widthY, FALSE);
  119.     designdata->scrollZ = new TScrollBar(this, ID_SCROLL_Z, widthX, widthY+barwidth, barwidth,   widthZ, FALSE);
  120.  
  121.     int i = 0;
  122.     designdata->button[i++] = new TBitmapButton(this, designdata, BITMAP_BUTTON_LP, Attr.W-buttonsize-1, buttonsize*0, buttonsize, buttonsize);
  123.     designdata->button[i++] = new TBitmapButton(this, designdata, BITMAP_BUTTON_RP, Attr.W-buttonsize-1, buttonsize*1, buttonsize, buttonsize);
  124.     designdata->button[i++] = new TBitmapButton(this, designdata, BITMAP_BUTTON_UP, Attr.W-buttonsize-1, buttonsize*2, buttonsize, buttonsize);
  125.     designdata->button[i++] = new TBitmapButton(this, designdata, BITMAP_BUTTON_DP, Attr.W-buttonsize-1, buttonsize*3, buttonsize, buttonsize);
  126.     designdata->button[i++] = new TBitmapButton(this, designdata, BITMAP_BUTTON_LR, Attr.W-buttonsize-1, buttonsize*4, buttonsize, buttonsize);
  127.     designdata->button[i++] = new TBitmapButton(this, designdata, BITMAP_BUTTON_RR, Attr.W-buttonsize-1, buttonsize*5, buttonsize, buttonsize);
  128.     designdata->button[i++] = new TBitmapButton(this, designdata, BITMAP_BUTTON_UR, Attr.W-buttonsize-1, buttonsize*6, buttonsize, buttonsize);
  129.     designdata->button[i++] = new TBitmapButton(this, designdata, BITMAP_BUTTON_DR, Attr.W-buttonsize-1, buttonsize*7, buttonsize, buttonsize);
  130.     designdata->button[i++] = new TBitmapButton(this, designdata, BITMAP_BUTTON_FD, Attr.W-buttonsize-1, buttonsize*8, buttonsize, buttonsize);
  131.     designdata->button[i++] = new TBitmapButton(this, designdata, BITMAP_BUTTON_BD, Attr.W-buttonsize-1, buttonsize*9, buttonsize, buttonsize);
  132.  
  133.     designdata->button_ok     = new TButton(this, BUTTON_OK, "確定",0,0,0,0);
  134.     designdata->button_cancel = new TButton(this, BUTTON_CANCEL, "キャンセル",0,0,0,0);
  135.     designdata->button_zoom   = new TButton(this, BUTTON_ZOOM, "解除",0,0,0,0);
  136.  
  137.     designdata->CalcPoints(designdata->camera);
  138.  
  139. }
  140.  
  141.  
  142. TWinFrame::~TWinFrame ()
  143. {
  144.     Destroy();
  145.  
  146.     // INSERT>> デストラクタ用のコードはここに
  147.  
  148. }
  149.  
  150. void TWinFrame::EvScrollX(UINT code)
  151. {
  152.     if (code != SB_ENDSCROLL
  153.      && designdata->displayoffset.x != -designdata->scrollX->GetPosition() * designdata->displayscale * scrollstep) {
  154.         designdata->displayoffset.x = -designdata->scrollX->GetPosition() * designdata->displayscale * scrollstep;
  155.         designdata->Redraw(SelYZ, TRUE);
  156.     }
  157.     ::SetFocus(designdata->Status->HWindow);
  158. }
  159.  
  160. void TWinFrame::EvScrollY(UINT code)
  161. {
  162.     if (code != SB_ENDSCROLL
  163.      && designdata->displayoffset.y != designdata->scrollY->GetPosition() * designdata->displayscale * scrollstep) {
  164.         designdata->displayoffset.y = designdata->scrollY->GetPosition() * designdata->displayscale * scrollstep;
  165.         designdata->Redraw(SelZX, TRUE);
  166.     }
  167.     ::SetFocus(designdata->Status->HWindow);
  168. }
  169.  
  170. void TWinFrame::EvScrollZ(UINT code)
  171. {
  172.     if (code != SB_ENDSCROLL
  173.      && designdata->displayoffset.z != designdata->scrollZ->GetPosition() * designdata->displayscale * scrollstep) {
  174.         designdata->displayoffset.z = designdata->scrollZ->GetPosition() * designdata->displayscale * scrollstep;
  175.         designdata->Redraw(SelXY, TRUE);
  176.     }
  177.     ::SetFocus(designdata->Status->HWindow);
  178. }
  179.  
  180. void TWinFrame::Paint (TDC& dc, BOOL erase, TRect& rect)
  181. {
  182.     TWindow::Paint(dc, erase, rect);
  183.  
  184.     // INSERT>> 追加のコードはここに
  185.  
  186.     dc.MoveTo(designdata->PersView->Attr.X,
  187.               designdata->PersView->Attr.H);
  188.     dc.LineTo(designdata->PersView->Attr.X,
  189.               designdata->SideView->Attr.Y - 1);
  190.     dc.LineTo(Attr.W,
  191.               designdata->SideView->Attr.Y - 1);
  192.  
  193.     dc.MoveTo(designdata->FrontView->Attr.X + designdata->FrontView->Attr.W,
  194.               designdata->FrontView->Attr.Y);
  195.     dc.LineTo(designdata->FrontView->Attr.X + designdata->FrontView->Attr.W,
  196.               Attr.H);
  197.  
  198.     int x = designdata->PersView->Attr.X + designdata->PersView->Attr.W;
  199.     int y = designdata->PersView->Attr.H;
  200.     dc.MoveTo(x, 0); dc.LineTo(x, y);
  201.  
  202.     dc.SelectObject(TBrush(cTextBG));
  203.     dc.SelectObject(TPen(cTextBG));
  204.     dc.Rectangle(x, 0, Attr.W, designdata->PersView->Attr.H);
  205. }
  206.  
  207. void TWinFrame::SetupWindow ()
  208. {
  209.     TWindow::SetupWindow();
  210.  
  211.     // INSERT>> 追加のコードはここに
  212.  
  213.     designdata->SetScrollLimit();
  214. //    designdata->scrollX->SetRange(-scrolllimit, scrolllimit);
  215. //    designdata->scrollY->SetRange(-scrolllimit, scrolllimit);
  216. //    designdata->scrollZ->SetRange(-scrolllimit, scrolllimit);
  217.     designdata->scrollX->SetPosition(0);
  218.     designdata->scrollY->SetPosition(0);
  219.     designdata->scrollZ->SetPosition(0);
  220.  
  221.     if (_argc > 1) {
  222.         designdata->FileRead(_argv[1]);
  223.     }
  224. }
  225.  
  226.  
  227.  
  228.  
  229. void TWinFrame::EvKeyDown (UINT key, UINT repeatCount, UINT flags)
  230. {
  231.     TWindow::EvKeyDown(key, repeatCount, flags);
  232.  
  233.     // INSERT>> 追加コードはここに
  234.  
  235. }
  236.  
  237.  
  238. BOOL TWinFrame::CanClose ()
  239. {
  240.     BOOL result;
  241.  
  242.     result = TWindow::CanClose();
  243.  
  244.     // INSERT>> 追加のコードはここに
  245.  
  246.     if (designdata->editflag > 0) {
  247.         int response = MessageBox("デザインが変更されています。\n保存しますか?",
  248.                                     designdata->filename[0] ? designdata->filename : "無名",
  249.                                     MB_YESNOCANCEL|MB_ICONQUESTION);
  250.         if (response == IDCANCEL) {
  251.             return FALSE;
  252.         } else if (response == IDYES) {
  253.             if (designdata->filename[0] != '\0') {
  254.                 designdata->FileWrite();
  255.                 return TRUE;
  256.             } else {
  257. #if 0
  258.                 TOpenSaveDialog::TData FileData(
  259.                             OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
  260.                             "フレームファイル(*.fsc)|*.fsc|",
  261.                             0, designdata->filedir, "FSC");
  262.                 if (TFileSaveDialog(GetApplicationObject()->GetMainWindow(), FileData).Execute() == IDOK) {
  263.                     return designdata->FileWrite(FileData.FileName);
  264.                 }
  265. #else
  266.                 char fname[MAX_PATH];
  267.                 if (FileSaveDialogWithBMP(
  268.                             GetApplicationObject()->GetMainWindow(), fname,
  269.                             OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
  270.                             "フレームファイル(*.fsc)|*.fsc|",
  271.                             0, designdata->filedir, "FSC") == IDOK) {
  272.                     return designdata->FileWrite(fname);
  273.                 }
  274. #endif
  275.                 return FALSE;
  276.             }
  277.         }
  278.     }
  279.  
  280.     return result;
  281. }
  282.  
  283.  
  284. void TWinFrame::EvPaletteChanged (HWND /*hWndPalChg*/)
  285. {
  286. //    TWindow::EvPaletteChanged(hWndPalChg);
  287.  
  288.     // INSERT>> 追加コードはここに
  289.  
  290. }
  291.  
  292.  
  293. void TWinFrame::EvSize (UINT sizeType, TSize& size)
  294. {
  295.     TWindow::EvSize(sizeType, size);
  296.  
  297.     // INSERT>> 追加コードはここに
  298.  
  299.     int barwidth = barwidth_org;
  300.     int buttonsize = buttonsize_org;
  301.  
  302.     if (Attr.W < 700 || Attr.H < 500) {
  303.         barwidth = 12;
  304.     }
  305.  
  306.     int widthX, widthY, widthZ, viewW, viewH;
  307.     widthY = (Attr.H - barwidth) / 2;
  308.     widthZ = Attr.H - barwidth - widthY;
  309.     viewH = widthY + barwidth-1;
  310.  
  311.  
  312.     int separater = 2;
  313.     if (viewH < buttonsize * 11 + separater * 3) {
  314.         buttonsize = (viewH - separater*3) / 11;
  315.     } else {
  316.         separater = (viewH - buttonsize * 11) / 3;
  317.     }
  318. //    viewH = widthY;
  319.     viewW = viewH * 4 / 3;
  320.     widthX = Attr.W - barwidth - viewW -buttonsize;//- (buttonsize*2+1);
  321.     viewW -= buttonsize;
  322. //    viewW -= buttonsize*2+1;
  323.  
  324. #if 0
  325.     for (int i = 0; i < buttons; ++i) {
  326.         designdata->button[i]->MoveWindow(Attr.W-buttonsize-1, i * buttonsize, buttonsize, buttonsize);
  327.     }
  328. #endif
  329.     int x = Attr.W - buttonsize*2;
  330.     int y = 0;
  331.     designdata->button[2]->MoveWindow(x + buttonsize/2, y, buttonsize, buttonsize); y += buttonsize;
  332.     designdata->button[0]->MoveWindow(x               , y, buttonsize, buttonsize);
  333.     designdata->button[1]->MoveWindow(x + buttonsize  , y, buttonsize, buttonsize); y += buttonsize;
  334.     designdata->button[3]->MoveWindow(x + buttonsize/2, y, buttonsize, buttonsize); y += buttonsize+separater;
  335.     designdata->button[6]->MoveWindow(x + buttonsize/2, y, buttonsize, buttonsize); y += buttonsize;
  336.     designdata->button[4]->MoveWindow(x               , y, buttonsize, buttonsize);
  337.     designdata->button[5]->MoveWindow(x + buttonsize  , y, buttonsize, buttonsize); y += buttonsize;
  338.     designdata->button[7]->MoveWindow(x + buttonsize/2, y, buttonsize, buttonsize); y += buttonsize+separater;
  339.     designdata->button[8]->MoveWindow(x + buttonsize/2, y, buttonsize, buttonsize); y += buttonsize;
  340.     designdata->button[9]->MoveWindow(x + buttonsize/2, y, buttonsize, buttonsize); y += buttonsize+separater;
  341.  
  342.     designdata->button_zoom->MoveWindow(x,y, buttonsize*2, buttonsize); y += buttonsize;
  343.     designdata->button_ok->MoveWindow(x,y, buttonsize*2, buttonsize); y += buttonsize;
  344.     designdata->button_cancel->MoveWindow(x,y, buttonsize*2, buttonsize);
  345.  
  346.     designdata->scrollX->MoveWindow(     0, widthY         ,   widthX, barwidth, TRUE);
  347.     designdata->scrollY->MoveWindow(widthX,               0, barwidth,   widthY, FALSE);
  348.     designdata->scrollZ->MoveWindow(widthX, widthY+barwidth, barwidth,   widthZ, FALSE);
  349.  
  350. #if 0
  351.     designdata->scrollX->PageMagnitude = widthX / scrollunit;
  352.     designdata->scrollX->LineMagnitude = (widthX/scrollunit+7) / 8;
  353.  
  354.     designdata->scrollY->PageMagnitude = widthY / scrollunit;
  355.     designdata->scrollY->LineMagnitude = (widthY/scrollunit+7) / 8;
  356.  
  357.     designdata->scrollZ->PageMagnitude = widthZ / scrollunit;
  358.     designdata->scrollZ->LineMagnitude = (widthZ/scrollunit+7) / 8;
  359. #endif
  360.  
  361.     designdata->TopView  ->MoveWindow(                0,                 0, widthX, widthY);
  362.     designdata->SideView ->MoveWindow(                0, widthY + barwidth, widthX, widthZ);
  363.     designdata->FrontView->MoveWindow(widthX + barwidth, widthY + barwidth, widthY, widthZ);
  364.     designdata->PersView ->MoveWindow(widthX+barwidth  ,                 0,  viewW,  viewH);
  365.  
  366.     designdata->SetScrollLimit();
  367.     designdata->Status->MoveWindow(widthX + barwidth + widthY+1, widthY + barwidth, Attr.W - widthX - barwidth - widthY, widthZ);
  368.  
  369.     ::SetFocus(designdata->Status->HWindow);
  370.  
  371.     Invalidate();
  372.     designdata->CalcViewAll();
  373.     designdata->Redraw();
  374. }
  375.  
  376.  
  377. void TWinFrame::EvButtonLP(SelectType t)
  378. {
  379.     double tr = targetrot;
  380.     if (GetKeyState(VK_CONTROL) & 0x8000U) {tr *= 0.1;}
  381.  
  382.     CameraParts *p = designdata->camera;
  383.     Vector tmpvec = p->target - p->position;
  384.     double c = cos(deg(tr)), s = sin(deg(tr));
  385.     Vector nvec( tmpvec.x * c - tmpvec.y * s,
  386.                  tmpvec.x * s + tmpvec.y * c,
  387.                  tmpvec.z);
  388.     p->SetTarget(nvec + p->position);
  389.     designdata->CalcPoints(designdata->camera);
  390.     designdata->CalcViewAll();
  391. //    designdata->editflag++;
  392.     designdata->Redraw(t);
  393. }
  394.  
  395. void TWinFrame::EvButtonRP(SelectType t)
  396. {
  397.     double tr = targetrot;
  398.     if (GetKeyState(VK_CONTROL) & 0x8000U) {tr *= 0.1;}
  399.  
  400.     CameraParts *p = designdata->camera;
  401.     Vector tmpvec = p->target - p->position;
  402.     double c = cos(deg(tr)), s = sin(deg(tr));
  403.     Vector nvec( tmpvec.x * c + tmpvec.y * s,
  404.                 -tmpvec.x * s + tmpvec.y * c,
  405.                  tmpvec.z);
  406.     p->SetTarget(nvec + p->position);
  407.     designdata->CalcPoints(designdata->camera);
  408.     designdata->CalcViewAll();
  409. //    designdata->editflag++;
  410.     designdata->Redraw(t);
  411. }
  412.  
  413. void TWinFrame::EvButtonDP(SelectType t)
  414. {
  415.     double tr = targetrot;
  416.     if (GetKeyState(VK_CONTROL) & 0x8000U) {tr *= 0.1;}
  417.  
  418.     CameraParts *p = designdata->camera;
  419.     if (p->rotation.y >= deg(90.0 - tr)) {
  420.         return;
  421.     }
  422.     Vector tmpvec = p->target - p->position;
  423.     double len = tmpvec.length();
  424.     Matrix rot  = Matrix(1).rotz(p->rotation.z).roty(p->rotation.y).rotx(p->rotation.x);
  425.     Vector nvec = (cos(deg(tr)) * len) * rot.v[0]
  426.                 - (sin(deg(tr)) * len) * rot.v[2];
  427.     p->SetTarget(nvec + p->position);
  428.     designdata->CalcPoints(designdata->camera);
  429.     designdata->CalcViewAll();
  430. //    designdata->editflag++;
  431.     designdata->Redraw(t);
  432. }
  433.  
  434. void TWinFrame::EvButtonUP(SelectType t)
  435. {
  436.     double tr = targetrot;
  437.     if (GetKeyState(VK_CONTROL) & 0x8000U) {tr *= 0.1;}
  438.  
  439.     CameraParts *p = designdata->camera;
  440.     if (p->rotation.y < -deg(90.0 - tr)) {
  441.         return;
  442.     }
  443.     Vector tmpvec = p->target - p->position;
  444.     double len = tmpvec.length();
  445.     Matrix rot  = Matrix(1).rotz(p->rotation.z).roty(p->rotation.y).rotx(p->rotation.x);
  446.     Vector nvec = (cos(deg(tr)) * len) * rot.v[0]
  447.                 + (sin(deg(tr)) * len) * rot.v[2];
  448.     p->SetTarget(nvec + p->position);
  449.     designdata->CalcPoints(designdata->camera);
  450.     designdata->CalcViewAll();
  451. //    designdata->editflag++;
  452.     designdata->Redraw(t);
  453. }
  454.  
  455. void TWinFrame::EvButtonLR(SelectType t)
  456. {
  457.     double cr = camerarot;
  458.     if (GetKeyState(VK_CONTROL) & 0x8000U) {cr *= 0.1;}
  459.  
  460.     CameraParts *p = designdata->camera;
  461.     Vector tmpvec = p->position - p->target;
  462.     double c = cos(deg(cr)), s = sin(deg(cr));
  463.     Vector nvec( tmpvec.x * c + tmpvec.y * s,
  464.                 -tmpvec.x * s + tmpvec.y * c,
  465.                  tmpvec.z);
  466.     p->position = nvec + p->target;
  467.     p->SetTarget(p->target);
  468.     designdata->CalcPoints(designdata->camera);
  469.     designdata->CalcViewAll();
  470. //    designdata->editflag++;
  471.     designdata->Redraw(t);
  472. }
  473.  
  474. void TWinFrame::EvButtonRR(SelectType t)
  475. {
  476.     double cr = camerarot;
  477.     if (GetKeyState(VK_CONTROL) & 0x8000U) {cr *= 0.1;}
  478.  
  479.     CameraParts *p = designdata->camera;
  480.     Vector tmpvec = p->position - p->target;
  481.     double c = cos(deg(cr)), s = sin(deg(cr));
  482.     Vector nvec( tmpvec.x * c - tmpvec.y * s,
  483.                  tmpvec.x * s + tmpvec.y * c,
  484.                  tmpvec.z);
  485.     p->position = nvec + p->target;
  486.     p->SetTarget(p->target);
  487.     designdata->CalcPoints(designdata->camera);
  488.     designdata->CalcViewAll();
  489. //    designdata->editflag++;
  490.     designdata->Redraw(t);
  491. }
  492.  
  493. void TWinFrame::EvButtonDR(SelectType t)
  494. {
  495.     double cr = camerarot;
  496.     if (GetKeyState(VK_CONTROL) & 0x8000U) {cr *= 0.1;}
  497.  
  498.     CameraParts *p = designdata->camera;
  499.     if (p->rotation.y < -deg(90.0 - cr)) {
  500.         return;
  501.     }
  502.     Vector tmpvec = p->position - p->target;
  503.     double len = tmpvec.length();
  504.     Matrix rot  = Matrix(1).rotz(p->rotation.z).roty(p->rotation.y).rotx(p->rotation.x);
  505.     Vector nvec = - (cos(deg(cr)) * len) * rot.v[0]
  506.                   - (sin(deg(cr)) * len) * rot.v[2];
  507.     p->position = nvec + p->target;
  508.     p->SetTarget(p->target);
  509.     designdata->CalcPoints(designdata->camera);
  510.     designdata->CalcViewAll();
  511. //    designdata->editflag++;
  512.     designdata->Redraw(t);
  513. }
  514.  
  515. void TWinFrame::EvButtonUR(SelectType t)
  516. {
  517.     double cr = camerarot;
  518.     if (GetKeyState(VK_CONTROL) & 0x8000U) {cr *= 0.1;}
  519.  
  520.     CameraParts *p = designdata->camera;
  521.     if (p->rotation.y >= deg(90.0 - cr)) {
  522.         return;
  523.     }
  524.     Vector tmpvec = p->position - p->target;
  525.     double len = tmpvec.length();
  526.     Matrix rot  = Matrix(1).rotz(p->rotation.z).roty(p->rotation.y).rotx(p->rotation.x);
  527.     Vector nvec = - (cos(deg(cr)) * len) * rot.v[0]
  528.                   + (sin(deg(cr)) * len) * rot.v[2];
  529.     p->position = nvec + p->target;
  530.     p->SetTarget(p->target);
  531.     designdata->CalcPoints(designdata->camera);
  532.     designdata->CalcViewAll();
  533. //    designdata->editflag++;
  534.     designdata->Redraw(t);
  535. }
  536.  
  537. void TWinFrame::EvButtonBD(SelectType t)
  538. {
  539.     double cm = cameramove;
  540.     if (GetKeyState(VK_CONTROL) & 0x8000U) {cm *= 0.1;}
  541.  
  542.     CameraParts *p = designdata->camera;
  543.     Vector tmpvec = p->position - p->target;
  544.     double len = tmpvec.length();
  545.     if (len < minimumdouble) {
  546.         return;
  547.     }
  548.     p->position = ((len + cm)/len) * tmpvec + p->target;
  549.     p->SetTarget(p->target);
  550.     designdata->CalcPoints(designdata->camera);
  551.     designdata->CalcViewAll();
  552. //    designdata->editflag++;
  553.     designdata->Redraw(t);
  554. }
  555.  
  556. void TWinFrame::EvButtonFD(SelectType t)
  557. {
  558.     double cm = cameramove;
  559.     if (GetKeyState(VK_CONTROL) & 0x8000U) {cm *= 0.1;}
  560.  
  561.     CameraParts *p = designdata->camera;
  562.     Vector tmpvec = p->position - p->target;
  563.     double len = tmpvec.length();
  564.     if (len <= cm) {
  565.         return;
  566.     }
  567.     p->position = ((len - cm)/len) * tmpvec + p->target;
  568.     p->SetTarget(p->target);
  569.     designdata->CalcPoints(designdata->camera);
  570.     designdata->CalcViewAll();
  571. //    designdata->editflag++;
  572.     designdata->Redraw(t);
  573. }
  574.  
  575. void TWinFrame::EvButton(UINT id, SelectType t)
  576. {
  577.     if (designdata->hiddenremove) {
  578.         KillTimer(0);
  579.         SetTimer(0, 600);
  580.     }
  581.     int h = designdata->hiddenremove;
  582.     designdata->hiddenremove = FALSE;
  583.     switch (id) {
  584.     case BITMAP_BUTTON_LP: EvButtonLP(t); break;
  585.     case BITMAP_BUTTON_RP: EvButtonRP(t); break;
  586.     case BITMAP_BUTTON_UP: EvButtonUP(t); break;
  587.     case BITMAP_BUTTON_DP: EvButtonDP(t); break;
  588.     case BITMAP_BUTTON_LR: EvButtonLR(t); break;
  589.     case BITMAP_BUTTON_RR: EvButtonRR(t); break;
  590.     case BITMAP_BUTTON_UR: EvButtonUR(t); break;
  591.     case BITMAP_BUTTON_DR: EvButtonDR(t); break;
  592.     case BITMAP_BUTTON_BD: EvButtonBD(t); break;
  593.     case BITMAP_BUTTON_FD: EvButtonFD(t); break;
  594.     }
  595.     designdata->hiddenremove = h;
  596.  
  597. }
  598.  
  599. void TWinFrame::EvButtonZoom(void)
  600. {
  601.     designdata->SelectZoom();
  602.     designdata->SelectParts(NULL);
  603.     designdata->Redraw();
  604. }
  605.  
  606.  
  607. void TWinFrame::EvButtonOk(void)
  608. {
  609.     designdata->SelectParts(NULL);
  610.     designdata->Redraw();
  611. }
  612.  
  613. void TWinFrame::EvButtonCancel(void)
  614. {
  615.     designdata->CancelParts();
  616. //    designdata->Redraw();
  617. }
  618.  
  619. void TWinFrame::EvTimer (UINT timerId)
  620. {
  621.     TWindow::EvTimer(timerId);
  622.  
  623.     // INSERT>> 追加コードはここに
  624.  
  625.     KillTimer(0);
  626.     designdata->BuildWireFrame();
  627.     designdata->Redraw(SelPers);
  628.  
  629. #if 0
  630.     designdata->scrollX->SetPosition(designdata->displayoffset.x / scrollunit);
  631.     designdata->scrollY->SetPosition(designdata->displayoffset.y / scrollunit);
  632.     designdata->scrollZ->SetPosition(designdata->displayoffset.z / scrollunit);
  633.     designdata->Redraw(SelAll, TRUE);
  634.     KillTimer(0);
  635. #endif
  636. }
  637.  
  638.