home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 March
/
VPR9703A.ISO
/
VPR_DATA
/
DOGA
/
SOURCES
/
WIREVIEW.LZH
/
VIEW.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1996-07-10
|
4KB
|
202 lines
#include <owl\owlpch.h>
#pragma hdrstop
#include <toolhelp.h>
#include "view.h"
#include "matrix.h"
#include "anim.h"
#include "syscolor.h"
#include "motion.h"
#include "mecha.h"
#include "winframe.h"
#include "log.h"
//
// このアプリケーションで処理するすべてのメッセージ/コマンドの
// 応答テーブルを作成する
//
DEFINE_RESPONSE_TABLE1(TWinView, TWindow)
//{{TWinViewRSP_TBL_BEGIN}}
EV_WM_SIZE,
//{{TWinViewRSP_TBL_END}}
END_RESPONSE_TABLE;
//{{TWinView Implementation}}
TWinView::TWinView (TWindow* parent, AnimationData *a, int x, int y, int w, int h):
TWindow(parent, 0, 0)
{
// INSERT>> コンストラクタ用のコードはここに
anim = a;
Attr.X = x;
Attr.Y = y;
Attr.W = w;
Attr.H = h;
}
TWinView::~TWinView ()
{
Destroy();
// INSERT>> デストラクタ用のコードはここに
}
void TWinView::SetupWindow ()
{
TWindow::SetupWindow();
// INSERT>> 追加のコードはここに
if (_argc > 1) {
anim->ReadFile(_argv[1]);
}
}
void TWinView::Paint (TDC& dc, BOOL erase, TRect& rect)
{
TWindow::Paint(dc, erase, rect);
// INSERT>> 追加のコードはここに
if (anim->wireframe != NULL) {
Redraw();
}
}
void TWinView::Animation(void)
{
if (anim->wireframe == NULL
|| anim->opstat == OpPause
|| anim->playmode == PmTimer) return;
TClientDC dc(*this);
TMemoryDC mdc(dc);
TBitmap bitmap(dc, Attr.W, Attr.H);
mdc.SelectObject(bitmap);
mdc.SelectObject(TBrush(cBackGround));
// mdc.SelectObject(TPen(cBackGround));
mdc.SelectObject(TPen(cWireNormal));
#ifdef __WIN32__
unsigned long last = GetTickCount(), now;
#else
TIMERINFO info;
unsigned long last;
info.dwSize = sizeof(TIMERINFO);
TimerCount(&info);
last = info.dwmsThisVM;
#endif
#define TICK 33
volatile WireFrame **wireframe = (volatile WireFrame **)&anim->wireframe;
while (1) {
if (*wireframe == NULL) {
break;
}
mdc.Rectangle(dc.GetClipBox());
if ((*wireframe)[anim->selectframe-BEGIN].line == NULL) {
anim->Frame->SetTimer(OpPlay, 100);
return;
}
LineSegment *l = anim->wireframe[anim->selectframe - BEGIN].line;
for (int i = anim->wireframe[anim->selectframe - BEGIN].lines; i > 0; --i) {
mdc.MoveTo(l->x1, l->y1);
mdc.LineTo(l->x2, l->y2);
l++;
}
dc.BitBlt(0,0,Attr.W, Attr.H, mdc, 0, 0, SRCCOPY);
if (anim->selectframe >= anim->maxframe) {
anim->SelectFrame(BEGIN);
} else {
anim->SelectFrame(anim->selectframe+1);
}
MSG msg;
do {
if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
if (msg.message == WM_QUIT) {
return;
} else {
GetMessage(&msg, NULL, 0, 0);
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
if (anim->playmode== PmTimer) {
anim->Frame->SetTimer(OpPause, 100);
return;
}
if (anim->opstat != OpPlay) {
return;
}
#ifdef __WIN32__
} while (now = GetTickCount(), (last + TICK > now && last < now) );
last = now;
#else
} while (TimerCount(&info), last + TICK > info.dwmsThisVM);
last = info.dwmsThisVM;
#endif
if (anim->opstat != OpPlay) {
return;
}
}
}
void TWinView::Redraw(void)
{
if (anim->wireframe == NULL) {
TClientDC dc(*this);
dc.SelectObject(TBrush(cBackGround));
dc.Rectangle(dc.GetClipBox());
return;
}
TClientDC dc(*this);
TMemoryDC mdc(dc);
TBitmap bitmap(dc, Attr.W, Attr.H);
mdc.SelectObject(bitmap);
mdc.SelectObject(TPen(cBackGround));
mdc.SelectObject(TBrush(cBackGround));
mdc.Rectangle(dc.GetClipBox());
mdc.SelectObject(TPen(cWireNormal));
if (anim->wireframe[anim->selectframe-BEGIN].line == NULL) {
char str[32];
sprintf(str, "%d/%d...", anim->selectframe, anim->maxframe);
dc.TextOut(0,0,str);
anim->BuildWireFrame(anim->selectframe);
}
LineSegment *l = anim->wireframe[anim->selectframe - BEGIN].line;
for (int i = anim->wireframe[anim->selectframe - BEGIN].lines; i > 0; --i) {
mdc.MoveTo(l->x1, l->y1);
mdc.LineTo(l->x2, l->y2);
l++;
}
dc.BitBlt(0,0,Attr.W, Attr.H, mdc, 0, 0, SRCCOPY);
}
void TWinView::EvSize (UINT sizeType, TSize& size)
{
// INSERT>> 追加コードはここに
if (sizeType != SIZE_MINIMIZED) {
anim->Resize(size.cx, size.cy, Attr.W, Attr.H);
Attr.W = size.cx;
Attr.H = size.cy;
}
TWindow::EvSize(sizeType, size);
}