From 6e1f65e5f34c4ef3c02ee9b0f79be8f3332912e5 Mon Sep 17 00:00:00 2001 From: Sylvain Thery Date: Mon, 13 Apr 2015 17:32:22 +0200 Subject: [PATCH] fix lineWidth & fixed Size of window --- .../Utils/Shaders/shaderBoldColorLines.cpp | 4 +- CGoGN/src/Utils/Shaders/shaderBoldLines.cpp | 4 +- SCHNApps/include/schnapps.h | 2 +- SCHNApps/src/schnapps.cpp | 1 + SCHNApps/src/view.cpp | 464 +++++++----------- 5 files changed, 197 insertions(+), 278 deletions(-) diff --git a/CGoGN/src/Utils/Shaders/shaderBoldColorLines.cpp b/CGoGN/src/Utils/Shaders/shaderBoldColorLines.cpp index a9e1019c5..4f7be07cb 100644 --- a/CGoGN/src/Utils/Shaders/shaderBoldColorLines.cpp +++ b/CGoGN/src/Utils/Shaders/shaderBoldColorLines.cpp @@ -88,7 +88,7 @@ void ShaderBoldColorLines::setLineWidth(float pix) { glm::i32vec4 viewport; glGetIntegerv(GL_VIEWPORT, &(viewport[0])); - float lw = float((0.5*pix)/double(viewport[2])); + float lw = float(double(pix)/double(viewport[2])); bind(); glUniform1f(*m_uniform_lineWidth, lw); @@ -101,7 +101,7 @@ void ShaderBoldColorLines::updatePixelWidth() { glm::i32vec4 viewport; glGetIntegerv(GL_VIEWPORT, &(viewport[0])); - float lw = float((0.5*m_pixWidth)/double(viewport[2])); + float lw = float(double(m_pixWidth)/double(viewport[2])); bind(); glUniform1f(*m_uniform_lineWidth, lw); diff --git a/CGoGN/src/Utils/Shaders/shaderBoldLines.cpp b/CGoGN/src/Utils/Shaders/shaderBoldLines.cpp index 57dff9f22..2ec3cce54 100644 --- a/CGoGN/src/Utils/Shaders/shaderBoldLines.cpp +++ b/CGoGN/src/Utils/Shaders/shaderBoldLines.cpp @@ -86,7 +86,7 @@ void ShaderBoldLines::setLineWidth(float pix) { glm::i32vec4 viewport; glGetIntegerv(GL_VIEWPORT, &(viewport[0])); - float lw = float((0.5*pix)/double(viewport[2])); + float lw = float(double(pix)/double(viewport[2])); bind(); glUniform1f(*m_uniform_lineWidth, lw); @@ -99,7 +99,7 @@ void ShaderBoldLines::updatePixelWidth() { glm::i32vec4 viewport; glGetIntegerv(GL_VIEWPORT, &(viewport[0])); - float lw = float((0.5*m_pixWidth)/double(viewport[2])); + float lw = float(double(m_pixWidth)/double(viewport[2])); bind(); glUniform1f(*m_uniform_lineWidth, lw); diff --git a/SCHNApps/include/schnapps.h b/SCHNApps/include/schnapps.h index b0ca13f47..511472910 100644 --- a/SCHNApps/include/schnapps.h +++ b/SCHNApps/include/schnapps.h @@ -153,7 +153,7 @@ public slots: QString saveFileDialog(const QString& title, const QString& dir = QString(), const QString& filter = QString()); - void setWindowSize(int w, int h) { this->setFixedSize(w, h); } + void setWindowSize(int w, int h) { this->resize(w, h); } private slots: void loadPythonScriptFromFileDialog(); diff --git a/SCHNApps/src/schnapps.cpp b/SCHNApps/src/schnapps.cpp index 6cb4f7854..3d74fee4b 100644 --- a/SCHNApps/src/schnapps.cpp +++ b/SCHNApps/src/schnapps.cpp @@ -118,6 +118,7 @@ SCHNApps::SCHNApps(const QString& appPath, PythonQtObjectPtr& pythonContext, Pyt // create & setup central widget (views) m_centralLayout = new QVBoxLayout(centralwidget); + m_centralLayout->setMargin(2); m_rootSplitter = new QSplitter(centralwidget); b_rootSplitterInitialized = false; diff --git a/SCHNApps/src/view.cpp b/SCHNApps/src/view.cpp index a1b08eecd..86e6b1c44 100644 --- a/SCHNApps/src/view.cpp +++ b/SCHNApps/src/view.cpp @@ -13,7 +13,6 @@ #include #include #include -#include namespace CGoGN { @@ -22,15 +21,13 @@ namespace SCHNApps { unsigned int View::viewCount = 0; - -View::View(const QString& name, SCHNApps* s, const QGLWidget* shareWidget) : - QGLViewer( NULL, shareWidget), +View::View(const QString& name, SCHNApps* s, QGLFormat& format) : + QGLViewer(format, NULL, NULL), b_updatingUI(false), m_name(name), m_schnapps(s), m_currentCamera(NULL), - m_bbMin(0.0, 0.0, 0.0), - m_bbMax(0.0, 0.0, 0.0), + m_lastSelectedMap(NULL), m_buttonArea(NULL), m_closeButton(NULL), m_VsplitButton(NULL), @@ -39,19 +36,12 @@ View::View(const QString& name, SCHNApps* s, const QGLWidget* shareWidget) : m_mapsButton(NULL), m_pluginsButton(NULL), m_camerasButton(NULL), - m_dialogMaps(NULL), - m_dialogPlugins(NULL), - m_dialogCameras(NULL), - m_frameDrawer(NULL), - m_textureWallpaper(NULL), - m_shaderWallpaper(NULL), - b_saveSnapshots(false) + m_dialogMaps(NULL) { ++viewCount; - setSnapshotFormat("BMP"); - setSnapshotFileName(m_name); - setSnapshotQuality(100); + m_currentCamera = m_schnapps->addCamera(); + m_currentCamera->linkView(this); connect(m_schnapps, SIGNAL(selectedMapChanged(MapHandlerGen*,MapHandlerGen*)), this, SLOT(selectedMapChanged(MapHandlerGen*,MapHandlerGen*))); @@ -59,6 +49,8 @@ View::View(const QString& name, SCHNApps* s, const QGLWidget* shareWidget) : m_dialogPlugins = new ListPopUp("Enabled Plugins"); m_dialogCameras = new ListPopUp("Cameras"); +// setCurrentCamera(m_schnapps->addCamera()); + connect(m_schnapps, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(mapAdded(MapHandlerGen*))); connect(m_schnapps, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(mapRemoved(MapHandlerGen*))); connect(m_dialogMaps->list(), SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(mapCheckStateChanged(QListWidgetItem*))); @@ -80,11 +72,65 @@ View::View(const QString& name, SCHNApps* s, const QGLWidget* shareWidget) : foreach(Camera* cam, m_schnapps->getCameraSet().values()) cameraAdded(cam); + m_dialogCameras->check(m_currentCamera->getName(),Qt::Checked); +} + + + + + +View::View(const QString& name, SCHNApps* s, QGLFormat& format, const QGLWidget* shareWidget) : + QGLViewer(format, NULL, shareWidget), + b_updatingUI(false), + m_name(name), + m_schnapps(s), + m_currentCamera(NULL), + m_lastSelectedMap(NULL), + m_buttonArea(NULL), + m_closeButton(NULL), + m_VsplitButton(NULL), + m_HsplitButton(NULL), + m_buttonAreaLeft(NULL), + m_mapsButton(NULL), + m_pluginsButton(NULL), + m_camerasButton(NULL), + m_dialogMaps(NULL) +{ + ++viewCount; + m_currentCamera = m_schnapps->addCamera(); m_currentCamera->linkView(this); - m_dialogCameras->check(m_currentCamera->getName(),Qt::Checked); - connect(m_schnapps, SIGNAL(schnappsClosing()), this, SLOT(closeDialogs())); + connect(m_schnapps, SIGNAL(selectedMapChanged(MapHandlerGen*,MapHandlerGen*)), this, SLOT(selectedMapChanged(MapHandlerGen*,MapHandlerGen*))); + + m_dialogMaps = new ListPopUp("Linked Maps"); + m_dialogPlugins = new ListPopUp("Enabled Plugins"); + m_dialogCameras = new ListPopUp("Cameras"); + +// setCurrentCamera(m_schnapps->addCamera()); + + connect(m_schnapps, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(mapAdded(MapHandlerGen*))); + connect(m_schnapps, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(mapRemoved(MapHandlerGen*))); + connect(m_dialogMaps->list(), SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(mapCheckStateChanged(QListWidgetItem*))); + + foreach(MapHandlerGen* map, m_schnapps->getMapSet().values()) + mapAdded(map); + + connect(m_schnapps, SIGNAL(pluginEnabled(Plugin*)), this, SLOT(pluginEnabled(Plugin*))); + connect(m_schnapps, SIGNAL(pluginDisabled(Plugin*)), this, SLOT(pluginDisabled(Plugin*))); + connect(m_dialogPlugins->list(), SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(pluginCheckStateChanged(QListWidgetItem*))); + + foreach(Plugin* plug, m_schnapps->getPluginSet().values()) + pluginEnabled(plug); + + connect(m_schnapps, SIGNAL(cameraAdded(Camera*)), this, SLOT(cameraAdded(Camera*))); + connect(m_schnapps, SIGNAL(cameraRemoved(Camera*)), this, SLOT(cameraRemoved(Camera*))); + connect(m_dialogCameras->list(), SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(cameraCheckStateChanged(QListWidgetItem*))); + + foreach(Camera* cam, m_schnapps->getCameraSet().values()) + cameraAdded(cam); + + m_dialogCameras->check(m_currentCamera->getName(),Qt::Checked); } View::~View() @@ -93,12 +139,14 @@ View::~View() this->setCamera(c); m_currentCamera->unlinkView(this); + foreach(PluginInteraction* p, l_plugins) unlinkPlugin(p); foreach(MapHandlerGen* m, l_maps) unlinkMap(m); + delete m_buttonArea; delete m_buttonAreaLeft; @@ -107,16 +155,18 @@ View::~View() delete m_dialogCameras; } +void View::closeDialogs() +{ + m_dialogMaps->close(); + m_dialogPlugins->close(); + m_dialogCameras->close(); +} + void View::setCurrentCamera(Camera* c) { // DEBUG_SLOT(); - if(c != m_currentCamera && c) + if(c != m_currentCamera && c != NULL) { - // RECORDING - QTextStream* rec = m_schnapps->pythonStreamRecorder(); - if (rec) - *rec << this->getName() << ".setCurrentCamera(\"" << c->getName() << "\");" << endl; - Camera* prev = m_currentCamera; if(prev) prev->unlinkView(this); @@ -125,10 +175,10 @@ void View::setCurrentCamera(Camera* c) this->setCamera(m_currentCamera); m_currentCamera->linkView(this); - DEBUG_EMIT("currentCameraChanged"); - emit(currentCameraChanged(prev, c)); +// DEBUG_EMIT("currentCameraChanged"); +// emit(currentCameraChanged(prev, c)); - if (prev) + if(prev) { QListWidgetItem* prevItem = m_dialogCameras->findItem(prev->getName()); if(prevItem) @@ -138,8 +188,7 @@ void View::setCurrentCamera(Camera* c) b_updatingUI = false; } } - - if (m_currentCamera) + if(m_currentCamera) { QListWidgetItem* curItem = m_dialogCameras->findItem(m_currentCamera->getName()); if(curItem) @@ -150,7 +199,12 @@ void View::setCurrentCamera(Camera* c) } } - m_currentCamera->fitToViewsBoundingBox(); +// b_updatingUI = true; +// m_dialogCameras->check(c->getName(),Qt::Checked); +// b_updatingUI = false; + +// updateCurrentCameraBB(); + m_currentCamera->updateParams(); updateGL(); } } @@ -162,32 +216,23 @@ void View::setCurrentCamera(const QString& name) setCurrentCamera(c); } -bool View::usesCamera(const QString& name) const +bool View::usesCamera(const QString& cameraName) const { - Camera* c = m_schnapps->getCamera(name); - return usesCamera(c); + return m_currentCamera->getName() == cameraName; } - - void View::linkPlugin(PluginInteraction* plugin) { - // RECORDING - QTextStream* rec = m_schnapps->pythonStreamRecorder(); - if (rec) - *rec << this->getName() << ".linkPlugin(\"" << plugin->getName() << "\");" << endl; - DEBUG_SLOT(); if(plugin && !l_plugins.contains(plugin)) { l_plugins.push_back(plugin); plugin->linkView(this); - DEBUG_EMIT("pluginLinked"); emit(pluginLinked(plugin)); b_updatingUI = true; - m_dialogPlugins->check(plugin->getName(), Qt::Checked); + m_dialogPlugins->check(plugin->getName(),Qt::Checked); b_updatingUI = false; updateGL(); @@ -206,19 +251,12 @@ void View::unlinkPlugin(PluginInteraction* plugin) DEBUG_SLOT(); if(l_plugins.removeOne(plugin)) { - // RECORDING - QTextStream* rec = m_schnapps->pythonStreamRecorder(); - if (rec) - *rec << this->getName() << ".unlinkPlugin(\"" << plugin->getName() << "\");" << endl; - - plugin->unlinkView(this); - DEBUG_EMIT("pluginUnlinked"); emit(pluginUnlinked(plugin)); b_updatingUI = true; - m_dialogPlugins->check(plugin->getName(), Qt::Unchecked); + m_dialogPlugins->check(plugin->getName(),Qt::Unchecked); b_updatingUI = false; updateGL(); @@ -240,30 +278,27 @@ bool View::isLinkedToPlugin(const QString& name) const void View::linkMap(MapHandlerGen* map) { - // RECORDING - QTextStream* rec = m_schnapps->pythonStreamRecorder(); - if (rec) - *rec << this->getName() << ".linkMap(\"" << map->getName() << "\");" << endl; - DEBUG_SLOT(); if(map && !l_maps.contains(map)) { l_maps.push_back(map); map->linkView(this); - DEBUG_EMIT("mapLinked"); emit(mapLinked(map)); + std::cout << "View::linkMap Maps:"<getName().toStdString()<< std::endl; + m_currentCamera->updateParams(); + updateGL(); + +// connect(map->getFrame(), SIGNAL(modified()), this, SLOT(updateGL())); +// connect(map->getFrame(), SIGNAL(modified()), m_currentCamera, SLOT(BBModified(map))); connect(map, SIGNAL(selectedCellsChanged(CellSelectorGen*)), this, SLOT(updateGL())); - connect(map, SIGNAL(boundingBoxModified()), this, SLOT(updateBoundingBox())); if(map->isSelectedMap()) setManipulatedFrame(map->getFrame()); - updateBoundingBox(); - b_updatingUI = true; - m_dialogMaps->check(map->getName(), Qt::Checked); + m_dialogMaps->check(map->getName(),Qt::Checked); b_updatingUI = false; } } @@ -280,27 +315,24 @@ void View::unlinkMap(MapHandlerGen* map) DEBUG_SLOT(); if(l_maps.removeOne(map)) { - QTextStream* rec = m_schnapps->pythonStreamRecorder(); - if (rec) - *rec << this->getName() << ".unlinkMap(\"" << map->getName() << "\");" << endl; - - map->unlinkView(this); - DEBUG_EMIT("mapUnlinked"); emit(mapUnlinked(map)); +// updateCurrentCameraBB(); + m_currentCamera->updateParams(); + updateGL(); + + disconnect(map->getFrame(), SIGNAL(modified()), this, SLOT(updateGL())); disconnect(map, SIGNAL(selectedCellsChanged(CellSelectorGen*)), this, SLOT(updateGL())); - disconnect(map, SIGNAL(boundingBoxModified()), this, SLOT(updateBoundingBox())); if(map == m_schnapps->getSelectedMap()) setManipulatedFrame(NULL); - updateBoundingBox(); - b_updatingUI = true; - m_dialogMaps->check(map->getName(), Qt::Unchecked); + m_dialogMaps->check(map->getName(),Qt::Unchecked); b_updatingUI = false; + } } @@ -317,20 +349,21 @@ bool View::isLinkedToMap(const QString& name) const return l_maps.contains(m); } - - - - void View::init() { glewExperimental = GL_TRUE; // needed for GL Core Profile 3.3 glewInit(); - std::cout << "using " << glGetString(GL_VERSION) << std::endl; +// int major = 0; +// int minor = 0; +// glGetIntegerv(GL_MAJOR_VERSION, &major); +// glGetIntegerv(GL_MINOR_VERSION, &minor); +// std::cout << this->getName().toStdString() << "is using GL "<< major <<"."<< minor << std::endl; + qglviewer::Camera* c = this->camera(); this->setCamera(m_currentCamera); -// delete c; + delete c; this->setBackgroundColor(QColor(0,0,0)); glEnable(GL_DEPTH_TEST); @@ -354,6 +387,7 @@ void View::init() m_buttonAreaLeft = new ViewButtonArea(this); m_buttonAreaLeft->setTopLeftPosition(0, 0); + m_mapsButton = new ViewButton(":icons/icons/maps.png", this); m_buttonAreaLeft->addButton(m_mapsButton); connect(m_mapsButton, SIGNAL(clicked(int, int, int, int)), this, SLOT(ui_mapsListView(int, int, int, int))); @@ -366,13 +400,13 @@ void View::init() m_buttonAreaLeft->addButton(m_camerasButton); connect(m_camerasButton, SIGNAL(clicked(int, int, int, int)), this, SLOT(ui_camerasListView(int, int, int, int))); + // FRAME DRAWER m_frameDrawer = new Utils::Drawer(); glm::mat4 mm(1.0); glm::mat4 pm(1.0); -// m_frameDrawer->getShader()->updateMatrices(mm, pm); - m_frameDrawer->updateMatrices(mm, pm); + m_frameDrawer->getShader()->updateMatrices(mm, pm); m_frameDrawer->newList(GL_COMPILE); m_frameDrawer->color3f(0.0f,1.0f,0.0f); @@ -385,32 +419,18 @@ void View::init() m_frameDrawer->end(); m_frameDrawer->endList(); - // WALLPAPER + std::cout << "end INIT of "<< this->getName().toStdString()<< std::endl; - m_textureWallpaper = new Utils::Texture<2, Geom::Vec3uc>(GL_UNSIGNED_BYTE); - m_textureWallpaper->create(Geom::Vec2ui(16, 16)); - const float max = m_textureWallpaper->size()[0]; - for (unsigned int ki = 0; ki < m_textureWallpaper->size()[0]; ++ki) - { - for (unsigned int kj = 0; kj < m_textureWallpaper->size()[1]; ++kj) - { - float col = 255 - (255 * ((kj/max)*0.6 + 0.2)); - (*m_textureWallpaper)(ki, kj) = Geom::Vec3f(col, col, col); - } - } - m_textureWallpaper->update(); - m_textureWallpaper->setWrapping(GL_CLAMP_TO_EDGE); - - m_shaderWallpaper = new Utils::ShaderWallPaper(); - m_shaderWallpaper->setTextureUnit(GL_TEXTURE0); - m_shaderWallpaper->setTexture(m_textureWallpaper); +// qglviewer::Camera* c = this->camera(); +// this->setCamera(m_currentCamera); +// delete c; this->setBackgroundColor(QColor(0,0,0)); } void View::preDraw() { - if (Utils::GLSLShader::CURRENT_OGL_VERSION >= 3) + if (Utils::GLSLShader::CURRENT_OGL_VERSION>=3) makeCurrent(); m_currentCamera->setScreenWidthAndHeight(width(), height()); @@ -419,26 +439,27 @@ void View::preDraw() void View::draw() { - if (Utils::GLSLShader::CURRENT_OGL_VERSION >= 3) + if (Utils::GLSLShader::CURRENT_OGL_VERSION>=3) { glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT); } - m_shaderWallpaper->draw(); - const CameraSet& cams = m_schnapps->getCameraSet(); QList lc = cams.values(); - foreach (Camera* camera, lc) + foreach(Camera* camera, lc) { - if (camera != m_currentCamera) + if(camera != m_currentCamera) { - if (camera->getDraw()) camera->draw(); - if (camera->getDrawPath()) camera->drawAllPaths(); + if(camera->getDraw()) camera->draw(); + if(camera->getDrawPath()) camera->drawAllPaths(); } } +// for debugging +// m_currentCamera->drawBBCam(); + glm::mat4 mm = getCurrentModelViewMatrix(); glm::mat4 pm = getCurrentProjectionMatrix(); @@ -450,9 +471,9 @@ void View::draw() if(map == selectedMap) { - Utils::Drawer* bbDr = map->getBBDrawer(); - if(bbDr) - bbDr->updateMatrices(pm, map_mm); + Utils::GLSLShader* bbShader = map->getBBDrawerShader(); + if(bbShader) + bbShader->updateMatrices(pm, map_mm); map->drawBB(); } @@ -479,9 +500,8 @@ void View::postDraw() void View::resizeGL(int width, int height) { QGLViewer::resizeGL(width, height); - if(m_buttonArea) - m_buttonArea->setTopRightPosition(width/ this->pixelRatio(), 0); + m_buttonArea->setTopRightPosition(width, 0); if(m_buttonAreaLeft) m_buttonAreaLeft->setTopLeftPosition(0, 0); @@ -502,51 +522,9 @@ void View::drawFrame() void View::keyPressEvent(QKeyEvent* event) { - if (event->key() == Qt::Key_S) - { - b_saveSnapshots = !b_saveSnapshots; - - if (b_saveSnapshots) - { - QMessageBox msgBox; - msgBox.setText("Snapshot every frame?"); - msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); - msgBox.setDefaultButton(QMessageBox::Ok); - if (msgBox.exec() == QMessageBox::Ok) - { - m_schnapps->statusBarMessage("frame snapshot !!", 2000); - connect(this, SIGNAL(drawFinished(bool)), this, SLOT(saveSnapshot(bool))); - } - else - { - m_schnapps->statusBarMessage("cancel frame snapshot", 2000); - b_saveSnapshots = false; - } - } - else - { - disconnect(this, SIGNAL(drawFinished(bool)), this, SLOT(saveSnapshot(bool))); - m_schnapps->statusBarMessage("Stop frame snapshot", 2000); - } - - } - else - { - foreach(PluginInteraction* plugin, l_plugins) - plugin->keyPress(this, event); - - if (event->key() == Qt::Key_Escape) - { - QMessageBox msgBox; - msgBox.setText("Really quit SCHNApps ?"); - msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); - msgBox.setDefaultButton(QMessageBox::Ok); - if (msgBox.exec() == QMessageBox::Ok) - m_schnapps->close(); - } - else - QGLViewer::keyPressEvent(event); - } + foreach(PluginInteraction* plugin, l_plugins) + plugin->keyPress(this, event); + QGLViewer::keyPressEvent(event); } void View::keyReleaseEvent(QKeyEvent *event) @@ -558,23 +536,17 @@ void View::keyReleaseEvent(QKeyEvent *event) void View::mousePressEvent(QMouseEvent* event) { - if (!isSelectedView()) - m_schnapps->setSelectedView(this); - - if (m_buttonAreaLeft->isClicked(event->x(), event->y())) + if(m_buttonArea->isClicked(event->x(), event->y())) + m_buttonArea->clickButton(event->x(), event->y(), event->globalX(), event->globalY()); + else if(m_buttonAreaLeft->isClicked(event->x(), event->y())) m_buttonAreaLeft->clickButton(event->x(), event->y(), event->globalX(), event->globalY()); else { - hideDialogs(); - if (m_buttonArea->isClicked(event->x(), event->y())) - m_buttonArea->clickButton(event->x(), event->y(), event->globalX(), event->globalY()); - else - { - foreach(PluginInteraction* plugin, l_plugins) - plugin->mousePress(this, event); - - QGLViewer::mousePressEvent(event); - } + if(!isSelectedView()) + m_schnapps->setSelectedView(this); + foreach(PluginInteraction* plugin, l_plugins) + plugin->mousePress(this, event); + QGLViewer::mousePressEvent(event); } } @@ -639,27 +611,6 @@ glm::mat4 View::getCurrentModelViewProjectionMatrix() const } - - - -void View::closeDialogs() -{ - m_dialogMaps->close(); - m_dialogPlugins->close(); - m_dialogCameras->close(); -} - -void View::hideDialogs() -{ - if (m_dialogCameras->isVisible()) - m_dialogCameras->hide(); - if (m_dialogMaps->isVisible()) - m_dialogMaps->hide(); - if (m_dialogPlugins->isVisible()) - m_dialogPlugins->hide(); -} - - void View::selectedMapChanged(MapHandlerGen* prev, MapHandlerGen* cur) { DEBUG_SLOT(); @@ -668,17 +619,18 @@ void View::selectedMapChanged(MapHandlerGen* prev, MapHandlerGen* cur) updateGL(); } -void View::ui_verticalSplitView(int x, int y, int /*globalX*/, int /*globalY*/) + +void View::ui_verticalSplitView(int x, int y, int globalX, int globalY) { m_schnapps->splitView(m_name, Qt::Horizontal); } -void View::ui_horizontalSplitView(int x, int y, int /*globalX*/, int /*globalY*/) +void View::ui_horizontalSplitView(int x, int y, int globalX, int globalY) { m_schnapps->splitView(m_name, Qt::Vertical); } -void View::ui_closeView(int x, int y, int /*globalX*/, int /*globalY*/) +void View::ui_closeView(int x, int y, int globalX, int globalY) { m_schnapps->removeView(m_name); } @@ -693,12 +645,11 @@ void View::ui_mapsListView(int x, int y, int globalX, int globalY) m_dialogPlugins->hide(); } else - { m_dialogMaps->hide(); - } } + void View::ui_pluginsListView(int x, int y, int globalX, int globalY) { if (m_dialogPlugins->isHidden()) @@ -709,9 +660,8 @@ void View::ui_pluginsListView(int x, int y, int globalX, int globalY) m_dialogCameras->hide(); } else - { m_dialogPlugins->hide(); - } + } void View::ui_camerasListView(int x, int y, int globalX, int globalY) @@ -724,137 +674,105 @@ void View::ui_camerasListView(int x, int y, int globalX, int globalY) m_dialogMaps->hide(); } else - { m_dialogCameras->hide(); - } + } -void View::mapAdded(MapHandlerGen* mh) +void View::mapAdded(MapHandlerGen* mh ) { DEBUG_SLOT(); if (mh) + { m_dialogMaps->addItem(mh->getName()); + } } -void View::mapRemoved(MapHandlerGen* mh) +void View::mapRemoved(MapHandlerGen* mh ) { DEBUG_SLOT(); if (mh) - m_dialogMaps->removeItem(mh->getName()); -} - -void View::mapCheckStateChanged(QListWidgetItem* item) -{ - if (!b_updatingUI) { - DEBUG_SLOT(); - if (item->checkState() == Qt::Checked) - linkMap(item->text()); - else - unlinkMap(item->text()); + m_dialogMaps->removeItem(mh->getName()); } } + void View::pluginEnabled(Plugin *plugin) { DEBUG_SLOT(); if (dynamic_cast(plugin)) + { m_dialogPlugins->addItem(plugin->getName()); + } + } void View::pluginDisabled(Plugin *plugin) { DEBUG_SLOT(); if (dynamic_cast(plugin)) - m_dialogPlugins->removeItem(plugin->getName()); -} - -void View::pluginCheckStateChanged(QListWidgetItem* item) -{ - if (!b_updatingUI) { - DEBUG_SLOT(); - if (item->checkState() == Qt::Checked) - linkPlugin(item->text()); - else - unlinkPlugin(item->text()); + m_dialogPlugins->removeItem(plugin->getName()); } } + void View::cameraAdded(Camera* camera) { DEBUG_SLOT(); if (camera) + { m_dialogCameras->addItem(camera->getName()); + } } void View::cameraRemoved(Camera* camera) { DEBUG_SLOT(); if (camera) + { m_dialogCameras->removeItem(camera->getName()); + } } -void View::cameraCheckStateChanged(QListWidgetItem* item) +void View::mapCheckStateChanged(QListWidgetItem* item) { - if (!b_updatingUI) - { - DEBUG_SLOT(); - if (item->checkState() == Qt::Checked) - setCurrentCamera(item->text()); - } + if (b_updatingUI) + return; + + DEBUG_SLOT(); + + if (item->checkState()==Qt::Checked) + linkMap(item->text()); + else + unlinkMap(item->text()); + + } -void View::updateBoundingBox() +void View::pluginCheckStateChanged(QListWidgetItem* item) { - if (!l_maps.empty()) - { - bool initialized = false; - - foreach (MapHandlerGen* mhg, l_maps) - { - qglviewer::Vec minbb; - qglviewer::Vec maxbb; - if (mhg->transformedBB(minbb, maxbb)) - { - if (initialized) - { - for (unsigned int dim = 0; dim < 3; ++dim) - { - if (minbb[dim] < m_bbMin[dim]) - m_bbMin[dim] = minbb[dim]; - if (maxbb[dim] > m_bbMax[dim]) - m_bbMax[dim] = maxbb[dim]; - } - } - else - { - for (unsigned int dim = 0; dim < 3; ++dim) - { - m_bbMin[dim] = minbb[dim]; - m_bbMax[dim] = maxbb[dim]; - } - initialized = true; - } - } - } + if (b_updatingUI) + return; - if (!initialized) - { - m_bbMin.setValue(0, 0, 0); - m_bbMax.setValue(0, 0, 0); - } - } + DEBUG_SLOT(); + if (item->checkState()==Qt::Checked) + linkPlugin(item->text()); else - { - m_bbMin.setValue(0, 0, 0); - m_bbMax.setValue(0, 0, 0); - } + unlinkPlugin(item->text()); +} + +void View::cameraCheckStateChanged(QListWidgetItem* item) +{ + if (b_updatingUI) + return; - DEBUG_EMIT("View::boundingBoxChanged"); - emit(boundingBoxChanged()); + DEBUG_SLOT(); + if (item->checkState()==Qt::Checked) + setCurrentCamera(item->text()); } + } // namespace SCHNApps } // namespace CGoGN -- GitLab