HUDCamera.cpp
Go to the documentation of this file.
00001 /* 
00002  * Copyright (c) 2013 University of Jaume-I.
00003  * All rights reserved. This program and the accompanying materials
00004  * are made available under the terms of the GNU Public License v3.0
00005  * which accompanies this distribution, and is available at
00006  * http://www.gnu.org/licenses/gpl.html
00007  * 
00008  * Contributors:
00009  *     Mario Prats
00010  *     Javier Perez
00011  */
00012 
00013 #include <uwsim/HUDCamera.h>
00014 #include <string.h>
00015 #include <iostream>
00016 
00017 HUDCamera::HUDCamera(unsigned int width, unsigned int height, unsigned int posx, unsigned int posy, double scale,
00018                      int blackWhite)
00019 {
00020   this->width = width;
00021   this->height = height;
00022   this->posx = posx;
00023   this->posy = posy;
00024   this->scale = scale;
00025   osg_image = new osg::Image();
00026   if (blackWhite)
00027   {
00028     osg_image->allocateImage(width, height, 1, GL_LUMINANCE, GL_UNSIGNED_BYTE);
00029     memset(osg_image->data(), 0, width * height * 1 * sizeof(unsigned char));
00030   }
00031   else
00032   {
00033     osg_image->allocateImage(width, height, 1, GL_RGB, GL_UNSIGNED_BYTE);
00034     memset(osg_image->data(), 0, width * height * 3 * sizeof(unsigned char));
00035   }
00036 
00037   ready_ = false;
00038   //OSG_INFO << "HUDCamera::HUDCamera Constructor finished " << info_topic << std::endl;
00039 }
00040 
00041 osg::ref_ptr<osgWidget::Window> HUDCamera::getWidgetWindow()
00042 {
00043   osg::ref_ptr < osgWidget::Box > box = new osgWidget::Box("HUDCameraBox", osgWidget::Box::HORIZONTAL, true);
00044   widget = new osgWidget::Widget("HUDCameraWidget", width, height);
00045   widget->setUpdateCallback(new widgetUpdateCallback(osg_image));
00046   //widget->setImage(osg_image,true,false);
00047   box->addWidget(widget);
00048   box->setX(posx);
00049   box->setY(posy);
00050   box->setScale(scale);
00051   box->getBackground()->setColor(1.0f, 0.0f, 0.0f, 0.8f);
00052   box->attachMoveCallback();
00053   box->attachScaleCallback();
00054   return box;
00055 }
00056 
00057 HUDCamera::~HUDCamera()
00058 {
00059 }
00060 


uwsim
Author(s): Mario Prats
autogenerated on Mon Oct 6 2014 08:24:07