Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » RepositionBars VS2005 x VS2008 Collapse All
Subject Author Date
Luis Alberto Pereira Jan 14, 2010 - 3:40 PM

Reply


 


I created a new post because I could not reply the reply post for technical support.


 


This post is continuationa of this: www.prof-uis.com/prof-uis/tech-support/general-forum/repositionbars-windows-xp-x-windows-vista-66570.aspx,


 


Dear technical support, I did not understand your orientation. What exactly I need to do in my code do solve the problem with VS2008.


 


Follow you post:


 


 


 


Please take at the end of the code snippet from your .cpp file. The following line is the most interesting:


 


RepositionBars( 0, 0xFFFF, nID );

 






The nID variable is the identifier of the window which should occupy the central space which is free of control bars occupying their paces near borders. If the nID variable is set to IDC_STATIC value, then the RepositionBars( 0, 0xFFFF, nID ); code will work well compiled with Visual Studio 2005 or earlier. It will position the central window correctly. But it will not work in Visual Studio 2008 or later. This is specific improvement introduced in Visual Studio 2008. That’s why Prof-UIS uses its own __EXT_MFC_IDC_STATIC value instead of MFC’s IDC_STATIC value.


 


Thanks,

Luis Alberto Pereira Jan 19, 2010 - 5:52 AM


 



Hi, thanks for help, but I did not understand when you say IDC_STATIC dialog control.


In CMainFrame I´m creating my deriveted CView class (m_wndAxiView) under CExtControlBar (m_wndRBAxiView) 


Where is the problem  ?


Thanks,



 


if( ! m_wndRBAxiView.Create(_T("Axial View"),this,ID_VIEW_AXI_RBBAR))



{


TRACE0("Failed to create m_wndResizableBar0\n");


return -1; // fail to create

}


this->m_wndRBAxiView.EnableDocking( CBRS_ALIGN_ANY );


if( !this->m_wndAxiView.Create(NULL,NULL,WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),


&m_wndRBAxiView,AFX_IDW_PANE_FIRST))


{


TRACE0("Failed to create m_wndDockedCtrlEdit\n");


return -1; // fail to create

}



Technical Support Jan 19, 2010 - 1:21 PM

The code snippet in your message creates a resizable control bar window (m_wndRBAxiView) and then creates some other window inside it (m_wndAxiView). This code snippet is OK. The resizable bar requires only one child window inside it. This child window can have any dialog control identifier. This code snippet is not related to the problem. The problem is hidden somewhere inside m_wndAxiView window which is, we suspect, the container for one Prof-UIS toolbar window and one 3-D model view window. Please provide us with the source code of the m_wndAxiView window.

Luis Alberto Pereira Jan 20, 2010 - 4:40 AM

 


Thanks for help, I´m sending the .h and .cpp code.


 


VTKViewAxial.h


#ifndef __VtkViewAxial_h

#define __VtkViewAxial_h

#pragma once

#include "implantplandoc.h"

#include "vtkRenderer.h"

#include "vtkWin32OpenGLRenderWindow.h"

#include "vtkWin32RenderWindowInteractor.h"

#include "vtkInteractorStyleImage.h"

#include "interactorvtkview.h"

#include "vtkActor.h"

#include "vtkCamera.h"

#include "vtkProperty.h"

#include "vtkPiecewiseFunction.h"

#include "vtkColorTransferFunction.h"

#include "vtkVolumeProperty.h"

#include "vtkImageData.h"

#include "vtkVolumeTextureMapper3D.h"

#include "vtkFixedPointVolumeRayCastMapper.h"

#include "vtkDICOMImageReader.h"

#include "VtkWrapperText.h"

#include "vtkcommand.h"

#include "vtkDistanceWidget.h"

#include "vtkseedwidget.h"

#include "vtkDistanceRepresentation2D.h"

#include "vtkmath.h"

#include "vtkaxisactor2d.h"

#include "vtkPointHandleRepresentation2D.h"

#include "vtkProperty2D.h"

#include "vtkImageActor.h"

#include "vtkpointpicker.h"

#include "vtkSeedRepresentation.h"


//#define VTKVIEWAXIAL_CLASSNAME    _T("VTKViewAxial")  // Window class name


#define FmtStr(str_out, strm) { std::ostringstream oss; oss << strm; str_out = oss.str(); }


class CVTKViewAxial : public CView

{

public: // create from serialization only

