void CreateLineFunc::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]) { BrushVar* brVar = (BrushVar*) _ed->GetState("BrushVar"); PatternVar* patVar = (PatternVar*) _ed->GetState("PatternVar"); ColorVar* colVar = (ColorVar*) _ed->GetState("ColorVar"); Transformer* rel = get_transformer(al); ArrowVar* aVar = (ArrowVar*) _ed->GetState("ArrowVar"); ArrowLine* line = new ArrowLine(coords[x0], coords[y0], coords[x1], coords[y1], aVar->Head(), aVar->Tail(), _ed->GetViewer()->GetMagnification(), stdgraphic); if (brVar != nil) line->SetBrush(brVar->GetBrush()); if (colVar != nil) { line->FillBg(!colVar->GetBgColor()->None()); line->SetColors(colVar->GetFgColor(), colVar->GetBgColor()); } line->SetTransformer(rel); Unref(rel); ArrowLineOvComp* comp = new ArrowLineOvComp(line); comp->SetAttributeList(al); if (PasteModeFunc::paste_mode()==0) cmd = new PasteCmd(_ed, new Clipboard(comp)); ComValue compval(new OverlayViewRef(comp), symbol_add("ArrowLineComp")); push_stack(compval); execute_log(cmd); } else push_stack(ComValue::nullval()); Unref(al); }
void ArrowLineComp::Write (ostream& out) { LineComp::Write(out); ArrowLine* arrow = GetArrowLine(); out << arrow->Head() << " " << arrow->Tail() << " "; out << arrow->ArrowScale() << " "; WritePattern(arrow->GetPattern(), out); }
boolean PSArrowLine::Definition (ostream& out) { ArrowLineComp* comp = (ArrowLineComp*) GetSubject(); ArrowLine* aline = comp->GetArrowLine(); Coord x0, y0, x1, y1; aline->GetOriginal(x0, y0, x1, y1); float arrow_scale = aline->ArrowScale(); out << "Begin " << MARK << " Line\n"; MinGS(out); out << MARK << "\n"; out << x0 << " " << y0 << " " << x1 << " " << y1 << " Line\n"; out << MARK << " " << arrow_scale << "\n"; out << "End\n\n"; return out.good(); }
void ArrowLineComp::Read (istream& in) { LineComp::Read(in); Line* line = GetLine(); Coord x0, y0, x1, y1; int h, t; float scale; line->GetOriginal(x0, y0, x1, y1); in >> h >> t >> scale; ArrowLine* arrow = new ArrowLine(x0, y0, x1, y1, h, t, scale, line); arrow->SetPattern(ReadPattern(in)); SetGraphic(arrow); delete line; }
void ArrowLineComp::Uninterpret (Command* cmd) { if (cmd->IsA(ARROW_CMD)) { ArrowLine* line = GetArrowLine(); if (line != nil) { _ArrowData* ad = (_ArrowData*) cmd->Recall(this); if (ad != nil) { line->SetArrows(ad->_head, ad->_tail); Notify(); } } } else { LineComp::Uninterpret(cmd); } }
void ArrowLineComp::Interpret (Command* cmd) { if (cmd->IsA(ARROW_CMD)) { ArrowLine* line = GetArrowLine(); if (line != nil) { ArrowCmd* arrowCmd = (ArrowCmd*) cmd; cmd->Store(this, new _ArrowData(line->Head(), line->Tail())); line->SetArrows(arrowCmd->Head(), arrowCmd->Tail()); Notify(); } } else if (cmd->IsA(PATTERN_CMD)) { GraphicComp::Interpret(cmd); } else { LineComp::Interpret(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; }