home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 March / VPR9703A.ISO / VPR_DATA / DOGA / SOURCES / PASM.LZH / PERS.CPP < prev    next >
C/C++ Source or Header  |  1996-05-31  |  4KB  |  157 lines

  1. /*  Project partsasm
  2.     Project Team DoGA
  3.     Copyright (c) 1995. All Rights Reserved.
  4.  
  5.     サブシステム:    partsasm.apx Application
  6.     ファイル:        pers.cpp
  7.     作成者:          Taka2
  8.  
  9.  
  10.     概要
  11.     ====
  12.     TWinPers (TWindow) のインプリメンテーション用のソースファイル
  13. */
  14.  
  15. #include <owl\owlpch.h>
  16. #pragma hdrstop
  17.  
  18. #include "design.h"
  19. #include "pers.h"
  20. #include "parts.h"
  21. #include "syscolor.h"
  22. #include "log.h"
  23.  
  24. //{{TWinPers Implementation}}
  25.  
  26.  
  27. TWinPers::TWinPers (TWindow* parent, DesignData *dat, int x, int y, int w, int h):
  28.     TWindow(parent, 0, 0)
  29. {
  30.     // INSERT>> コンストラクタ用のコードはここに
  31.  
  32.     SetBkgndColor(TColor::LtGray);
  33.  
  34.     Attr.X = x;
  35.     Attr.Y = y;
  36.     Attr.W = w;
  37.     Attr.H = h;
  38.     designdata = dat;
  39.  
  40. }
  41.  
  42.  
  43.  
  44.  
  45. TWinPers::~TWinPers ()
  46. {
  47.     Destroy();
  48.  
  49.     // INSERT>> デストラクタ用のコードはここに
  50.  
  51. }
  52.  
  53.  
  54. void TWinPers::Paint (TDC& dc, BOOL erase, TRect& rect)
  55. {
  56.     TWindow::Paint(dc, erase, rect);
  57.  
  58.     // INSERT>> 追加のコードはここに
  59.  
  60.     designdata->Redraw(SelPers, FALSE);
  61. }
  62.  
  63. void TWinPers::ShowObject(TDC& dc, Parts *p)
  64. {
  65.     if (p == designdata->select
  66.      || (designdata->select == designdata->combined && p->sel)) {
  67.         dc.SelectObject(TPen(cWireSelect));
  68.     } else if (p == designdata->camera) {
  69.         dc.SelectObject(TPen(cWireCamera));
  70.     } else if (designdata->select != NULL && designdata->select != designdata->camera) {
  71.         dc.SelectObject(TPen(cWireNoSelect));
  72.     } else {
  73.         dc.SelectObject(TPen(cWireNormal));
  74.     }
  75.     int begin, end = -1;
  76.     for (int i = 0; i < p->lines; ++i) {
  77.         if (p->view_z[p->line_1[i]] <= 0 || p->view_z[p->line_2[i]] <= 0) {
  78.             end = -1;
  79.         } else {
  80.             if ((begin = p->line_1[i]) != end) {
  81.                 dc.MoveTo(p->view_x[begin], p->view_y[begin]);
  82.             }
  83.             end = p->line_2[i];
  84.             dc.LineTo(p->view_x[end], p->view_y[end]);
  85.         }
  86.     }
  87. }
  88.  
  89. void TWinPers::Redraw(void)
  90. {
  91. #if 1
  92.     TClientDC cdc(*this);
  93.     TMemoryDC dc(cdc);
  94.     TBitmap bitmap(cdc, Attr.W, Attr.H);
  95.     dc.SelectObject(bitmap);
  96. #else
  97.     TClientDC dc(*this);
  98. #endif
  99.  
  100.     dc.SelectObject(TPen(cBackGround));
  101.     dc.SelectObject(TBrush(cBackGround));
  102.     dc.Rectangle(dc.GetClipBox());
  103.  
  104.     dc.SetBkColor(cBackGround);
  105.     dc.SetTextColor(TColor::White);
  106.  
  107.     if (designdata->hiddenremove && designdata->wireframe.line != NULL) {
  108.         LineSegment *l = designdata->wireframe.line;
  109.         int lastx = l->x1, lasty = l->y1;
  110.         dc.MoveTo(lastx, lasty);
  111.         if (designdata->select != NULL && designdata->select != designdata->camera) {
  112.             dc.SelectObject(TPen(cWireNoSelect));
  113.             int sel=FALSE;
  114.             int combflag = (designdata->select == designdata->combined);
  115.             for (int i = designdata->wireframe.lines; i > 0; --i) {
  116.                 int nsel = (l->id == designdata->select
  117.                             || (combflag && l->id && ((Parts*)(l->id))->sel));
  118.                 if (!sel && nsel) {
  119.                     dc.SelectObject(TPen(cWireSelect));
  120.                 } else if (sel && !nsel) {
  121.                     dc.SelectObject(TPen(cWireNoSelect));
  122.                 }
  123.                 sel = nsel;
  124.                 if (lastx != l->x1 || lasty != l->y1) {
  125.                     dc.MoveTo(l->x1, l->y1);
  126.                 }
  127.                 dc.LineTo(l->x2, l->y2);
  128.                 lastx = l->x2; lasty = l->y2;
  129.                 l++;
  130.             }
  131.  
  132.         } else {
  133.             dc.SelectObject(TPen(cWireNormal));
  134.             for (int i = designdata->wireframe.lines; i > 0; --i) {
  135.                 if (lastx != l->x1 || lasty != l->y1) {
  136.                     dc.MoveTo(l->x1, l->y1);
  137.                 }
  138.                 dc.LineTo(l->x2, l->y2);
  139.                 lastx = l->x2; lasty = l->y2;
  140.                 l++;
  141.             }
  142.         }
  143.     } else {
  144.         for (Parts *p = designdata->parts; p != NULL; p = p->next) {
  145.             if (p !=designdata->select) {
  146.                 ShowObject(dc, p);
  147.             }
  148.         }
  149.         if (designdata->select != designdata->camera && designdata->select != NULL) {
  150.             ShowObject(dc, designdata->select);
  151.         }
  152.     }
  153. #if 1
  154.     cdc.BitBlt(0,0,Attr.W, Attr.H, dc, 0, 0, SRCCOPY);
  155. #endif
  156. }
  157.