  CVTKViewAxial();

  DECLARE_DYNCREATE(CVTKViewAxial)


  class vtkDistanceAxiCallback : public vtkCommand

  {

 public:

   static vtkDistanceAxiCallback *New()

  { return new vtkDistanceAxiCallback; }

   void vtkDistanceAxiCallback::Execute(vtkObject*, unsigned long eid, void* callData)

  {

   if ( eid == vtkCommand::InteractionEvent ||

      eid == vtkCommand::EndInteractionEvent ||

      eid == vtkCommand::MouseMoveEvent ||

      eid == vtkCommand::MouseWheelBackwardEvent ||

      eid == vtkCommand::MouseWheelForwardEvent)

   {

    double pos1[3], pos2[3];

    // Modify the measure axis

    this->Distance->GetPoint1WorldPosition(pos1);

    this->Distance->GetPoint2WorldPosition(pos2);

    double dist=sqrt(vtkMath::Distance2BetweenPoints(pos1,pos2));

    //double dist=(pos1[0]>pos2[0]?pos1[0]-pos2[0]:pos2[0]-pos1[0]);


    //char title[256];

    CString title;

    this->Distance->GetAxis()->SetRange(0.0,dist);

    //sprintf(title,"%-#6.3g mm",dist);

    title.Format(_T("%-#6.3g mm"),dist);

    this->Distance->GetAxis()->SetTitle(title.GetBuffer());

   }

   else

   {

    if (callData == 0)

     return;

    int pid = *(reinterpret_cast<int*>(callData));

    //From the point id, get the display coordinates

    double pos1[3], pos2[3], *pos;

    this->Distance->GetPoint1DisplayPosition(pos1);

    this->Distance->GetPoint2DisplayPosition(pos2);

    if ( pid == 0 )

      {

      pos = pos1;

      }

    else

      {

      pos = pos2;

      }


    // Okay, render without the widget, and get the color buffer

    int enabled = this->DistanceWidget->GetEnabled();

    if ( enabled )

      {

      this->DistanceWidget->SetEnabled(0); //does a Render() as a side effect

      }


    // Pretend we are doing something serious....just randomly bump the

    // location of the point.

    double p[3];

    p[0] = pos[0] + static_cast<int>(vtkMath::Random(-5.5,5.5));

    p[1] = pos[1] + static_cast<int>(vtkMath::Random(-5.5,5.5));

    p[2] = 0.0;

    // Set the new position

    if ( pid == 0 )

      {

      this->Distance->SetPoint1DisplayPosition(p);

      }

    else

      {

      this->Distance->SetPoint2DisplayPosition(p);

      }


    // Side effect of a render here

    if ( enabled )

      {

      this->DistanceWidget->SetEnabled(1);

      }

   }

  }


   vtkDistanceAxiCallback():Renderer(0),RenderWindow(0),DistanceWidget(0),Distance(0) {}

   vtkRenderer *Renderer;

   vtkWin32OpenGLRenderWindow *RenderWindow;

   vtkDistanceWidget *DistanceWidget;

   vtkDistanceRepresentation2D *Distance;


   double *m_pSliceThickness;

   long *m_pNumberPixelsAlongAxis;

   double *m_pPixelSizeMilimeter;


 };




  class vtkSeedAxiCallback : public vtkCommand

 {

  public:

    static vtkSeedAxiCallback *New()

   { return new vtkSeedAxiCallback; }

    virtual void Execute(vtkObject*, unsigned long eid, void *calldata)

   {

       if (eid == vtkCommand::PlacePointEvent)

       {

           numberofseeds = this->SeedRepresentation->GetNumberOfSeeds();

                    this->SeedRepresentation->GetSeedDisplayPosition(numberofseeds-1, point);

       }

   }

          //vtkCommand::CursorChangedEvent

    vtkSeedAxiCallback() : SeedRepresentation(0) {}

    vtkSeedRepresentation *SeedRepresentation;

         int numberofseeds;

          double point[3];

 };


  class CNavigationBar : public CExtToolControlBar

 {

 public:

  CNavigationBar()

  {

  }

  ~CNavigationBar()

  {

  }


    public: //Controls

        CExtComboBox m_cmbDistances;

        CExtComboBox m_cmbPoints;


    public: //methods

  virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam)

