Hi all,

I'm writing an application that has a dialog window in which there is an a2dCanvas. In the dialog window, the user can open up an image and view it on the a2dCanvas. But when the window is resized, the image appears to be jumping back and forth horizontally. I say "appears to" because it could be the view port that is incorrectly moving. Below are screen captures so you can see what I mean:

Image before sizing:







Image will bounce to this position and back rapidly when resizing:





Here is the code I'm using to set the canvas and the image:

    wxSizerItem *SizeItem;
    wxSizer *Sizer;
    TSizeInfo *SizeInfo;
    double PixX, PixY;
    double FovX, FovY;
 
    // Size of pixels in wold units
    GetPixelSize( &PixX, &PixY );

    // Size of image field in world units
    GetFieldofView( &FovX, &FovY );

    // Get the wxpanel's sizer.
    if ( (Sizer = Panel1->GetSizer()) == NULL )
        return;

    // Get the sizer used for the a2dCanvas.
    if ( (SizeItem = Sizer->GetItem(cnvsImage)) == NULL )
        return;


    cnvsImage->Freeze();

   
    m_CanvasDoc->DeleteContents();

    m_adModelImage = new a2dImage();
    m_BBox = new a2dRect(0,0,0,0);
    m_BBox->SetFill(*a2dTRANSPARENT_FILL);

    cnvsImage->FixScrollMaximum( false );

     // Set Y axis positive up.
    cnvsImage->SetYaxis( true );

    // Don't show the origin.
    cnvsImage->SetShowOrigin( false );

    // Define the number of world units moved when scroll.
    cnvsImage->SetScrollStepX( .1 );
    cnvsImage->SetScrollStepY( .1 );

    // Don't allow scrolling outside the scroll maximum.
    cnvsImage->FixScrollMaximum( true );

    // Load the specified file.
    m_wxImage.LoadFile( m_ImagePath );


    // Resize the image to coincide with desired size. SizeInfo is in pixels.
    GetSizeInfo( &SizeInfo );
    m_wxImage.Rescale( SizeInfo->NumCols, SizeInfo->NumRows);

    // Load the image into the a2dImage and set width and height.
    m_adModelImage->SetImage( m_wxImage );
    m_adModelImage->SetName(IMAGE_NAME);
    m_adModelImage->SetWidth(FovX);
    m_adModelImage->SetHeight(FovY);

    m_adModelImage->GetImage().Resize( wxSize(SizeInfo->NumCols,
        SizeInfo->NumRows), wxPoint(0, 0), 0, 0, 0 );

   
    cnvsImage->SetMappingWidthHeight( -FovX/2.0, -FovY/2.0, FovX, FovY, true );

    // Append the image and selection box to the canvas.
    m_CanvasDoc->Append( m_adModelImage );
    m_CanvasDoc->Append( m_BBox );



    cnvsImage->SetScaleOnResize( true );



    // Show updates.
    cnvsImage->Thaw();

    Panel1->GetSizer()->Layout();


  
Does anyone have any idea what I'm doing wrong and why I'm seeing the results I'm seeing?  Any insight would be appreciated.
-Mike
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Wxart2d-users_dev mailing list
Wxart2d-users_dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxart2d-users_dev

Reply via email to