How to force viewportDraw call

How to force viewportDraw call

Anonymous
Not applicable
1,372 Views
9 Replies
Message 1 of 10

How to force viewportDraw call

Anonymous
Not applicable

I want to force the AutoCAD graphics system to call MyEntity::viewportDraw(). How can I achieve this ? 

 

Regards

0 Likes
Accepted solutions (2)
1,373 Views
9 Replies
Replies (9)
Message 2 of 10

maisoui
Advocate
Advocate

"Return Adesk::kFalse" in subWorldDraw(...).

Regards,

--
Jonathan
0 Likes
Message 3 of 10

Anonymous
Not applicable

Of course I have to return Adesk::kFalse" in subWorldDraw. But, I want subViewportDraw(...) to be called every time I zoom or pan. this function gets called during regen, not necessarly on 'zoom' or 'pan'

0 Likes
Message 4 of 10

nick83
Advocate
Advocate

if i understand a problem correctly, AcEditorReactor::commandEnded can't help in all cases, cause you want to see changes inside pan/zoom. So, as a variant, Hook on mouse events is what you need. inside hook use pEnt->draw()

you need in something like the code below:

 

int startCommand = 0;

BOOL redrawHook(MSG* pMsg)
{
  if (pMsg->message == WM_MOUSEWHEEL)
  {
    if (startCommand < 2)
    {
       startCommand++;
       PostMessage(adsw_hwndAcad,pMsg->message,pMsg->wParam,pMsg->lParam);
       return FALSE;
    }
    else
    {// will work for 1/3 of mousewheel
      CYourClassApp::your_transparent_command();
      startCommand = 0;
      return TRUE;
    }
  }

  if (pMsg->message == WM_MBUTTONUP)
  {
    CYourClassApp::your_transparent_command();
    return FALSE;
  }

return FALSE; } class CYourClassApp : public AcRxArxApp { virtual AcRx::AppRetCode On_kInitAppMsg(void* pkt) { ... acedRegisterFilterWinMsg(redrawHook); ... } virtual AcRx::AppRetCode On_kUnloadAppMsg(void* pkt) { ... acedRemoveFilterWinMsg(redrawHook); ... } static void your_transparent_command() { // force "draw" for needed entities using pEnt->draw(); } }

 

0 Likes
Message 5 of 10

owenwengerd
Advisor
Advisor
Accepted solution

You need to override subSetAttributes() in your custom entity and include the kDrawableViewDependentViewportDraw flag in the returned value.

--
Owen Wengerd
ManuSoft
0 Likes
Message 6 of 10

Anonymous
Not applicable

Thanks Owen,

 

kDrawableViewDependentViewportDraw works correctly during ZOOM , but AutoCAD(2015) stops working(freezes) during PAN. Any idea what the problem is ? 

0 Likes
Message 7 of 10

owenwengerd
Advisor
Advisor

Without seeing your code I can only guess. My guess is that your viewport drawing code changes the view.

--
Owen Wengerd
ManuSoft
0 Likes
Message 8 of 10

Anonymous
Not applicable

Hi Owen, 

 

Panning deosn't freeze autocad when I turn off Adaptive Degradation. But unlike Zooming it doesn't regenarate my drawing.

 

In my viewport Drawing, I have replaced  " AcGsView *view " by " getNumPixelsInUnitSquare " to get aspect ratio. But that didn't help. Could you please explain what you mean by the viewport drawing code changes the view ?

 

Thanks in advance

 

0 Likes
Message 9 of 10

Balaji_Ram
Alumni
Alumni
Accepted solution

 I have seen issues with the viewportDraw not getting called in a AcGiDrawableOverrule even when kDrawableViewDependentViewportDraw was specified when in "2d Wireframe" visual style. It had worked ok in other shaded modes. I am not sure if this is related to your query, so you can also try changing the Visual style.

 

The other way could be to use "kDrawableViewIndependentViewportDraw" as the attribute and ensure that the viewportDraw gets called using AcGsView::invalidateCachedViewportGeometry.

 

Regards,

Balaji

 



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 10 of 10

Anonymous
Not applicable

I put 'AcGsView::invalidateCachedViewportGeometry'   inside    'AcEditorReactor::viewChanged' and PANNING is working fine. It's a bit slower compared to Zooming though. 

0 Likes