void VRAMEditorLayeredGraphicScene::renderTiles(
                 Graphic& g,
                 int tileIndex,
                 GGTileSet& tiles,
                 GGPalette& palette,
                 Graphic::TileTransferTransOption tileTransOption) {
  // Render each tile and blit to Graphic
  for (int j = 0; j < tiles.numTiles(); j++) {
    // Render tile
    Graphic tileGraphic(tiles[j],
                        palette,
                        tileTransOption);
                        
    // Calculate position in Graphic
    int xPos = tileIndexToXPos(tileIndex);
    int yPos = tileIndexToYPos(tileIndex);
    
    // Blit if transparency is enabled; copy otherwise
    if (tileTransOption == Graphic::tileTrans) {
      g.blit(tileGraphic,
             Box(xPos, yPos, 0, 0),
             Graphic::noTransUpdate);
    }
    else {
      g.copy(tileGraphic,
             Box(xPos, yPos, 0, 0),
             Graphic::noTransUpdate);
    }
    
    // Move to next tile position
    ++tileIndex;
  }
}
Exemplo n.º 2
0
void
Scene::Collect()
{
    ListIter<Graphic> iter = graphics;

    while (++iter) {
        Graphic* g = iter.value();
        if (g->Life() == 0) {
            delete iter.removeItem();
        }
    }   

    iter.attach(sprites);

    while (++iter) {
        Graphic* g = iter.value();
        if (g->Life() == 0) {
            delete iter.removeItem();
        }
    }   

    ListIter<Light> iter1 = lights;

    while (++iter1) {
        Light* l = iter1.value();
        if (l->Life() == 0) {
            delete iter1.removeItem();
        }
    }   
}
void VRAMEditorLayeredGraphicScene::boxGenericLength(
                    Graphic& dst,
                    int baseIndex,
                    int numTiles,
                    Color color,
                    int width,
                    double scale) {
  for (int i = 0; i < numTiles; i++) {
    // Calculate position in Graphic
    int xPos = tileIndexToXPos(baseIndex + i);
    int yPos = tileIndexToYPos(baseIndex + i);
  
    BoxGraphicSceneObject box(color,
                              width,
                              GGTile::width * scale,
                              GGTile::height * scale,
                              xPos * scale,
                              yPos * scale,
                              true);
    
    box.render(dst,
               Box(0, 0, dst.w(), dst.h()),
               1.00);
  }
}
//-----------------------------------------------------------------------------
// Mouse motion (with either key pressed) event handler
//-----------------------------------------------------------------------------
void GlutDisplay::mouseMotionEvent(const int x, const int y)
{
   if (isMessageEnabled(MSG_DEBUG)) {
      std::cout << "GlutDisplay::mouseEvent(): " << std::endl;
   }

   if (picked != nullptr) {
      Graphic* selected = pick();
      if (selected != nullptr) {
         if (selected != picked) {
            picked->event(ON_CANCEL);
            picked->unref();
            picked = nullptr;
         }
         selected->event(ON_MOTION);

      }
      else {
         if (picked != nullptr) {
            picked->event(ON_CANCEL);
            picked->unref();
            picked = nullptr;
         }
      }
   }
   setMouse(x,y);
}
Exemplo n.º 5
0
void TransformerFunc::execute() {
    
    ComValue objv(stack_arg(0));
    ComValue transv(stack_arg(0));
    reset_stack();
    if (objv.object_compview()) {
      ComponentView* compview = (ComponentView*)objv.obj_val();
      if (compview && compview->GetSubject()) {
	OverlayComp* comp = (OverlayComp*)compview->GetSubject();
	Graphic* gr = comp->GetGraphic();
	if (gr) {
	  Transformer* trans = gr->GetTransformer();
	  if (transv.is_unknown() || !transv.is_array() || transv.array_val()->Number()!=6) {
	    AttributeValueList* avl = new AttributeValueList();
	    float a00, a01, a10, a11, a20, a21;
	    trans->matrix(a00, a01, a10, a11, a20, a21);
	    avl->Append(new AttributeValue(a00));
	    avl->Append(new AttributeValue(a01));
	    avl->Append(new AttributeValue(a10));
	    avl->Append(new AttributeValue(a11));
	    avl->Append(new AttributeValue(a20));
	    avl->Append(new AttributeValue(a21));
	    ComValue retval(avl);
	    push_stack(retval);

	  } else {
	    float a00, a01, a10, a11, a20, a21;
	    AttributeValueList* avl = transv.array_val();
	    Iterator it;
	    AttributeValue* av;

	    avl->First(it);
	    av = avl->GetAttrVal(it);
	    a00 = av->float_val();
	    avl->Next(it);
	    av = avl->GetAttrVal(it);
	    a01 = av->float_val();
	    avl->Next(it);
	    av = avl->GetAttrVal(it);
	    a10 = av->float_val();
	    avl->Next(it);
	    av = avl->GetAttrVal(it);
	    a11 = av->float_val();
	    avl->Next(it);
	    av = avl->GetAttrVal(it);
	    a20 = av->float_val();
	    avl->Next(it);
	    av = avl->GetAttrVal(it);
	    a21 = av->float_val();

	    Transformer t(a00, a01, a10, a11, a20, a21);
	    *gr->GetTransformer()=t;

	    ComValue compval(new OverlayViewRef(comp), comp->class_symid());
	    push_stack(compval);
	  }
	}
      } 	
    }
}
Exemplo n.º 6
0
void Viewer::SetOrientation (Orientation o) {
    if (_orientation != o) {
        _orientation = o;

        Coord l, b, r, t;
        GetGraphicBox(l, b, r, t);
        Graphic* g = GraphicBlock::GetGraphic();

        if (
            _orientation == Normal ||
            _orientation == Portrait ||
            _orientation == Vertical
        ) {
            g->Rotate(90., l, b);
            g->Translate(t-b, 0.);

        } else if (
            _orientation == Rotated ||
            _orientation == Landscape ||
            _orientation == Horizontal
        ) {
            g->Rotate(-90., l, b);
            g->Translate(0., r-l);
        }
        GraphicBlock::Update();
    }
}
Exemplo n.º 7
0
	void TextField::draw(const Graphic& graphic, double deltaTime) {
		Component::draw(graphic, deltaTime);

		Dimension dim = getSize();
		float x = 0.0;
		// Text should 
		switch (alignment_) {
			case Alignment::LEFT:
				x = 2;
				break;
			case Alignment::CENTER:
				x = dim.width_ * 0.5f - (text_.getWidth() - 2) * 0.5f;
				break;
			case Alignment::RIGHT:
				x = dim.width_ - text_.getWidth() - 2;
				break;
		}

		graphic.setColor(textColor_);
		graphic.drawText(text_, x, 0);
		if (editable_) {
			if (hasFocus()) {
				markerDeltaTime_ += deltaTime;
				if (markerDeltaTime_ < 0.5) {
					graphic.drawSquare(markerWidth_ + x, 1, 1, text_.getCharacterSize());
				} else if (markerDeltaTime_ > 1.0) {
					markerDeltaTime_ = 0;
				}
			} else {
				markerDeltaTime_ = 0;
			}
		}
	}