  {

   if( message == WM_CONTEXTMENU )

    return 0L;

   if(  message == WM_LBUTTONDOWN

    || message == WM_LBUTTONUP

    || message == WM_MBUTTONDOWN

    || message == WM_MBUTTONUP

    || message == WM_RBUTTONDOWN

    || message == WM_RBUTTONUP

    )

   {

    HWND hWndThis = GetSafeHwnd();

    ASSERT( hWndThis != NULL );

    ASSERT( ::IsWindow( hWndThis ) );

    HWND hWndParent = ::GetParent( hWndThis );

    ASSERT( hWndParent != NULL );

    ASSERT( ::IsWindow( hWndParent ) );

    HWND hWndFocus = ::GetFocus();

    if(  hWndFocus == NULL

     || hWndFocus == hWndThis

     || ::IsChild( hWndThis, hWndFocus )

     )

     ::SetFocus( hWndParent );

    else if( ! ::IsChild( hWndParent, hWndFocus ) )

     ::SetFocus( hWndParent );

   }

   return CExtToolControlBar::WindowProc(message,wParam,lParam);

  }


  bool InitNavigationBar()

  {

   m_bPresubclassDialogMode = true;

            LPCTSTR pn = AfxGetApp()->m_pszProfileName;


            if( !m_cmbDistances.Create(

                WS_CHILD | WS_VISIBLE | CBS_DROPDOWN,  CRect( 0, 0, 150, 180 ),  this, //&m_wndToolBarMain,

                ID_TBAV_CMBDISTANCES)

               || !this->SetButtonCtrl(this->CommandToIndex(m_cmbDistances.GetDlgCtrlID()), &m_cmbDistances))

            {

                TRACE0("Failed to create help search combobox\n" );

                return -1;

            }

            

            m_cmbDistances.SetItemHeight( -1, 16 );

            

            m_cmbDistances.SetFont( &g_PaintManager->m_FontNormal );

            g_CmdManager->CmdGetPtr(pn, m_cmbDistances.GetDlgCtrlID())->m_sMenuText = _T( "Measures" );


            if( !m_cmbPoints.Create(

                WS_CHILD | WS_VISIBLE | CBS_DROPDOWN,  CRect( 0, 0, 150, 180 ),  this, //&m_wndToolBarMain,

                ID_TBAV_CMBPOINTS)

               || !this->SetButtonCtrl(this->CommandToIndex(m_cmbPoints.GetDlgCtrlID()), &m_cmbPoints))

            {

                TRACE0("Failed to create help search combobox\n" );

                return -1;

            }

            

            m_cmbPoints.SetItemHeight( -1, 16 );

            

            m_cmbPoints.SetFont( &g_PaintManager->m_FontNormal );

            g_CmdManager->CmdGetPtr(pn, m_cmbPoints.GetDlgCtrlID())->m_sMenuText = _T( "Points" );


            return true;


  }

 }; // class CNavigationBar


  CNavigationBar m_wndToolbar;


public:

    virtual ~CVTKViewAxial();

    virtual void OnDraw(CDC* pDC);  // overridden to draw this view

 void Pipeline ( void );

    void ResetSize(int cx, int cy);


    enum {WIDGET_NULL, WIDGET_RULER, WIDGET_SEED};


protected:

    //BOOL RegisterWindowClass();


public:

    virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);

    virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);

    virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);

    virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);

    //}}AFX_VIRTUAL


private:


 //renderrizacao

 vtkRenderer       *m_ren;

 vtkWin32OpenGLRenderWindow   *m_renWin;

 vtkWin32RenderWindowInteractor  *m_iren;

 vtkInteractorStyleImage    *m_irenStyle;

    //CInteractorVTKView    *m_irenStyle;


 //widget distance

 vtkPointHandleRepresentation2D*    m_pPtDistHandle2D;

 vtkDistanceRepresentation2D*    m_pDistRepr2D;

 vtkDistanceWidget*       m_pDistWidget;

 vtkDistanceAxiCallback*            m_DistCallback;


 //vtkPointPicker*       picker;

   //vtkPickerAxiCallback*            m_PickerCallback;


 vtkSeedWidget*                     m_pSeedWidget;

 vtkSeedAxiCallback*                m_SeedCallback;

 vtkPointHandleRepresentation2D*    m_pSeedHandle;

 vtkSeedRepresentation*      m_pSeedRepr;


#ifdef _DEBUG

    virtual void AssertValid() const;

    virtual void Dump(CDumpContext& dc) const;

