Adjusting Line Weights for ToPixMap

I'm using V3d_View::ToPixMap() to create high resolution bitmaps for printing the contents of my OpenCascade window. In general, this is working. However, I have an issue with line weights.

The problem is that my screen is showing an area of maybe 500 x 500 pixels, in which a lineweight of 2 looks fine. My printer, on the other hand, is drawing an image of ~4000 x 4000 pixels, at 600 dpi. When I create my 4000 x 4000 pixmap, the lineweight of 2 looks much too fine.

Is there any way that I can scale the lineweight in my view, or do I need to go throught each element in my scene and adjust the lineweight on each? I'll also have to fix the trihedron, and probably textures and maybe text.

Any suggestions on the 'right' way to fix this would be appreciated.


Jonathan Greig's picture

What are you using to set the lineweight with?

Last night I was toying around with:

Handle_Prs3d_Drawer drawer = myContext->DefaultDrawer();
Handle_Prs3d_LineAspect newWireAspect = new Prs3d_LineAspect(newColor, Aspect_TOL_DOTDASH, 1.0); //0.0 segfaults, 1.0 min, 10.0 max
to set any new lines drawn to that color/linetype/lineweight.

and it appears that any lineweight greater than 10.0 doesn't make a difference on screen.

I'm not sure if there is a way to do it if you are just taking screenshots, but offseting your elements with a heavier lineweight should theoretically solve the problem. After the screenshot is made, you could erase the temporary offset lines.

Stephane Routelous's picture

the [1.0,10.0] is an opengl limitation and usually depends on your opengl driver implementation
see glLineWidth ( )



EricThompson's picture

I solved my problem by iterating through all objects in my context and applying a scale factor to the weight as follows:

void scaleLineWeights( double scaleFactor )
if (!mAisContext.IsNull())
AIS_ListOfInteractive aList;
AIS_ListIteratorOfListOfInteractive aListIt;
mAisContext->DisplayedObjects( aList );
for (aListIt.Initialize(aList);
aListIt.More ();
aListIt.Next ())
Handle_AIS_InteractiveObject hObject = aListIt.Value();
if( hObject->HasWidth() )
double dWidth = hObject->Width() * scaleFactor;
hObject->SetWidth( dWidth );

I then call it from the following code:

double scaleFactor = 5.0;
scaleLineWeights( scaleFactor );
Handle_Aspect_PixMap pixMap;
pixMap = mView->ToPixMap( width, height, 24 );
pixMap->Dump( fileName );
scaleLineWeights( 1.0/scaleFactor );

This is working perfectly for me, the lines appear nice and solid for the print-out, but are never redrawn on the screen itself so the user has no idea I've been messing with it.

I may try it again by changing the default drawer's aspect. That was exactly the sort of elegant solution I was looking for when I posted my question.


JuryS's picture

EricThompson! Many thanks for your IDEA! Good Luck with your working.