void QtOgreRenderWindow::setCameraAspectRatio()
{
  if ( camera_ )
  {
    camera_->setAspectRatio( Ogre::Real( width() ) / Ogre::Real( height() ) );

    if ( camera_->getProjectionType() == Ogre::PT_ORTHOGRAPHIC )
    {
      Ogre::Matrix4 proj;
      buildScaledOrthoMatrix( proj,
                              -width() / ortho_scale_ / 2, width() / ortho_scale_ / 2,
                              -height() / ortho_scale_ / 2, height() / ortho_scale_ / 2,
                              camera_->getNearClipDistance(), camera_->getFarClipDistance() );
      camera_->setCustomProjectionMatrix(true, proj);
    }
  }
}
void wxOgreRenderWindow::setCameraAspectRatio()
{
  Ogre::Camera* camera = viewport_->getCamera();
  if ( camera )
  {
    int width;
    int height;
    GetSize( &width, &height );

    camera->setAspectRatio( Ogre::Real( width ) / Ogre::Real( height ) );

    if ( camera->getProjectionType() == Ogre::PT_ORTHOGRAPHIC )
    {
      Ogre::Matrix4 proj;
      buildScaledOrthoMatrix( proj, -width / ortho_scale_ / 2, width / ortho_scale_ / 2, -height / ortho_scale_ / 2, height / ortho_scale_ / 2,
                              camera->getNearClipDistance(), camera->getFarClipDistance() );
      camera->setCustomProjectionMatrix(true, proj);
    }
  }
}
void OrthoViewControllerCustom::updateCamera()
{
  //orientCamera();

  if(!panel_)
    return;
  //ROS_INFO("UPDATE CAMERA");

  float width = panel_->getViewport()->getActualWidth();
  float height = panel_->getViewport()->getActualHeight();

  float scale = scale_property_->getFloat();
  Ogre::Matrix4 proj;
  buildScaledOrthoMatrix( proj, -width / scale / 2, width / scale / 2, -height / scale / 2, height / scale / 2,
                          camera_->getNearClipDistance(), camera_->getFarClipDistance() );
  camera_->setCustomProjectionMatrix(true, proj);

  // For Z, we use half of the far-clip distance set in
  // selection_context.cpp, so that the shader program which computes
  // depth can see equal distances above and below the Z=0 plane.
  if(view_plane_property_->getString() == "XY")
  {
    camera_->setPosition( x_property_->getFloat(), y_property_->getFloat(), 500 );
  	camera_->lookAt(x_property_->getFloat(), y_property_->getFloat(), 0);
  }
  else if(view_plane_property_->getString() == "XZ")
  {
    camera_->setFixedYawAxis( true, Ogre::Vector3::UNIT_Z );
    camera_->setPosition( x_property_->getFloat(), -500, y_property_->getFloat());
	camera_->lookAt(x_property_->getFloat(), 0, y_property_->getFloat());
  }
  else if(view_plane_property_->getString() == "YZ")
  {
    camera_->setFixedYawAxis( true, Ogre::Vector3::UNIT_Z );
    camera_->setPosition( 500, x_property_->getFloat(), y_property_->getFloat());
	camera_->lookAt(0, x_property_->getFloat(), y_property_->getFloat());
  }

  //ROS_INFO("  %x (%f, %f)  (%f, %f)", camera_->getViewport(), width, height, width / scale, height / scale);
  context_->getSelectionManager()->setOrthoConfig(camera_->getViewport(), width / scale, height / scale);
}