#endif


protected:

 // Generated message map functions


public:

 //{{AFX_MSG(CVTKViewAxial)

 virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);

    afx_msg void OnSize(UINT nType, int cx, int cy);

    afx_msg BOOL OnEraseBkgnd(CDC* pDC);

    //afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);

    //}}AFX_MSG

   DECLARE_MESSAGE_MAP()


public:

    double m_zslicepos;

    int m_zsliceidx;


public:

 CImplantDoc* GetMainFrmDoc(void);

protected:

 virtual void PostNcDestroy();


    int m_flg_ResetCamera;


public:

    void NewMeasureDistance(void);

protected:

    int m_flg_widget;

    int m_flg_widget_selected;

public:

    void WidgetSelection(void);

    void NewSeed(void);

};


#endif


VTKViewAxial.CPP


#include "stdafx.h"

#include "ImplantPlan.h"

#include "VTKViewAxial.h"

#include "mainfrm.h"

#include "vtkActor.h"

#include "vtkCamera.h"

#include "vtkContourFilter.h"

#include "vtkImageData.h"

#include "vtkImageMapToColors.h"

#include "vtkimagemapper.h"

#include "vtkLight.h"

#include "vtkLookupTable.h"

#include "vtkOutlineFilter.h"

#include "vtkPolyData.h"

#include "vtkPolyDataMapper.h"

#include "vtkPolyDataNormals.h"

#include "vtkPropPicker.h"

#include "vtkProperty.h"

#include "vtkRenderWindow.h"

#include "vtkRenderer.h"

#include "vtkStripper.h"

#include "VtkObserverWindowLevel.h"

#include "VtkObserverErrorWarning.h"

#include "VtkObserverFileLoad.h"

#include "dlgnewmeasuredistance.h"

#include "measuredistance.h"

#include "vtkWidgetEvent.h"

#include "vtkAxisActor.h"

#include "vtkAxisActor2D.h"

#include "vtkCubeAxesActor2D.h"

#include "vtkTextProperty.h"


#include <string>

#include <sstream>




#ifdef _DEBUG

#define new DEBUG_NEW

#endif


// CVTKViewAxial


IMPLEMENT_DYNCREATE(CVTKViewAxial, CView)


BEGIN_MESSAGE_MAP(CVTKViewAxial, CView)

 // Standard printing commands

 ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)

 ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)

 ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)

    ON_COMMAND(ID_TBAV_DISTANCE, CVTKViewAxial::NewMeasureDistance)

    ON_COMMAND(ID_TBAV_SEED, CVTKViewAxial::NewSeed)

 ON_WM_SIZE()

 ON_WM_ERASEBKGND()

END_MESSAGE_MAP()




CVTKViewAxial::CVTKViewAxial()

: m_flg_ResetCamera(true)

, m_flg_widget(0)

, m_flg_widget_selected(0)

,m_zslicepos(0)

,m_zsliceidx(-1)

{

    //this->RegisterWindowClass();


 this->m_ren   = vtkRenderer::New();

    this->m_renWin  = vtkWin32OpenGLRenderWindow::New();

    this->m_iren    = vtkWin32RenderWindowInteractor::New();

 this->m_irenStyle = vtkInteractorStyleImage::New();

    //this->m_irenStyle = CInteractorVTKView::New();

 this->m_iren->SetInteractorStyle(m_irenStyle);

}




CVTKViewAxial::~CVTKViewAxial()

{

    // Delete the the renderer, window and interactor objects.

    //this->m_iren->RemoveObserver(m_PickerCallback);

    this->m_flg_widget = this->WIDGET_NULL;

    this->WidgetSelection();

    this->m_ren->Delete();

    this->m_iren->Delete();

    this->m_renWin->Delete();

}


void CVTKViewAxial::OnDraw(CDC* pDC)

