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; }
Command* LineView::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)) { RubberLine* rl = (RubberLine*) dm->GetRubberband(); Coord x0, y0, x1, y1; rl->GetCurrent(x0, y0, x1, y1); if (x0 != x1 || y0 != y1) { BrushVar* brVar = (BrushVar*) ed->GetState("BrushVar"); ColorVar* colVar = (ColorVar*) ed->GetState("ColorVar"); 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()); if (colVar != nil) { line->SetColors(colVar->GetFgColor(), colVar->GetBgColor()); } line->SetTransformer(rel); Unref(rel); cmd = new PasteCmd(ed, new Clipboard(new LineComp(line))); } } else if (tool->IsA(MOVE_TOOL)) { Coord x0, y0, x1, y1, dummy1, dummy2; float fx0, fy0, fx1, fy1; SlidingLine* sl = (SlidingLine*) dm->GetRubberband(); sl->GetOriginal(x0, y0, dummy1, dummy2); sl->GetCurrent(x1, y1, dummy1, dummy2); if (rel != nil) { rel->InvTransform(float(x0), float(y0), fx0, fy0); rel->InvTransform(float(x1), float(y1), fx1, fy1); } cmd = new MoveCmd(ed, fx1 - fx0, fy1 - fy0); } else if (tool->IsA(SCALE_TOOL)) { ScalingLine* sl = (ScalingLine*) dm->GetRubberband(); float sxy = sl->CurrentScaling(); cmd = new ScaleCmd(ed, sxy, sxy); } else if (tool->IsA(ROTATE_TOOL)) { RotatingLine* rl = (RotatingLine*) dm->GetRubberband(); float angle = rl->CurrentAngle() - rl->OriginalAngle(); cmd = new RotateCmd(ed, angle); } else if (tool->IsA(RESHAPE_TOOL)) { RubberLine* rl = (RubberLine*) dm->GetRubberband(); Coord x0, y0, x1, y1; rl->GetCurrent(x0, y0, x1, y1); if (rel != nil) { rel = new Transformer(rel); rel->Invert(); } Line* line = new Line(x0, y0, x1, y1, GetGraphic()); line->SetTransformer(rel); Unref(rel); cmd = new ReplaceCmd(ed, new LineComp(line)); } else { cmd = GraphicView::InterpretManipulator(m); } return cmd; }
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; }
Command* ArrowLineView::InterpretManipulator (Manipulator* m) { DragManip* dm = (DragManip*) m; Editor* ed = dm->GetViewer()->GetEditor(); Tool* tool = dm->GetTool(); Transformer* rel = dm->GetTransformer(); Command* cmd = nil; ArrowVar* aVar = (ArrowVar*) ed->GetState("ArrowVar"); if (tool->IsA(GRAPHIC_COMP_TOOL)) { RubberLine* rl = (RubberLine*) dm->GetRubberband(); Coord x0, y0, x1, y1; rl->GetCurrent(x0, y0, x1, y1); if (x0 != x1 || y0 != y1) { BrushVar* brVar = (BrushVar*) ed->GetState("BrushVar"); ColorVar* colVar = (ColorVar*) ed->GetState("ColorVar"); PatternVar* patVar = (PatternVar*) ed->GetState("PatternVar"); if (rel != nil) { rel = new Transformer(rel); rel->Invert(); } ArrowLine* aline = new ArrowLine( x0, y0, x1, y1, aVar->Head(), aVar->Tail(), dm->GetViewer()->GetMagnification(), stdgraphic ); if (brVar != nil) aline->SetBrush(brVar->GetBrush()); if (patVar != nil) { aline->SetPattern(patVar->GetPattern()); } if (colVar != nil) { aline->SetColors(colVar->GetFgColor(), colVar->GetBgColor()); } aline->SetTransformer(rel); Unref(rel); cmd = new PasteCmd(ed, new Clipboard(new ArrowLineComp(aline))); } } else if (tool->IsA(RESHAPE_TOOL)) { RubberLine* rl = (RubberLine*) dm->GetRubberband(); Coord epx0, epy0, epx1, epy1; GetEndpoints(epx0, epy0, epx1, epy1); Coord x0, y0, x1, y1; rl->GetCurrent(x0, y0, x1, y1); if (x0 == epx1 && y0 == epy1) { x0 = x1; y0 = y1; x1 = epx1; y1 = epy1; } if (rel != nil) { rel = new Transformer(rel); rel->Invert(); } ArrowLine* orig = GetArrowLineComp()->GetArrowLine(); ArrowLine* aline = new ArrowLine( x0, y0, x1, y1, orig->Head(), orig->Tail(), dm->GetViewer()->GetMagnification(), GetGraphic() ); aline->SetTransformer(rel); Unref(rel); cmd = new ReplaceCmd(ed, new ArrowLineComp(aline)); } else { cmd = LineView::InterpretManipulator(m); } return cmd; }