PanelPaletteManager::PanelPaletteManager(Unity2dPanel* panel)
 : QObject(panel), m_panel(panel)
{
    connect(DashClient::instance(), SIGNAL(activeChanged(bool)), this, SLOT(updatePalette()));
    connect(DashClient::instance(), SIGNAL(dashDisconnected()), this, SLOT(updatePalette()));
    connect(HUDClient::instance(), SIGNAL(activeChanged(bool)), this, SLOT(updatePalette()));
    connect(DashClient::instance(), SIGNAL(screenChanged(int)), this, SLOT(updatePalette()));
    connect(HUDClient::instance(), SIGNAL(screenChanged(int)), this, SLOT(updatePalette()));
    connect(&unity2dConfiguration(), SIGNAL(averageBgColorChanged(QString)), this, SLOT(updatePalette()));

    m_gConnector.connect(gtk_settings_get_default(), "notify::gtk-theme-name", G_CALLBACK(onThemeChanged), this);
    updatePalette();
}
void QGraphicsWidgetPrivate::resolvePalette(uint inheritedMask)
{
    inheritedPaletteResolveMask = inheritedMask;
    QPalette naturalPalette = naturalWidgetPalette();
    QPalette resolvedPalette = palette.resolve(naturalPalette);
    updatePalette(resolvedPalette);
}
示例#3
0
void Utility::updateShader() {
  if(config->video.shader == "None") {
    video.set(Video::Shader, (const char*)"");
    video.set(Video::Filter, Video::FilterNearest);
  } else if(config->video.shader == "Blur") {
    video.set(Video::Shader, (const char*)"");
    video.set(Video::Filter, Video::FilterLinear);
  } else if(config->video.shader == "Display Emulation" && config->video.driver != "OpenGL") {
    video.set(Video::Shader, (const char*)"");
    video.set(Video::Filter, Video::FilterLinear);
  } else if(config->video.shader == "Display Emulation") {
    if(program->active) {
      string pathname = program->path("Video Shaders/");
      pathname.append("Display Emulation/");
      pathname.append(presentation->systemName, ".shader/");
      if(directory::exists(pathname)) {
        video.set(Video::Shader, (const char*)pathname);
      } else {
        video.set(Video::Shader, (const char*)"");
        video.set(Video::Filter, Video::FilterLinear);
      }
    } else {
      video.set(Video::Shader, (const char*)"");
      video.set(Video::Filter, Video::FilterLinear);
    }
  } else {
    video.set(Video::Shader, (const char*)config->video.shader);
  }
  updatePalette();
}
示例#4
0
void SmackerPlayer::updateFrame() {

	if (!_smackerDecoder || !_smackerSurface)
		return;

	const Graphics::Surface *smackerFrame = _smackerDecoder->decodeNextFrame();

	if (_smackerFirst) {
		_smackerSurface->setSmackerFrame(smackerFrame);
		if (_drawX < 0 || _drawY < 0) {
			if (_doubleSurface) {
				_drawX = 320 - _smackerDecoder->getWidth();
				_drawY = 240 - _smackerDecoder->getHeight();
			} else {
				_drawX = (640 - _smackerDecoder->getWidth()) / 2;
				_drawY = (480 - _smackerDecoder->getHeight()) / 2;
			}
		}
		_smackerSurface->getDrawRect().x = _drawX;
		_smackerSurface->getDrawRect().y = _drawY;
		_smackerFirst = false;
	}

	if (_smackerDecoder->hasDirtyPalette())
		updatePalette();

}
K3ActiveLabelPrivate::K3ActiveLabelPrivate(K3ActiveLabel *qq)
    : q(qq)
{
   q->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
   q->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
   q->setFrameStyle(QFrame::NoFrame);
   q->setFocusPolicy(Qt::TabFocus);
   updatePalette();
}
示例#6
0
void Screen::update() {
	_ticks = _vm->_system->getMillis();
	updatePalette();

	if (_fullRefresh) {
		// NOTE When playing a fullscreen/doubled Smacker video usually a full screen refresh is needed
		_vm->_system->copyRectToScreen((const byte*)_backScreen->getPixels(), _backScreen->pitch, 0, 0, 640, 480);
		_fullRefresh = false;
		return;
	}

	_microTiles->clear();

	for (RenderQueue::iterator it = _renderQueue->begin(); it != _renderQueue->end(); ++it) {
		RenderItem &renderItem = (*it);
		renderItem._refresh = true;
		for (RenderQueue::iterator jt = _prevRenderQueue->begin(); jt != _prevRenderQueue->end(); ++jt) {
			RenderItem &prevRenderItem = (*jt);
			if (prevRenderItem == renderItem) {
				prevRenderItem._refresh = false;
				renderItem._refresh = false;
			}
		}
	}

	for (RenderQueue::iterator jt = _prevRenderQueue->begin(); jt != _prevRenderQueue->end(); ++jt) {
		RenderItem &prevRenderItem = (*jt);
		if (prevRenderItem._refresh)
			_microTiles->addRect(Common::Rect(prevRenderItem._destX, prevRenderItem._destY, prevRenderItem._destX + prevRenderItem._width, prevRenderItem._destY + prevRenderItem._height));
	}

	for (RenderQueue::iterator it = _renderQueue->begin(); it != _renderQueue->end(); ++it) {
		RenderItem &renderItem = (*it);
		if (renderItem._refresh)
			_microTiles->addRect(Common::Rect(renderItem._destX, renderItem._destY, renderItem._destX + renderItem._width, renderItem._destY + renderItem._height));
		renderItem._refresh = true;
	}

	RectangleList *updateRects = _microTiles->getRectangles();

	for (RenderQueue::iterator it = _renderQueue->begin(); it != _renderQueue->end(); ++it) {
		RenderItem &renderItem = (*it);
		for (RectangleList::iterator ri = updateRects->begin(); ri != updateRects->end(); ++ri)
			blitRenderItem(renderItem, *ri);
	}

	SWAP(_renderQueue, _prevRenderQueue);
	_renderQueue->clear();

	for (RectangleList::iterator ri = updateRects->begin(); ri != updateRects->end(); ++ri) {
		Common::Rect &r = *ri;
		_vm->_system->copyRectToScreen((const byte*)_backScreen->getBasePtr(r.left, r.top), _backScreen->pitch, r.left, r.top, r.width(), r.height());
	}

	delete updateRects;

}
示例#7
0
void
KdmItem::setWidgetAttribs(QWidget *widget)
{
    widget->setStyle(style.guistyle);
    widget->setPalette(style.palette);
    ::setWidgetAttribs(widget, style, style.frame);
    widget->installEventFilter(this);
    updatePalette(widget);
}
void PaletteViewControl::refresh()
{
  updatePalette();
  int sw = w/16;
  int sh = h/16;
  for(int i = 0; i < colors; i++) {
    render(palette[i], i & (sw-1), i/sw);
  }
  InvalidateRect(NULL, FALSE);
}
示例#9
0
TrackView::TrackView(SyncPage *page, QWidget *parent) :
    QAbstractScrollArea(parent),
    page(page),
    windowRows(0),
    readOnly(false),
    dragging(false)
{
	Q_ASSERT(page);

	lineEdit = new QLineEdit(this);
	lineEdit->setAutoFillBackground(true);
	lineEdit->hide();
	QDoubleValidator *lineEditValidator = new QDoubleValidator();
	lineEditValidator->setNotation(QDoubleValidator::StandardNotation);
	lineEditValidator->setLocale(QLocale::c());
	lineEdit->setValidator(lineEditValidator);

	QObject::connect(lineEdit, SIGNAL(editingFinished()), this, SLOT(onEditingFinished()));

	viewport()->setAutoFillBackground(false);

	setFocus(Qt::OtherFocusReason);

	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);

	scrollPosX = 0;
	scrollPosY = 0;

	editRow = 0;
	editTrack = 0;

	selectionStart = selectionEnd = QPoint(0, 0);

	updateFont(fontMetrics());
	updatePalette();

	stepPen = QPen();
	lerpPen = QPen(QBrush(Qt::red), 2);
	smoothPen = QPen(QBrush(Qt::green), 2);
	rampPen = QPen(QBrush(Qt::blue), 2);

	editBrush = Qt::yellow;
	bookmarkBrush = QColor(128, 128, 255);

	handCursor = QCursor(Qt::OpenHandCursor);
	setMouseTracking(true);

	setupScrollBars();
	QObject::connect(horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(onHScroll(int)));
	QObject::connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(onVScroll(int)));

	QObject::connect(page, SIGNAL(trackHeaderChanged(int)), this, SLOT(onTrackHeaderChanged(int)));
	QObject::connect(page, SIGNAL(trackDataChanged(int, int, int)), this, SLOT(onTrackDataChanged(int, int, int)));
}
示例#10
0
void PlayQueueView::readConfig()
{
    int origOpacity=backgroundOpacity;
    int origBlur=backgroundBlur;
    QString origCustomBackgroundFile=customBackgroundFile;
    BackgroundImage origType=backgroundImageType;
    setAutoExpand(Settings::self()->playQueueAutoExpand());
    setStartClosed(Settings::self()->playQueueStartClosed());
    backgroundImageType=(BackgroundImage)Settings::self()->playQueueBackground();
    backgroundOpacity=Settings::self()->playQueueBackgroundOpacity();
    backgroundBlur=Settings::self()->playQueueBackgroundBlur();
    customBackgroundFile=Settings::self()->playQueueBackgroundFile();
    setMode((ItemView::Mode)Settings::self()->playQueueView());
    switch (backgroundImageType) {
    case BI_None:
        if (origType!=backgroundImageType) {
            updatePalette();
            previousBackground=QPixmap();
            curentCover=QImage();
            curentBackground=QPixmap();
            view()->viewport()->update();
            setImage(QImage());
        }
        break;
    case BI_Cover:
        if (BI_None==origType) {
            updatePalette();
        }
        if ((origType!=backgroundImageType || backgroundOpacity!=origOpacity || backgroundBlur!=origBlur)) {
            setImage(CurrentCover::self()->isValid() ? CurrentCover::self()->image() : QImage());
        }
        break;
   case BI_Custom:
        if (BI_None==origType) {
            updatePalette();
        }
        if (origType!=backgroundImageType || backgroundOpacity!=origOpacity || backgroundBlur!=origBlur || origCustomBackgroundFile!=customBackgroundFile) {
            setImage(QImage(customBackgroundFile));
        }
        break;
    }
}
示例#11
0
MapDisplay::MapDisplay()
  : Display()
  , manual_object_( NULL )
  , loaded_( false )
  , resolution_( 0.0f )
  , width_( 0 )
  , height_( 0 )
{
  connect(this, SIGNAL( mapUpdated() ), this, SLOT( showMap() ));
  topic_property_ = new RosTopicProperty( "Topic", "",
                                          QString::fromStdString( ros::message_traits::datatype<nav_msgs::OccupancyGrid>() ),
                                          "nav_msgs::OccupancyGrid topic to subscribe to.",
                                          this, SLOT( updateTopic() ));

  alpha_property_ = new FloatProperty( "Alpha", 0.7,
                                       "Amount of transparency to apply to the map.",
                                       this, SLOT( updateAlpha() ));
  alpha_property_->setMin( 0 );
  alpha_property_->setMax( 1 );

  color_scheme_property_ = new EnumProperty( "Color Scheme", "map", "How to color the occupancy values.",
                                             this, SLOT( updatePalette() ));
  // Option values here must correspond to indices in palette_textures_ array in onInitialize() below.
  color_scheme_property_->addOption( "map", 0 );
  color_scheme_property_->addOption( "costmap", 1 );

  draw_under_property_ = new Property( "Draw Behind", false,
                                       "Rendering option, controls whether or not the map is always"
                                       " drawn behind everything else.",
                                       this, SLOT( updateDrawUnder() ));

  resolution_property_ = new FloatProperty( "Resolution", 0,
                                            "Resolution of the map. (not editable)", this );
  resolution_property_->setReadOnly( true );

  width_property_ = new IntProperty( "Width", 0,
                                     "Width of the map, in meters. (not editable)", this );
  width_property_->setReadOnly( true );
  
  height_property_ = new IntProperty( "Height", 0,
                                      "Height of the map, in meters. (not editable)", this );
  height_property_->setReadOnly( true );

  position_property_ = new VectorProperty( "Position", Ogre::Vector3::ZERO,
                                           "Position of the bottom left corner of the map, in meters. (not editable)",
                                           this );
  position_property_->setReadOnly( true );

  orientation_property_ = new QuaternionProperty( "Orientation", Ogre::Quaternion::IDENTITY,
                                                  "Orientation of the map. (not editable)",
                                                  this );
  orientation_property_->setReadOnly( true );
}
示例#12
0
bool
KdmItem::eventFilter(QObject *o, QEvent *e)
{
    if (e->type() == QEvent::WindowActivate ||
        e->type() == QEvent::WindowDeactivate ||
        e->type() == QEvent::EnabledChange)
    {
        updatePalette((QWidget *)o);
    } else if (e->type() == QEvent::ChildAdded) {
        ::setWidgetAttribs(myWidget, style, style.frame);
    }
    return false;
}
示例#13
0
static void updateWidget(EditorWidget *my_widget,QWidget *widget){
  QPalette pal(widget->palette());

  updatePalette(my_widget,widget,pal);

  if(override_default_qt_colors)
    widget->setPalette(pal);
  else
    widget->setPalette(sys_palette);

  //QFont font=QFont("Bitstream Vera Sans Mono",4);
  //widget->setFont(QApplication::font());
}
示例#14
0
void TrackView::changeEvent(QEvent *event)
{
	switch (event->type()) {
	case QEvent::FontChange:
		updateFont(fontMetrics());
		update();
		break;

	case QEvent::PaletteChange:
		updatePalette();
		break;

	default: ;
	}
}
示例#15
0
EffectsListWidget::EffectsListWidget(QWidget *parent) :
    QTreeWidget(parent)
{
    setColumnCount(1);
    setDragEnabled(true);
    setAcceptDrops(false);
    setHeaderHidden(true);
    setFrameShape(QFrame::NoFrame);
    setAutoFillBackground(false);
    setRootIsDecorated(true);
    setIndentation(10);
    //setSelectionMode(QAbstractItemView::ExtendedSelection);
    setDragDropMode(QAbstractItemView::DragOnly);
    updatePalette();
    connect(this, &EffectsListWidget::activated, this, &EffectsListWidget::slotExpandItem);
}
示例#16
0
void ToucheEngine::res_loadRoom(int num) {
	debugC(9, kDebugResource, "ToucheEngine::res_loadRoom() num=%d flag115=%d", num, _flagsTable[115]);

	debug(0, "Setting up room %d", num);

	const uint32 offsInfo = res_getDataOffset(kResourceTypeRoomInfo, num);
	_fData.seek(offsInfo);
	_fData.skip(2);
	const int roomImageNum = _fData.readUint16LE();
	_fData.skip(2);
	for (int i = 0; i < 256; ++i) {
		_fData.read(&_paletteBuffer[i * 4], 3);
		_paletteBuffer[i * 4 + 3] = 0;
	}

	const uint32 offsImage = res_getDataOffset(kResourceTypeRoomImage, roomImageNum);
	_fData.seek(offsImage);
	res_loadBackdrop();

	bool updateScreenPalette = _flagsTable[115] == 0;

	// Workaround to what appears to be a scripting bug. Scripts 27 and 100 triggers
	// a palette fading just after loading a room. Catch this, so that only *one*
	// palette refresh occurs.
	if ((_currentEpisodeNum == 27 && _currentRoomNum == 56 && num == 34) ||
	    (_currentEpisodeNum == 100 && _currentRoomNum == 2 && num == 1)) {
		updateScreenPalette = false;
	}

	if (updateScreenPalette) {
		updatePalette();
	} else {
		setPalette(0, 255, 0, 0, 0);
	}

	_currentRoomNum = num;
	_updatedRoomAreasTable[0] = 1;

	_fullRedrawCounter = 1;
	_roomNeedRedraw = true;

	_sequenceEntryTable[5].sprNum = -1;
	_sequenceEntryTable[5].seqNum = -1;
	_sequenceEntryTable[6].sprNum = -1;
	_sequenceEntryTable[6].seqNum = -1;
}
示例#17
0
void Screen::forceFadeOut() {
	const int FADE_AMOUNT = 2;
	bool repeatFlag;
	byte *srcP;
	int count;

	do {
		repeatFlag = false;
		for (srcP = &_tempPalette[0], count = 0; count < PALETTE_SIZE; ++count, ++srcP) {
			int v = *srcP;
			if (v) {
				repeatFlag = true;
				*srcP = MAX((int)*srcP - FADE_AMOUNT, 0);
			}
		}

		updatePalette();
		_vm->_events->pollEventsAndWait();
	} while (repeatFlag && !_vm->shouldQuit());
}
示例#18
0
void Screen::forceFadeIn() {
	Common::fill(&_tempPalette[0], &_tempPalette[PALETTE_SIZE], 0);

	const int FADE_AMOUNT = 2;
	bool repeatFlag;
	do {
		repeatFlag = false;
		const byte *srcP = &_rawPalette[0];
		byte *destP = &_tempPalette[0];

		for (int idx = 0; idx < PALETTE_SIZE; ++idx, ++srcP, ++destP) {
			if (*destP != *srcP) {
				repeatFlag = true;
				*destP = MIN((int)*destP + FADE_AMOUNT, (int)*srcP);
			}
		}

		updatePalette();
		_vm->_events->pollEventsAndWait();
	} while (repeatFlag);
}
示例#19
0
MainWindow::MainWindow() : QWidget()
, _positionUpdatedTimer(this)
, _body(this)
, _icon(CreateIcon())
, _titleText(qsl("Telegram")) {
	subscribe(Theme::Background(), [this](const Theme::BackgroundUpdate &data) {
		if (data.paletteChanged()) {
			if (_title) {
				_title->update();
			}
			updatePalette();
		}
	});
	subscribe(Global::RefUnreadCounterUpdate(), [this] { updateUnreadCounter(); });
	subscribe(Global::RefWorkMode(), [this](DBIWorkMode mode) { workmodeUpdated(mode); });
	subscribe(Messenger::Instance().authSessionChanged(), [this] { checkAuthSession(); });
	checkAuthSession();

	_isActiveTimer.setCallback([this] { updateIsActive(0); });
	_inactivePressTimer.setCallback([this] { setInactivePress(false); });
}
示例#20
0
void MainWindow::init() {
	Expects(!windowHandle());
	createWinId();

	initHook();
	updateWindowIcon();

	connect(windowHandle(), &QWindow::activeChanged, this, [this] { handleActiveChanged(); }, Qt::QueuedConnection);
	connect(windowHandle(), &QWindow::windowStateChanged, this, [this](Qt::WindowState state) { handleStateChanged(state); });

	_positionUpdatedTimer->setSingleShot(true);
	connect(_positionUpdatedTimer, SIGNAL(timeout()), this, SLOT(savePositionByTimer()));

	updatePalette();

	if ((_title = Platform::CreateTitleWidget(this))) {
		_title->init();
	}

	initSize();
	updateUnreadCounter();
}
示例#21
0
void PlayQueueView::setMode(ItemView::Mode m)
{
    if (m==mode || (ItemView::Mode_GroupedTree!=m && ItemView::Mode_Table!=m)) {
        return;
    }

    if (ItemView::Mode_Table==mode) {
        treeView->saveHeader();
    }

    switch (m) {
    case ItemView::Mode_GroupedTree:
        if (!groupedView) {
            groupedView=new PlayQueueGroupedView(this);
            groupedView->setContextMenuPolicy(Qt::ActionsContextMenu);
            groupedView->setIndentation(0);
            groupedView->setItemsExpandable(false);
            groupedView->setExpandsOnDoubleClick(false);
            groupedView->installFilter(new KeyEventHandler(groupedView, removeFromAction));
            addWidget(groupedView);
            connect(groupedView, SIGNAL(itemsSelected(bool)), SIGNAL(itemsSelected(bool)));
            connect(groupedView, SIGNAL(doubleClicked(const QModelIndex &)), SIGNAL(doubleClicked(const QModelIndex &)));
            updatePalette();
            #ifdef Q_OS_MAC
            groupedView->setAttribute(Qt::WA_MacShowFocusRect, 0);
            #endif
            groupedView->setProperty(ProxyStyle::constModifyFrameProp, ProxyStyle::VF_Top);
        }
        break;
    case ItemView::Mode_Table:
        if (!treeView) {
            treeView=new PlayQueueTreeView(this);
            treeView->setContextMenuPolicy(Qt::ActionsContextMenu);
            treeView->installFilter(new KeyEventHandler(treeView, removeFromAction));
            treeView->initHeader();
            addWidget(treeView);
            connect(treeView, SIGNAL(itemsSelected(bool)), SIGNAL(itemsSelected(bool)));
            connect(treeView, SIGNAL(doubleClicked(const QModelIndex &)), SIGNAL(doubleClicked(const QModelIndex &)));
            updatePalette();
            #ifdef Q_OS_MAC
            treeView->setAttribute(Qt::WA_MacShowFocusRect, 0);
            #endif
            treeView->setProperty(ProxyStyle::constModifyFrameProp, ProxyStyle::VF_Top);
        }
    default:
        break;
    }

    QAbstractItemModel *model=0;
    QList<QAction *> actions;
    if (ItemView::Mode_Count!=mode) {
        QAbstractItemView *v=view();
        model=v->model();
        v->setModel(0);
        actions=v->actions();
    }

    mode=m;
    QAbstractItemView *v=view();
    v->setModel(model);
    if (!actions.isEmpty() && v->actions().isEmpty()) {
        v->addActions(actions);
    }

    if (ItemView::Mode_Table==mode) {
        treeView->initHeader();
    }

    setCurrentWidget(static_cast<QWidget *>(view()));
    if (spinner) {
        spinner->setWidget(view());
        if (spinner->isActive()) {
            spinner->start();
        }
    }
    if (msgOverlay) {
        msgOverlay->setWidget(view());
    }
}
示例#22
0
static void updateApplication(EditorWidget *my_widget,QApplication *app){
  QPalette pal(app->palette());
  updatePalette(my_widget,NULL,pal);
  app->setPalette(pal);
}
示例#23
0
Highlighter::Highlighter(QTextDocument* parent)
	: QSyntaxHighlighter(parent)
	, m_Palette(std::make_shared<PythonPalette>(PythonPaletteManager::instance().palette()))
{
	updatePalette();
}
示例#24
0
void MapDisplay::showMap()
{
  if (current_map_.data.empty())
  {
    return;
  }

  if( !validateFloats( current_map_ ))
  {
    setStatus( StatusProperty::Error, "Map", "Message contained invalid floating point values (nans or infs)" );
    return;
  }

  if( current_map_.info.width * current_map_.info.height == 0 )
  {
    std::stringstream ss;
    ss << "Map is zero-sized (" << current_map_.info.width << "x" << current_map_.info.height << ")";
    setStatus( StatusProperty::Error, "Map", QString::fromStdString( ss.str() ));
    return;
  }

  setStatus( StatusProperty::Ok, "Message", "Map received" );

  ROS_DEBUG( "Received a %d X %d map @ %.3f m/pix\n",
             current_map_.info.width,
             current_map_.info.height,
             current_map_.info.resolution );

  float resolution = current_map_.info.resolution;

  int width = current_map_.info.width;
  int height = current_map_.info.height;


  Ogre::Vector3 position( current_map_.info.origin.position.x,
                          current_map_.info.origin.position.y,
                          current_map_.info.origin.position.z );
  Ogre::Quaternion orientation( current_map_.info.origin.orientation.w,
                                current_map_.info.origin.orientation.x,
                                current_map_.info.origin.orientation.y,
                                current_map_.info.origin.orientation.z );
  frame_ = current_map_.header.frame_id;
  if (frame_.empty())
  {
    frame_ = "/map";
  }

  unsigned int pixels_size = width * height;
  unsigned char* pixels = new unsigned char[pixels_size];
  memset(pixels, 255, pixels_size);

  bool map_status_set = false;
  unsigned int num_pixels_to_copy = pixels_size;
  if( pixels_size != current_map_.data.size() )
  {
    std::stringstream ss;
    ss << "Data size doesn't match width*height: width = " << width
       << ", height = " << height << ", data size = " << current_map_.data.size();
    setStatus( StatusProperty::Error, "Map", QString::fromStdString( ss.str() ));
    map_status_set = true;

    // Keep going, but don't read past the end of the data.
    if( current_map_.data.size() < pixels_size )
    {
      num_pixels_to_copy = current_map_.data.size();
    }
  }

  memcpy( pixels, &current_map_.data[0], num_pixels_to_copy );

  Ogre::DataStreamPtr pixel_stream;
  pixel_stream.bind( new Ogre::MemoryDataStream( pixels, pixels_size ));

  if( !texture_.isNull() )
  {
    Ogre::TextureManager::getSingleton().remove( texture_->getName() );
    texture_.setNull();
  }

  static int tex_count = 0;
  std::stringstream ss;
  ss << "MapTexture" << tex_count++;
  try
  {
    texture_ = Ogre::TextureManager::getSingleton().loadRawData( ss.str(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
                                                                 pixel_stream, width, height, Ogre::PF_L8, Ogre::TEX_TYPE_2D,
                                                                 0);

    if( !map_status_set )
    {
      setStatus( StatusProperty::Ok, "Map", "Map OK" );
    }
  }
  catch(Ogre::RenderingAPIException&)
  {
    Ogre::Image image;
    pixel_stream->seek(0);
    float fwidth = width;
    float fheight = height;
    if( width > height )
    {
      float aspect = fheight / fwidth;
      fwidth = 2048;
      fheight = fwidth * aspect;
    }
    else
    {
      float aspect = fwidth / fheight;
      fheight = 2048;
      fwidth = fheight * aspect;
    }

    {
      std::stringstream ss;
      ss << "Map is larger than your graphics card supports.  Downsampled from [" << width << "x" << height << "] to [" << fwidth << "x" << fheight << "]";
      setStatus(StatusProperty::Ok, "Map", QString::fromStdString( ss.str() ));
    }

    ROS_WARN("Failed to create full-size map texture, likely because your graphics card does not support textures of size > 2048.  Downsampling to [%d x %d]...", (int)fwidth, (int)fheight);
    //ROS_INFO("Stream size [%d], width [%f], height [%f], w * h [%f]", pixel_stream->size(), width, height, width * height);
    image.loadRawData(pixel_stream, width, height, Ogre::PF_L8);
    image.resize(fwidth, fheight, Ogre::Image::FILTER_NEAREST);
    ss << "Downsampled";
    texture_ = Ogre::TextureManager::getSingleton().loadImage(ss.str(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, image);
  }

  delete [] pixels;

  Ogre::Pass* pass = material_->getTechnique(0)->getPass(0);
  Ogre::TextureUnitState* tex_unit = NULL;
  if (pass->getNumTextureUnitStates() > 0)
  {
    tex_unit = pass->getTextureUnitState(0);
  }
  else
  {
    tex_unit = pass->createTextureUnitState();
  }

  tex_unit->setTextureName(texture_->getName());
  tex_unit->setTextureFiltering( Ogre::TFO_NONE );

  updatePalette();

  resolution_property_->setValue( resolution );
  width_property_->setValue( width );
  height_property_->setValue( height );
  position_property_->setVector( position );
  orientation_property_->setQuaternion( orientation );

  transformMap();
  manual_object_->setVisible( true );
  scene_node_->setScale( resolution * width, resolution * height, 1.0 );

  context_->queueRender();
}
示例#25
0
void QGraphicsWidgetPrivate::setPalette_helper(const QPalette &palette)
{
    if (this->palette == palette && this->palette.resolve() == palette.resolve())
        return;
    updatePalette(palette);
}