PhotoTexturingWidget::PhotoTexturingWidget(MeshEditInterface* plugin, PhotoTexturer* texturer,MeshModel &m,GLArea *gla): MeshlabEditDockWidget(gla) { lastDirectory = ""; connect(this,SIGNAL(updateGLAreaTextures()),gla,SLOT(updateTexture())); connect(this,SIGNAL(setGLAreaTextureMode(vcg::GLW::TextureMode)),gla,SLOT(setTextureMode(vcg::GLW::TextureMode))); connect(this,SIGNAL(updateMainWindowMenus()),gla,SIGNAL(updateMainWindowMenus())); ptPlugin = plugin; photoTexturer = texturer; PhotoTexturingWidget::ui.setupUi(this); this->setWidget(ui.main_frame); //this->setFeatures(QDockWidget::AllDockWidgetFeatures); this->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetClosable); this->setAllowedAreas(Qt::NoDockWidgetArea); this->setFloating(true); mesh = &m; glarea = gla; //setting up the headers for the tblewidget //QStringList headers; //headers << "Camera" << "Image"; //ui.cameraTableWidget->setHorizontalHeaderLabels(headers); connect(ui.configurationLoadPushButton, SIGNAL(clicked()),this,SLOT(loadConfigurationFile())); connect(ui.configurationSavePushButton, SIGNAL(clicked()),this,SLOT(saveConfigurationFile())); connect(ui.exportToMaxScriptPushButton, SIGNAL(clicked()),this,SLOT(exportCamerasToMaxScript())); connect(ui.convertToTsaiCameraPushButton, SIGNAL(clicked()),this,SLOT(convertToTsaiCamera())); connect(ui.addCameraPushButton, SIGNAL(clicked()),this,SLOT(addCamera())); connect(ui.removeCameraPushButton, SIGNAL(clicked()),this,SLOT(removeCamera())); connect(ui.assignImagePushButton, SIGNAL(clicked()),this,SLOT(assignImage())); connect(ui.calculateTexturesPushButton, SIGNAL(clicked()),this,SLOT(calculateTextures())); connect(ui.combineTexturesPushButton, SIGNAL(clicked()),this,SLOT(combineTextures())); connect(ui.unprojectTexturePushButton, SIGNAL(clicked()),this,SLOT(unprojectTextures())); connect(ui.bakeTexturePushButton, SIGNAL(clicked()),this,SLOT(bakeTextures())); connect(ui.textureListWidget, SIGNAL(itemClicked(QListWidgetItem* )),this,SLOT(selectCurrentTexture())); connect(ui.resetPushButton, SIGNAL(clicked()),this,SLOT(reset())); connect(ui.closePushButton, SIGNAL(clicked()),this,SLOT(close())); //connect(ui.cancelPushButton, SIGNAL(clicked()),this,SLOT(cancel())); photoTexturer->storeOriginalTextureCoordinates(mesh); loadDefaultSettings(); update(); }
QGraphicsViewAdapter::QGraphicsViewAdapter(osg::Image* image, QWidget* widget): _image(image), _previousQtMouseX(-1), _previousQtMouseY(-1), _previousSentEvent(false), _qtKeyModifiers(Qt::NoModifier), _backgroundColor(255, 255, 255), _widget(widget) { // make sure we have a valid QApplication before we start creating widgets. getOrCreateQApplication(); setUpKeyMap(); _graphicsScene = new QGraphicsScene; _graphicsScene->addWidget(widget); _graphicsView = new QGraphicsView; _graphicsView->setScene(_graphicsScene); _graphicsView->viewport()->setParent(0); #if (QT_VERSION_CHECK(4, 5, 0) <= QT_VERSION) _graphicsScene->setStickyFocus(true); #endif _width = _graphicsScene->width(); _height = _graphicsScene->height(); _qimages[0] = QImage(QSize(_width, _height), s_imageFormat); _qimages[1] = QImage(QSize(_width, _height), s_imageFormat); _qimages[2] = QImage(QSize(_width, _height), s_imageFormat); _currentRead = 0; _currentWrite = 1; _previousWrite = 2; _previousFrameNumber = 0; _newImageAvailable = false; connect(_graphicsScene, SIGNAL(changed(const QList<QRectF> &)), this, SLOT(repaintRequestedSlot(const QList<QRectF> &))); connect(_graphicsScene, SIGNAL(sceneRectChanged(const QRectF &)), this, SLOT(repaintRequestedSlot(const QRectF &))); assignImage(0); }
QGraphicsViewAdapter::QGraphicsViewAdapter( osg::Image* image, QWidget* widget ): _image( image ), _qtKeyModifiers( Qt::NoModifier ), _backgroundColor( 255,255,255 ) { // make sure we have a valid QApplication before we start creating widgets. this->getOrCreateQApplication(); setUpKeyMap(); _graphicsScene = new QGraphicsScene(); _graphicsView = new QGraphicsView; _graphicsScene->addWidget( widget ); _graphicsView->setScene( _graphicsScene ); #if (QT_VERSION_CHECK(4, 5, 0) <= QT_VERSION) _graphicsScene->setStickyFocus( true ); #endif _graphicsView->viewport()->setParent( 0 ); int width = ( int ) _graphicsScene->width(); int height = ( int ) _graphicsScene->height(); _qimages[0] = QImage( QSize( width, height ), QImage::Format_ARGB32 ); _qimages[0].fill( _backgroundColor.rgba() ); _qimages[0] = QGLWidget::convertToGLFormat( _qimages[0] ); _qimages[1] = QImage( QSize( width, height ), QImage::Format_ARGB32 ); _qimages[1].fill( _backgroundColor.rgba() ); _qimages[2] = QImage( QSize( width, height ), QImage::Format_ARGB32 ); _qimages[2].fill( _backgroundColor.rgba() ); _currentRead = 0; _currentWrite = 1; _previousWrite = 2; _previousFrameNumber = 0; _newImageAvailable = false; connect( _graphicsScene, SIGNAL( changed( const QList<QRectF>& ) ), this, SLOT( repaintRequestedSlot( const QList<QRectF>& ) ) ); assignImage( 0 ); }
void QGraphicsViewAdapter::setFrameLastRendered(const osg::FrameStamp* frameStamp) { OSG_INFO<<"setFrameLastRendered("<<frameStamp->getFrameNumber()<<")"<<std::endl; if (_newImageAvailable && _previousFrameNumber!=frameStamp->getFrameNumber()) { { OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_qimagesMutex); // make sure that _previousFrameNumber hasn't been updated by another thread since we entered this branch. if (_previousFrameNumber==frameStamp->getFrameNumber()) return; _previousFrameNumber = frameStamp->getFrameNumber(); std::swap(_currentRead, _previousWrite); _newImageAvailable = false; } assignImage(_currentRead); } }