home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Virtual Reality Zone
/
VRZONE.ISO
/
mac
/
PC
/
PCGLOVE
/
GLOVE
/
OBJGLV.ZIP
/
SRC
/
WINACTOR.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-05-11
|
4KB
|
176 lines
//
// WinActor.cpp:
// Implementation of classes TDataDialog and WinGraphicsActor.
// Example use of Object Glove.
//
// Purpose:
// Outputs graphics and text in Windows.
//
// Compatibility:
// Windows only!
//
// Copyright 1993 Mark Thomas Pflaging
//
// Date: 3/22/93 (Release 3.0)
//
#include "WinActor.hpp"
#include <math.h>
#include "winres.h"
HDC WinPolygon::DC;
PTDialog winGraphicsActor::InfoScreen = NULL;
static int getmaxcolor()
{
return 256;
}
void winGraphicsActor::eraseGlove()
{
// erase old box.
RECT temprect = { newRect.left, newRect.top, newRect.right, newRect.bottom};
InvalidateRect(where.HWindow, &temprect, TRUE);
if (leaveTrails) return;
temprect.left = oldData.left;
temprect.top = oldData.top;
temprect.right = oldData.right;
temprect.bottom = oldData.bottom;
InvalidateRect(where.HWindow, &temprect, TRUE);
}
void winGraphicsActor::Paint(HDC DC)
{
if (gloveActive) {
where.setupHDC(DC, currentColor);
Rectangle(DC, newRect.left, newRect.top, newRect.right, newRect.bottom);
((Win_PolySpace *)poly_space)->WinDrawAll(DC);
where.releaseHDC(DC);
}
}
// draw square cursor
void winGraphicsActor::drawGlove(gloveDriver &gd)
{
RECT size;
GetClientRect(where.HWindow, &size);
XYZ temprect;
temprect.scaleToGlove(gd, size.right, size.bottom);
// prevent redundant drawing.
if ((temprect == oldData) && (gd.getFingers() == oldFingers) &&
(gd.getKeys() == -1))
return;
if (((temprect.right - temprect.left) > 2) && ((temprect.bottom - temprect.top) > 2)) {
newRect = temprect;
newRect.displayGlove(gd, *this);
eraseGlove();
oldData = newRect; // save pos'n for next erase
oldFingers = gd.getFingers();
drawn = 0;
}
}
void winGraphicsActor::Process(gloveDriver& gd)
{
if (gloveActive)
drawGlove(gd); // animate glove cursor
/****
if (handActive)
drawFingers(gd, instance); // draw the nonmoving "hand"
****/
if (infoActive)
infoDisplay(gd);
}
void winGraphicsActor::displayHelp()
{
}
#pragma argsused
void winGraphicsActor::infoErase(int start)
{
}
void winGraphicsActor::displayGestures()
{
gact.displayDataBox();
}
void winGraphicsActor::clearGestures()
{
gact.closeDataBox();
}
void winGraphicsActor::infoDisplay(gloveDriver & gd)
{
if (DataPlace1) DataPlace1->infoDisplay(gd);
}
void winGraphicsActor::Init(InitFile & ini)
{
drawn = 2;
xx = 0;
keyDown = False;
if (!getInstance()) {
}
currentColor = ini.find(title, "startColor", -1);
fillMode = ini.find(title, "fillMode", 0);
upIncrement = (int)sqrt((double)(getmaxcolor() + 1));
if (currentColor == -1) currentColor = getmaxcolor();
}
winGraphicsActor::winGraphicsActor(InitFile & ini, TDemoWindow & arg, winGestureActor & garg) :
graphicsActor(ini, *(new Win_PolySpace)), where(arg), gact(garg)
{
Init(ini);
}
winGraphicsActor::winGraphicsActor(InitFile & ini, TDemoWindow & arg, ButtonGestSet &buttons, winGestureActor & garg) :
graphicsActor(ini, *(new Win_PolySpace), buttons), where(arg), gact(garg)
{
Init(ini);
}
TDataDialog::TDataDialog(PTWindowsObject AParent, int ResourceID, PTModule AModule) :
TDialog(AParent, ID_GLOVE_DATA_1 + ResourceID * 100, AModule),
old_X(0), old_Y(0), old_Z(0), old_Rotation(-1), old_Keys(-2),
old_Thumb(-1), old_Index(-1), old_Middle(-1), old_Ring(-1)
{
X_Spot = new TStatic(this, ID_X_1 + ResourceID * 100, 5);
Y_Spot = new TStatic(this, ID_Y_1 + ResourceID * 100, 5);
Z_Spot = new TStatic(this, ID_Z_1 + ResourceID * 100, 5);
Rotation_Spot = new TStatic(this, ID_ROTATION_1 + ResourceID * 100, 5);
Keys_Spot = new TStatic(this, ID_KEYS_1 + ResourceID * 100, 5);
Thumb_Spot = new TStatic(this, ID_THUMB_1 + ResourceID * 100, 5);
Index_Spot = new TStatic(this, ID_INDEX_1 + ResourceID * 100, 5);
Middle_Spot = new TStatic(this, ID_MIDDLE_1 + ResourceID * 100, 5);
Ring_Spot = new TStatic(this, ID_RING_1 + ResourceID * 100, 5);
}
#define update(variable) \
val = gd.get##variable(); \
if (val != old_##variable) { \
itoa(val, temp, 10); \
variable##_Spot->SetText(temp); \
old_##variable = val; \
}
void TDataDialog::infoDisplay(gloveDriver & gd)
{
char temp[18];
char val;
update(X);
update(Y);
update(Z);
update(Rotation);
update(Keys);
update(Thumb);
update(Index);
update(Middle);
update(Ring);
}