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

selection

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