{

 CImplantDoc* pDoc = this->GetMainFrmDoc();

 //ASSERT_VALID(pDoc);

    if ( !this->m_iren->GetInitialized() )

    {

        this->m_iren->Initialize();

        Pipeline();

        CRect rect;

        this->GetClientRect(&rect);

        RepositionBars( 0, 0xFFFF, 0);

        this->m_renWin->SetSize(rect.right-rect.left,rect.bottom-rect.top);

    }

 else

  Pipeline();


    if ( pDC->IsPrinting() )

    {

        this->BeginWaitCursor();

        // Obtain the size of the printer page in pixels.

        int cxPage = pDC->GetDeviceCaps(HORZRES);

        int cyPage = pDC->GetDeviceCaps(VERTRES);

        // Get the size of the window in pixels.

        int *size = this->m_renWin->GetSize();

        int cxWindow = size[0];

        int cyWindow = size[1];

        float fx = float(cxPage) / float(cxWindow);

        float fy = float(cyPage) / float(cyWindow);

        float scale; // = min(fx,fy);

  if (fx < fy)

   scale = fx;

  else

   scale = fy;

  int x = int(scale * float(cxWindow));

        int y = int(scale * float(cyWindow));

        this->m_renWin->SetupMemoryRendering(cxWindow, cyWindow, pDC->GetSafeHdc());

        this->m_renWin->Render();

        HDC memDC = this->m_renWin->GetMemoryDC();

        StretchBlt(pDC->GetSafeHdc(),0,0,x,y,memDC,0,0,cxWindow,cyWindow,SRCCOPY);

        this->m_renWin->ResumeScreenRendering();

        this->EndWaitCursor();

    }

}


void CVTKViewAxial::ResetSize(int cx, int cy)

{

    // Reset the render window size, reposition the text actors.

    this->m_renWin->SetSize(cx, cy);

}


void CVTKViewAxial::OnSize(UINT nType, int cx, int cy)

{

    CView::OnSize(nType, cx, cy);

    CRect rect;

    this->GetClientRect(&rect);

    RepositionBars( 0, 0xFFFF, 0);

    this->m_renWin->SetSize(rect.right-rect.left,rect.bottom-rect.top);

}


BOOL CVTKViewAxial::OnEraseBkgnd(CDC* pDC)

{

    return TRUE;

}


BOOL CVTKViewAxial::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)

{

 if ((CView::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext))==-1)

  return false;


    this->m_renWin->AddRenderer(this->m_ren);

    //this->m_renWin->SetParentId(this->m_hWnd);

    this->m_renWin->SetParentId(this->GetSafeHwnd());

    this->m_iren->SetRenderWindow(this->m_renWin);

    m_wndToolbar.m_bPresubclassDialogMode = true;


    if( !m_wndToolbar.Create(_T(""), this, AFX_IDW_DIALOGBAR,  WS_CHILD|WS_VISIBLE

    |CBRS_ALIGN_TOP|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_SIZE_DYNAMIC))

 {

  ASSERT( FALSE );

  return -1;

 }

 if( !m_wndToolbar.LoadToolBar(IDR_TOOLBAR_AXIALVIEW) )

 {

  ASSERT( FALSE );

  return -1;

 }

 if(!m_wndToolbar.InitNavigationBar())

  return -1;


    RepositionBars(0, 0xFFFF, 0);

    return true;

}


LRESULT CVTKViewAxial::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)

{

      switch (message)

      {

        //case WM_PAINT:

        case WM_LBUTTONDOWN:

        case WM_LBUTTONUP:

        case WM_MBUTTONDOWN:

        case WM_MBUTTONUP:

        case WM_RBUTTONDOWN:

        case WM_RBUTTONUP:

        case WM_MOUSEMOVE:

        case WM_CHAR:

        case WM_TIMER:

      if (this->m_iren->GetInitialized())

      {

                return vtkHandleMessage2(this->GetSafeHwnd(), message, wParam, lParam, this->m_iren);

      }

      break;

      }

      return CView::WindowProc(message, wParam, lParam);

}


void CVTKViewAxial::Pipeline()

