void ArrowSplineComp::Uninterpret (Command* cmd) { if (cmd->IsA(ARROW_CMD)) { ArrowOpenBSpline* amline = GetArrowOpenBSpline(); if (amline != nil) { _ArrowData* ad = (_ArrowData*) cmd->Recall(this); if (ad != nil) { amline->SetArrows(ad->_head, ad->_tail); Notify(); } } } else { SplineComp::Uninterpret(cmd); } }
void ArrowSplineComp::Interpret (Command* cmd) { if (cmd->IsA(ARROW_CMD)) { ArrowOpenBSpline* amline = GetArrowOpenBSpline(); if (amline != nil) { ArrowCmd* arrowCmd = (ArrowCmd*) cmd; cmd->Store(this, new _ArrowData(amline->Head(), amline->Tail())); amline->SetArrows(arrowCmd->Head(), arrowCmd->Tail()); Notify(); } } else if (cmd->IsA(PATTERN_CMD)) { GraphicComp::Interpret(cmd); } else { SplineComp::Interpret(cmd); } }
boolean PSArrowSpline::Definition (ostream& out) { ArrowSplineComp* comp = (ArrowSplineComp*) GetSubject(); ArrowOpenBSpline* aml = comp->GetArrowOpenBSpline(); const Coord* x, *y; int n = aml->GetOriginal(x, y); float arrow_scale = aml->ArrowScale(); out << "Begin " << MARK << " " << Name() << "\n"; MinGS(out); out << MARK << " " << n << "\n"; for (int i = 0; i < n; i++) { out << x[i] << " " << y[i] << "\n"; } out << n << " " << Name() << "\n"; out << MARK << " " << arrow_scale << "\n"; out << "End\n\n"; return out.good(); }
void CreateOpenSplineFunc::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"); ArrowOpenBSpline* openspline = new ArrowOpenBSpline(x, y, npts, aVar->Head(), aVar->Tail(), _ed->GetViewer()->GetMagnification(), stdgraphic); if (brVar != nil) openspline->SetBrush(brVar->GetBrush()); if (patVar != nil) openspline->SetPattern(patVar->GetPattern()); if (colVar != nil) { openspline->FillBg(!colVar->GetBgColor()->None()); openspline->SetColors(colVar->GetFgColor(), colVar->GetBgColor()); } openspline->SetTransformer(rel); Unref(rel); ArrowSplineOvComp* comp = new ArrowSplineOvComp(openspline); comp->SetAttributeList(al); if (PasteModeFunc::paste_mode()==0) cmd = new PasteCmd(_ed, new Clipboard(comp)); ComValue compval(new OverlayViewRef(comp), symbol_add("ArrowSplineComp")); push_stack(compval); execute_log(cmd); } else push_stack(ComValue::nullval()); Unref(al); }
Command* ArrowSplineView::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)) { GrowingVertices* gv = (GrowingVertices*) dm->GetRubberband(); Coord* x, *y; int n; gv->GetCurrent(x, y, n); if (n > 2 || x[0] != x[1] || y[0] != y[1]) { 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(); } ArrowOpenBSpline* aml = new ArrowOpenBSpline( x, y, n, aVar->Head(), aVar->Tail(), dm->GetViewer()->GetMagnification(), stdgraphic ); if (brVar != nil) aml->SetBrush(brVar->GetBrush()); if (patVar != nil) aml->SetPattern(patVar->GetPattern()); if (colVar != nil) { aml->SetColors(colVar->GetFgColor(), colVar->GetBgColor()); } aml->SetTransformer(rel); Unref(rel); cmd = new PasteCmd(ed, new Clipboard(new ArrowSplineComp(aml))); } delete x; delete y; } else if (tool->IsA(RESHAPE_TOOL)) { GrowingVertices* gv = (GrowingVertices*) dm->GetRubberband(); Coord* x, *y; int n, pt; gv->RemoveVertex(); gv->GetCurrent(x, y, n, pt); if (rel != nil) { rel = new Transformer(rel); rel->Invert(); } ArrowOpenBSpline* orig = GetArrowSplineComp()->GetArrowOpenBSpline(); ArrowOpenBSpline* aml = new ArrowOpenBSpline( x, y, n, orig->Head(), orig->Tail(), dm->GetViewer()->GetMagnification(), GetGraphic() ); delete x; delete y; aml->SetTransformer(rel); Unref(rel); cmd = new ReplaceCmd(ed, new ArrowSplineComp(aml)); } else { cmd = SplineView::InterpretManipulator(m); } return cmd; }
void ArrowSplineComp::Write (ostream& out) { SplineComp::Write(out); ArrowOpenBSpline* as = GetArrowOpenBSpline(); out << as->Head() << " " << as->Tail() << " " << as->ArrowScale() << " "; }