示例#1
0
boolean ConnectManip::Manipulating (Event& e) {
    GraphicView* views = GetViewer()->GetGraphicView();
    Rubberband* r = GetRubberband();
    float cx, cy;

    if (r == nil) {
        return false;
    }

    if (e.eventType == MotionEvent) {
        _target = views->ConnectorIntersecting(
            e.x-SLOP, e.y-SLOP, e.x+SLOP, e.y+SLOP
        );

        if (_target == nil) {
            r->Track(e.x, e.y);

        } else {
            _target->GetGraphic()->GetCenter(cx, cy);
            r->Track(Math::round(cx), Math::round(cy));
        }

    } else if (e.eventType == UpEvent) {
	r->Erase();
	return false;
    }
    return true;
}
示例#2
0
文件: link.c 项目: barak/ivtools-cvs
Manipulator* LinkView::CreateLinkCompManip (
    Viewer* v, Event& e, Transformer* rel, Tool* tool
) {
    GraphicView* views = v->GetGraphicView();
    Selection* s = v->GetSelection();
    RubberGroup* rg = new RubberGroup(nil, nil);
    float x, y, tx, ty;
    Coord cx = 0, rad = PIN_RAD, dum1 = 0, dum2 = 0;
    ConnectorView* target = views->ConnectorIntersecting(
        e.x-SLOP, e.y-SLOP, e.x+SLOP, e.y+SLOP
    );

    s->Clear();
    if (target != nil) {
        target->GetConnector()->GetCenter(x, y);
        rel->Transform(x, y, tx, ty);
        e.x = Math::round(tx);
        e.y = Math::round(ty);
    }
    if (rel != nil) {
        rel->Transform(cx, dum1);
        rel->Transform(rad, dum2);
        rad = abs(rad - cx);
    }
    rg->Append(
        new RubberLine(nil, nil, e.x, e.y, e.x, e.y),
        new FixedPin(nil, nil, e.x, e.y, rad),
        new SlidingPin(nil, nil, e.x, e.y, rad, e.x, e.y)
    );
    return new ConnectManip(v, rg, rel, tool);
}
示例#3
0
Manipulator* ConnectTool::CreateManipulator (
    Viewer* v, Event& e, Transformer* rel
) {
    GraphicView* views = v->GetGraphicView();
    Selection* s = v->GetSelection();
    Manipulator* m = nil;

    _source = views->ConnectorIntersecting(
        e.x-SLOP, e.y-SLOP, e.x+SLOP, e.y+SLOP
    );
    if (_source == nil) {
	s->Clear();
    } else {
        m = _source->CreateManipulator(v, e, rel, this);
    }
    return m;
}
示例#4
0
文件: link.c 项目: barak/ivtools-cvs
Command* LinkView::InterpLinkCompManip (Manipulator* m) {
    Viewer* v = m->GetViewer();
    Editor* ed = v->GetEditor();
    GraphicView* views = v->GetGraphicView();
    BrushVar* brVar = (BrushVar*) ed->GetState("BrushVar");
    ConnectManip* cm = (ConnectManip*) m;
    Transformer* rel = cm->GetTransformer();
    RubberGroup* rg = (RubberGroup*) cm->GetRubberband();
    RubberLine* rl = (RubberLine*) rg->First();
    Coord x0, y0, x1, y1;
    Connector* c1, *c2;
    ConnectorView* target1, *target2;
    MacroCmd* macro = new MacroCmd(ed);
    
    rl->GetCurrent(x0, y0, x1, y1);
    if (rel != nil) {
        rel = new Transformer(rel);
        rel->Invert();
    }

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

    if (brVar != nil) line->SetBrush(brVar->GetBrush());
    line->SetTransformer(rel);
    Unref(rel);
    LinkComp* linkComp = NewSubject(line);
    linkComp->GetConnectors(c1, c2);

    macro->Append(new PasteCmd(ed, new Clipboard(linkComp)));
    target1 = views->ConnectorIntersecting(x0-SLOP, y0-SLOP, x0+SLOP, y0+SLOP);
    target2 = views->ConnectorIntersecting(x1-SLOP, y1-SLOP, x1+SLOP, y1+SLOP);

    if (target1 != nil) {
        macro->Append(new ConnectCmd(ed, c1, target1->GetConnector()));
    }
    if (target2 != nil) {
        macro->Append(new ConnectCmd(ed, c2, target2->GetConnector()));
    }
    return macro;
}