Ejemplo n.º 1
0
void GridSpacingCmd::Execute () {
    float xincr, yincr;
    Editor* ed = GetEditor();

    if (_dialog == nil) {
        _dialog = new GridDialog();
    }

    ed->InsertDialog(_dialog);
    bool accepted = _dialog->Accept();
    ed->RemoveDialog(_dialog);

    if (accepted) {
        _dialog->GetValues(xincr, yincr);

        if (xincr != 0.0 && yincr != 0.0) {
	    Viewer* viewer;

	    for (int i = 0; (viewer = ed->GetViewer(i)) != nil; ++i) {
		viewer->GetGrid()->SetSpacing(xincr, yincr);
		viewer->Draw();
	    }
        }
    }
}
Ejemplo n.º 2
0
void AlignToGridCmd::Align (GraphicView* gv, float refx, float refy) {
    MoveData* md = (MoveData*) Recall(gv->GetGraphicComp());

    if (md == nil) {
        Viewer* v = gv->GetViewer();
        Grid* grid = (v == nil) ? nil : v->GetGrid();

        if (grid == nil) {
            return;
        }

        Graphic* g = gv->GetGraphic();
        Transformer t;
        g->Parent()->TotalTransformation(t);
        t.Invert();

        Coord cx = iv26_round(refx);
        Coord cy = iv26_round(refy);

        grid->Constrain(cx, cy);

        float dx, dy, trefx, trefy;

        t.Transform(float(cx), float(cy), dx, dy);
        t.Transform(refx, refy, trefx, trefy);

        dx -= trefx;
        dy -= trefy;
        Store(gv->GetGraphicComp(), new MoveData(dx, dy));

    }
    Move(gv->GetGraphicComp());
}
Ejemplo n.º 3
0
void GridCmd::Execute () {
    Viewer* viewer;

    for (int i = 0; (viewer = GetEditor()->GetViewer(i)) != nil; ++i) {
	Grid* grid = viewer->GetGrid();

	if (grid != nil) grid->Visibility(!grid->IsVisible());
	viewer->Draw();
    }
}