For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

ConvertToGrid ShowGridEcho does not take effect

w d's picture
Forums: 

Hello everyone, I am using occt7.4.0. When testing the sample program ocaf, I rewritten the OCC_3dView :: OnMouseMove process under OCC_3dview.cpp. The code is as follows. The part marked is my modification. I want to implement converttogrid and showgridecho The purpose of the design. In fact, the mark is not displayed. Can you check what is wrong? Or can give a valid example? Thank you all.
 

// Set the background grid
myView-> Viewer ()-> SetGridEcho (Standard_True);
Handle (Graphic3d_AspectMarker3d) aGridAspect = new Graphic3d_AspectMarker3d (Aspect_TOM_PLUS, Quantity_NOC_RED, 50); // Set the pick mark shape
myView-> Viewer ()-> SetGridEcho (aGridAspect); // Enable display of pick marks
Standard_Integer aWidth = 1500, aHeight = 1500, anOffset = 0;
// myView-> Window ()-> Size (aWidth, aHeight);
myView-> Viewer ()-> SetRectangularGridGraphicValues ​​(aWidth, aHeight, anOffset);
myView-> Viewer ()-> ActivateGrid (Aspect_GT_Rectangular, Aspect_GDM_Lines);
myView-> Viewer ()-> SetRectangularGridValues ​​(0, 0, 5, 5, 0);

void OCC_3dView :: OnMouseMove (UINT nFlags, CPoint point)
{
   // =============================== LEFT BUTTON =================== =====
  if (nFlags & MK_LBUTTON)
  {
    if (nFlags & MK_CONTROL)
    {
      // move with MB1 and Control: on the dynamic zooming
      // Do the zoom in function of mouse's coordinates
      myView-> Zoom (myXmax, myYmax, point.x, point.y);
      // save the current mouse coordinate in min
      myXmax = point.x;
      myYmax = point.y;
    }
    else // if (Ctrl)
    {
      const Handle (AIS_InteractiveContext) & aContext = GetDocument ()-> GetAISContext ();
      switch (myCurrentMode)
      {
      case CurAction3d_Nothing:
        myXmax = point.x;
        myYmax = point.y;

        if (nFlags & MK_SHIFT)
          GetDocument ()-> ShiftDragEvent (myXmax, myYmax, 0, myView);
        else
          GetDocument ()-> DragEvent (myXmax, myYmax, 0, myView);

        drawRectangle (myXmin, myYmin, myXmax, myYmax, aContext);

        break;
      case CurAction3d_DynamicZooming:
        myView-> Zoom (myXmax, myYmax, point.x, point.y);
        // save the current mouse coordinate in min \ n ";
        myXmax = point.x;
        myYmax = point.y;
        break;
      case CurAction3d_WindowZooming:
        myXmax = point.x;
        myYmax = point.y;
        drawRectangle (myXmin, myYmin, myXmax, myYmax, aContext);
        break;
      case CurAction3d_DynamicPanning:
        myView-> Pan (point.x-myXmax, myYmax-point.y); // Realize the panning
        myXmax = point.x; myYmax = point.y;
        break;
      case CurAction3d_GlobalPanning: // nothing
        break;
      case CurAction3d_DynamicRotation:
        myView-> Rotation (point.x, point.y);
        myView-> Redraw ();
        break;
      default:
        throw Standard_Failure ("incompatible Current Mode");
        break;
      } // switch (myCurrentMode)
    } // if (nFlags & MK_CONTROL) else
  }
  else if (nFlags & MK_MBUTTON)
  {
    if (nFlags & MK_CONTROL)
    {
      myView-> Pan (point.x-myXmax, myYmax-point.y); // Realize the panning
      myXmax = point.x;
      myYmax = point.y;
    }
  }
  else if (nFlags & MK_RBUTTON)
  {
    if (nFlags & MK_CONTROL)
    {
      myView-> Rotation (point.x, point.y);
    }
  }
  else
  {// No buttons
    myXmax = point.x;
    myYmax = point.y;
    if (nFlags & MK_SHIFT)
    {
        GetDocument ()-> ShiftMoveEvent (point.x, point.y, myView);
    }
    else
    {
        //GetDocument()->MoveEvent(point.x, point.y, myView);
        if (GetDocument ()-> GetAISContext ()-> MoveTo (point.x, point.y, myView, true) == AIS_SOD_Nothing) {
        if (GetView ()-> Viewer ()-> Grid ()-> IsActive ()) {
           Standard_Real X, Y, Z;
           myView-> ConvertToGrid (point.x, point.y, X, Y, Z);
           GetDocument ()-> GetViewer ()-> ShowGridEcho (myView, Graphic3d_Vertex (X, Y, Z));
           myView-> RedrawImmediate ();
        }
        else
        {
            Standard_Real X, Y, Z;
            myView-> Convert (point.x, point.y, X, Y, Z);
        }
      }
    }
  }
}

Contact us

Attention: DO NOT use this form for all kind of request for the removal of your personal data. Please follow this link for such cases.