Esempio n. 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);
}
NS_IMETHODIMP nsHTMLSelectOptionAccessible::DoAction(PRUint8 index)
{
  if (index == eAction_Select) {   // default action
    nsCOMPtr<nsIDOMHTMLOptionElement> newHTMLOption(do_QueryInterface(mDOMNode));
    if (!newHTMLOption) 
      return NS_ERROR_FAILURE;
    // Clear old selection
    nsCOMPtr<nsIDOMNode> oldHTMLOptionNode, selectNode;
    nsCOMPtr<nsIAccessible> parent(GetParent());
    nsCOMPtr<nsIAccessNode> accessNode(do_QueryInterface(parent));
    NS_ASSERTION(accessNode, "Unable to QI to nsIAccessNode");
    accessNode->GetDOMNode(getter_AddRefs(selectNode));
    GetFocusedOptionNode(selectNode, getter_AddRefs(oldHTMLOptionNode));
    nsCOMPtr<nsIDOMHTMLOptionElement> oldHTMLOption(do_QueryInterface(oldHTMLOptionNode));
    if (oldHTMLOption)
      oldHTMLOption->SetSelected(PR_FALSE);
    // Set new selection
    newHTMLOption->SetSelected(PR_TRUE);

    // If combo box, and open, close it
    // First, get the <select> widgets list control frame
    nsCOMPtr<nsIDOMNode> testSelectNode;
    nsCOMPtr<nsIDOMNode> thisNode(do_QueryInterface(mDOMNode));
    do {
      thisNode->GetParentNode(getter_AddRefs(testSelectNode));
      nsCOMPtr<nsIDOMHTMLSelectElement> selectControl(do_QueryInterface(testSelectNode));
      if (selectControl)
        break;
      thisNode = testSelectNode;
    } while (testSelectNode);

    nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(mWeakShell));
    nsCOMPtr<nsIContent> selectContent(do_QueryInterface(testSelectNode));
    nsCOMPtr<nsIDOMHTMLOptionElement> option(do_QueryInterface(mDOMNode));

    if (!testSelectNode || !selectContent || !presShell || !option) 
      return NS_ERROR_FAILURE;

    nsIFrame *selectFrame = presShell->GetPrimaryFrameFor(selectContent);
    nsIComboboxControlFrame *comboBoxFrame = do_QueryFrame(selectFrame);
    if (comboBoxFrame) {
      nsIFrame *listFrame = comboBoxFrame->GetDropDown();
      if (comboBoxFrame->IsDroppedDown() && listFrame) {
        // use this list control frame to roll up the list
        nsIListControlFrame *listControlFrame = do_QueryFrame(listFrame);
        if (listControlFrame) {
          PRInt32 newIndex = 0;
          option->GetIndex(&newIndex);
          listControlFrame->ComboboxFinish(newIndex);
        }
      }
    }
    return NS_OK;
  }

  return NS_ERROR_INVALID_ARG;
}
Esempio n. 3
0
void CQPlotSubwidget::selectPlotItem(CPlotItem *item)
{
  CQPlotEditWidget *current = static_cast< CQPlotEditWidget * >(mpStack->currentWidget());

  if (current == NULL) return;

  if (item != NULL)
    {
      current = selectControl(item->getType());
    }

  if (item == NULL)
    {
      mpStack->setEnabled(false);
    }

  current->setModel(mpDataModel->getModel());
  current->LoadFromCurveSpec(item);
  pdelete(mLastItem);

  if (item != NULL)
    mLastItem = new CPlotItem(*item, NO_PARENT);
}
Esempio n. 4
0
void MapTool::
buttonCallback(int buttonSlotIndex,
               Vrui::InputDevice::ButtonCallbackData* cbData)
{
statsMan.start(StatsManager::EDITLINE);

    Geometry::Point<double,3> pos = getPosition();
    pos        = crusta->mapToUnscaledGlobe(pos);

    Shape*& curShape = crusta->getMapManager()->getActiveShape(toolId);

    if (cbData->newButtonState)
    {
        if (buttonSlotIndex==0)
        {
            switch (mode)
            {
                case MODE_IDLE:
                {
                    createShape(curShape, curControl, pos);
                    crusta->getMapManager()->updateActiveShape(toolId);
                    mode = MODE_DRAGGING;
                    break;
                }

                case MODE_SELECTING_CONTROL:
                {
                    selectControl(pos);
                    addControlPoint(curShape, curControl, pos);
                    mode = MODE_DRAGGING;
                    break;
                }

                case MODE_SELECTING_SHAPE:
                {
                    if (curShape != NULL)
                    {
                        deleteShape(curShape, curControl);
                    }
                    break;
                }

                default:
                    break;
            }
        }
        else
        {
            switch (mode)
            {
                case MODE_DRAGGING:
                {
                    removeControl(curShape, curControl);
                    //destroy empty shapes
                    if (curShape->getControlPoints().size()==0)
                    {
                        deleteShape(curShape, curControl);
                        mode = MODE_IDLE;
                    }
                    else
                        mode = MODE_SELECTING_CONTROL;
                    break;
                }

                case MODE_IDLE:
                case MODE_SELECTING_CONTROL:
                {
                    selectShape(pos);
                    mode = MODE_SELECTING_SHAPE;
                   break;
                }

                default:
                    break;
            }
        }
    }
    else
    {
        if (buttonSlotIndex==0)
        {
            switch (mode)
            {
                case MODE_DRAGGING:
                {
                    mode = MODE_SELECTING_CONTROL;
                    break;
                }

                default:
                    break;
            }
        }
        else
        {
            switch (mode)
            {
                case MODE_SELECTING_SHAPE:
                {
                    if (curShape != NULL)
                    {
                        mode = MODE_SELECTING_CONTROL;
                    }
                    else
                    {
                        mode = MODE_IDLE;
                    }
                    break;
                }

                default:
                    break;
            }
        }
    }

statsMan.stop(StatsManager::EDITLINE);
}