void GrStreamFunc::execute() { ComValue convertv(stack_arg_post_eval(0)); if (convertv.object_compview()) { reset_stack(); static StreamNextFunc* snfunc = nil; if (!snfunc) { snfunc = new StreamNextFunc(comterp()); snfunc->funcid(symbol_add("stream")); } AttributeValueList* avl = new AttributeValueList(); Component* comp = ((ComponentView*)convertv.obj_val())->GetSubject(); if (!comp->IsA(OVERLAYS_COMP)) { push_stack(ComValue::nullval()); return; } OverlaysComp* ovcomps = (OverlaysComp*)comp; Iterator it; for(ovcomps->First(it); !ovcomps->Done(it); ovcomps->Next(it)) { OverlayComp* subcomp = (OverlayComp*) ovcomps->GetComp(it); AttributeValue* av = new AttributeValue(new OverlayViewRef(subcomp), subcomp->classid()); avl->Append(av); } ComValue stream(snfunc, avl); stream.stream_mode(-1); // for internal use (use by this func) push_stack(stream); } else { StreamFunc strmfunc(comterp()); strmfunc.exec(funcstate()->nargs(), funcstate()->nkeys(), pedepth()); return; } }
void SelectFunc::execute() { static int all_symid = symbol_add("all"); ComValue all_flagv(stack_key(all_symid)); boolean all_flag = all_flagv.is_true(); static int clear_symid = symbol_add("clear"); ComValue clear_flagv(stack_key(clear_symid)); boolean clear_flag = clear_flagv.is_true(); Selection* sel = _ed->GetViewer()->GetSelection(); if (clear_flag) { sel->Clear(); unidraw->Update(); reset_stack(); return; } OverlaySelection* newSel = ((OverlayEditor*)_ed)->overlay_kit()->MakeSelection(); Viewer* viewer = _ed->GetViewer(); AttributeValueList* avl = new AttributeValueList(); if (all_flag) { GraphicView* gv = ((OverlayEditor*)_ed)->GetFrame(); Iterator i; int count=0; for (gv->First(i); !gv->Done(i); gv->Next(i)) { GraphicView* subgv = gv->GetView(i); newSel->Append(subgv); OverlayComp* comp = (OverlayComp*)subgv->GetGraphicComp(); ComValue* compval = new ComValue(new OverlayViewRef(comp), comp->classid()); avl->Append(compval); } } else if (nargs()==0) { Iterator i; int count=0; for (sel->First(i); !sel->Done(i); sel->Next(i)) { GraphicView* grview = sel->GetView(i); OverlayComp* comp = grview ? (OverlayComp*)grview->GetSubject() : nil; ComValue* compval = comp ? new ComValue(new OverlayViewRef(comp), comp->classid()) : nil; if (compval) { avl->Append(compval); } delete newSel; newSel = nil; } } else { for (int i=0; i<nargsfixed(); i++) { ComValue& obj = stack_arg(i); if (obj.object_compview()) { ComponentView* comview = (ComponentView*)obj.obj_val(); OverlayComp* comp = (OverlayComp*)comview->GetSubject(); if (comp) { GraphicView* view = comp->FindView(viewer); if (view) { newSel->Append(view); ComValue* compval = new ComValue(new OverlayViewRef(comp), comp->classid()); avl->Append(compval); } } } else if (obj.is_array()) { Iterator it; AttributeValueList* al = obj.array_val(); al->First(it); while (!al->Done(it)) { if (al->GetAttrVal(it)->object_compview()) { ComponentView* comview = (ComponentView*)al->GetAttrVal(it)->obj_val(); OverlayComp* comp = (OverlayComp*)comview->GetSubject(); if (comp) { GraphicView* view = comp->FindView(viewer); if (view) { newSel->Append(view); ComValue* compval = new ComValue(new OverlayViewRef(comp), comp->classid()); avl->Append(compval); } } } al->Next(it); } } } } if (newSel){ sel->Clear(); delete sel; _ed->SetSelection(newSel); newSel->Update(viewer); unidraw->Update(); } reset_stack(); ComValue retval(avl); push_stack(retval); }