Esempio n. 1
0
Command* MagnifyTool::InterpretManipulator (Manipulator* m) {
    Viewer* v = m->GetViewer();
    DragManip* dm = (DragManip*) m;
    RubberRect* rr = (RubberRect*) dm->GetRubberband();
    Coord l, r, b, t;

    rr->GetCurrent(l, b, r, t);
    v->Magnify(l, b, r, t);
    return nil;
}
Esempio n. 2
0
Command* SelectTool::InterpretManipulator (Manipulator* m) {
    DragManip* dm = (DragManip*) m;
    Viewer* viewer = dm->GetViewer();
    GraphicView* views = viewer->GetGraphicView();
    Selection* s = viewer->GetSelection();
    RubberRect* rr = (RubberRect*) dm->GetRubberband();
    Selection* newSel;
    Coord l, b, r, t;

    rr->GetCurrent(l, b, r, t);
    newSel = views->ViewsWithin(l, b, r, t);
    s->Exclusive(newSel);
    delete newSel;

    return nil;
}
Esempio n. 3
0
Command* StrBrowserView::InterpretManipulator (Manipulator* m) {
    Command* cmd = nil;
    Tool* tool = m->GetTool();

    if (tool->IsA(IBGRAPHIC_COMP_TOOL)) {
	cmd = InteractorView::InterpretManipulator(m);

    } else if (tool->IsA(GRAPHIC_COMP_TOOL)) {
        DragManip* dm = (DragManip*) m;
        IBEditor* ed = (IBEditor*) dm->GetViewer()->GetEditor();

        Tool* tool = dm->GetTool();
        Transformer* rel = dm->GetTransformer();
        RubberRect* rubberRect = (RubberRect*) dm->GetRubberband();
        Coord x0, y0, x1, y1;
        rubberRect->GetCurrent(x0, y0, x1, y1);
        NormalRect(x0, y0, x1, y1);

        if (rel != nil) {
            rel->InvTransformRect(x0, y0, x1, y1);
        }
	GetABSCoord(ed, x0, y0, x1, y1);

	ColorVar* colVar = (ColorVar*) ed->GetState("ColorVar");
	FontVar* fontVar = (FontVar*) ed->GetState("FontVar");

        StrBrowserComp* comp = (StrBrowserComp*) GetStrBrowserComp()->Copy();
        StrBrowserGraphic* g = (StrBrowserGraphic*) comp->GetGraphic();
	g->SetRowsCols(y1-y0+1, x1-x0+1);

	if (colVar != nil) {
            g->SetColors(colVar->GetFgColor(), colVar->GetBgColor());
        }
        if (fontVar != nil) {
            g->SetFont(fontVar->GetFont());
        }
	cmd = new MacroCmd(
            ed, new PasteCmd(ed, new Clipboard(comp)),
            new PlaceCmd(ed, x0, y0, x1-1, y1-1, new Clipboard(comp))
        );

    } else if (!tool->IsA(RESHAPE_TOOL)){
        cmd = MessageView::InterpretManipulator(m);
    }
    return cmd;
}
Esempio n. 4
0
Manipulator* StrBrowserView::CreateManipulator (
    Viewer* v, Event& e, Transformer* rel, Tool* tool
) {
    Rubberband* rub = nil;
    Manipulator* m = nil;
    Coord l, b, r, t;
    int ixcon, iycon;

    l = 0, b = 0, r = 1, t = 1;
    rel->TransformRect(l, b, r, t);
    ixcon = r-l, iycon = t-b;
	

    if (tool->IsA(IBGRAPHIC_COMP_TOOL)) {
	m = InteractorView::CreateManipulator(v, e, rel, tool);

    } else if (tool->IsA(GRAPHIC_COMP_TOOL)) {
        rub = new ConstrainRect(
	    nil, nil, e.x, e.y, e.x, e.y, 0, 0, ixcon, iycon 
	);
        m = new DragManip(v, rub, rel, tool, XYEqual);

    } else if (tool->IsA(STRETCH_TOOL)) {
	m = MessageView::CreateManipulator(v, e, rel, tool);
	DragManip* dm = (DragManip*) m;
	DragConstraint dc = dm->GetConstraint();
	RubberRect* rr = (RubberRect*) dm->GetRubberband();
	rr->GetOriginal(l, b, r, t);
	delete dm;

        rub = new ConstrainRect(
	    nil, nil, l, b, r, t, 0, 0, ixcon, iycon 
	);
        m = new DragManip(
	    v, rub, rel, tool, DragConstraint(dc | Gravity), r, t
	);
    } else if (!tool->IsA(RESHAPE_TOOL)){
        m = MessageView::CreateManipulator(v, e, rel, tool);
    }
    return m;
}
Esempio n. 5
0
File: rect.cpp Progetto: PNCG/neuron
Command* RectView::InterpretManipulator (Manipulator* m) {
    DragManip* dm = (DragManip*) m;
    Editor* ed = dm->GetViewer()->GetEditor();
    Tool* tool = dm->GetTool();
    Transformer* rel = dm->GetTransformer();
    Command* cmd = nil;

    if (tool->IsA(GRAPHIC_COMP_TOOL)) {
        RubberRect* rr = (RubberRect*) dm->GetRubberband();
        Coord x0, y0, x1, y1;
        rr->GetCurrent(x0, y0, x1, y1);

        if (x0 != x1 || y0 != y1) {
            BrushVar* brVar = (BrushVar*) ed->GetState("BrushVar");
            PatternVar* patVar = (PatternVar*) ed->GetState("PatternVar");
            ColorVar* colVar = (ColorVar*) ed->GetState("ColorVar");

            if (rel != nil) {
                rel = new Transformer(rel);
                rel->Invert();
            }

            Graphic* pg = GetGraphicComp()->GetGraphic();
            SF_Rect* rect = new SF_Rect(x0, y0, x1, y1, pg);

            if (brVar != nil) rect->SetBrush(brVar->GetBrush());
            if (patVar != nil) rect->SetPattern(patVar->GetPattern());

            if (colVar != nil) {
                rect->SetColors(colVar->GetFgColor(), colVar->GetBgColor());
            }
            rect->SetTransformer(rel);
            Unref(rel);
            cmd = new PasteCmd(ed, new Clipboard(new RectComp(rect)));
        }

    } else if (tool->IsA(RESHAPE_TOOL)) {
        RubberGroup* rubberGroup = (RubberGroup*) dm->GetRubberband();
	RubberLine* rubberLine = (RubberLine*) rubberGroup->First();
        SF_Polygon* polygon;
        Coord x[4], y[4];
	Coord x0, y0;
        
	GetCorners(x, y);
	rubberLine->GetCurrent(x0, y0, x[_reshapeCorner], y[_reshapeCorner]);

        if (rel != nil) {
            rel = new Transformer(rel);
            rel->Invert();
        }
        polygon = new SF_Polygon(x, y, 4, GetGraphic());
        polygon->SetTransformer(rel);
        Unref(rel);
        cmd = new ReplaceCmd(ed, new PolygonComp(polygon));

    } else if (tool->IsA(MOVE_TOOL)) {
        SlidingLineList* sll;
        Transformer* rel = dm->GetTransformer();
        Coord* ox, *oy, *cx, *cy;
        float fx0, fy0, fx1, fy1;
        int n;

        sll = (SlidingLineList*) dm->GetRubberband();
        sll->GetOriginal(ox, oy, n);
        sll->GetCurrent(cx, cy, n);
        if (rel != nil) {
            rel->InvTransform(float(ox[0]), float(oy[0]), fx0, fy0);
            rel->InvTransform(float(cx[0]), float(cy[0]), fx1, fy1);
        }
        delete ox; delete oy; delete cx; delete cy;
        cmd = new MoveCmd(ed, fx1 - fx0, fy1 - fy0);

    } else if (tool->IsA(SCALE_TOOL)) {
        ScalingLineList* sll = (ScalingLineList*) dm->GetRubberband();
        float sxy = sll->CurrentScaling();

        cmd = new ScaleCmd(ed, sxy, sxy);

    } else if (tool->IsA(ROTATE_TOOL)) {
        RotatingLineList* rll = (RotatingLineList*) dm->GetRubberband();
        float angle = rll->CurrentAngle() - rll->OriginalAngle();

        cmd = new RotateCmd(ed, angle);

    } else {
        cmd = GraphicView::InterpretManipulator(m);
    }
    return cmd;
}