Exemplo n.º 8
0
boolean GraphicMaster::effect (const Event& e, Tool& tool) {
    boolean flag = true;
    Window* w = e.window();
    if (w != nil) {
        w->cursor(window_cursor);
        Canvas* c = w->canvas();
        long count = _gr_list->count();
        Coord l, b, r, t;
        for (long i = 0; i < count && flag; i++) {
            Graphic* target = _gr_list->item(i);
            target->getbounds(l, b, r, t);
            c->damage(l, b, r, t);
            flag = target->effect(e, tool);
            if (flag) {
                target->getbounds(l, b, r, t);
                c->damage(l, b, r, t);
            }
            target->flush();
            CanvasRep& rep = *c->rep();
            CanvasDamage& cd = rep.damage_;
            rep.start_repair();
            drawclipped(c, cd.left, cd.bottom, cd.right, cd.top);
            rep.finish_repair();
        }
        _gr_list->remove_all();
    } 
    return flag;
}
Exemplo n.º 9
0
void VMouse::Sim_Press(Graphic* orig, Graphic* porig, Event& e) {
    Canvas* screen = _myglass->GetCanvas();
    Graphic* parent;
    if (e.eventType == DownEvent) {
        parent = orig->Parent();
        if (parent != nil) {
            orig->Erase(screen);
            parent->Remove(orig);
            parent->Append(porig);
            porig->Draw(screen);
            if (e.leftmouse) {
                _vwriter->Request(1);

            } else if (e.middlemouse) {
                _vwriter->Request(2);

            } else if (e.rightmouse) {
                _vwriter->Request(3);
            }
        }
            
    } else if (e.eventType == UpEvent) {
        parent = porig->Parent();
        if (parent != nil) {
            porig->Erase(screen);
            parent->Remove(porig);
            parent->Append(orig);
            orig->Draw(screen);
        }
    }
}
Exemplo n.º 10
0
void AlignToGridCmd::Align (GraphicView* gv, float refx, float refy) {
    MoveData* md = (MoveData*) Recall(gv->GetGraphicComp());

    if (md == nil) {
        Viewer* v = gv->GetViewer();
        Grid* grid = (v == nil) ? nil : v->GetGrid();

        if (grid == nil) {
            return;
        }

        Graphic* g = gv->GetGraphic();
        Transformer t;
        g->Parent()->TotalTransformation(t);
        t.Invert();

        Coord cx = iv26_round(refx);
        Coord cy = iv26_round(refy);

        grid->Constrain(cx, cy);

        float dx, dy, trefx, trefy;

        t.Transform(float(cx), float(cy), dx, dy);
        t.Transform(refx, refy, trefx, trefy);

        dx -= trefx;
        dy -= trefy;
        Store(gv->GetGraphicComp(), new MoveData(dx, dy));

    }
    Move(gv->GetGraphicComp());
}
Exemplo n.º 11
0
boolean PSLink::Definition (ostream& out) {
    LinkComp* comp = (LinkComp*) GetSubject();
    Graphic* link = comp->GetGraphic();
    Line* line = comp->GetLine();

    Transformer* link_t = link->GetTransformer();
    Transformer* line_t = line->GetTransformer();
    Transformer* temp_t = new Transformer(line_t);

    Resource::ref(link_t);
    temp_t->postmultiply(*link_t);
    link->SetTransformer(temp_t);

    Coord x0, y0, x1, y1;
    line->GetOriginal(x0, y0, x1, y1);

    out << "Begin " << MARK << " Line\n";
    MinGS(out);
    out << MARK << "\n";
    out << x0 << " " << y0 << " " << x1 << " " << y1 << " Line\n";
    out << "End\n\n";

    link->SetTransformer(link_t);
    Resource::unref(link_t);
    Resource::unref(temp_t);

    return out.good();
}
Exemplo n.º 12
0
void PolyGraphic::remove_ (GlyphIndex i) { 
    Graphic* gr = (Graphic*)_body->component(i);
    if (gr != nil) {
        gr->parent(nil);
    }
    _body->remove(i); 
}
Exemplo n.º 13
0
LinkComp::LinkComp (Line* line) {
    if (line != nil) {
        Coord x0, y0, x1, y1;
        float fx0, fy0, fx1, fy1;

        line->GetOriginal(x0, y0, x1, y1);
        Transformer* t = line->GetTransformer();
        Graphic* parent = new Picture(line);
        parent->SetTransformer(nil);

        if (t == nil) {
            fx0 = x0; fy0 = y0; fx1 = x1; fy1 = y1;
        } else {
            t->Transform(float(x0), float(y0), fx0, fy0);
            t->Transform(float(x1), float(y1), fx1, fy1);
        }
        delete line;
        line = new Line(0, 0, 1, 1);
        InitLine(line, fx0, fy0, fx1, fy1);

        PinGraphic* pg1 = new PinGraphic;
        PinGraphic* pg2 = new PinGraphic;
        pg1->SetBrush(psnonebr);
        pg2->SetBrush(psnonebr);
        pg1->Translate(fx0, fy0);
        pg2->Translate(fx1, fy1);

        _conn1 = new PinComp(pg1);
        _conn2 = new PinComp(pg2);

        parent->Append(line, pg1, pg2);
        SetGraphic(parent);
    }
}
Exemplo n.º 14
0
Line* LinkView::GetLine () {
    Iterator i;
    Graphic* gr = GetGraphic();

    gr->First(i);
    return (Line*) gr->GetGraphic(i);
}
Exemplo n.º 15
0
void   Morphining::DoAffineTrsform(IplImage *src,IplImage *dst,vector<Coordinate> coord1,vector<Coordinate> coord2,double T,int type,bool debug)//T:Threshold of SSD's error;
{
	CvMat* Matrix = cvCreateMat(3,3,CV_32FC1);
	Matrix = GetAffineMatrix(coord1,coord2,debug);

	//if(SSD(coord1,coord2,Matrix,100))
	//{ 
		Vertex = new Coordinate [m_numFeature];
		for(int i = 0;i < m_numFeature;i++)
		{
			Vertex[i] = coord1[i];
		}
		Graphic FindLine;
		FindLine.CuttingRegion(coord1,m_numFeature,m,b);	
        AffineTrsform(src,dst,Matrix,type,debug);
		if(debug)
		{
			cvNamedWindow("dst",0);
			cvShowImage("dst",dst);
			cvWaitKey(0);
		}
	//}
		
	cvReleaseMat(&Matrix);	   
}
Exemplo n.º 16
0
void Viewer::Align (GraphicComp* comp, Alignment a) {
    Graphic* g = comp->GetGraphic();
    float cl, cb, cr, ct;
    g->GetBounds(cl, cb, cr, ct);

    Perspective* p = GetPerspective();
    float mag = GetMagnification();
    float vl = float(p->curx - p->x0) / mag;
    float vb = float(p->cury - p->y0) / mag;
    float vr = float(p->curx - p->x0 + p->curwidth - 1) / mag;
    float vt = float(p->cury - p->y0 + p->curheight - 1) / mag;

    float dx, dy;

    switch (a) {
    case TopLeft:
    case CenterLeft:
    case BottomLeft:
    case Left:
        dx = vl - cl;
        break;

    case TopCenter:
    case Center:
    case BottomCenter:
        dx = (vr + vl - cr - cl) / 2;
        break;

    case TopRight:
    case CenterRight:
    case BottomRight:
    case Right:
        dx = vr - cr;
        break;
    }
    
    switch (a) {
    case TopLeft:
    case TopCenter:
    case TopRight:
    case Top:
        dy = vt - ct;
        break;

    case CenterLeft:
    case Center:
    case CenterRight:
        dy = (vt + vb - ct - cb) / 2;
        break;

    case BottomLeft:
    case BottomCenter:
    case BottomRight:
    case Bottom:
        dy = vb - cb;
        break;
    }
    MoveCmd mvcmd(GetEditor(), dx, dy);
    comp->Interpret(&mvcmd);
}
Exemplo n.º 17
0
void PolyGraphic::getextent_gs (
    Coord& l, Coord& b, Coord& cx, Coord& cy, float& tol, Graphic* gs
) {
    Extent e;
    l = b = cx = cy = tol = 0.0;
        
    Graphic gstemp;
    Transformer ttemp;
    Extent te;
    gstemp.transformer(&ttemp);

    GlyphIndex count = _body->count();
    for (GlyphIndex i = 0; i < count; i++) {
        Graphic* gr = (Graphic*) _body->component(i);
        
        concatgs_(gr, gr, gs, &gstemp);
        concatXform_(gr, nil, gr->transformer(), &ttemp);
        getextent_(gr, te._left, te._bottom, te._cx, te._cy, te._tol, &gstemp);
        e.Merge(te);
    }
    gstemp.transformer(nil); // to avoid deleting ttemp explicitly
    l = e._left; b = e._bottom; cx = l+(e._cx-l)*2.0; cy = b+(e._cy-b)*2.0;
    tol = e._tol;

    Transformer* tx = gs->transformer();
    if (tx != nil) {
        corners(l, b, cx, cy, *tx);
    }
    cx = (cx + l)/2.0;
    cy = (cy + b)/2.0;
}
Exemplo n.º 18
0
void Graphic::uncacheParents () {
    Graphic* p = Parent();

    if (p != nil) {
        p->uncacheExtent();
        p->uncacheParents();
    }
}
Exemplo n.º 19
0
	void Component::draw(const Graphic& graphic, double deltaTime) {
		// Draw panel background.
		graphic.setColor(backgroundColor_);
		graphic.drawSquare(0, 0, dimension_.width_, dimension_.height_);
		graphic.drawSprite(background_, 0, 0, dimension_.width_, dimension_.height_);
		graphic.setColor(borderColor_);
		graphic.drawBorder(0, 0, dimension_.width_, dimension_.height_);
	}
