Exemple #1
0
void MapTool::
frame()
{
if (PROJECTION_FAILED)
    return;

statsMan.start(StatsManager::EDITLINE);

    //handle motion
    Geometry::Point<double,3> pos = getPosition();
    pos = crusta->mapToUnscaledGlobe(pos);
    if (pos == prevPosition)
        return;

    switch (mode)
    {
        case MODE_DRAGGING:
        {
            MapManager* mapMan = crusta->getMapManager();
            Shape*& curShape   = mapMan->getActiveShape(toolId);
            assert(curShape != NULL);
///\todo implement a way to check validity of curControl that doesn't suck
            assert(curShape->isValid(curControl));

///\todo HACK: avoid moving control point if projection has failed Vis2010
            float scaleFac = Vrui::getNavigationTransformation().getScaling();
            if (scaleFac*Geometry::dist(pos, curControl.handle->pos) > 5.0)
                return;

            curShape->moveControlPoint(curControl, pos);
            break;
        }

        case MODE_SELECTING_CONTROL:
        {
            Shape*& curShape = crusta->getMapManager()->getActiveShape(toolId);
            if (curShape == NULL)
            {
                curControl = Shape::BAD_ID;
                mode       = MODE_IDLE;
            }
            else
            {
                selectControl(pos);
            }
            break;
        }

        case MODE_SELECTING_SHAPE:
        {
            selectShape(pos);
            break;
        }

        default:
            break;
    }

statsMan.stop(StatsManager::EDITLINE);
}
Exemple #2
0
void MapTool::
selectShape(const Geometry::Point<double,3>& pos)
{
    MapManager* mapMan = crusta->getMapManager();
    Shape*& curShape = mapMan->getActiveShape(toolId);
    Shape*  oldShape = curShape;

    ShapePtrs shapes = getShapes();

    double threshold = 1.0 / Vrui::getNavigationTransformation().getScaling();
    threshold       *= mapMan->getSelectDistance();

    bool noShapeSelected = true;
    for (ShapePtrs::iterator it=shapes.begin(); it!=shapes.end(); ++it)
    {
        double distance;
        Shape::ControlId control = (*it)->select(pos, distance);
        if (control!=Shape::BAD_ID && distance<=threshold)
        {
            curShape        = *it;
            threshold       = distance;
            noShapeSelected = false;
        }
    }

    if (noShapeSelected && curShape!=NULL)
        unselectShape(curShape, curControl);

    //inform the manager that the active shape has changed
    if (curShape != oldShape)
        mapMan->updateActiveShape(toolId);
}
Exemple #3
0
MapTool::
~MapTool()
{
    MapManager* mapMan = crusta->getMapManager();

    Shape*& curShape = mapMan->getActiveShape(toolId);
    if (curShape != NULL)
    {
        unselectShape(curShape, curControl);
        mapMan->updateActiveShape(toolId);
    }

    mapMan->unregisterMappingTool(toolId);
}
Exemple #4
0
void MapTool::
selectControl(const Geometry::Point<double,3>& pos)
{
    MapManager* mapMan = crusta->getMapManager();
    Shape*& curShape   = mapMan->getActiveShape(toolId);
    assert(curShape != NULL);

    curControl = Shape::BAD_ID;

    double distance;
    Shape::ControlId control = curShape->select(pos, distance,
                                         mapMan->getPointSelectionBias());

    if (control == Shape::BAD_ID)
        return;

    double threshold = 1.0 / Vrui::getNavigationTransformation().getScaling();
    threshold       *= mapMan->getSelectDistance();
    if (distance > threshold)
        return;

    curControl = control;
}