void CreateClosedSplineFunc::execute() { ComValue& vect = stack_arg(0); if (!vect.is_type(ComValue::ArrayType) || vect.array_len()==0) { reset_stack(); push_stack(ComValue::nullval()); return; } const int len = vect.array_len(); const int npts = len/2; int x[npts]; int y[npts]; ALIterator i; AttributeValueList* avl = vect.array_val(); avl->First(i); for (int j=0; j<npts && !avl->Done(i); j++) { x[j] = avl->GetAttrVal(i)->int_val(); avl->Next(i); y[j] = avl->GetAttrVal(i)->int_val(); avl->Next(i); } AttributeList* al = stack_keys(); Resource::ref(al); reset_stack(); PasteCmd* cmd = nil; if (npts) { 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"); SFH_ClosedBSpline* closedspline = new SFH_ClosedBSpline(x, y, npts, stdgraphic); if (brVar != nil) closedspline->SetBrush(brVar->GetBrush()); if (patVar != nil) closedspline->SetPattern(patVar->GetPattern()); if (colVar != nil) { closedspline->FillBg(!colVar->GetBgColor()->None()); closedspline->SetColors(colVar->GetFgColor(), colVar->GetBgColor()); } closedspline->SetTransformer(rel); Unref(rel); ClosedSplineOvComp* comp = new ClosedSplineOvComp(closedspline); comp->SetAttributeList(al); if (PasteModeFunc::paste_mode()==0) cmd = new PasteCmd(_ed, new Clipboard(comp)); ComValue compval(new OverlayViewRef(comp), symbol_add("ClosedSplineComp")); push_stack(compval); execute_log(cmd); } else push_stack(ComValue::nullval()); Unref(al); }
void ClosedSplineComp::Read (istream& in) { VerticesComp::Read(in); Coord* x, *y; int count; ReadVertices(in, x, y, count); SFH_ClosedBSpline* spline = new SFH_ClosedBSpline(x, y, count); delete x; delete y; spline->FillBg(ReadBgFilled(in)); PSColor* fg = ReadColor(in); PSColor* bg = ReadColor(in); spline->SetColors(fg, bg); spline->SetBrush(ReadBrush(in)); spline->SetPattern(ReadPattern(in)); Transformer* t = ReadTransformer(in); spline->SetTransformer(t); Unref(t); SetGraphic(spline); }