Exemplo n.º 20
0
void Graphic::draw(Canvas* c, const Allocation&) const {
    if (c != nil) {
        Graphic* gr = (Graphic*) this;
        CanvasDamage& cd = c->rep()->damage_;
        gr->drawclipped(
            c, cd.left, cd.bottom, cd.right, cd.top
        );
    }
}
Exemplo n.º 21
0
void Graphic::parentXform (Transformer& t) {
    Graphic* parent = Parent();

    if (parent == nil) {
        t = *_identity;
    } else {
        parent->TotalTransformation(t);
    }
}
Exemplo n.º 22
0
void Grapher::Retranslate (Picture* p, float sx, float sy, float l, float b) {
    float ml, mb;
    Iterator i;
    for (p->First(i); !p->Done(i); p->Next(i)) {
        Graphic* kid = p->GetGraphic(i);
        kid->GetCenter(ml, mb);
        kid->Translate((ml-l)*sx, (mb-b)*sy);
    }
}
Exemplo n.º 23
0
VMouse::VMouse(const char* name, const char* host) : VMouse_core(name) {
    Graphic* parent;
    parent = _pbutton1->Parent();
    parent->Remove(_pbutton1);
    parent = _pbutton2->Parent();
    parent->Remove(_pbutton2);
    parent = _pbutton3->Parent();
    parent->Remove(_pbutton3);
    _vwriter = new VMouseWriter(host, port_id);
}
Exemplo n.º 24
0
void Graphic::parentXform (Transformer& t) {
    Transformer identity;
    Graphic* p = parent();

    if (p == nil) {
        *(&t) = *(&identity);
    } else {
        p->eqv_transformer(t);
    }
}
Exemplo n.º 25
0
Glyph* GraphicMaster::clone () const {
    Graphic* pg = new GraphicMaster((Graphic*)this);

    GlyphIndex count = _body->count();
    for (GlyphIndex i = 0; i < count; i++) {
        Glyph* gr = _body->component(i);
        pg->append(gr->clone());
    }
    return pg;
}
Exemplo n.º 26
0
void PaletteEditor::drawPreviewGraphic(Graphic& dst) {
  colorPreview_.setColor(
    Color(currentColor().realR(),
          currentColor().realG(),
          currentColor().realB(),
          Color::fullAlphaOpacity));
  colorPreview_.render(dst,
                       Box(0, 0, dst.w(), dst.h()),
                       1.00);
}
Exemplo n.º 27
0
void EditorCode::Update () {
    IGraphicComps* igrcomps = GetEditorComp()->GetIGraphicComps();
    _gcode = (GroupCode*) igrcomps->Create(CODE_VIEW);
    igrcomps->Attach(_gcode);
    _gcode->Update();
    MonoSceneClassCode::Update();
    InteractorComp* subj = GetIntComp();
    Graphic* gr = subj->GetGraphic();
    gr->SetColors(nil, nil);
    gr->SetFont(nil);
}
Exemplo n.º 28
0
void Graphic::TotalTransformation (Transformer& total) {
    Graphic* parent = Parent();

    if (parent == nil) {
        concatTransformer(nil, _t, &total);

    } else {
        parent->TotalTransformation(total);
        concatTransformer(_t, &total, &total);
    }
}
Exemplo n.º 29
0
void GraphicalPlayer::set_is_frozen(bool is_frozen, int64_t freeze_time, PhysicsObject* source) {
    Player::set_is_frozen(is_frozen, freeze_time, source);
    Graphic* graphic = m_graphic_root.get_texture();
    if (is_frozen) {
        graphic->set_shader_set(m_blur);
        graphic->set_color(Color(0.7f, 0.7f, 0.7f));
    } else {
        graphic->set_shader_set(NULL);
        graphic->set_color(Color::WHITE);
    }
}
Exemplo n.º 30
0
void Graphic::totalGS (Graphic& gs) {
    Graphic* parent = Parent();

    if (parent == nil) {
        concat(nil, this, &gs);

    } else {
        parent->totalGS(gs);
        concat(this, &gs, &gs);
    }
}