Exemple #1
0
Document::~Document()
{
	m_bDeleted = true;
	
	ViewList viewsToDelete = m_viewList;
	const ViewList::iterator end = viewsToDelete.end();
	for ( ViewList::iterator it = viewsToDelete.begin(); it != end; ++it )
		(*it)->deleteLater();
}
Exemple #2
0
void Canvas::drawForeground(QPainter &p, const QRect & clip) {
	QCanvas::drawForeground(p, clip);

	if (!m_pMessageTimeout->isActive())
		return;

	// Following code stolen and adapted from amarok/src/playlist.cpp :)

	// Find out width of smallest view
	QSize minSize;

	const ViewList viewList = p_itemDocument->viewList();

	ViewList::const_iterator end = viewList.end();
	View *firstView = 0;
	for (ViewList::const_iterator it = viewList.begin(); it != end; ++it) {
		if (!*it) continue;

		if (!firstView) {
			firstView = *it;
			minSize = (*it)->size();
		} else	minSize = minSize.boundedTo((*it)->size());
	}

	if (!firstView) return;

	QSimpleRichText *t = new QSimpleRichText(m_message, QApplication::font());

	const int w = t->width();
	const int h = t->height();
	const int x = rect().left() + 15;
	const int y = rect().top() + 15;
	const int b = 10; // text padding

	if (w + 2 * b >= minSize.width() || h + 2 * b >= minSize.height()) {
		delete t;
		return;
	}

	p.setBrush(firstView->colorGroup().background());

	p.drawRoundRect(x, y,
			w + 2 * b,
			h + 2 * b,
			(8 * 200) / (w + 2 * b),
			(8 * 200) / (h + 2 * b));

	t->draw(&p, x + b, y + b, QRect(), firstView->colorGroup());
	delete t;
}
    virtual ReadResult readObject(std::istream& fin, const osgDB::ReaderWriter::Options* options) const
    {
        osgDB::Input fr;
        fr.attach(&fin);
        fr.setOptions(options);

        typedef std::vector< osg::ref_ptr<osgViewer::View> > ViewList;
        ViewList viewList;

        // load all nodes in file, placing them in a group.
        while(!fr.eof())
        {
            osg::ref_ptr<osg::Object> object = fr.readObject();
            osgViewer::View* view = dynamic_cast<osgViewer::View*>(object.get());
            if (view)
            {
                viewList.push_back(view);
            }
            else fr.advanceOverCurrentFieldOrBlock();
        }

        if  (viewList.empty())
        {
            return ReadResult("No data loaded");
        }
        else if (viewList.size()==1)
        {
            return viewList.front().get();
        }
        else
        {
            OSG_NOTICE<<"Found multiple view's, just taking first"<<std::endl;
            return viewList.front().get();
        }

    }