<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Sarah,<br>
<br>
I'm new to VTK and there might be a better way to do it, but here's how
I did it in a small prototype program. This was with C# and vtkdotnet,
so you'll have to change it slightly for C++. In my case, it ensures
that my vtkOrientationMarkerWidget has a fixed minimum size and that
the square aspect ratio is preserved. I allowed it to grow however, to
properly support rendering to large images.<br>
<br>
Handle the window's OnSize() event (or whatever it's called for your
platform). In my case, this is called even if my marker isn't created
yet, so I have to check. I also call SetOrientationMarkerViewport() in
my form's constructor to set the initial size.<br>
<br>
<tt> // To fix the viewport of the 3D orientation marker widget to
be square.<br>
private void vtkControl1_Resize(object sender, EventArgs e)<br>
{<br>
if (m_marker != null)<br>
SetOrientationMarkerViewport();<br>
}<br>
<br>
</tt><tt> // The marker's viewport is always 0.2 of the minimum
width/height of<br>
// the window. The other is scaled to give a "square" viewport.<br>
// But regardless, it will always be at least min_dim X min_dim.<br>
private void SetOrientationMarkerViewport()<br>
{<br>
const double min_dim= 75;<br>
Size size= vtkControl1.Size;<br>
double width= 0.2,<br>
height= 0.2;<br>
<br>
if (size.Width < size.Height)<br>
height*= ((double) size.Width)/size.Height;<br>
else if (size.Width > size.Height)<br>
width*= ((double) size.Height)/size.Width;<br>
<br>
if (width*size.Width < min_dim)<br>
width= min_dim/size.Width;<br>
if (height*size.Height < min_dim)<br>
height= min_dim/size.Height;<br>
<br>
m_marker.SetViewport(0, 0, width, height);<br>
}<br>
</tt><br>
I hope that this helps.<br>
<br>
Sarah Macumber wrote:
<blockquote
cite="mid:CD74BDC3C0CCBE46A88842384F38B093169488@ems03.ems-1.net"
type="cite">
<pre wrap="">Hi Gerrick,
The issue was "relative to the window" . SetWidth and SetHeight set the position as a fraction of the viewport
and not as an absolute size so that when the window resizes so does the scalar bar. Ideally I would just like
to set a minimum size so that the scalar bar never becomes illegible but that doesn't seem possible.
Currently I am trying to use the ScalarBarWidget to give the user control over resizing it when it becomes too
small. The problem with that is that when I use the Widget I loose control over setting its width, height and position
and it begins as a square in the bottom right corner no matter that the ScalarBarActor attached to the Widget is set
correctly.
Thanks Gerrick,
Sarah
________________________________
From: <a class="moz-txt-link-abbreviated" href="mailto:vtkusers-bounces@vtk.org">vtkusers-bounces@vtk.org</a> on behalf of Gerrick Bivins
Sent: Wed 7/30/2008 9:05 AM
To: <a class="moz-txt-link-abbreviated" href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a>
Subject: Re: [vtkusers] Turning Auto Rescaling Off on vtkActor2D
Hi Sarah,
How is your vtkScalarBarActor set up? At what point does it become
unreadable? Can you provide a screen cap of the problem. I'm using
vtkScalarBarActor w/o issues when resizing my window.
Here is my setup:
scalarbar = new vtkScalarBarActor();
scalarbar.SetOrientationToHorizontal();
scalarbar.GetPositionCoordinate().SetCoordinateSystemToNormalizedViewport();
scalarbar.GetPositionCoordinate().SetValue(.2,.05);
scalarbar.SetWidth( 0.7 );
scalarbar.SetHeight( 0.1 );
scalarbar.SetPosition( 0.1, 0.01 );
scalarbar.SetLabelFormat("%-#6.3f");
scalarbar.GetTitleTextProperty().SetFontFamilyToArial();
scalarbar.GetTitleTextProperty().SetFontSize( 12 );
scalarbar.GetLabelTextProperty().SetFontFamilyToArial();
scalarbar.GetLabelTextProperty().SetFontSize(10);
scalarbar.GetLabelTextProperty().SetJustificationToCentered();
This keeps it placed at the bottom of my window with all of it's properties
(width,height,position) relative to the window.
Gerrick
Sarah Macumber wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Is there any way to turn off the auto rescaling of the vtkActor2D which
happens when the window changes sizes? Specifically I am trying to keep a
vtkScalarBarActor from becoming illegible. It would be nice if I could
set a minimum size & font but a fixed size would do as well. I looked at
the code for a vtkActor2D and I am not sure how one would turn the auto
scaling off.
Thanks Sarah
_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at:
<a class="moz-txt-link-freetext" href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a>
Follow this link to subscribe/unsubscribe:
<a class="moz-txt-link-freetext" href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a>
</pre>
</blockquote>
<pre wrap=""><!---->
--
View this message in context: <a class="moz-txt-link-freetext" href="http://www.nabble.com/Turning-Auto-Rescaling-Off-on-vtkActor2D-tp18715272p18734015.html">http://www.nabble.com/Turning-Auto-Rescaling-Off-on-vtkActor2D-tp18715272p18734015.html</a>
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: <a class="moz-txt-link-freetext" href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a>
Follow this link to subscribe/unsubscribe:
<a class="moz-txt-link-freetext" href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a>
_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: <a class="moz-txt-link-freetext" href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a>
Follow this link to subscribe/unsubscribe:
<a class="moz-txt-link-freetext" href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a>
</pre>
</blockquote>
<br>
<div class="moz-signature">-- <br>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Signature</title>
<a href="http:://www.infolytica.com">www.infolytica.com </a><br>
300 Leo Pariseau, Suite 2222, Montreal, QC, Canada, H2X 4B3<br>
(514) 849-8752 x236, Fax: (514) 849-4239
</div>
</body>
</html>