Commit 03178203 authored by Pierre Kraemer's avatar Pierre Kraemer

minor code improvements

parent 8021f98c
......@@ -87,7 +87,7 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map)
const std::vector<Dart>& selectedCells = selector->getSelectedCells();
m_drawer->newList(GL_COMPILE_AND_EXECUTE);
m_drawer->pointSize(2.0f);
m_drawer->pointSize(3.0f);
m_drawer->color3f(0.0f, 0.0f, 1.0f);
m_drawer->begin(GL_POINTS);
for(std::vector<Dart>::const_iterator it = selectedCells.begin(); it != selectedCells.end(); ++it)
......
......@@ -43,6 +43,9 @@ private:
void linkView(View* view);
void unlinkView(View* view);
private slots:
void frameModified();
public slots:
void setProjectionType(int t);
void setDraw(bool b);
......
......@@ -37,25 +37,9 @@ private slots:
void mapCheckStateChanged(QListWidgetItem* item);
void vertexAttributeCheckStateChanged(QListWidgetItem* item);
void selectedDartSelectorChanged();
void addDartSelector();
void removeDartSelector();
void selectedVertexSelectorChanged();
void addVertexSelector();
void removeVertexSelector();
void selectedEdgeSelectorChanged();
void addEdgeSelector();
void removeEdgeSelector();
void selectedFaceSelectorChanged();
void addFaceSelector();
void removeFaceSelector();
void selectedVolumeSelectorChanged();
void addVolumeSelector();
void removeVolumeSelector();
void selectedSelectorChanged();
void addSelector();
void removeSelector();
// slots called from SCHNApps signals
void mapAdded(MapHandlerGen* m);
......
......@@ -45,6 +45,9 @@ public slots:
GenericMap* getGenericMap() const { return m_map; }
const QList<View*>& getLinkedViews() const { return l_views; }
bool isLinkedToView(View* view) const { return l_views.contains(view); }
const qglviewer::Vec& getBBmin() const { return m_bbMin; }
const qglviewer::Vec& getBBmax() const { return m_bbMax; }
float getBBdiagSize() const { return m_bbDiagSize; }
......@@ -71,8 +74,12 @@ public slots:
return matrix;
}
const QList<View*>& getLinkedViews() const { return l_views; }
bool isLinkedToView(View* view) const { return l_views.contains(view); }
private slots:
void frameModified()
{
foreach(View* view, l_views)
view->updateGL();
}
public:
virtual void draw(Utils::GLSLShader* shader, int primitive) = 0;
......@@ -178,13 +185,13 @@ protected:
GenericMap* m_map;
qglviewer::ManipulatedFrame* m_frame;
qglviewer::Vec m_bbMin;
qglviewer::Vec m_bbMax;
float m_bbDiagSize;
Utils::Drawer* m_bbDrawer;
qglviewer::ManipulatedFrame* m_frame;
Algo::Render::GL2::MapRender* m_render;
QList<View*> l_views;
......
......@@ -15,6 +15,7 @@ Camera::Camera(const QString& name, SCHNApps* s) :
m_drawPath(false)
{
++cameraCount;
connect(this->frame(), SIGNAL(modified()), this, SLOT(frameModified()));
}
Camera::~Camera()
......@@ -55,6 +56,20 @@ void Camera::unlinkView(View* view)
l_views.removeOne(view);
}
void Camera::frameModified()
{
if(m_draw || m_drawPath)
{
foreach(View* view, m_schnapps->getViewSet().values())
view->updateGL();
}
else
{
foreach(View* view, l_views)
view->updateGL();
}
}
} // namespace SCHNApps
} // namespace CGoGN
......@@ -27,25 +27,25 @@ ControlDock_MapTab::ControlDock_MapTab(SCHNApps* s) :
connect(m_schnapps, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(mapRemoved(MapHandlerGen*)));
connect(m_schnapps, SIGNAL(selectedViewChanged(View*,View*)), this, SLOT(selectedViewChanged(View*,View*)));
connect(list_dartSelectors, SIGNAL(itemSelectionChanged()), this, SLOT(selectedDartSelectorChanged()));
connect(button_dartAddSelector, SIGNAL(clicked()), this, SLOT(addDartSelector()));
connect(button_dartRemoveSelector, SIGNAL(clicked()), this, SLOT(removeDartSelector()));
connect(list_dartSelectors, SIGNAL(itemSelectionChanged()), this, SLOT(selectedSelectorChanged()));
connect(button_dartAddSelector, SIGNAL(clicked()), this, SLOT(addSelector()));
connect(button_dartRemoveSelector, SIGNAL(clicked()), this, SLOT(removeSelector()));
connect(list_vertexSelectors, SIGNAL(itemSelectionChanged()), this, SLOT(selectedVertexSelectorChanged()));
connect(button_vertexAddSelector, SIGNAL(clicked()), this, SLOT(addVertexSelector()));
connect(button_vertexRemoveSelector, SIGNAL(clicked()), this, SLOT(removeVertexSelector()));
connect(list_vertexSelectors, SIGNAL(itemSelectionChanged()), this, SLOT(selectedSelectorChanged()));
connect(button_vertexAddSelector, SIGNAL(clicked()), this, SLOT(addSelector()));
connect(button_vertexRemoveSelector, SIGNAL(clicked()), this, SLOT(removeSelector()));
connect(list_edgeSelectors, SIGNAL(itemSelectionChanged()), this, SLOT(selectedEdgeSelectorChanged()));
connect(button_edgeAddSelector, SIGNAL(clicked()), this, SLOT(addEdgeSelector()));
connect(button_edgeRemoveSelector, SIGNAL(clicked()), this, SLOT(removeEdgeSelector()));
connect(list_edgeSelectors, SIGNAL(itemSelectionChanged()), this, SLOT(selectedSelectorChanged()));
connect(button_edgeAddSelector, SIGNAL(clicked()), this, SLOT(addSelector()));
connect(button_edgeRemoveSelector, SIGNAL(clicked()), this, SLOT(removeSelector()));
connect(list_faceSelectors, SIGNAL(itemSelectionChanged()), this, SLOT(selectedFaceSelectorChanged()));
connect(button_faceAddSelector, SIGNAL(clicked()), this, SLOT(addFaceSelector()));
connect(button_faceRemoveSelector, SIGNAL(clicked()), this, SLOT(removeFaceSelector()));
connect(list_faceSelectors, SIGNAL(itemSelectionChanged()), this, SLOT(selectedSelectorChanged()));
connect(button_faceAddSelector, SIGNAL(clicked()), this, SLOT(addSelector()));
connect(button_faceRemoveSelector, SIGNAL(clicked()), this, SLOT(removeSelector()));
connect(list_volumeSelectors, SIGNAL(itemSelectionChanged()), this, SLOT(selectedVolumeSelectorChanged()));
connect(button_volumeAddSelector, SIGNAL(clicked()), this, SLOT(addVolumeSelector()));
connect(button_volumeRemoveSelector, SIGNAL(clicked()), this, SLOT(removeVolumeSelector()));
connect(list_volumeSelectors, SIGNAL(itemSelectionChanged()), this, SLOT(selectedSelectorChanged()));
connect(button_volumeAddSelector, SIGNAL(clicked()), this, SLOT(addSelector()));
connect(button_volumeRemoveSelector, SIGNAL(clicked()), this, SLOT(removeSelector()));
}
unsigned int ControlDock_MapTab::getCurrentOrbit()
......@@ -135,177 +135,58 @@ void ControlDock_MapTab::vertexAttributeCheckStateChanged(QListWidgetItem *item)
}
}
void ControlDock_MapTab::selectedDartSelectorChanged()
{
if(!b_updatingUI)
{
QList<QListWidgetItem*> items = list_dartSelectors->selectedItems();
if(!items.empty())
{
QString selectedSelectorName = items[0]->text();
m_selectedSelector[DART] = m_selectedMap->getCellSelector(DART, selectedSelectorName);
}
}
}
void ControlDock_MapTab::addDartSelector()
{
if(!b_updatingUI)
{
if(m_selectedMap)
m_selectedMap->addCellSelector(DART, QString("selector_") + QString::number(CellSelectorGen::selectorCount));
}
}
void ControlDock_MapTab::removeDartSelector()
void ControlDock_MapTab::selectedSelectorChanged()
{
if(!b_updatingUI)
{
if(m_selectedMap)
{
QList<QListWidgetItem*> items = list_dartSelectors->selectedItems();
if(!items.empty())
m_selectedMap->removeCellSelector(DART, items[0]->text());
}
}
}
void ControlDock_MapTab::selectedVertexSelectorChanged()
{
if(!b_updatingUI)
{
QList<QListWidgetItem*> items = list_vertexSelectors->selectedItems();
if(!items.empty())
{
QString selectedSelectorName = items[0]->text();
m_selectedSelector[VERTEX] = m_selectedMap->getCellSelector(VERTEX, selectedSelectorName);
}
}
}
void ControlDock_MapTab::addVertexSelector()
{
if(!b_updatingUI)
{
if(m_selectedMap)
m_selectedMap->addCellSelector(VERTEX, QString("selector_") + QString::number(CellSelectorGen::selectorCount));
}
}
void ControlDock_MapTab::removeVertexSelector()
{
if(!b_updatingUI)
{
if(m_selectedMap)
{
QList<QListWidgetItem*> items = list_vertexSelectors->selectedItems();
if(!items.empty())
m_selectedMap->removeCellSelector(VERTEX, items[0]->text());
}
}
}
void ControlDock_MapTab::selectedEdgeSelectorChanged()
{
if(!b_updatingUI)
{
QList<QListWidgetItem*> items = list_edgeSelectors->selectedItems();
if(!items.empty())
{
QString selectedSelectorName = items[0]->text();
m_selectedSelector[EDGE] = m_selectedMap->getCellSelector(EDGE, selectedSelectorName);
}
}
}
void ControlDock_MapTab::addEdgeSelector()
{
if(!b_updatingUI)
{
if(m_selectedMap)
m_selectedMap->addCellSelector(EDGE, QString("selector_") + QString::number(CellSelectorGen::selectorCount));
}
}
void ControlDock_MapTab::removeEdgeSelector()
{
if(!b_updatingUI)
{
if(m_selectedMap)
{
QList<QListWidgetItem*> items = list_edgeSelectors->selectedItems();
QList<QListWidgetItem*> items;
unsigned int orbit = getCurrentOrbit();
switch(orbit)
{
case DART: items = list_dartSelectors->selectedItems(); break;
case VERTEX: items = list_vertexSelectors->selectedItems(); break;
case EDGE: items = list_edgeSelectors->selectedItems(); break;
case FACE: items = list_faceSelectors->selectedItems(); break;
case VOLUME: items = list_volumeSelectors->selectedItems(); break;
}
if(!items.empty())
m_selectedMap->removeCellSelector(EDGE, items[0]->text());
}
}
}
void ControlDock_MapTab::selectedFaceSelectorChanged()
{
if(!b_updatingUI)
{
QList<QListWidgetItem*> items = list_faceSelectors->selectedItems();
if(!items.empty())
{
QString selectedSelectorName = items[0]->text();
m_selectedSelector[FACE] = m_selectedMap->getCellSelector(FACE, selectedSelectorName);
m_selectedSelector[orbit] = m_selectedMap->getCellSelector(orbit, items[0]->text());
}
}
}
void ControlDock_MapTab::addFaceSelector()
void ControlDock_MapTab::addSelector()
{
if(!b_updatingUI)
{
if(m_selectedMap)
m_selectedMap->addCellSelector(FACE, QString("selector_") + QString::number(CellSelectorGen::selectorCount));
}
}
void ControlDock_MapTab::removeFaceSelector()
{
if(!b_updatingUI)
{
if(m_selectedMap)
{
QList<QListWidgetItem*> items = list_faceSelectors->selectedItems();
if(!items.empty())
m_selectedMap->removeCellSelector(FACE, items[0]->text());
}
}
}
void ControlDock_MapTab::selectedVolumeSelectorChanged()
{
if(!b_updatingUI)
{
QList<QListWidgetItem*> items = list_volumeSelectors->selectedItems();
if(!items.empty())
{
QString selectedSelectorName = items[0]->text();
m_selectedSelector[VOLUME] = m_selectedMap->getCellSelector(VOLUME, selectedSelectorName);
unsigned int orbit = getCurrentOrbit();
m_selectedMap->addCellSelector(orbit, QString("selector_") + QString::number(CellSelectorGen::selectorCount));
}
}
}
void ControlDock_MapTab::addVolumeSelector()
{
if(!b_updatingUI)
{
if(m_selectedMap)
m_selectedMap->addCellSelector(VOLUME, QString("selector_") + QString::number(CellSelectorGen::selectorCount));
}
}
void ControlDock_MapTab::removeVolumeSelector()
void ControlDock_MapTab::removeSelector()
{
if(!b_updatingUI)
{
if(m_selectedMap)
{
QList<QListWidgetItem*> items = list_volumeSelectors->selectedItems();
QList<QListWidgetItem*> items;
unsigned int orbit = getCurrentOrbit();
switch(orbit)
{
case DART: items = list_dartSelectors->selectedItems(); break;
case VERTEX: items = list_vertexSelectors->selectedItems(); break;
case EDGE: items = list_edgeSelectors->selectedItems(); break;
case FACE: items = list_faceSelectors->selectedItems(); break;
case VOLUME: items = list_volumeSelectors->selectedItems(); break;
}
if(!items.empty())
m_selectedMap->removeCellSelector(VOLUME, items[0]->text());
m_selectedMap->removeCellSelector(orbit, items[0]->text());
}
}
}
......
......@@ -10,15 +10,21 @@ MapHandlerGen::MapHandlerGen(const QString& name, SCHNApps* s, GenericMap* map)
m_name(name),
m_schnapps(s),
m_map(map),
m_bbDrawer(NULL),
m_frame(NULL),
m_bbDrawer(NULL),
m_render(NULL)
{
m_frame = new qglviewer::ManipulatedFrame();
connect(m_frame, SIGNAL(modified()), this, SLOT(frameModified()));
}
MapHandlerGen::~MapHandlerGen()
{
if(m_frame)
{
disconnect(m_frame, SIGNAL(modified()), this, SLOT(frameModified()));
delete m_frame;
}
if(m_bbDrawer)
delete m_bbDrawer;
if(m_render)
......
......@@ -134,6 +134,7 @@ void View::linkMap(MapHandlerGen* map)
emit(mapLinked(map));
updateCurrentCameraBB();
updateGL();
connect(map->getFrame(), SIGNAL(modified()), this, SLOT(updateGL()));
}
}
......@@ -152,6 +153,7 @@ void View::unlinkMap(MapHandlerGen* map)
emit(mapUnlinked(map));
updateCurrentCameraBB();
updateGL();
disconnect(map->getFrame(), SIGNAL(modified()), this, SLOT(updateGL()));
}
}
......@@ -320,23 +322,6 @@ void View::mouseMoveEvent(QMouseEvent* event)
foreach(PluginInteraction* plugin, l_plugins)
plugin->mouseMove(this, event);
QGLViewer::mouseMoveEvent(event);
if(m_currentCamera->getDraw() || m_currentCamera->getDrawPath())
{
foreach(View* view, m_schnapps->getViewSet().values())
{
if(view != this)
view->updateGL();
}
}
else
{
foreach(View* view, m_currentCamera->getLinkedViews())
{
if(view != this)
view->updateGL();
}
}
}
void View::wheelEvent(QWheelEvent* event)
......@@ -344,23 +329,6 @@ void View::wheelEvent(QWheelEvent* event)
foreach(PluginInteraction* plugin, l_plugins)
plugin->wheelEvent(this, event);
QGLViewer::wheelEvent(event);
if(m_currentCamera->getDraw() || m_currentCamera->getDrawPath())
{
foreach(View* view, m_schnapps->getViewSet().values())
{
if(view != this)
view->updateGL();
}
}
else
{
foreach(View* view, m_currentCamera->getLinkedViews())
{
if(view != this)
view->updateGL();
}
}
}
glm::mat4 View::getCurrentModelViewMatrix() const
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment