Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AIS_Manipulator issues #230

Closed
pycode74 opened this issue Jan 2, 2025 · 6 comments
Closed

AIS_Manipulator issues #230

pycode74 opened this issue Jan 2, 2025 · 6 comments
Assignees
Labels
0. New The issue was created, but not updated by maintainer. Waiting for updates labels and categories 1. Visualization AIS cases, animation, ray-tracing, viewer integration into external software and etc... 2. Bug Something isn't working

Comments

@pycode74
Copy link

pycode74 commented Jan 2, 2025

Description

I am trying to use the AIS_Manipulator to select and perform translations of a box (created with BRepPrimAPI_MakeBox).

The translation works fine the first time, but somethings seems to break after that.

Expected Behavior

  • I click on the box to select it
  • The manipulator appears
  • I click and drag one of the manipulators arrows to translate the box
  • I release the mouse
  • I can click on the box to select it again
  • The manipulator appears
  • I click and drag one of the manipulators arrows to translate the box

Actual Behavior

  • I click on the box to select it
  • The manipulator appears
  • I click and drag one of the manipulators arrows to translate the box (works fine)
  • I release the mouse
  • I cannot re select the box again

Sample Code or DRAW Tcl Script

void ViewerWidget::init()
{
    // ...
    gp_Ax2 anAxisManipulator;
    myManipulator = new AIS_Manipulator(anAxisManipulator);
    myManipulator->SetPart(AIS_ManipulatorMode::AIS_MM_Translation, Standard_True);
    myManipulator->SetPart(AIS_ManipulatorMode::AIS_MM_Rotation, Standard_False);
    myManipulator->SetPart(AIS_ManipulatorMode::AIS_MM_Scaling, Standard_False);
    myManipulator->EnableMode(AIS_ManipulatorMode::AIS_MM_Translation);
    // ...
}

void ViewerWidget::mousePressEvent(QMouseEvent* event)
{
    int x = event->pos().x();
    int y = event->pos().y();

    myContext->MoveTo(x, y, myView, Standard_True);

    if (event->button() == Qt::LeftButton) {
        myContext->SelectDetected();
        Handle(AIS_InteractiveObject) selected = myContext->FirstSelectedObject();
        if (selected) {

            myManipulator->Attach(selected);
            myContext->Display(myManipulator, Standard_True);

            if (myManipulator->HasActiveMode()) {
                myManipulator->StartTransform(x, y, myView);
            }
        }
        else {
            if (myContext->IsDisplayed(myManipulator)) {
                myContext->Erase(myManipulator, Standard_True);
            }
        }
    }
}

void ViewerWidget::mouseMoveEvent(QMouseEvent* event)
{
    int x = event->pos().x();
    int y = event->pos().y();

    myContext->MoveTo(x, y, myView, Standard_True);

    if (myManipulator->HasActiveMode()) {
        myManipulator->Transform(x, y, myView);
        myView->Redraw();
    }
}

void ViewerWidget::mouseReleaseEvent(QMouseEvent* event)
{
    int x = event->pos().x();
    int y = event->pos().y();

    myContext->MoveTo(x, y, myView, Standard_True);

    if (myManipulator->HasActiveMode()) {
        myManipulator->StopTransform();
        myManipulator->DeactivateCurrentMode();
        myManipulator->Detach();
        myView->Redraw();
    }
}

Operating System

Windows

Compiler

MSVC

Bitness

64-bit

OCCT Version

7.8.2 dev

Additional Files

No response

@pycode74 pycode74 added 0. New The issue was created, but not updated by maintainer. Waiting for updates labels and categories 2. Bug Something isn't working labels Jan 2, 2025
@dpasukhi dpasukhi added the 1. Visualization AIS cases, animation, ray-tracing, viewer integration into external software and etc... label Jan 3, 2025
@dpasukhi
Copy link
Member

dpasukhi commented Jan 3, 2025

Hello, could you please check on latest version (master).

@pycode74
Copy link
Author

pycode74 commented Jan 3, 2025

Hello, could you please check on latest version (master).

This was using the latest master build (7.8.2).

@pycode74
Copy link
Author

Any update on this? Is it reproducible?

@dpasukhi dpasukhi moved this from Todo to Analyzing in Maintenance Jan 28, 2025
@pycode74
Copy link
Author

I have commented out this line, but the problem persists:

//myManipulator->DeactivateCurrentMode();

@mzernova
Copy link

Hello @pycode74,

Try modifying your code slightly; this should help

void ViewerWidget::mousePressEvent(QMouseEvent* event)
{
  myView->Invalidate();

  int x = event->pos().x();
  int y = event->pos().y();

  if (event->button() == Qt::LeftButton) {
    myContext->SelectDetected();
    Handle(AIS_InteractiveObject) selected = myContext->FirstSelectedObject();
    if (selected) {

      myManipulator->Attach(selected);
      myContext->Display(myManipulator, Standard_True);

      if (myManipulator->HasActiveMode()) {
        myManipulator->StartTransform(x, y, myView);
      }
    }
    else {
      if (myContext->IsDisplayed(myManipulator)) {
        myContext->Erase(myManipulator, Standard_True);
      }
    }
  }
}

void ViewerWidget::mouseMoveEvent(QMouseEvent* event)
{
  myView->Invalidate();

  int x = event->pos().x();
  int y = event->pos().y();

  if (myManipulator->HasActiveMode()) {
    myManipulator->Transform(x, y, myView);
    myContext->ClearDetected();
    myView->Redraw();
  }
  myContext->MoveTo(x, y, myView, Standard_True);
}

void ViewerWidget::mouseReleaseEvent(QMouseEvent* event)
{
  myView->Invalidate();

  int x = event->pos().x();
  int y = event->pos().y();

  if (myManipulator->HasActiveMode()) {
    myManipulator->StopTransform();
    myManipulator->DeactivateCurrentMode();
    myContext->RecomputeSelectionOnly (myManipulator);
    myManipulator->Detach();
  }
}

@pycode74
Copy link
Author

Thanks @mzernova, it works definitely better.
However, I am losing the object selection (and the highlight) as soon as I start using the manipulator.
Is there a way to fix that?

@Open-Cascade-SAS Open-Cascade-SAS locked and limited conversation to collaborators Jan 29, 2025
@dpasukhi dpasukhi converted this issue into discussion #306 Jan 29, 2025
@github-project-automation github-project-automation bot moved this from Analyzing to Done in Maintenance Jan 29, 2025
@dpasukhi dpasukhi moved this from Done to Closed in Maintenance Jan 29, 2025

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
0. New The issue was created, but not updated by maintainer. Waiting for updates labels and categories 1. Visualization AIS cases, animation, ray-tracing, viewer integration into external software and etc... 2. Bug Something isn't working
Projects
Status: Closed
Development

No branches or pull requests

3 participants