Esempio n. 1
0
File: pin.cpp Progetto: PNCG/neuron
Command* PinView::InterpGraphicCompManip (Manipulator* m) {
    DragManip* dm = (DragManip*) m;
    Editor* ed = dm->GetViewer()->GetEditor();
    BrushVar* brVar = (BrushVar*) ed->GetState("Brush");
    SlidingPin* sp = (SlidingPin*) dm->GetRubberband();
    Transformer* rel = dm->GetTransformer();
    Coord px, py, dum;
    float dx, dy;
    PinGraphic* pinGraphic;

    sp->GetCurrent(px, py, dum, dum);
    if (rel != nil) {
        GetOffset(rel, px, py, dx, dy);
        rel = new Transformer;
        rel->Translate(dx, dy);
    }

    Graphic* pg = GetGraphicComp()->GetGraphic();
    pinGraphic = new PinGraphic(px, py, pg);

    if (brVar != nil) pinGraphic->SetBrush(brVar->GetBrush());
    pinGraphic->SetTransformer(rel);
    Unref(rel);
    return new PasteCmd(ed, new Clipboard(NewSubject(pinGraphic)));
}
Esempio n. 2
0
void CreateRasterFunc::execute() {
    const int x0 = 0;  
    const int y0 = 1;  
    const int x1 = 2;  
    const int y1 = 3;  
    const int n = 4;
    int coords[n];
    ComValue& vect = stack_arg(0);
    if (!vect.is_type(ComValue::ArrayType) || vect.array_len() != n) {
        reset_stack();
	push_stack(ComValue::nullval());
	return;
    }

    ALIterator i;
    AttributeValueList* avl = vect.array_val();
    avl->First(i);
    for (int j=0; j<n && !avl->Done(i); j++) {
        coords[j] = avl->GetAttrVal(i)->int_val();
	avl->Next(i);
    }

    AttributeList* al = stack_keys();
    Resource::ref(al);
    reset_stack();

    PasteCmd* cmd = nil;

    if (coords[x0] != coords[x1] || coords[y0] != coords[y1]) {

	float dcoords[n];
	((OverlayViewer*)GetEditor()->GetViewer())->ScreenToDrawing
	  (coords[x0], coords[y0], dcoords[x0], dcoords[y0]);
	((OverlayViewer*)GetEditor()->GetViewer())->ScreenToDrawing
	  (coords[x1], coords[y1], dcoords[x1], dcoords[y1]);
	
	OverlayRaster* raster = 
	  new OverlayRaster((int)(dcoords[x1]-dcoords[x0]+1), 
			    (int)(dcoords[y1]-dcoords[y0]+1), 
			    2 /* initialize with border of 2 */);

	OverlayRasterRect* rasterrect = new OverlayRasterRect(raster, stdgraphic);

#if 1
	Transformer* t = new Transformer();
	t->Translate(dcoords[x0], dcoords[y0]);
	rasterrect->SetTransformer(t);
	Unref(t);
#else
        Transformer* rel = get_transformer(al);
#endif

	RasterOvComp* comp = new RasterOvComp(rasterrect);
	comp->SetAttributeList(al);
	if (PasteModeFunc::paste_mode()==0)
	  cmd = new PasteCmd(_ed, new Clipboard(comp));
	ComValue compval(new OverlayViewRef(comp), symbol_add("RasterComp"));
	push_stack(compval);
	execute_log(cmd);
    } else 
	push_stack(ComValue::nullval());

    Unref(al);
}