{

  CMainFrame *pFrame  = (CMainFrame*)AfxGetApp()->m_pMainWnd;

  if (pFrame->m_pDoc == NULL)

   return;


  if (!pFrame->m_pDoc->m_flg_img3D_Loaded)

      return;


  if (pFrame->m_wndView.m_flg_widget_selected != pFrame->m_wndView.WIDGET_3D)

   return;


  if (this->m_zsliceidx != pFrame->m_wndView.m_planeWidgetZ->GetSliceIndex())

  {

  this->m_zsliceidx = pFrame->m_wndView.m_planeWidgetZ->GetSliceIndex();

  this->m_zslicepos = pFrame->m_wndView.m_planeWidgetZ->GetSlicePosition();


  //this->m_DistCallback->m_pNumberPixelsAlongAxis = &pFrame->m_pDoc->m_0028_0100_NumberPixelsAlongAxis;

    //this->m_DistCallback->m_pPixelSizeMilimeter    = &pFrame->m_pDoc->m_0028_0030_PixelSizeMilimeter;

  //this->m_DistCallback->m_pSliceThickness        = &pFrame->m_pDoc->m_0018_0050_SliceThickness;


    //if (this->m_ren->GetNumberOfPropsRendered() > 0)

    //{

    // this->m_ren->RemoveAllProps();

    // this->m_ren->RemoveAllViewProps();

    //}


   vtkImageMapToColors* colorMap = vtkImageMapToColors::New();

  colorMap->PassAlphaToOutputOff();

  colorMap->SetActiveComponent(0);

  colorMap->SetOutputFormatToLuminance();

  colorMap->SetInput(pFrame->m_wndView.m_planeWidgetZ->GetResliceOutput());

  colorMap->SetLookupTable(pFrame->m_wndView.m_planeWidgetX->GetLookupTable());


   vtkImageActor* imageActor = vtkImageActor::New();

  imageActor->SetInput(colorMap->GetOutput());

  imageActor->PickableOff();

  imageActor->SetPosition(0, 0, 0);


   double iabounds[6];

   imageActor->GetBounds(iabounds);

   double *center = imageActor->GetCenter();




   vtkTextProperty* tprop = vtkTextProperty::New();

  tprop->SetColor(0, 0, 1);

  

  vtkCubeAxesActor2D* axes2 = vtkCubeAxesActor2D::New();

   axes2->SetViewProp(imageActor);

   axes2->SetCamera(this->m_ren->GetActiveCamera());

   axes2->SetLabelFormat("%6.4g");

   axes2->SetFlyModeToClosestTriad();

   axes2->SetFontFactor(1);

   axes2->ScalingOn();

   axes2->SetAxisTitleTextProperty(tprop);

   axes2->SetAxisLabelTextProperty(tprop);

   axes2->SetNumberOfLabels(10);

   axes2->SetZAxisVisibility(false);

   this->m_ren->AddViewProp(axes2);

   axes2->GetXAxisActor2D()->GetProperty()->SetColor(0, 0, 1);

   axes2->GetYAxisActor2D()->GetProperty()->SetColor(0, 0, 1);


   this->m_ren->AddActor(imageActor);


   this->m_renWin->Render();

   if (this->m_flg_ResetCamera)

   {

  this->m_ren->ResetCamera();

  this->m_flg_ResetCamera = false;

   }


   colorMap->Delete();

   imageActor->Delete();

   axes2->Delete();

   tprop->Delete();

  } //if (this->m_zsliceidx != pFrame->m_wndView.m_planeWidgetZ->GetSliceIndex())


 }


 


// CVTKViewAxialCoronal printing

BOOL CVTKViewAxial::OnPreparePrinting(CPrintInfo* pInfo)

{

 return DoPreparePrinting(pInfo);

}


void CVTKViewAxial::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)

{

}


void CVTKViewAxial::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)

{

}


// CVTKViewAxial diagnostics

#ifdef _DEBUG

void CVTKViewAxial::AssertValid() const

{

 CView::AssertValid();

}


void CVTKViewAxial::Dump(CDumpContext& dc) const

{

 CView::Dump(dc);

}


#endif //_DEBUG




CImplantDoc* CVTKViewAxial::GetMainFrmDoc(void)

{

 CMainFrame *pFrame  = (CMainFrame*)AfxGetApp()->m_pMainWnd;

 return pFrame->GetDocument();

}


void CVTKViewAxial::PostNcDestroy()

{

    return;

}


void CVTKViewAxial::NewMeasureDistance(void)

{

    CMainFrame *pFrame  = (CMainFrame*)AfxGetApp()->m_pMainWnd;

    if (pFrame->m_pDoc == NULL)

     return;


    if (!pFrame->m_pDoc->m_flg_img3D_Loaded)

       return;


    CDlgNewMeasureDistance dlg;

    dlg.m_axis = pFrame->A_AXIS;

    if (!dlg.DoModal())

        return;

    this->m_flg_widget = this->WIDGET_RULER;

    this->WidgetSelection();

}




void CVTKViewAxial::WidgetSelection(void)

