AIS_Manipulator unresponsive (7.9)

could have sworn this worked before upgrading to 7.9.0...

I've got a problem with AIS_Manipulator::HasActiveMode() never returning true...

Implementing AIS_Manipulator as:

void Ccanvas::showManipulator(CCutShape *selection)
{
    if (m_Manipulator->IsAttached())
        m_Manipulator->Detach();
     AIS_Manipulator::OptionsForAttach anOptions;
     anOptions.SetAdjustPosition(true);
     anOptions.SetAdjustSize(false);
     anOptions.SetEnableModes(true);
   // m_Manipulator->SetModeActivationOnDetection(true);
    m_Manipulator->Attach (selection, anOptions);
     //done internally
    //m_Manipulator->EnableMode(AIS_MM_Translation);
    //m_Manipulator->EnableMode(AIS_MM_Rotation);

    _context->Display(m_Manipulator, true);
}

then corresponding calls in MouseEvent/MouseMove:

void Ccanvas::mousePressEvent(QMouseEvent* event)
{

    if (event->button() == Qt::LeftButton)
    {
        // Save the current mouse coordinate in min.
        m_mouseLDown.viewx = x;
        m_mouseLDown.viewy = y;
        _view->Convert(m_mouseLDown.viewx, m_mouseLDown.viewy, m_mouseLDown.canvasx, m_mouseLDown.canvasy, m_mouseLDown.canvasz);

        if (m_Manipulator->HasActiveMode())
        {
            m_Manipulator->StartTransform (x, y, _view);
        }
        update();
    }

}

//--------------------------------------------------------------------------------------
void Ccanvas::mouseMoveEvent(QMouseEvent* event)
{
    double x = event->position().x();
    double y = event->position().y();

    if (m_Manipulator->HasActiveMode())
    {
        m_Manipulator->Transform(x, y, _view);
        _view->Redraw();
    }
    update();
}

Chasing into the source code, I can see [myCurrentMode] is set perpetually to AIS_MM_None, and I can't find where its set to anything else?

Can anyone sanity check this for me, sure I must be doing something stupid here?

gkv311 n's picture

If you are using AIS_ViewController then it is better relying on its logic handling dragging events. For this you need just enable AIS_Manipulator::SetModeActivationOnDetection(true) automatic detection mechanism and remove any AIS_Manipulator::StartTransform()/AIS_Manipulator::Transform() from your code. All you need is just attaching manipulator and handle detaching:

    Handle(AIS_Shape) aShape = new AIS_Shape (aBox);
    myContext->Display (aShape, AIS_Shaded, 0, false);

    Handle(AIS_Manipulator) aManip = new AIS_Manipulator();
    aManip->SetModeActivationOnDetection(true);
    aManip->Attach(aShape);
Mat M's picture

Oh, it gets much stranger than that!

Neither code would work - just completely unresponsive. I had a bit of a Eureka moment: turning off automatic highlights cripples the manipulator!

_context->SetAutomaticHilight(false);

Is there any workaround for this - I don't particularly want automatic hilighting because its messy, but I do want a manipulator?

The SetModeActivationOnDetection() mode is painful: I ended up moving and rotating my shape all over the place by accident, just by being in the wrong place at the wrong time!

Daniel Duesentrieb's picture

The SetModeActivationOnDetection() mode is painful: I ended up moving and rotating my shape all over the place by accident, just by being in the wrong place at the wrong time!

Same here

gkv311 n's picture

The SetModeActivationOnDetection() mode is painful: I ended up moving and rotating my shape all over the place by accident, just by being in the wrong place at the wrong time!

I don't quite understand what is exactly wrong with SetModeActivationOnDetection() and how not using it may avoid issues with AIS_Manipulator. Do you see some bugs or want another behavior of manipulator (which one?)?

Mat M's picture

There are two issues here:
1. The manipulator just doesn't work unless automatic highlights are enabled. This, for me, is a bug
2. Automatic Detection is incredibly "trigger happy" : it's too easy to perform unwanted translations just by navigating around. I, personally, don't class this as a bug specifically, but it's just not useful for my particular application (especially where my objects are small in comparison to the manipulator)

gkv311 n's picture
  1. The manipulator just doesn't work unless automatic highlights are enabled. This, for me, is a bug

Manipulator is just another interactive object that implements presentation and selection mechanisms. Only through detection mechanism object may understand that mouse is currently over rotation/translation/scaling part to activate it. And only by dynamic highlighting user might understand what has been activated. Without visual feedback (like in case of a common touchscreen, where dynamic highlighting is usually impossible) user is much easier to miss and do something unexpected.

  1. Automatic Detection is incredibly "trigger happy" : it's too easy to perform unwanted translations just by navigating around.

In which scenarios you experience unwanted translations and how they could be avoided (are there any suggestions to improve dragging logic?)? Note that AIS_ViewController implements aborting mechanism to revert undesired or accidental changes. When user starts dragging object holding left mouse button, he may click right button to put object back - the similar behavior could be found in other applications like Inkscape.

Mat M's picture

For me a middle-ground approach would be best: let the Automatic Detection routines handle the translation and logic: just activated via mouse button click/drag, as opposed to trigger-happy random mouse scrolling. This way it'd just work like any other 3D cad manipulator. blender is a good example (quite possibly the first time I've ever said that, probably the last :)).

gkv311 n's picture

Sorry, In still don't get from your description what is exactly wrong right now. Could you try formulating the changes in current API or in behavior that would make it better for your problem? Or maybe some step by step description of actions at application level with reaction from AIS level...