home *** CD-ROM | disk | FTP | other *** search
- /**
- GRAB Graph Layout and Browser System
-
- Copyright (c) 1987, 1988, 1989 Stanford University
- Copyright (c) 1989, Tera Computer Company
- **/
-
- /**
- Nearly a direct ripoff of the InterViews 2.5 source for adjusters.
- However, these adjusters have adjustable zoom factors
- **/
-
- #include "myadjuster.h"
- #include <InterViews/adjuster.h>
- #include <InterViews/bitmap.h>
- #include <InterViews/painter.h>
- #include <InterViews/perspective.h>
- #include <InterViews/sensor.h>
- #include <InterViews/shape.h>
- #include <stdio.h>
-
- MyZoomer::MyZoomer (Interactor* i, float f) : (i, NO_AUTOREPEAT)
- {
- Init(f);
- }
-
- MyZoomer::MyZoomer (const char* name, Interactor* i, float f)
- : (name, i, NO_AUTOREPEAT)
- {
- Init(f);
- }
-
- MyZoomer::MyZoomer (Interactor* i, float f, Painter* p)
- : (i, NO_AUTOREPEAT, p)
- {
- Init(f);
- }
-
- void MyZoomer::Init (float f)
- {
- SetClassName("MyZoomer");
- factor = f;
- }
-
- void MyZoomer::AdjustView (Event&)
- {
- register Perspective* s = shown;
- Coord cx, cy;
-
- *s = *view->GetPerspective();
- cx = s->curx + s->curwidth/2;
- cy = s->cury + s->curheight/2;
- s->curwidth = round(float(s->curwidth) / factor);
- s->curheight = round(float(s->curheight) / factor);
- s->curx = cx - s->curwidth/2;
- s->cury = cy - s->curheight/2;
- view->Adjust(*s);
- }
-
- static const int enl_width = 25;
- static const int enl_height = 15;
- static unsigned char enl_mask[] =
- {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
- 0x00, 0xfe, 0x00, 0x00, 0xc0, 0xff, 0x07, 0x00, 0xf0, 0xff, 0x1f, 0x00,
- 0xf0, 0xff, 0x1f, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0xf8, 0xff, 0x3f, 0x00,
- 0xf8, 0xff, 0x3f, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0xc0, 0xff, 0x07, 0x00,
- 0xc0, 0xff, 0x07, 0x00, 0xc0, 0xff, 0x07, 0x00, 0xc0, 0xff, 0x07, 0x00
- };
-
- static unsigned char enl_plain[] =
- {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x38, 0x00, 0x00, 0x00, 0xc6, 0x00, 0x00, 0x80, 0x01, 0x03, 0x00,
- 0x60, 0x00, 0x0c, 0x00, 0x18, 0x00, 0x30, 0x00, 0xf8, 0x01, 0x3f, 0x00,
- 0x88, 0x00, 0x22, 0x00, 0x78, 0x00, 0x3c, 0x00, 0xc0, 0xff, 0x07, 0x00,
- 0x40, 0x00, 0x04, 0x00, 0x40, 0x00, 0x04, 0x00, 0xc0, 0xff, 0x07, 0x00
- };
-
- static unsigned char enl_hit[] =
- {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
- 0x00, 0xee, 0x00, 0x00, 0xc0, 0x01, 0x07, 0x00, 0x30, 0x00, 0x18, 0x00,
- 0xf0, 0x83, 0x1f, 0x00, 0x10, 0x01, 0x11, 0x00, 0xf0, 0xff, 0x1f, 0x00,
- 0x80, 0x00, 0x02, 0x00, 0x80, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
- };
-
- static Bitmap* enlMask;
- static Bitmap* enlPlain;
- static Bitmap* enlHit;
-
- MyEnlarger::MyEnlarger (Interactor* i, float zg) : (i, zg)
- {
- Init();
- }
-
- MyEnlarger::MyEnlarger (const char* name, Interactor* i, float zg)
- : (name, i, zg)
- {
- Init();
- }
-
- MyEnlarger::MyEnlarger (Interactor* i, Painter* p, float zg) : (i, zg, p)
- {
- Init();
- }
-
- void MyEnlarger::Init ()
- {
- SetClassName("MyEnlarger");
- if (enlMask == nil) {
- enlMask = new Bitmap(enl_mask, enl_width, enl_height);
- enlPlain = new Bitmap(enl_plain, enl_width, enl_height);
- enlHit = new Bitmap(enl_hit, enl_width, enl_height);
- }
- mask = enlMask;
- plain = enlPlain;
- hit = enlHit;
- shape->Rigid(shape->width/2, hfil, shape->height/2);
- }
-
- void MyEnlarger::ChangeZGrad(float zg)
- {
- factor = zg;
- }
-
- static const int red_width = 25;
- static const int red_height = 15;
- static unsigned char red_mask[] =
- {
- 0x00, 0x7c, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xff, 0x01, 0x00,
- 0xf8, 0xff, 0x3f, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0xff, 0xff, 0xff, 0x01,
- 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0x01,
- 0xfe, 0xff, 0xff, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0xe0, 0xff, 0x0f, 0x00,
- 0x80, 0xff, 0x03, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00
- };
-
- static unsigned char red_plain[] =
- {
- 0x00, 0x7c, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00,
- 0xf8, 0x00, 0x3e, 0x00, 0x38, 0x00, 0x38, 0x00, 0xc8, 0x00, 0x26, 0x00,
- 0x08, 0x83, 0x21, 0x00, 0x30, 0x6c, 0x18, 0x00, 0xc0, 0x10, 0x06, 0x00,
- 0x00, 0x93, 0x01, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
- };
-
- static unsigned char red_hit[] =
- {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00,
- 0x80, 0x00, 0x02, 0x00, 0x40, 0x00, 0x04, 0x00, 0x3f, 0x00, 0xf8, 0x01,
- 0x07, 0x00, 0xc0, 0x01, 0x19, 0x00, 0x30, 0x01, 0x61, 0x00, 0x0c, 0x01,
- 0x86, 0x01, 0xc3, 0x00, 0x18, 0xc6, 0x30, 0x00, 0x60, 0x38, 0x0c, 0x00,
- 0x80, 0x11, 0x03, 0x00, 0x00, 0xd6, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00
- };
-
- static Bitmap* redMask;
- static Bitmap* redPlain;
- static Bitmap* redHit;
-
- MyReducer::MyReducer (Interactor* i, float zg) : (i, zg)
- {
- Init();
- }
-
- MyReducer::MyReducer (const char* name, Interactor* i, float zg) :
- (name, i, zg)
- {
- Init();
- }
-
- MyReducer::MyReducer (Interactor* i, Painter* p, float zg) : (i, zg, p)
- {
- Init();
- }
-
- void MyReducer::Init ()
- {
- SetClassName("MyReducer");
- if (redMask == nil) {
- redMask = new Bitmap(red_mask, red_width, red_height);
- redPlain = new Bitmap(red_plain, red_width, red_height);
- redHit = new Bitmap(red_hit, red_width, red_height);
- }
- mask = redMask;
- plain = redPlain;
- hit = redHit;
- shape->Rigid(shape->width/2, hfil, shape->height/2);
- }
-
- void MyReducer::ChangeZGrad(float zg)
- {
- factor = zg;
- }
-