{

    /*

    CMainFrame *pFrame  = (CMainFrame*)AfxGetApp()->m_pMainWnd;

    if (pFrame->m_pDoc == NULL)

     return;


    if (!pFrame->m_pDoc->m_flg_img3D_Loaded)

       return;+

    */


    if ((this->m_flg_widget_selected == this->WIDGET_RULER) &&

        (this->m_flg_widget != this->WIDGET_RULER))

    {

        m_pDistWidget->RemoveObserver(m_DistCallback);

        m_DistCallback->Delete();

        m_pDistWidget->Delete();

        m_pDistRepr2D->Delete();

        m_pPtDistHandle2D->Delete();

    }


    if ((this->m_flg_widget_selected == this->WIDGET_SEED) &&

        (this->m_flg_widget != this->WIDGET_SEED))

    {

        m_pSeedWidget->RemoveObserver(m_SeedCallback);

        m_SeedCallback->Delete();

        m_pSeedWidget->Delete();

        m_pSeedRepr->Delete();

        m_pSeedHandle->Delete();

    }


    if (m_flg_widget == this->WIDGET_NULL)

        return;


    if ((this->m_flg_widget_selected != this->WIDGET_RULER) &&

        (this->m_flg_widget == this->WIDGET_RULER))

    {

        //distance

     // Create the widget and its representation

     m_pPtDistHandle2D = vtkPointHandleRepresentation2D::New();

     m_pPtDistHandle2D->GetProperty()->SetColor(1,0,0);


     m_pDistRepr2D = vtkDistanceRepresentation2D::New();

     m_pDistRepr2D->SetHandleRepresentation(m_pPtDistHandle2D);

     m_pDistRepr2D->GetAxis()->SetNumberOfMinorTicks(4);

     m_pDistRepr2D->GetAxis()->SetTickLength(9);

     m_pDistRepr2D->GetAxis()->SetTitlePosition(0.2);


        m_pDistWidget = vtkDistanceWidget::New();

        m_pDistWidget->SetInteractor(this->m_iren);

        m_pDistWidget->CreateDefaultRepresentation();

        m_pDistWidget->SetRepresentation(m_pDistRepr2D);

       

        m_DistCallback = vtkDistanceAxiCallback::New();

        m_DistCallback->Renderer = this->m_ren;

        m_DistCallback->RenderWindow = this->m_renWin;

        m_DistCallback->Distance = m_pDistRepr2D;

        m_DistCallback->DistanceWidget = m_pDistWidget;

     m_DistCallback->m_pNumberPixelsAlongAxis = NULL;

     m_DistCallback->m_pPixelSizeMilimeter = NULL;

     m_DistCallback->m_pSliceThickness = NULL;

        m_pDistWidget->AddObserver(vtkDistanceAxiCallback::AnyEvent, m_DistCallback);

        m_pDistWidget->On();

    }




    if ((this->m_flg_widget_selected != this->WIDGET_SEED) &&

        (this->m_flg_widget == this->WIDGET_SEED))

    {

        //seed

        m_pSeedHandle = vtkPointHandleRepresentation2D::New();

        m_pSeedHandle->GetProperty()->SetColor(1,0,0);

        m_pSeedRepr = vtkSeedRepresentation::New();

        m_pSeedRepr->SetHandleRepresentation(m_pSeedHandle);


        m_pSeedWidget = vtkSeedWidget::New();

        m_pSeedWidget->SetInteractor(this->m_iren);

        m_pSeedWidget->SetRepresentation(m_pSeedRepr);


        m_SeedCallback = vtkSeedAxiCallback::New();

        m_SeedCallback->SeedRepresentation = m_pSeedRepr;

        m_pSeedWidget->AddObserver(vtkCommand::PlacePointEvent,m_SeedCallback);

        m_pSeedWidget->AddObserver(vtkCommand::InteractionEvent,m_SeedCallback);

        m_pSeedWidget->On();

    }


    this->m_flg_widget_selected = this->m_flg_widget;

}


void CVTKViewAxial::NewSeed(void)

{

    this->m_flg_widget = this->WIDGET_SEED;

    this->WidgetSelection();

}


 


 

Technical Support Jan 20, 2010 - 1:34 PM

We think the problem is hidden in these methods:

void CVTKViewAxial::ResetSize( int cx, int cy )
{
    // Reset the render window size, reposition the text actors.
    this->m_renWin->SetSize( cx, cy );
}

