Commit 7cb93846 authored by Sylvain Thery's avatar Sylvain Thery

selection

parent 55cfef98
......@@ -14,26 +14,6 @@
<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">
......@@ -127,12 +107,49 @@
<item row="5" column="0" colspan="2">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Vertex Size Drawing</string>
<string>Selected vertice size</string>
</property>
</widget>
</item>
<item row="9" 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="7" column="0" colspan="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Selected vertices color</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="ColorComboBox" name="combo_color"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>ColorComboBox</class>
<extends>QComboBox</extends>
<header>colorComboBox.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
......@@ -31,6 +31,7 @@ struct MapParameters
SelectionMethod selectionMethod;
float verticesScaleFactor;
float basePSradius;
QColor color;
};
class Surface_Selection_Plugin : public PluginInteraction
......@@ -82,6 +83,7 @@ public slots:
void changeSelectionMethod(const QString& map, unsigned int method);
void changeVerticesScaleFactor(const QString& map, float f);
void changeVerticesBaseSize(const QString& map, float f);
void changeSelectedColor(const QString& map, const QString& col);
protected:
Surface_Selection_DockTab* m_dockTab;
......
......@@ -33,6 +33,7 @@ private slots:
void selectionMethodChanged(int index);
void verticesScaleFactorChanged(int i);
void verticesScaleFactorPressed();
void colorChanged(int i);
private:
void addVertexAttribute(const QString& name);
......
......@@ -6,6 +6,7 @@
#include "Algo/Selection/raySelector.h"
#include "Algo/Selection/collector.h"
#include "Algo/Geometry/centroid.h"
#include <QKeyEvent>
#include <QMouseEvent>
......@@ -110,7 +111,9 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map)
updateSelectedCellsRendering();
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));
const QColor& col = p.color;
m_pointSprite->setColor(Geom::Vec4f(col.redF(), col.greenF(), col.blueF(), 0.0f));
m_pointSprite->setLightPosition(CGoGN::Geom::Vec3f(0.0f, 0.0f, 1.0f));
// m_pointSprite->setSize(map->getBBdiagSize() / 75.0f);
m_pointSprite->setSize(p.basePSradius*p.verticesScaleFactor);
......@@ -178,8 +181,10 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map)
break;
}
case WithinSphere : {
PFP2::MAP* m = static_cast<MapHandler<PFP2>*>(map)->getMap();
std::vector<PFP2::VEC3> selectionPoint;
selectionPoint.push_back(p.positionAttribute[m_selectingEdge.dart]);
selectionPoint.push_back((p.positionAttribute[m_selectingEdge.dart] + (p.positionAttribute[m->phi1(m_selectingEdge.dart)])/2.0f));
//selectionPoint.push_back(p.positionAttribute[m_selectingEdge.dart]);
m_selectionSphereVBO->updateData(selectionPoint);
m_pointSprite->setAttributePosition(m_selectionSphereVBO);
......@@ -225,8 +230,11 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map)
break;
}
case WithinSphere : {
PFP2::MAP* m = static_cast<MapHandler<PFP2>*>(map)->getMap();
std::vector<PFP2::VEC3> selectionPoint;
selectionPoint.push_back(p.positionAttribute[m_selectingFace.dart]);
selectionPoint.push_back(Algo::Surface::Geometry::faceCentroid<PFP2>(*m, m_selectingFace, p.positionAttribute));
// selectionPoint.push_back(p.positionAttribute[m_selectingFace.dart]);
m_selectionSphereVBO->updateData(selectionPoint);
m_pointSprite->setAttributePosition(m_selectionSphereVBO);
......@@ -557,7 +565,8 @@ void Surface_Selection_Plugin::updateSelectedCellsRendering()
m_selectedEdgesDrawer->newList(GL_COMPILE);
m_selectedEdgesDrawer->lineWidth(3.0f);
m_selectedEdgesDrawer->color3f(1.0f, 0.0f, 0.0f);
// m_selectedEdgesDrawer->color3f(1.0f, 0.0f, 0.0f);
m_selectedEdgesDrawer->color3f(p.color.redF(), p.color.greenF(), p.color.blueF());
m_selectedEdgesDrawer->begin(GL_LINES);
for(std::vector<Edge>::const_iterator e = selectedCells.begin(); e != selectedCells.end(); ++e)
{
......@@ -576,7 +585,8 @@ void Surface_Selection_Plugin::updateSelectedCellsRendering()
const std::vector<Face>& selectedCells = cs->getSelectedCells();
m_selectedFacesDrawer->newList(GL_COMPILE);
m_selectedFacesDrawer->color3f(1.0f, 0.0f, 0.0f);
// m_selectedFacesDrawer->color3f(1.0f, 0.0f, 0.0f);
m_selectedFacesDrawer->color3f(p.color.redF(), p.color.greenF(), p.color.blueF());
m_selectedFacesDrawer->begin(GL_TRIANGLES);
for(std::vector<Face>::const_iterator f = selectedCells.begin(); f != selectedCells.end(); ++f)
{
......@@ -686,6 +696,27 @@ void Surface_Selection_Plugin::changeVerticesBaseSize(const QString& map, float
if (m)
{
h_parameterSet[m].basePSradius = f;
if (m->isSelectedMap())
m_dockTab->updateMapParameters();
}
}
void Surface_Selection_Plugin::changeSelectedColor( const QString& map, const QString& col)
{
MapHandlerGen* m = m_schnapps->getMap(map);
if (m)
{
h_parameterSet[m].color = QColor(col);
if (m->isSelectedMap())
m_dockTab->updateMapParameters();
View* v = m_schnapps->getSelectedView();
if (v)
{
if (v->isLinkedToMap(m))
v->updateGL();
}
}
}
......
......@@ -16,11 +16,17 @@ Surface_Selection_DockTab::Surface_Selection_DockTab(SCHNApps* s, Surface_Select
{
setupUi(this);
combo_color->setEnabled(true);
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()));
connect(combo_color, SIGNAL(currentIndexChanged(int)), this, SLOT(colorChanged(int)));
// force color for map parameter updating
combo_color->setCurrentIndex(0);
}
......@@ -120,6 +126,34 @@ void Surface_Selection_DockTab::addVertexAttribute(const QString& nameAttr)
b_updatingUI = false;
}
void Surface_Selection_DockTab::colorChanged(int i)
{
if (!b_updatingUI)
{
View* view = m_schnapps->getSelectedView();
MapHandlerGen* map = m_schnapps->getSelectedMap();
std::cout << "colorChanged: " << combo_color->color().name().toStdString() << std::endl;
std::cout << "colorChanged: " << i << std::endl;
if (view && map )
{
// MapParameters& p = m_plugin->h_parameterSet[map];
QColor& col = m_plugin->h_parameterSet[map].color;
if (col != combo_color->color())
{
col = combo_color->color();
m_plugin->updateSelectedCellsRendering();
m_plugin->pythonRecording("changeSelectedColor", "", map->getName(), combo_color->color().name());
}
view->updateGL();
}
}
}
void Surface_Selection_DockTab::updateMapParameters()
{
b_updatingUI = true;
......@@ -156,6 +190,7 @@ void Surface_Selection_DockTab::updateMapParameters()
}
combo_selectionMethod->setCurrentIndex(p.selectionMethod);
combo_color->setColor(p.color);
}
b_updatingUI = false;
......
......@@ -152,6 +152,7 @@ private slots:
public:
void updateMutuallyExclusiveSelectors(unsigned int orbit);
/*********************************************************
* MANAGE LINKED VIEWS
*********************************************************/
......
......@@ -119,6 +119,8 @@ public slots:
void notifySelectedCellSelectorChanged(CellSelectorGen* cs) { DEBUG_EMIT("selectedCellSelectorChanged"); emit(selectedCellSelectorChanged(cs)); }
CellSelectorGen* getSelectedSelector(unsigned int orbit) const;
void setSelectedSelectorCurrentMap(unsigned int orbit, const QString& name);
const StaticPointers& getStaticPointers() const { return m_sp; }
/*********************************************************
......
......@@ -237,10 +237,10 @@ void ControlDock_MapTab::selectedSelectorChanged()
m_selectedSelector[orbit] = m_selectedMap->getCellSelector(orbit, items[0]->text());
m_schnapps->notifySelectedCellSelectorChanged(m_selectedSelector[orbit]);
//// RECORDING TODO
//QTextStream* rec = m_schnapps->pythonStreamRecorder();
//if (rec)
// *rec << m_selectedMap->getName() << ".setSelectedSelector(" << orbit << ", \"" << items[0]->text() << "\");" << endl;
// RECORDING TODO
QTextStream* rec = m_schnapps->pythonStreamRecorder();
if (rec)
*rec << m_selectedMap->getName() << ".setSelectedSelector(" << orbit << ", \"" << items[0]->text() << "\");" << endl;
}
}
......
......@@ -339,7 +339,7 @@ void MapHandlerGen::removeCellSelector(unsigned int orbit, const QString& name)
DEBUG_EMIT("cellSelectorRemoved");
emit(cellSelectorRemoved(orbit, name));
disconnect(cs, SIGNAL(selectedCellsChanged()), this, SIGNAL(selectedCellsChanged()));
disconnect(cs, SIGNAL(selectedCellsChanged()), this, SLOT(selectedCellsChanged()));
delete cs;
}
......@@ -372,6 +372,7 @@ void MapHandlerGen::updateMutuallyExclusiveSelectors(unsigned int orbit)
cs->setMutuallyExclusiveSet(mex);
}
/*********************************************************
* MANAGE LINKED VIEWS
*********************************************************/
......
......@@ -794,6 +794,22 @@ CellSelectorGen* SCHNApps::getSelectedSelector(unsigned int orbit) const
return m_controlMapTab->getSelectedSelector(orbit);
}
void SCHNApps::setSelectedSelectorCurrentMap(unsigned int orbit, const QString& name)
{
QList<QListWidgetItem*> items;
switch (orbit)
{
case DART: items = m_controlMapTab->list_dartSelectors->findItems(name,Qt::MatchExactly); break;
case VERTEX: items = m_controlMapTab->list_vertexSelectors->findItems(name, Qt::MatchExactly); break;
case EDGE: items = m_controlMapTab->list_edgeSelectors->findItems(name, Qt::MatchExactly); break;
case FACE: items = m_controlMapTab->list_faceSelectors->findItems(name, Qt::MatchExactly); break;
case VOLUME: items = m_controlMapTab->list_volumeSelectors->findItems(name, Qt::MatchExactly); break;
}
if (!items.empty())
items[0]->setSelected(true);
}
/*********************************************************
* MANAGE TEXTURES
*********************************************************/
......
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