Commit cdfff0a1 authored by Sylvain Thery's avatar Sylvain Thery

auto radius render & selection

parent 46beef72
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
<property name="text"> <property name="text">
<string>render boundary</string> <string>render boundary</string>
</property> </property>
<property name="checked">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item row="0" column="2"> <item row="0" column="2">
......
...@@ -43,6 +43,7 @@ private slots: ...@@ -43,6 +43,7 @@ private slots:
void colorVBOChanged(int index); void colorVBOChanged(int index);
void renderVerticesChanged(bool b); void renderVerticesChanged(bool b);
void verticesScaleFactorChanged(int i); void verticesScaleFactorChanged(int i);
void verticesScaleFactorPressed();
void renderEdgesChanged(bool b); void renderEdgesChanged(bool b);
void renderFacesChanged(bool b); void renderFacesChanged(bool b);
void faceStyleChanged(QAbstractButton* b); void faceStyleChanged(QAbstractButton* b);
......
...@@ -115,8 +115,7 @@ void Surface_Render_Plugin::drawMap(View* view, MapHandlerGen* map) ...@@ -115,8 +115,7 @@ void Surface_Render_Plugin::drawMap(View* view, MapHandlerGen* map)
if(p.renderVertices) if(p.renderVertices)
{ {
// m_pointSprite->setSize(map->getBBdiagSize() / 200.0f * p.verticesScaleFactor); m_pointSprite->setSize(p.basePSradius * p.verticesScaleFactor);
m_pointSprite->setSize(p.basePSradius * 2 * p.verticesScaleFactor);
m_pointSprite->setAttributePosition(p.positionVBO); m_pointSprite->setAttributePosition(p.positionVBO);
m_pointSprite->setColor(p.vertexColor); m_pointSprite->setColor(p.vertexColor);
map->draw(m_pointSprite, CGoGN::Algo::Render::GL2::POINTS); map->draw(m_pointSprite, CGoGN::Algo::Render::GL2::POINTS);
...@@ -298,6 +297,8 @@ void Surface_Render_Plugin::changeRenderVertices(const QString& view, const QStr ...@@ -298,6 +297,8 @@ void Surface_Render_Plugin::changeRenderVertices(const QString& view, const QStr
if(v && m) if(v && m)
{ {
h_viewParameterSet[v][m].renderVertices = b; h_viewParameterSet[v][m].renderVertices = b;
if (b)
h_viewParameterSet[v][m].basePSradius = m->getBBdiagSize() / (2 * std::sqrt(m->getNbOrbits(EDGE)));
if(v->isSelectedView()) if(v->isSelectedView())
{ {
if(v->isLinkedToMap(m)) v->updateGL(); if(v->isLinkedToMap(m)) v->updateGL();
...@@ -330,6 +331,8 @@ void Surface_Render_Plugin::changeRenderEdges(const QString& view, const QString ...@@ -330,6 +331,8 @@ void Surface_Render_Plugin::changeRenderEdges(const QString& view, const QString
if(v && m) if(v && m)
{ {
h_viewParameterSet[v][m].renderEdges = b; h_viewParameterSet[v][m].renderEdges = b;
if (b)
h_viewParameterSet[v][m].basePSradius = m->getBBdiagSize() / (16 * std::sqrt(m->getNbOrbits(EDGE)));
if(v->isSelectedView()) if(v->isSelectedView())
{ {
if(v->isLinkedToMap(m)) v->updateGL(); if(v->isLinkedToMap(m)) v->updateGL();
......
...@@ -24,6 +24,7 @@ Surface_Render_DockTab::Surface_Render_DockTab(SCHNApps* s, Surface_Render_Plugi ...@@ -24,6 +24,7 @@ Surface_Render_DockTab::Surface_Render_DockTab(SCHNApps* s, Surface_Render_Plugi
connect(combo_colorVBO, SIGNAL(currentIndexChanged(int)), this, SLOT(colorVBOChanged(int))); connect(combo_colorVBO, SIGNAL(currentIndexChanged(int)), this, SLOT(colorVBOChanged(int)));
connect(check_renderVertices, SIGNAL(toggled(bool)), this, SLOT(renderVerticesChanged(bool))); connect(check_renderVertices, SIGNAL(toggled(bool)), this, SLOT(renderVerticesChanged(bool)));
connect(slider_verticesScaleFactor, SIGNAL(valueChanged(int)), this, SLOT(verticesScaleFactorChanged(int))); connect(slider_verticesScaleFactor, SIGNAL(valueChanged(int)), this, SLOT(verticesScaleFactorChanged(int)));
connect(slider_verticesScaleFactor, SIGNAL(sliderPressed()), this, SLOT(verticesScaleFactorPressed()));
connect(check_renderEdges, SIGNAL(toggled(bool)), this, SLOT(renderEdgesChanged(bool))); connect(check_renderEdges, SIGNAL(toggled(bool)), this, SLOT(renderEdgesChanged(bool)));
connect(check_renderFaces, SIGNAL(toggled(bool)), this, SLOT(renderFacesChanged(bool))); connect(check_renderFaces, SIGNAL(toggled(bool)), this, SLOT(renderFacesChanged(bool)));
connect(group_faceShading, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(faceStyleChanged(QAbstractButton*))); connect(group_faceShading, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(faceStyleChanged(QAbstractButton*)));
...@@ -98,7 +99,7 @@ void Surface_Render_DockTab::renderVerticesChanged(bool b) ...@@ -98,7 +99,7 @@ void Surface_Render_DockTab::renderVerticesChanged(bool b)
if (view && map) if (view && map)
{ {
if (b) if (b)
m_plugin->h_viewParameterSet[view][map].basePSradius = map->getBBdiagSize() / (8 * std::sqrt(map->getNbOrbits(EDGE))); m_plugin->h_viewParameterSet[view][map].basePSradius = map->getBBdiagSize() / (2 * std::sqrt(map->getNbOrbits(EDGE)));
m_plugin->h_viewParameterSet[view][map].renderVertices = b; m_plugin->h_viewParameterSet[view][map].renderVertices = b;
view->updateGL(); view->updateGL();
...@@ -107,6 +108,21 @@ void Surface_Render_DockTab::renderVerticesChanged(bool b) ...@@ -107,6 +108,21 @@ void Surface_Render_DockTab::renderVerticesChanged(bool b)
} }
} }
void Surface_Render_DockTab::verticesScaleFactorPressed()
{
if (!b_updatingUI)
{
View* view = m_schnapps->getSelectedView();
MapHandlerGen* map = m_schnapps->getSelectedMap();
if (view && map)
{
m_plugin->h_viewParameterSet[view][map].basePSradius = map->getBBdiagSize() / (2 * std::sqrt(map->getNbOrbits(EDGE)));
}
}
}
void Surface_Render_DockTab::verticesScaleFactorChanged(int i) void Surface_Render_DockTab::verticesScaleFactorChanged(int i)
{ {
if (!b_updatingUI) if (!b_updatingUI)
......
...@@ -14,6 +14,26 @@ ...@@ -14,6 +14,26 @@
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="7" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Method :</string>
</property>
</widget>
</item>
<item row="3" column="1"> <item row="3" column="1">
<widget class="QComboBox" name="combo_selectionMethod"> <widget class="QComboBox" name="combo_selectionMethod">
<property name="sizePolicy"> <property name="sizePolicy">
...@@ -39,30 +59,19 @@ ...@@ -39,30 +59,19 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item row="1" column="1">
<spacer name="verticalSpacer"> <widget class="QComboBox" name="combo_normalAttribute">
<property name="orientation"> <item>
<enum>Qt::Vertical</enum> <property name="text">
</property> <string>- select attribute -</string>
<property name="sizeHint" stdset="0"> </property>
<size> </item>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Method :</string>
</property>
</widget> </widget>
</item> </item>
<item row="2" column="0" colspan="2"> <item row="1" column="0">
<widget class="Line" name="line"> <widget class="QLabel" name="label">
<property name="orientation"> <property name="text">
<enum>Qt::Horizontal</enum> <string>Normal :</string>
</property> </property>
</widget> </widget>
</item> </item>
...@@ -88,20 +97,38 @@ ...@@ -88,20 +97,38 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="2" column="0" colspan="2">
<widget class="QLabel" name="label"> <widget class="Line" name="line">
<property name="text"> <property name="orientation">
<string>Normal :</string> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="6" column="0" colspan="2">
<widget class="QComboBox" name="combo_normalAttribute"> <widget class="QSlider" name="slider_verticesScaleFactor">
<item> <property name="value">
<property name="text"> <number>50</number>
<string>- select attribute -</string> </property>
</property> <property name="orientation">
</item> <enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::NoTicks</enum>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Vertex Size Drawing</string>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
......
...@@ -29,6 +29,8 @@ struct MapParameters ...@@ -29,6 +29,8 @@ struct MapParameters
VertexAttribute<PFP2::VEC3, PFP2::MAP> positionAttribute; VertexAttribute<PFP2::VEC3, PFP2::MAP> positionAttribute;
VertexAttribute<PFP2::VEC3, PFP2::MAP> normalAttribute; VertexAttribute<PFP2::VEC3, PFP2::MAP> normalAttribute;
SelectionMethod selectionMethod; SelectionMethod selectionMethod;
float verticesScaleFactor;
float basePSradius;
}; };
class Surface_Selection_Plugin : public PluginInteraction class Surface_Selection_Plugin : public PluginInteraction
...@@ -78,6 +80,8 @@ public slots: ...@@ -78,6 +80,8 @@ public slots:
void changePositionAttribute(const QString& map, const QString& name); void changePositionAttribute(const QString& map, const QString& name);
void changeNormalAttribute(const QString& map, const QString& name); void changeNormalAttribute(const QString& map, const QString& name);
void changeSelectionMethod(const QString& map, unsigned int method); void changeSelectionMethod(const QString& map, unsigned int method);
void changeVerticesScaleFactor(const QString& map, float f);
void changeVerticesBaseSize(const QString& map, float f);
protected: protected:
Surface_Selection_DockTab* m_dockTab; Surface_Selection_DockTab* m_dockTab;
......
...@@ -31,6 +31,8 @@ private slots: ...@@ -31,6 +31,8 @@ private slots:
void positionAttributeChanged(int index); void positionAttributeChanged(int index);
void normalAttributeChanged(int index); void normalAttributeChanged(int index);
void selectionMethodChanged(int index); void selectionMethodChanged(int index);
void verticesScaleFactorChanged(int i);
void verticesScaleFactorPressed();
private: private:
void addVertexAttribute(const QString& name); void addVertexAttribute(const QString& name);
......
...@@ -60,6 +60,8 @@ bool Surface_Selection_Plugin::enable() ...@@ -60,6 +60,8 @@ bool Surface_Selection_Plugin::enable()
connect(cur, SIGNAL(connectivityModified()), this, SLOT(selectedMapConnectivityModified())); connect(cur, SIGNAL(connectivityModified()), this, SLOT(selectedMapConnectivityModified()));
connect(cur, SIGNAL(boundingBoxModified()), this, SLOT(selectedMapBoundingBoxModified())); connect(cur, SIGNAL(boundingBoxModified()), this, SLOT(selectedMapBoundingBoxModified()));
m_selectionRadiusBase = cur->getBBdiagSize() / 50.0f; m_selectionRadiusBase = cur->getBBdiagSize() / 50.0f;
h_parameterSet[cur].basePSradius = cur->getBBdiagSize() / (std::sqrt(cur->getNbOrbits(EDGE)));
h_parameterSet[cur].verticesScaleFactor = m_dockTab->slider_verticesScaleFactor->value() / 50.0f;
} }
m_dockTab->updateMapParameters(); m_dockTab->updateMapParameters();
...@@ -110,7 +112,8 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map) ...@@ -110,7 +112,8 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map)
m_pointSprite->setAttributePosition(m_selectedVerticesVBO); m_pointSprite->setAttributePosition(m_selectedVerticesVBO);
m_pointSprite->setColor(CGoGN::Geom::Vec4f(1.0f, 0.0f, 0.0f, 1.0f)); m_pointSprite->setColor(CGoGN::Geom::Vec4f(1.0f, 0.0f, 0.0f, 1.0f));
m_pointSprite->setLightPosition(CGoGN::Geom::Vec3f(0.0f, 0.0f, 1.0f)); m_pointSprite->setLightPosition(CGoGN::Geom::Vec3f(0.0f, 0.0f, 1.0f));
m_pointSprite->setSize(map->getBBdiagSize() / 75.0f); // m_pointSprite->setSize(map->getBBdiagSize() / 75.0f);
m_pointSprite->setSize(p.basePSradius*p.verticesScaleFactor);
m_pointSprite->enableVertexAttribs(); m_pointSprite->enableVertexAttribs();
glDrawArrays(GL_POINTS, 0, selector->getNbSelectedCells()); glDrawArrays(GL_POINTS, 0, selector->getNbSelectedCells());
...@@ -131,8 +134,8 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map) ...@@ -131,8 +134,8 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map)
{ {
case NormalAngle : case NormalAngle :
case SingleCell : { case SingleCell : {
m_pointSprite->setSize(map->getBBdiagSize() / 60.0f); // m_pointSprite->setSize(map->getBBdiagSize() / 60.0f);
break; m_pointSprite->setSize(p.basePSradius*p.verticesScaleFactor);
} }
case WithinSphere : { case WithinSphere : {
m_pointSprite->setSize(m_selectionRadiusBase * m_selectionRadiusCoeff); m_pointSprite->setSize(m_selectionRadiusBase * m_selectionRadiusCoeff);
...@@ -253,13 +256,14 @@ void Surface_Selection_Plugin::keyPress(View* view, QKeyEvent* event) ...@@ -253,13 +256,14 @@ void Surface_Selection_Plugin::keyPress(View* view, QKeyEvent* event)
{ {
if(event->key() == Qt::Key_Shift) if(event->key() == Qt::Key_Shift)
{ {
// generated a false mouse move to update drawing on shift keypressed ! view->setMouseTracking(true);
m_selecting = true;
// generate a false mouse move to update drawing on shift keypressed !
QPoint p = m_schnapps->getSelectedView()->mapFromGlobal(QCursor::pos()); QPoint p = m_schnapps->getSelectedView()->mapFromGlobal(QCursor::pos());
QMouseEvent me = QMouseEvent(QEvent::MouseMove, QPointF(p), Qt::NoButton, Qt::NoButton, Qt::ShiftModifier); QMouseEvent me = QMouseEvent(QEvent::MouseMove, QPointF(p), Qt::NoButton, Qt::NoButton, Qt::ShiftModifier);
mouseMove(view, &me); mouseMove(view, &me);
view->setMouseTracking(true);
m_selecting = true;
view->updateGL(); view->updateGL();
} }
} }
...@@ -517,6 +521,8 @@ void Surface_Selection_Plugin::selectedMapChanged(MapHandlerGen *prev, MapHandle ...@@ -517,6 +521,8 @@ void Surface_Selection_Plugin::selectedMapChanged(MapHandlerGen *prev, MapHandle
connect(cur, SIGNAL(connectivityModified()), this, SLOT(selectedMapConnectivityModified())); connect(cur, SIGNAL(connectivityModified()), this, SLOT(selectedMapConnectivityModified()));
connect(cur, SIGNAL(boundingBoxModified()), this, SLOT(selectedMapBoundingBoxModified())); connect(cur, SIGNAL(boundingBoxModified()), this, SLOT(selectedMapBoundingBoxModified()));
m_selectionRadiusBase = cur->getBBdiagSize() / 50.0f; m_selectionRadiusBase = cur->getBBdiagSize() / 50.0f;
h_parameterSet[cur].basePSradius = cur->getBBdiagSize() / (std::sqrt(cur->getNbOrbits(EDGE)));
h_parameterSet[cur].verticesScaleFactor = m_dockTab->slider_verticesScaleFactor->value() / 50.0f;
} }
} }
...@@ -660,6 +666,32 @@ void Surface_Selection_Plugin::changeSelectionMethod(const QString& map, unsigne ...@@ -660,6 +666,32 @@ void Surface_Selection_Plugin::changeSelectionMethod(const QString& map, unsigne
m_dockTab->updateMapParameters(); m_dockTab->updateMapParameters();
} }
} }
void Surface_Selection_Plugin::changeVerticesScaleFactor(const QString& map, float f)
{
DEBUG_SLOT();
MapHandlerGen* m = m_schnapps->getMap(map);
if (m)
{
h_parameterSet[m].verticesScaleFactor = f;
if (m->isSelectedMap())
m_dockTab->updateMapParameters();
}
}
void Surface_Selection_Plugin::changeVerticesBaseSize(const QString& map, float f)
{
DEBUG_SLOT();
MapHandlerGen* m = m_schnapps->getMap(map);
if (m)
{
h_parameterSet[m].basePSradius = f;
}
}
#if CGOGN_QT_DESIRED_VERSION == 5 #if CGOGN_QT_DESIRED_VERSION == 5
Q_PLUGIN_METADATA(IID "CGoGN.SCHNapps.Plugin") Q_PLUGIN_METADATA(IID "CGoGN.SCHNapps.Plugin")
#else #else
......
...@@ -19,6 +19,8 @@ Surface_Selection_DockTab::Surface_Selection_DockTab(SCHNApps* s, Surface_Select ...@@ -19,6 +19,8 @@ Surface_Selection_DockTab::Surface_Selection_DockTab(SCHNApps* s, Surface_Select
connect(combo_positionAttribute, SIGNAL(currentIndexChanged(int)), this, SLOT(positionAttributeChanged(int))); connect(combo_positionAttribute, SIGNAL(currentIndexChanged(int)), this, SLOT(positionAttributeChanged(int)));
connect(combo_normalAttribute, SIGNAL(currentIndexChanged(int)), this, SLOT(normalAttributeChanged(int))); connect(combo_normalAttribute, SIGNAL(currentIndexChanged(int)), this, SLOT(normalAttributeChanged(int)));
connect(combo_selectionMethod, SIGNAL(currentIndexChanged(int)), this, SLOT(selectionMethodChanged(int))); connect(combo_selectionMethod, SIGNAL(currentIndexChanged(int)), this, SLOT(selectionMethodChanged(int)));
connect(slider_verticesScaleFactor, SIGNAL(valueChanged(int)), this, SLOT(verticesScaleFactorChanged(int)));
connect(slider_verticesScaleFactor, SIGNAL(sliderPressed()), this, SLOT(verticesScaleFactorPressed()));
} }
...@@ -67,7 +69,41 @@ void Surface_Selection_DockTab::selectionMethodChanged(int index) ...@@ -67,7 +69,41 @@ void Surface_Selection_DockTab::selectionMethodChanged(int index)
} }
} }
void Surface_Selection_DockTab::verticesScaleFactorPressed()
{
if (!b_updatingUI)
{
MapHandlerGen* map = m_schnapps->getSelectedMap();
if (map)
{
m_plugin->h_parameterSet[map].basePSradius = map->getBBdiagSize() / (std::sqrt(map->getNbOrbits(EDGE)));
m_plugin->pythonRecording("changeVerticesBaseSize", "", map->getName(), m_plugin->h_parameterSet[map].basePSradius);
View* view = m_schnapps->getSelectedView();
if (view)
view->updateGL();
}
}
}
void Surface_Selection_DockTab::verticesScaleFactorChanged(int i)
{
if (!b_updatingUI)
{
MapHandlerGen* map = m_schnapps->getSelectedMap();
if (map)
{
m_plugin->h_parameterSet[map].verticesScaleFactor = i / 50.0;
m_plugin->pythonRecording("changeVerticesScaleFactor", "", map->getName(), i / 50.0);
View* view = m_schnapps->getSelectedView();
if (view)
view->updateGL();
}
}
}
......
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