예제 #1
0
Control* NarrowTool::CreateViewEntry (Selection* s, Editor* ed) {
    Control* ctrl = nil;
    Iterator i;

    if (s->Number() >= 1) {
        H_PopupMenu* popup = new H_PopupMenu;
        ctrl = popup;

        s->First(i);
        GraphicComp* kid = s->GetView(i)->GetGraphicComp();
        RecurPopupInclude(ed, popup, kid);
        popup->LockPosition();

        for (;!s->Done(i); s->Next(i)) {
            GraphicView* gv = s->GetView(i);
            GraphicComp* parent = gv->GetGraphicComp();
            if (parent->IsA(SCENE_COMP) || parent->IsA(IGRAPHIC_COMPS)){
                GraphicComp* mykid = nil;
                Iterator j(i);
                s->Next(j);
                if (!s->Done(j)) {
                    mykid = (GraphicComp*) s->GetView(j)->GetGraphicComp();
                }
                NavigateCmd* cmd = new NavigateCmd(ed, false, parent, mykid);
                popup->Include(new CommandItem(GetName(parent), Center, cmd));
            }
        }
    }
    return ctrl;
}
예제 #2
0
Manipulator* ScaleTool::CreateManipulator (
    Viewer* v, Event& e, Transformer* rel
) {
    GraphicView* views = v->GetGraphicView();
    Selection* s = v->GetSelection(), *newSel;
    GraphicView* gv;
    Manipulator* m = nil;
    Iterator i;

    newSel = views->ViewIntersecting(e.x-SLOP, e.y-SLOP, e.x+SLOP, e.y+SLOP);
    if (newSel->IsEmpty()) {
	s->Clear();
    } else {
        newSel->First(i);
	gv = newSel->GetView(i);

	if (s->Includes(gv)) {
            s->Remove(gv);
            s->Prepend(gv);
        } else {
	    s->Clear();
	    s->Append(gv);
	    s->Update();
	}
        m = gv->CreateManipulator(v, e, rel, this);
    }
    delete newSel;
    return m;
}
예제 #3
0
파일: viewer.cpp 프로젝트: PNCG/neuron
void Viewer::Update () {
    Selection* s = GetSelection();
    GraphicView* view = GetGraphicView();
    Component* viewComp = view->GetGraphicComp();
    Component* edComp = _editor->GetComponent();

    if (viewComp != edComp) {
        ComponentView* newView = edComp->Create(ViewCategory());

        if (newView->IsA(GRAPHIC_VIEW)) {
            edComp->Attach(newView);
            newView->Update();
            SetGraphicView((GraphicView*) newView);

        } else {
            delete newView;
        }

    } else {
	s->Hide(this);
        _viewerView->Update();
        GraphicBlock::UpdatePerspective();
	_damage->Repair();
        s->Show(this);
    }
}
예제 #4
0
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;
}
예제 #5
0
파일: link.c 프로젝트: barak/ivtools-cvs
Manipulator* LinkView::CreateLinkCompManip (
    Viewer* v, Event& e, Transformer* rel, Tool* tool
) {
    GraphicView* views = v->GetGraphicView();
    Selection* s = v->GetSelection();
    RubberGroup* rg = new RubberGroup(nil, nil);
    float x, y, tx, ty;
    Coord cx = 0, rad = PIN_RAD, dum1 = 0, dum2 = 0;
    ConnectorView* target = views->ConnectorIntersecting(
        e.x-SLOP, e.y-SLOP, e.x+SLOP, e.y+SLOP
    );

    s->Clear();
    if (target != nil) {
        target->GetConnector()->GetCenter(x, y);
        rel->Transform(x, y, tx, ty);
        e.x = Math::round(tx);
        e.y = Math::round(ty);
    }
    if (rel != nil) {
        rel->Transform(cx, dum1);
        rel->Transform(rad, dum2);
        rad = abs(rad - cx);
    }
    rg->Append(
        new RubberLine(nil, nil, e.x, e.y, e.x, e.y),
        new FixedPin(nil, nil, e.x, e.y, rad),
        new SlidingPin(nil, nil, e.x, e.y, rad, e.x, e.y)
    );
    return new ConnectManip(v, rg, rel, tool);
}
예제 #6
0
파일: manips.c 프로젝트: barak/ivtools-cvs
boolean ConnectManip::Manipulating (Event& e) {
    GraphicView* views = GetViewer()->GetGraphicView();
    Rubberband* r = GetRubberband();
    float cx, cy;

    if (r == nil) {
        return false;
    }

    if (e.eventType == MotionEvent) {
        _target = views->ConnectorIntersecting(
            e.x-SLOP, e.y-SLOP, e.x+SLOP, e.y+SLOP
        );

        if (_target == nil) {
            r->Track(e.x, e.y);

        } else {
            _target->GetGraphic()->GetCenter(cx, cy);
            r->Track(Math::round(cx), Math::round(cy));
        }

    } else if (e.eventType == UpEvent) {
	r->Erase();
	return false;
    }
    return true;
}
예제 #7
0
Manipulator* ExamineTool::CreateManipulator (
    Viewer* v, Event& e, Transformer* t
){
    GraphicView* views = v->GetGraphicView();
    Selection* s = v->GetSelection();
    _selPath = new Selection;
    Manipulator* m = nil;

    s->Clear();
    ComputeViewPath(e, views, _selPath);
    _shift = e.shift_is_down();

    if (!_selPath->IsEmpty()) {
        Iterator i;
        _selPath->First(i);
	GraphicView* gv = _selPath->GetView(i);
        s->Append(gv);
        s->Update();
        _selPath->Last(i);
	gv = _selPath->GetView(i);
        
        m = gv->CreateManipulator(v, e, t, this);
    }
    delete _selPath;
    return m;
}
예제 #8
0
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);
}
예제 #9
0
void Selection::Hide (Viewer* viewer) {
    Iterator i;
    
    for (First(i); !Done(i); Next(i)) {
        GraphicView* view = GetView(i);

        if (viewer == nil || view->GetViewer() == viewer) {
            view->EraseHandles();
        }
    }
}
예제 #10
0
void OverlaysComp::SelectViewsOf (OverlayComp* comp, Editor* ed) {
    Selection* s = ed->GetSelection();
    s->Clear();
    Viewer* viewer;

    for (int i = 0; (viewer = ed->GetViewer(i)) != nil; ++i) {
        GraphicView* views = viewer->GetGraphicView();
        GraphicView* view = views->GetGraphicView(comp);

        if (view != nil) s->Append(view);
    }
}
예제 #11
0
void Selection::Clear (Viewer* viewer) {
    Iterator i;
    First(i);

    while (!Done(i)) {
        GraphicView* view = GetView(i);

        if (viewer == nil || view->GetViewer() == viewer) {
            view->EraseHandles();
        }
        Remove(i);
    }
}
예제 #12
0
파일: select.cpp 프로젝트: PNCG/neuron
void SelectTool::Localize (Selection* s, Viewer* v) {
    Iterator i;

    for (s->First(i); !s->Done(i);) {
        GraphicView* view = s->GetView(i);

        if (view->GetViewer() != v) {
            s->Remove(i);
            view->EraseHandles();

        } else {
            s->Next(i);
        }
    }
}
예제 #13
0
파일: viewer.cpp 프로젝트: PNCG/neuron
void ViewerGraphic::Update () {
    GraphicComp* parent = (GraphicComp*) _view->GetGraphicComp()->GetParent();

    if (parent != nil) {
        FullGraphic gs;
        totalGSGraphic(parent->GetGraphic(), gs);

        if (Different(this, &gs)) {
            Damage* damage = _view->GetViewer()->GetDamage();
            
            damage->Incur(this);
            *(Graphic*)this = *(Graphic*)(&gs);
            damage->Incur(this);
        }
    }
}
예제 #14
0
void OverlaysComp::SelectClipboard (Clipboard* cb, Editor* ed) {
    Selection* s = ed->GetSelection();
    s->Clear();
    Viewer* viewer;
    Iterator i;

    for (int j = 0; (viewer = ed->GetViewer(j)) != nil; ++j) {
        for (cb->First(i); !cb->Done(i); cb->Next(i)) {
            GraphicView* views = viewer->GetGraphicView();
            GraphicView* view = views->GetGraphicView(cb->GetComp(i));

            if (view != nil) s->Append(view);
        }
    }
    ((OverlaySelection*)s)->Reserve();
}
예제 #15
0
파일: select.cpp 프로젝트: PNCG/neuron
Command* SelectTool::InterpretManipulator (Manipulator* m) {
    DragManip* dm = (DragManip*) m;
    Viewer* viewer = dm->GetViewer();
    GraphicView* views = viewer->GetGraphicView();
    Selection* s = viewer->GetSelection();
    RubberRect* rr = (RubberRect*) dm->GetRubberband();
    Selection* newSel;
    Coord l, b, r, t;

    rr->GetCurrent(l, b, r, t);
    newSel = views->ViewsWithin(l, b, r, t);
    s->Exclusive(newSel);
    delete newSel;

    return nil;
}
예제 #16
0
void Selection::Exclusive (Selection* s) {
    Iterator i;
    GraphicView* gv;

    for (s->First(i); !s->Done(i); s->Next(i)) {
        gv = GetView(i);

	if (Includes(gv)) {
	    Remove(gv);
            gv->EraseHandles();
	} else {
	    Append(gv);
	}
    }
    Update();
}
예제 #17
0
    TEST_FIXTURE(InteractorTestFixture, TaskSelection_MouseRightMove)
    {
        MyDoorway platform;
        LibraryScope libraryScope(cout, &platform);
        libraryScope.set_default_fonts_path(TESTLIB_FONTS_PATH);
        SpDocument spDoc( new Document(libraryScope) );
        spDoc->create_empty();
        GraphicView* pView = Injector::inject_SimpleView(libraryScope, spDoc.get());
        SpInteractor pIntor(Injector::inject_Interactor(libraryScope, WpDocument(spDoc), pView, NULL));
        pView->set_interactor(pIntor.get());
        MyTaskSelection task(pIntor.get());
        task.init_task();
        task.process_event( Event(Event::k_mouse_right_down, 10, 33, k_mouse_right) );

        task.process_event( Event(Event::k_mouse_move, 11, 35, k_mouse_right) );
        CHECK( task.is_waiting_for_point_2_right() == true );
    }
예제 #18
0
    TEST_FIXTURE(InteractorTestFixture, TaskSelection_Creation)
    {
        MyDoorway platform;
        LibraryScope libraryScope(cout, &platform);
        libraryScope.set_default_fonts_path(TESTLIB_FONTS_PATH);
        SpDocument spDoc( new Document(libraryScope) );
        spDoc->create_empty();
        GraphicView* pView = Injector::inject_SimpleView(libraryScope, spDoc.get());
        SpInteractor pIntor(Injector::inject_Interactor(libraryScope, WpDocument(spDoc), pView, NULL));
        pView->set_interactor(pIntor.get());
        MyTaskSelection task(pIntor.get());
        task.init_task();

        CHECK( task.is_waiting_for_first_point() == true );
        CHECK( task.first_point_x() == 0 );
        CHECK( task.first_point_y() == 0 );
    }
예제 #19
0
Manipulator* ConnectTool::CreateManipulator (
    Viewer* v, Event& e, Transformer* rel
) {
    GraphicView* views = v->GetGraphicView();
    Selection* s = v->GetSelection();
    Manipulator* m = nil;

    _source = views->ConnectorIntersecting(
        e.x-SLOP, e.y-SLOP, e.x+SLOP, e.y+SLOP
    );
    if (_source == nil) {
	s->Clear();
    } else {
        m = _source->CreateManipulator(v, e, rel, this);
    }
    return m;
}
예제 #20
0
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;
}
예제 #21
0
파일: link.c 프로젝트: barak/ivtools-cvs
Command* LinkView::InterpLinkCompManip (Manipulator* m) {
    Viewer* v = m->GetViewer();
    Editor* ed = v->GetEditor();
    GraphicView* views = v->GetGraphicView();
    BrushVar* brVar = (BrushVar*) ed->GetState("BrushVar");
    ConnectManip* cm = (ConnectManip*) m;
    Transformer* rel = cm->GetTransformer();
    RubberGroup* rg = (RubberGroup*) cm->GetRubberband();
    RubberLine* rl = (RubberLine*) rg->First();
    Coord x0, y0, x1, y1;
    Connector* c1, *c2;
    ConnectorView* target1, *target2;
    MacroCmd* macro = new MacroCmd(ed);
    
    rl->GetCurrent(x0, y0, x1, y1);
    if (rel != nil) {
        rel = new Transformer(rel);
        rel->Invert();
    }

    Graphic* pg = GetGraphicComp()->GetGraphic();
    Line* line = new Line(x0, y0, x1, y1, pg);

    if (brVar != nil) line->SetBrush(brVar->GetBrush());
    line->SetTransformer(rel);
    Unref(rel);
    LinkComp* linkComp = NewSubject(line);
    linkComp->GetConnectors(c1, c2);

    macro->Append(new PasteCmd(ed, new Clipboard(linkComp)));
    target1 = views->ConnectorIntersecting(x0-SLOP, y0-SLOP, x0+SLOP, y0+SLOP);
    target2 = views->ConnectorIntersecting(x1-SLOP, y1-SLOP, x1+SLOP, y1+SLOP);

    if (target1 != nil) {
        macro->Append(new ConnectCmd(ed, c1, target1->GetConnector()));
    }
    if (target2 != nil) {
        macro->Append(new ConnectCmd(ed, c2, target2->GetConnector()));
    }
    return macro;
}
예제 #22
0
파일: select.cpp 프로젝트: PNCG/neuron
Manipulator* SelectTool::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()) {		// select w/RubberRect if nothing hit
	m = new DragManip(v, new RubberRect(nil,nil, e.x,e.y,e.x,e.y), rel);
    } else {				// else user selected object directly
	s->Exclusive(newSel);
    }
    delete newSel;
    return m;
}
예제 #23
0
    TEST_FIXTURE(InteractorTestFixture, TaskSelection_MouseRightUp)
    {
        MyDoorway platform;
        LibraryScope libraryScope(cout, &platform);
        libraryScope.set_default_fonts_path(TESTLIB_FONTS_PATH);
        SpDocument spDoc( new Document(libraryScope) );
        spDoc->create_empty();
        GraphicView* pView = Injector::inject_SimpleView(libraryScope, spDoc.get());
        MyInteractor* pIntor = LOMSE_NEW MyInteractor(libraryScope, WpDocument(spDoc), pView);
        SpInteractor sp(pIntor);
        pView->set_interactor(pIntor);
        MyTaskSelection task(pIntor);
        task.init_task();
        task.process_event( Event(Event::k_mouse_right_down, 10, 33, k_mouse_right) );
        task.process_event( Event(Event::k_mouse_move, 11, 35, k_mouse_right) );
        CHECK( pIntor->select_object_invoked() == false );

        task.process_event( Event(Event::k_mouse_right_up, 12, 34, k_mouse_right) );
        CHECK( task.is_waiting_for_first_point() == true );
        CHECK( pIntor->select_object_invoked() == true );
        CHECK( pIntor->sel_point_is(10, 33) == true );
    }