void CVTKViewAxial::OnSize( UINT nType, int cx, int cy ) 
{
    CView::OnSize( nType, cx, cy );
CRect rect;
    this->GetClientRect( &rect );
    RepositionBars( 0, 0xFFFF, 0 );
    this->m_renWin->SetSize( rect.right - rect.left, rect.bottom - rect.top );
}

They should be improved:
void CVTKViewAxial::ResetSize( int cx, int cy )
{
    cx; cy; // unused, we don’t need them
    if( m_renWin->GetSafeHwnd() == NULL )
        return;
UINT nCenterID = UINT( m_renWin->GetDlgCtrlID() );
    ASSERT( 0 < nCenterID && nCenterID < 0xFFFF );
    RepositionBars( 0, 0xFFFF, nCenterID );
CRect rc;
    this->m_renWin->GetWindowRect( &rc );
    m_renWin->SetSize( rc.Width(), rc.Height() );
}

void CVTKViewAxial::OnSize( UINT nType, int cx, int cy ) 
{
    CView::OnSize( nType, cx, cy );
    if (m_renWin->GetSafeHwnd() == NULL )
        return;
UINT nCenterID = UINT( m_renWin->GetDlgCtrlID() );
    ASSERT( 0 < nCenterID && nCenterID < 0xFFFF );
    RepositionBars( 0, 0xFFFF, nCenterID );
CRect rc;
    this->m_renWin->GetWindowRect( &rc );
    m_renWin->SetSize( rc.Width(), rc.Height() );
}


Luis Alberto Pereira Jan 20, 2010 - 6:33 PM

Hi support,


I saw your suggestion, but it not work.


m_renWin is a VTK class vtkWin32OpenGLRenderWindow witch is attached in a CVTKVIewAxial at CVTKViewAxial Create method.


Before that, m_renWin don´t have the GetSafeHwnd, GetDlgCtrlID and GetWindowRect.


I understand that m_renWin is attached to CCTKViewAxial and you behavior depends to last one behavior. This methods sare under CVTKViewAxial.


I think this problem is some bug between VTK classes and MFC/VS2008 classes. I wiill think an alternative funcitionality in substituition of my Toolbar in the view.


If you have another insight, pleases, tell me.


 


Thanks,

 



 

Technical Support Jan 21, 2010 - 12:10 PM

You should make the m_renWin object HWND-based. Your 3D rendering window should be a standalone window responsible for 3D output only and not containing any other child windows. This is very recommended for OpenGL, DirectX, Video and any other hardware accelerated screen output. Please take a look at the AviFrames sample application. It draws frames from AVI file into the scrollable window and user assumes the video is playing on the screen. It’s possible to magnify the video frame size and the view window becomes scrollable. The view window is one window and it does not draw video frames. The view window contains the child window. This child window has size of video frame and it’s responsible for rendering video frames only. When the view window becomes scrolling, then it’s simply shifting position of its child video frame rendering window. It’s not possible to implement such video scrolling based on direct video frame rendering into the scrollable view window.

Technical Support Jan 17, 2010 - 10:56 AM

We just meant the view window’s dialog control identifier must be any value but not the IDC_STATIC. If you used the IDC_STATIC dialog control identifier when creating your view window, then the RepostionBars() API of VS2008/MFC9 will not move your view window. This is the only known difference which can produce the issue you come across in VS2008. Please check this. If your view window really uses the IDC_STATIC dialog control identifier, then please change it to something else. The AFX_IDW_PANE_FIRST is the good choice and it will work in any VS.

Luis Alberto Pereira Jan 19, 2010 - 11:24 AM

 


Hi, thanks for help, but I did not understand when you say IDC_STATIC dialog control.


 


In CMainFrame I´m creating my deriveted CView class (m_wndAxiView) under CExtControlBar (m_wndRBAxiView) 


 


Where is the problem  ?


 


Thanks,


 





 




{




TRACE0("Failed to create m_wndResizableBar0\n");




return -1; // fail to create


}




this->m_wndRBAxiView.EnableDocking( CBRS_ALIGN_ANY );




if( !this->m_wndAxiView.Create(NULL,NULL,WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),




&m_wndRBAxiView,AFX_IDW_PANE_FIRST))




{




TRACE0("Failed to create m_wndDockedCtrlEdit\n");




return -1; // fail to create


}



 


 


if( ! m_wndRBAxiView.Create(_T("Axial View"),this,ID_VIEW_AXI_RBBAR))