本文整理汇总了C++中Selection::First方法的典型用法代码示例。如果您正苦于以下问题:C++ Selection::First方法的具体用法?C++ Selection::First怎么用?C++ Selection::First使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Selection
的用法示例。
在下文中一共展示了Selection::First方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Execute
void BackCmd::Execute () {
Clipboard* cb = GetClipboard();
Editor* ed = GetEditor();
if (cb == nil) {
Selection* s = ed->GetSelection();
if (s->IsEmpty()) {
return;
}
SetClipboard(cb = new Clipboard);
GraphicView* views = ed->GetViewer()->GetGraphicView();
s->Sort(views);
Iterator i;
for (s->First(i); !s->Done(i); s->Next(i)) {
s->GetView(i)->Interpret(this);
}
} else {
Clipboard* oldcb = cb;
SetClipboard(cb = new Clipboard);
Iterator i;
for (oldcb->First(i); !oldcb->Done(i); oldcb->Next(i)) {
oldcb->GetComp(i)->Interpret(this);
}
delete oldcb;
}
if (!cb->IsEmpty()) {
ed->GetComponent()->Interpret(this);
}
}
示例2: CreateManipulator
Manipulator* AttributeTool::CreateManipulator (
Viewer* v, Event& e, Transformer* rel
) {
Manipulator* m = nil;
GraphicView* views = v->GetGraphicView();
Selection* s = v->GetSelection(), *newSel;
newSel = views->ViewIntersecting(e.x-SLOP, e.y-SLOP, e.x+SLOP, e.y+SLOP);
if (e.shift) {
Localize(s, v);
} else {
s->Clear();
}
if (newSel->IsEmpty()) { // do nothing
} else { // else user selected object directly
s->Exclusive(newSel);
}
delete newSel;
if (s->Number() == 1) {
Iterator i;
s->First(i);
GraphicView* view = s->GetView(i);
if (view->IsA(OVERLAY_VIEW)) {
((OverlayEditor*)v->GetEditor())->MouseDocObservable()->textvalue("");
((OverlayEditor*)v->GetEditor())->AttrEdit(((OverlayView*)view)->GetOverlayComp());
((OverlayEditor*)v->GetEditor())->MouseDocObservable()->textvalue(OverlayKit::mouse_attr);
}
}
return m;
}
示例3: CreateManipulator
Manipulator* TabTool::CreateManipulator (
Viewer* v, Event& e, Transformer* rel
) {
Iterator i;
Selection* s = v->GetSelection();
s->First(i);
GraphicView* gv = s->GetView(i);
return gv->CreateManipulator(v, e, rel, this);
}
示例4: InterpretManipulator
Command* ScaleTool::InterpretManipulator (Manipulator* m) {
Selection* s;
Command* cmd = nil;
Iterator i;
if (m != nil) {
s = m->GetViewer()->GetSelection();
s->First(i);
cmd = s->GetView(i)->InterpretManipulator(m);
}
return cmd;
}
示例5: ComputeViewPath
void ComputeViewPath (Event& e, GraphicView* views, Selection* s){
Selection* newSel =
views->ViewIntersecting(e.x-SLOP, e.y-SLOP, e.x+SLOP, e.y+SLOP);
Iterator i;
if (newSel != nil) {
for (newSel->First(i); !newSel->Done(i); newSel->Next(i)) {
GraphicView* gv = newSel->GetView(i);
if (gv != nil) {
s->Append(gv);
ComputeViewPath(e, gv, s);
}
}
delete newSel;
}
}
示例6: InterpretManipulator
Command* MoveTool::InterpretManipulator (Manipulator* m) {
Selection* s;
Command* cmd = nil;
Iterator i;
GraphicView* gv;
if (m != nil) {
s = m->GetViewer()->GetSelection();
s->First(i);
gv = s->GetView(i);
if (s->Number() > 1) {
cmd = gv->GraphicView::InterpretManipulator(m);
} else {
cmd = gv->InterpretManipulator(m);
}
}
return cmd;
}
示例7: Execute
void AlignToGridCmd::Execute () {
Selection* s = _editor->GetSelection();
if (!s->IsEmpty()) {
Clipboard* cb = GetClipboard();
Iterator i;
if (cb == nil) {
for (s->First(i); !s->Done(i); s->Next(i)) {
s->GetView(i)->Interpret(this);
}
SetClipboard(cb = new Clipboard);
cb->Init(s);
} else {
for (cb->First(i); !cb->Done(i); cb->Next(i)) {
Move(cb->GetComp(i));
}
}
unidraw->Update();
}
}
示例8: Export
boolean GraphExportCmd::Export (const char* pathname) {
Editor* editor = GetEditor();
Selection* s = editor->GetSelection();
GraphIdrawComp* real_top = (GraphIdrawComp*)editor->GetComponent();
boolean ok = false;
char* old_format = NULL;
boolean empty = s->IsEmpty();
GraphIdrawComp* false_top = new GraphIdrawComp();
Iterator i;
empty ? real_top->First(i) : s->First(i);
while (empty ? !real_top->Done(i) : !s->Done(i)) {
if (chooser_->idraw_format() || chooser_->postscript_format()) {
OverlayComp* oc = empty
? new OverlayComp(real_top->GetComp(i)->GetGraphic()->Copy())
: new OverlayComp(s->GetView(i)->GetGraphicComp()->GetGraphic()->Copy());
false_top->Append(oc);
} else {
OverlayComp* oc = empty
? (OverlayComp*)real_top->GetComp(i)->Copy()
: (OverlayComp*)s->GetView(i)->GetGraphicComp()->Copy();
false_top->Append(oc);
}
empty ? real_top->Next(i) : s->Next(i);
}
OverlayPS* ovpsv;
if (chooser_->idraw_format() || chooser_->postscript_format())
ovpsv = (OverlayPS*) false_top->Create(POSTSCRIPT_VIEW);
else {
ovpsv = (OverlayPS*) false_top->Create(SCRIPT_VIEW);
if(strcmp(chooser_->format(), "dot")==0) {
old_format = OverlayScript::format() ? strnew(OverlayScript::format()) : NULL;
OverlayScript::format("dot");
}
}
if (ovpsv != nil) {
filebuf fbuf;
char* tmpfilename;
if (chooser_->to_printer()) {
tmpfilename = tmpnam(nil);
false_top->SetPathName(tmpfilename);
ok = fbuf.open(tmpfilename, output) != 0;
} else {
ok = fbuf.open(pathname, output) != 0;
}
if (ok) {
ostream out(&fbuf);
false_top->Attach(ovpsv);
ovpsv->SetCommand(this);
if (!chooser_->idraw_format() && !chooser_->postscript_format())
((GraphIdrawScript*)ovpsv)->SetByPathnameFlag(chooser_->by_pathname_flag());
ovpsv->Update();
ok = ovpsv->Emit(out);
fbuf.close();
if (chooser_->to_printer()) {
char cmd[CHARBUFSIZE];
if (strstr(pathname, "%s")) {
char buf[CHARBUFSIZE];
sprintf(buf, pathname, tmpfilename);
sprintf(cmd, "(%s;rm %s)&", buf, tmpfilename);
} else
sprintf(cmd, "(%s %s;rm %s)&", pathname, tmpfilename, tmpfilename);
ok = system(cmd) == 0;
}
}
delete ovpsv;
}
delete false_top;
if (old_format) {
OverlayScript::format(old_format);
delete old_format;
}
return ok;
}
示例9: Reserve
void LinkSelection::Reserve() {
#if 0
fprintf(stderr, "LinkSelection::Reserve\n");
#endif
CompIdTable* table = ((DrawServ*)unidraw)->compidtable();
/* clear anything that was in the previous selection, but not in this one */
Selection* lastsel = _editor->last_selection();
if (!lastsel) return;
Iterator lt;
lastsel->First(lt);
Iterator it;
while (!lastsel->Done(lt)) {
First(it);
boolean match = false;
while (!Done(it) && !match) {
if(GetView(it)==lastsel->GetView(lt))
match = true;
else
Next(it);
}
if (!match) {
OverlayComp* comp = ((OverlayView*)lastsel->GetView(lt))->GetOverlayComp();
void* ptr = nil;
table->find(ptr, (void*)comp);
if (ptr) {
GraphicId* grid = (GraphicId*)ptr;
grid->selected(NotSelected);
((DrawServ*)unidraw)->grid_message(grid);
}
}
lastsel->Remove(lt);
}
/* remove anything from selection that has a remote selector */
First(it);
while (!Done(it)) {
int removed = false;
OverlayView* view = GetView(it);
OverlayComp* comp = view ? view->GetOverlayComp() : nil;
void* ptr = nil;
table->find(ptr, (void*)comp);
if (ptr) {
GraphicId* grid = (GraphicId*)ptr;
if (grid->selector() &&
((DrawServ*)unidraw)->sessionid()!=grid->selector()) {
Remove(it);
removed = true;
if (grid->selected()==NotSelected) {
/* make a request to select this in the future */
grid->selected(WaitingToBeSelected);
((DrawServ*)unidraw)->grid_message(grid);
}
} else {
if (grid->selected()!=LocallySelected) {
grid->selected(LocallySelected);
((DrawServ*)unidraw)->grid_message(grid);
}
}
}
if (!removed)
Next(it);
}
/* store copy of selection */
First(it);
while (!Done(it)) {
lastsel->Append(GetView(it));
Next(it);
}
}
示例10: execute
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);
}