예제 #24
0
Control* ExamineTool::CreateInfoEntry (Selection* s, Editor* ed) {
    Control* ctrl = nil;
    Iterator i;

    if (s->Number() > 1) {
        Menu* m = new H_PullrightMenu(new Message("Info...", Center, 2, hfil));
        ctrl = m;

        for (s->First(i); !s->Done(i); s->Next(i)) {
	    GraphicView* view = (GraphicView*) s->GetView(i);
            GraphicComp* comp = view->GetGraphicComp();
            InfoCmd* cmd = new InfoCmd(ed, view);
            m->Include(
                new CommandItem(GetName(comp, _shift, true), Center, cmd)
            );
        }
    } else {
	s->First(i);
	GraphicView* view = (GraphicView*) s->GetView(i);
        ctrl = new CommandItem("Info...", Center, new InfoCmd(ed, view));
    }
    return ctrl;
}
예제 #25
0
void FrameKit::InitViewer () {
    Catalog* catalog = unidraw->GetCatalog();

    const char* page_w = catalog->GetAttribute(page_width_attrib);
    const char* page_h = catalog->GetAttribute(page_height_attrib);
    const char* page_cols = catalog->GetAttribute(page_cols_attrib);
    const char* page_rows = catalog->GetAttribute(page_rows_attrib);
    const char* x_incr = catalog->GetAttribute(grid_x_incr);
    const char* y_incr = catalog->GetAttribute(grid_y_incr);

    GraphicView* view = (GraphicView*)((FrameEditor*)_ed)->_comp->Create(COMPONENT_VIEW);
    ((FrameEditor*)_ed)->_comp->Attach(view);
    view->Update();

    Style* style = Session::instance()->style();
    boolean bookgeom = style->value_is_on("bookgeom");

    float w = bookgeom ? 700 : Math::round(atof(page_w) * ivinches);
    float h = bookgeom ? 906 : Math::round(atof(page_h) * ivinches);
    if (page_cols && page_rows) {
      int ncols = atoi(page_cols);
      int nrows = atoi(page_rows);
      if (ncols>0 && nrows>0) {
	w = ncols;
	h = nrows;
      }
    }

    OverlayPage* page = new OverlayPage(w, h);
    Grid* grid = new Grid(w, h, atof(x_incr), atof(y_incr));
    grid->Visibility(false);

    if (!bookgeom)
	((FrameEditor*)_ed)->_viewer = new FrameViewer(_ed, view, page, grid);
    else 
	((FrameEditor*)_ed)->_viewer = new FrameViewer(_ed, view, page, grid, (int) h+1, (int) w+1, Rotated);
}
예제 #26
0
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);
}