Viewport specific geometry in only one viewport

Viewport specific geometry in only one viewport

Anonymous
Not applicable
758 Views
5 Replies
Message 1 of 6

Viewport specific geometry in only one viewport

Anonymous
Not applicable

Hello Autodesk Community,

similar to this post


https://forums.autodesk.com/t5/objectarx/viewport-specific-geometry/td-p/5673119


I want to draw some viewport specific geometry for custom entities.
However I need only one layout viewport with a different representation of my entities, all other layout viewports and the model space tab should show the normal drawing.

The only solution I came up with so far is to do all the drawing for my custom entities in the subViewportDraw methods. There I can check for the viewport and/or for e.g. the current visual style in this viewport and choose accordingly how to draw my entities.

Switching completely from worldDraw to viewportDraw would mean a lot of changes (as right now most of the drawing is done in subWorldDraw) and additionally some work for displaying proxy objects (and ???) -  so I was wondering whether there is any easier way to do this?

Thanks for any Help!

0 Likes
759 Views
5 Replies
Replies (5)
Message 2 of 6

owenwengerd
Advisor
Advisor

I think your proposed approach is the correct way to handle this. You can put your current worlddraw code into a new common function that gets called from viewportdraw when needed and from saveas for proxy graphics.

--
Owen Wengerd
ManuSoft
0 Likes
Message 3 of 6

tbrammer
Advisor
Advisor

You can take advantage of the fact that  AcGiWorldDraw and AcGiViewportDraw share a common baseclass.

 

  subWorldDraw(AcGiWorldDraw *mode);

  subViewportDraw(AcGiViewportDraw *mode);

  class AcGiViewportDraw: public AcGiCommonDraw {
    virtual AcGiViewportGeometry& geometry() const = 0;
  };

  class AcGiWorldDraw: public AcGiCommonDraw {
    virtual AcGiWorldGeometry& geometry() const = 0;
  };

 

The same is true for AcGiViewportGeometry and AcGiWorldGeometry.

 
  class AcGiWorldGeometry: public AcGiGeometry
  class AcGiViewportGeometry: public AcGiGeometry

 

AcGiGeometry contains the primitve drawing methods.

So you can write a "common draw" method that draws to the AcGiGeometry and use it in world- and viewportDraw.

This should be possible to do with minor changes to your code.

 


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes
Message 4 of 6

Anonymous
Not applicable

Thanks a lot for your replies. What you describe is basically what I have done/thought about so far.

All custom entities share a common base class. The base class subWorldDraw returns false and in the base class subViewportDraw I mimic the worldDraw/viewportDraw mechanism with two custom virtual functions where the former takes an AcGiCommonDraw instance and the latter an AcGiViewportDraw instance (as some of the entities always have viewport dependent geometry).

However as we have ~100 custom entities and need only a different representation for less than 20 in one viewport only I was hoping to get around this (even minor) change for all entities.

Moreover I'm still quite new to the AutoCAD world and objectArx and not sure about all the consequences of removing the native AutoCad worldDraw mechanism (graphics update, performance, ....?) for all our custom entities.
Recently I was experimenting with catching the layout switch event and applying a draw overrule to the necessary entities when I switch to the special layout that needs the different representation. But again, I might miss some severe consequences here, so I'm grateful for any thoughts, pro and cons, on these approches from the experts!

0 Likes
Message 5 of 6

Anonymous
Not applicable
I forgot to mention that, in the special layout, I want to show ONLY instances of the (~20) entities that have a different representation. That's why I would disable the worldDraw mechanism in the base class. In the base class subViewportDraw I check for the current viewport and if I'm in the special layout viewport I skip all entities that do not have a special representation and call the special drawing functions for those that do have a special representation.
0 Likes
Message 6 of 6

tbrammer
Advisor
Advisor

  > we have ~100 custom entities and need only a different representation for less than 20 in

  > one viewport only I was hoping to get around this (even minor) change for all entities.

 

You can decide on per-entity basis whether you need viewportDraw() or not.

If you can tell from the entities data that it doesn't need custom graphics, your worldDraw() can return Adesk::kTrue - so viewportDraw() won't be called.

 

 

  > not sure about all the consequences of removing the native AutoCad worldDraw mechanism

  > (graphics update, performance, ....?)

 

Using viewportDraw() always means additional function calls and more data to handle for AutoCAD's graphic system because it will be called for each viewport. The performance cost depends on the complexity.

 

If you only need additional graphics (like a custom marker) the only thing you have to change in worldDraw() is setting the return value to kFalse.

Then draw the additional stuff in viewportDraw(). Try to keep the viewportDraw() portion as small as possible.


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes