Commit cdfff0a1 authored by Sylvain Thery's avatar Sylvain Thery

auto radius render & selection

parent 46beef72
......@@ -19,6 +19,9 @@
<property name="text">
<string>render boundary</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2">
......
......@@ -43,6 +43,7 @@ private slots:
void colorVBOChanged(int index);
void renderVerticesChanged(bool b);
void verticesScaleFactorChanged(int i);
void verticesScaleFactorPressed();
void renderEdgesChanged(bool b);
void renderFacesChanged(bool b);
void faceStyleChanged(QAbstractButton* b);
......
......@@ -115,8 +115,7 @@ void Surface_Render_Plugin::drawMap(View* view, MapHandlerGen* map)
if(p.renderVertices)
{
// m_pointSprite->setSize(map->getBBdiagSize() / 200.0f * p.verticesScaleFactor);
m_pointSprite->setSize(p.basePSradius * 2 * p.verticesScaleFactor);
m_pointSprite->setSize(p.basePSradius * p.verticesScaleFactor);
m_pointSprite->setAttributePosition(p.positionVBO);
m_pointSprite->setColor(p.vertexColor);
map->draw(m_pointSprite, CGoGN::Algo::Render::GL2::POINTS);
......@@ -298,6 +297,8 @@ void Surface_Render_Plugin::changeRenderVertices(const QString& view, const QStr
if(v && m)
{
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->isLinkedToMap(m)) v->updateGL();
......@@ -330,6 +331,8 @@ void Surface_Render_Plugin::changeRenderEdges(const QString& view, const QString
if(v && m)
{
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->isLinkedToMap(m)) v->updateGL();
......
......@@ -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(check_renderVertices, SIGNAL(toggled(bool)), this, SLOT(renderVerticesChanged(bool)));
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_renderFaces, SIGNAL(toggled(bool)), this, SLOT(renderFacesChanged(bool)));
connect(group_faceShading, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(faceStyleChanged(QAbstractButton*)));
......@@ -98,7 +99,7 @@ void Surface_Render_DockTab::renderVerticesChanged(bool b)
if (view && map)
{
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;
view->updateGL();
......@@ -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)
{
if (!b_updatingUI)
......
......@@ -14,6 +14,26 @@
<string>Form</string>
</property>
<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">
<widget class="QComboBox" name="combo_selectionMethod">
<property name="sizePolicy">
......@@ -39,30 +59,19 @@
</item>
</widget>
</item>
<item row="4" 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>
<item row="1" column="1">
<widget class="QComboBox" name="combo_normalAttribute">
<item>
<property name="text">
<string>- select attribute -</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Normal :</string>
</property>
</widget>
</item>
......@@ -88,20 +97,38 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Normal :</string>
<item row="2" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="combo_normalAttribute">
<item>
<property name="text">
<string>- select attribute -</string>
</property>
</item>
<item row="6" column="0" colspan="2">
<widget class="QSlider" name="slider_verticesScaleFactor">
<property name="value">
<number>50</number>
</property>
<property name="orientation">
<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>
</item>
</layout>
......
......@@ -29,6 +29,8 @@ struct MapParameters
VertexAttribute<PFP2::VEC3, PFP2::MAP> positionAttribute;
VertexAttribute<PFP2::VEC3, PFP2::MAP> normalAttribute;
SelectionMethod selectionMethod;
float verticesScaleFactor;
float basePSradius;
};
class Surface_Selection_Plugin : public PluginInteraction
......@@ -78,6 +80,8 @@ public slots:
void changePositionAttribute(const QString& map, const QString& name);
void changeNormalAttribute(const QString& map, const QString& name);
void changeSelectionMethod(const QString& map, unsigned int method);
void changeVerticesScaleFactor(const QString& map, float f);
void changeVerticesBaseSize(const QString& map, float f);
protected:
Surface_Selection_DockTab* m_dockTab;
......
......@@ -31,6 +31,8 @@ private slots:
void positionAttributeChanged(int index);
void normalAttributeChanged(int index);
void selectionMethodChanged(int index);
void verticesScaleFactorChanged(int i);
void verticesScaleFactorPressed();
private:
void addVertexAttribute(const QString& name);
......
......@@ -60,6 +60,8 @@ bool Surface_Selection_Plugin::enable()
connect(cur, SIGNAL(connectivityModified()), this, SLOT(selectedMapConnectivityModified()));
connect(cur, SIGNAL(boundingBoxModified()), this, SLOT(selectedMapBoundingBoxModified()));
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();
......@@ -110,7 +112,8 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map)
m_pointSprite->setAttributePosition(m_selectedVerticesVBO);
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->setSize(map->getBBdiagSize() / 75.0f);
// m_pointSprite->setSize(map->getBBdiagSize() / 75.0f);
m_pointSprite->setSize(p.basePSradius*p.verticesScaleFactor);
m_pointSprite->enableVertexAttribs();
glDrawArrays(GL_POINTS, 0, selector->getNbSelectedCells());
......@@ -131,8 +134,8 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map)
{
case NormalAngle :
case SingleCell : {
m_pointSprite->setSize(map->getBBdiagSize() / 60.0f);
break;
// m_pointSprite->setSize(map->getBBdiagSize() / 60.0f);
m_pointSprite->setSize(p.basePSradius*p.verticesScaleFactor);
}
case WithinSphere : {
m_pointSprite->setSize(m_selectionRadiusBase * m_selectionRadiusCoeff);
......@@ -253,13 +256,14 @@ void Surface_Selection_Plugin::keyPress(View* view, QKeyEvent* event)
{
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());
QMouseEvent me = QMouseEvent(QEvent::MouseMove, QPointF(p), Qt::NoButton, Qt::NoButton, Qt::ShiftModifier);
mouseMove(view, &me);
view->setMouseTracking(true);
m_selecting = true;
view->updateGL();
}
}
......@@ -517,6 +521,8 @@ void Surface_Selection_Plugin::selectedMapChanged(MapHandlerGen *prev, MapHandle
connect(cur, SIGNAL(connectivityModified()), this, SLOT(selectedMapConnectivityModified()));
connect(cur, SIGNAL(boundingBoxModified()), this, SLOT(selectedMapBoundingBoxModified()));
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
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
Q_PLUGIN_METADATA(IID "CGoGN.SCHNapps.Plugin")
#else
......
......@@ -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_normalAttribute, SIGNAL(currentIndexChanged(int)), this, SLOT(normalAttributeChanged(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)
}
}
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