GLData::GLData(QGLContext * glcontext, CloudList *cl, LayerList *ll, QObject *parent) : QObject(parent) { ll_ = ll; cl_ = cl; glcontext_ = glcontext; selection_color_[0] = 0.0f; selection_color_[1] = 0.0f; selection_color_[2] = 1.0f; selection_color_[3] = 1.0f; // // Set up color lookup buffer // glcontext_->makeCurrent(); color_lookup_buffer_.reset(new QGLBuffer(QGLBuffer::VertexBuffer)); CE(); IF_FAIL("create failed") = color_lookup_buffer_->create(); CE(); IF_FAIL("bind failed") = color_lookup_buffer_->bind(); CE(); color_lookup_buffer_->allocate(sizeof(float)*4); CE(); color_lookup_buffer_->release(); CE(); CloudList * clp = cl_; connect(clp, SIGNAL(deletingCloud(boost::shared_ptr<PointCloud>)), this, SLOT(deleteCloud(boost::shared_ptr<PointCloud>))); }
NetworkGraphics::~NetworkGraphics(){ qDebug() << "NetworkGraphics::~NetworkGraphics()"; linkMap.clear(); QList<GraphicNetCloud*> clouds = cloudAddrMap.values(); for(int i=0; i<clouds.count(); i++){ deleteCloud(clouds[i]); } QList<GraphicNetNode*> nodes = nodeMap.values(); for(int i=0; i<nodes.count(); i++){ if(scene->items().contains(nodes[i])){ scene->removeItem(nodes[i]); } delete nodes[i]; } /*QList<GraphicNetLink*> links = linkMap.values(); for(int i=0; i<links.count(); i++){ delete links[i]; }*/ }
SWViewerInterface::SWViewerInterface(QApplication *parent) : m_uiViewer(new Ui::SWUI_Viewer), m_bDesactiveUpdateParameters(false), m_bGLFullScreen(false) { // set absolute path m_absolutePath = QDir::currentPath() + "/"; // init main widget m_uiViewer->setupUi(this); this->setWindowTitle(QString("SWoOz : Viewer")); this->setWindowIcon(QIcon(m_absolutePath + "../data/images/logos/icon_swooz_viewer.png")); // middle container QHBoxLayout *l_pGLContainerLayout = new QHBoxLayout(); m_pGLContainer = new QWidget(); QGLFormat l_glFormat; l_glFormat.setVersion( 4, 3 ); l_glFormat.setProfile( QGLFormat::CompatibilityProfile); l_glFormat.setSampleBuffers( true ); QGLContext *l_glContext = new QGLContext(l_glFormat); m_pGLMultiObject = new SWGLMultiObjectWidget(l_glContext, m_pGLContainer); l_pGLContainerLayout->addWidget(m_pGLMultiObject); l_pGLContainerLayout->layout()->setContentsMargins(0,0,0,0); m_pGLContainer->setLayout(l_pGLContainerLayout); m_uiViewer->glScene->addWidget(m_pGLContainer); // init worker m_pWViewer = new SWViewerWorker(); // init connections // menu QObject::connect(m_uiViewer->actionExit, SIGNAL(triggered()), parent, SLOT(quit())); QObject::connect(m_uiViewer->actionOnline_documentation, SIGNAL(triggered()), this, SLOT(openOnlineDocumentation())); QObject::connect(m_uiViewer->actionAbout, SIGNAL(triggered()), this, SLOT(openAboutWindow())); QObject::connect(m_uiViewer->pbLoadCloud, SIGNAL(clicked()), this, SLOT(loadCloud())); QObject::connect(m_uiViewer->pbLoadMesh, SIGNAL(clicked()), this, SLOT(loadMesh())); QObject::connect(m_uiViewer->pbDeleteCloud, SIGNAL(clicked()), this, SLOT(deleteCloud())); QObject::connect(m_uiViewer->pbDeleteMesh, SIGNAL(clicked()), this, SLOT(deleteMesh())); QObject::connect(m_uiViewer->pbSetTexture, SIGNAL(clicked()), this, SLOT(setTexture())); QObject::connect(m_uiViewer->lwClouds, SIGNAL(currentRowChanged(int)), this, SLOT(updateCloudInterfaceParameters())); QObject::connect(m_uiViewer->lwMeshes, SIGNAL(currentRowChanged(int)), this, SLOT(updateMeshInterfaceParameters())); QObject::connect(m_uiViewer->lwClouds, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(updateCloudInterfaceParameters(QListWidgetItem*))); QObject::connect(m_uiViewer->lwMeshes, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(updateMeshInterfaceParameters(QListWidgetItem*))); QObject::connect(m_uiViewer->lwClouds, SIGNAL(currentRowChanged(int)), m_pWViewer, SLOT(updateCloudAnimationPath(int))); QObject::connect(m_uiViewer->lwMeshes, SIGNAL(currentRowChanged(int)), m_pWViewer, SLOT(updateMeshAnimationPath(int))); QObject::connect(this, SIGNAL(cloudCurrentRowChanged(int)), m_pWViewer, SLOT(updateCloudAnimationPath(int))); QObject::connect(this, SIGNAL(meshCurrentRowChanged(int)), m_pWViewer, SLOT(updateMeshAnimationPath(int))); QObject::connect(m_uiViewer->lwClouds, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(updateCloudAnimationPath(QListWidgetItem*))); QObject::connect(m_uiViewer->lwMeshes, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(updateMeshAnimationPath(QListWidgetItem*))); // update interface QObject::connect(m_uiViewer->dsbRX, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double))); QObject::connect(m_uiViewer->dsbRY, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double))); QObject::connect(m_uiViewer->dsbRZ, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double))); QObject::connect(m_uiViewer->dsbTrX, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double))); QObject::connect(m_uiViewer->dsbTrY, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double))); QObject::connect(m_uiViewer->dsbTrZ, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double))); QObject::connect(m_uiViewer->dsbScaling, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double))); QObject::connect(m_uiViewer->cbDisplayLines, SIGNAL(clicked()), this, SLOT(updateParameters())); QObject::connect(m_uiViewer->cbVisible, SIGNAL(clicked()), this, SLOT(updateParameters())); QObject::connect(m_uiViewer->rbDisplayOriginalColor, SIGNAL(clicked()), this, SLOT(updateParameters())); QObject::connect(m_uiViewer->rbDisplayTexture, SIGNAL(clicked()), this, SLOT(updateParameters())); QObject::connect(m_uiViewer->rbDisplayUnicolor, SIGNAL(clicked()), this, SLOT(updateParameters())); QObject::connect(m_uiViewer->sbColorB, SIGNAL(valueChanged(int)), this, SLOT(updateParameters(int))); QObject::connect(m_uiViewer->sbColorG, SIGNAL(valueChanged(int)), this, SLOT(updateParameters(int))); QObject::connect(m_uiViewer->sbColorR, SIGNAL(valueChanged(int)), this, SLOT(updateParameters(int))); QObject::connect(m_uiViewer->dsbLightX, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double))); QObject::connect(m_uiViewer->dsbLightY, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double))); QObject::connect(m_uiViewer->dsbLightZ, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double))); QObject::connect(m_uiViewer->leTexturePath, SIGNAL(textChanged(QString)), this, SLOT(updateParameters(QString))); QObject::connect(m_uiViewer->dsbAmbiantLight1, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double))); QObject::connect(m_uiViewer->dsbAmbiantLight2, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double))); QObject::connect(m_uiViewer->dsbAmbiantLight3, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double))); QObject::connect(m_uiViewer->dsbDiffusLight1, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double))); QObject::connect(m_uiViewer->dsbDiffusLight2, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double))); QObject::connect(m_uiViewer->dsbDiffusLight3, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double))); QObject::connect(m_uiViewer->dsbSpecularLight1, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double))); QObject::connect(m_uiViewer->dsbSpecularLight2, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double))); QObject::connect(m_uiViewer->dsbSpecularLight3, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double))); QObject::connect(m_uiViewer->dsbAmbiantK, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double))); QObject::connect(m_uiViewer->dsbDiffusK, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double))); QObject::connect(m_uiViewer->dsbSpecularK, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double))); QObject::connect(m_uiViewer->dsbSpecularP, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double))); // push buttons QObject::connect(m_uiViewer->pbSetCamera, SIGNAL(clicked()), this, SLOT(setCameraToCurrentItem())); QObject::connect(m_uiViewer->pbResetCamera, SIGNAL(clicked()), m_pGLMultiObject, SLOT(resetCamera())); QObject::connect(m_uiViewer->pbLaunchAllAnim, SIGNAL(clicked()), m_pWViewer, SLOT(startLoop())); QObject::connect(m_uiViewer->pbSetModFile, SIGNAL(clicked()), this, SLOT(loadModFile())); QObject::connect(m_uiViewer->pbSetSeqFile, SIGNAL(clicked()), this, SLOT(loadSeqFile())); QObject::connect(m_uiViewer->pbSetMeshCorr, SIGNAL(clicked()), this, SLOT(loadMeshCorrFile())); // fullscreen QObject::connect(m_pGLMultiObject, SIGNAL(enableFullScreen()), this, SLOT(enableGLFullScreen())); QObject::connect(m_pGLMultiObject, SIGNAL(disableFullScreen()), this, SLOT(disableGLFullScreen())); // worker QObject::connect(this, SIGNAL(stopLoop()), m_pWViewer, SLOT(stopLoop())); QObject::connect(this, SIGNAL(setModFilePath(bool,int,QString)), m_pWViewer, SLOT(setModFile(bool,int,QString))); QObject::connect(this, SIGNAL(setSeqFilePath(bool,int,QString)), m_pWViewer, SLOT(setSeqFile(bool,int,QString))); QObject::connect(this, SIGNAL(setCorrFilePath(bool,int,QString)), m_pWViewer, SLOT(setCorrFilePath(bool,int,QString))); QObject::connect(m_pWViewer, SIGNAL(sendAnimationPathFile(QString,QString,QString)), this, SLOT(updateAnimationPathFileDisplay(QString,QString,QString))); QObject::connect(this, SIGNAL(deleteAnimation(bool,int)), m_pWViewer, SLOT(deleteAnimation(bool,int))); QObject::connect(this, SIGNAL(addAnimation(bool)), m_pWViewer, SLOT(addAnimation(bool))); QObject::connect(m_pWViewer, SIGNAL(sendOffsetAnimation(SWAnimationSendDataPtr)),m_pGLMultiObject, SLOT(setAnimationOffset(SWAnimationSendDataPtr)),Qt::DirectConnection); // QObject::connect(m_pWViewer, SIGNAL(sendOffsetAnimation(SWAnimationSendDataPtr)),m_pGLMultiObject, SLOT(setAnimationOffset(SWAnimationSendDataPtr))); QObject::connect(m_pWViewer, SIGNAL(startAnimation(bool,int)), m_pGLMultiObject, SLOT(beginAnimation(bool,int))); QObject::connect(m_pWViewer, SIGNAL(drawSceneSignal()), m_pGLMultiObject, SLOT(updateGL())); setStyleSheet("QGroupBox { padding: 10 0px 0 0px; color: blue; border: 1px solid gray; border-radius: 5px; margin-top: 1ex; /* leave space at the top for the title */}"); // init thread m_pWViewer->moveToThread(&m_TViewer); m_TViewer.start(); }
void NetworkGraphics::rebuildNetwork(){ //Update link data structures /*QList<NetLink*> links = network->getLinks(); for(int i=0; i<links.count(); i++){ NetLink* link = links[i]; if(!linkMap.contains(link)){ GraphicNetLink* graphicLink = new GraphicNetLink(link); linkMap.insert(link, graphicLink); //scene->addItem(graphLink); } } */ //Update node data structures QList<NetNode*> nodes = network->getNodes(); for(int i=0; i<nodes.count(); i++){ NetNode* node = nodes[i]; GraphicNetNode* graphicNode = NULL; if(!nodeMap.contains(node)){ graphicNode = new GraphicNetNode(node); graphicNode->setZValue(10); nodeMap.insert(node, graphicNode); } else{ graphicNode = nodeMap[node]; graphicNode->updateAddress(); } raw_address address = node->getAddress(); //Check if a cloud needs to be constructed GraphicNetCloud* cloud = NULL; if(cloudAddrMap.contains(address)){ //Retrive cloud cloud = cloudAddrMap[address]; if(!cloud->hasNode(graphicNode)){ cloud->addNode(graphicNode); } } else{ //Build new cloud QList<GraphicNetNode*> cloudNodes = getNodesByAddress(address); cloud = new GraphicNetCloud(address, cloudNodes); cloud->setZValue(5); cloudAddrMap.insert(address, cloud); scene->addItem(cloud); //cloud->setPos(-20.0, -20.0); } //Update cloud association if(cloudMap.contains(graphicNode)){ GraphicNetCloud* oldCloud = cloudMap[graphicNode]; if(oldCloud != cloud){ oldCloud->removeNode(graphicNode); if(oldCloud->getNodeCount() < 1){ cloudMap.remove(graphicNode); deleteCloud(oldCloud); } } } cloudMap.insert(graphicNode, cloud); } }