Commit ec5fcdbb authored by Sylvain Thery's avatar Sylvain Thery

update python loading & selection

parent 897bd129
...@@ -31,8 +31,10 @@ bool Surface_Import_Plugin::enable() ...@@ -31,8 +31,10 @@ bool Surface_Import_Plugin::enable()
return true; return true;
} }
MapHandlerGen* Surface_Import_Plugin::importMeshFromFile(const QString& fileName) MapHandlerGen* Surface_Import_Plugin::importMeshFromFile(const QString& nameOfFile)
{ {
QString fileName = SCHNApps::noBackSlash(nameOfFile);
QFileInfo fi(fileName); QFileInfo fi(fileName);
if(fi.exists()) if(fi.exists())
{ {
...@@ -75,8 +77,10 @@ void Surface_Import_Plugin::importMeshFromFileDialog() ...@@ -75,8 +77,10 @@ void Surface_Import_Plugin::importMeshFromFileDialog()
} }
} }
MapHandlerGen* Surface_Import_Plugin::importImageFromFile(const QString& fileName) MapHandlerGen* Surface_Import_Plugin::importImageFromFile(const QString& nameOfFile)
{ {
QString fileName = SCHNApps::noBackSlash(nameOfFile);
QFileInfo fi(fileName); QFileInfo fi(fileName);
if(fi.exists()) if(fi.exists())
{ {
......
...@@ -14,29 +14,11 @@ ...@@ -14,29 +14,11 @@
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="3" column="1"> <item row="5" column="0" colspan="2">
<widget class="QComboBox" name="combo_selectionMethod"> <widget class="QPushButton" name="button_clear">
<property name="sizePolicy"> <property name="text">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <string>Clear current selection</string>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<item>
<property name="text">
<string>SingleCell</string>
</property>
</item>
<item>
<property name="text">
<string>WithinSphere</string>
</property>
</item>
<item>
<property name="text">
<string>NormalAngle</string>
</property>
</item>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
...@@ -55,8 +37,8 @@ ...@@ -55,8 +37,8 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="3" column="1">
<widget class="QComboBox" name="combo_positionAttribute"> <widget class="QComboBox" name="combo_selectionMethod">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
...@@ -65,16 +47,19 @@ ...@@ -65,16 +47,19 @@
</property> </property>
<item> <item>
<property name="text"> <property name="text">
<string>- select attribute -</string> <string>SingleCell</string>
</property>
</item>
<item>
<property name="text">
<string>WithinSphere</string>
</property>
</item>
<item>
<property name="text">
<string>NormalAngle</string>
</property> </property>
</item> </item>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Position :</string>
</property>
</widget> </widget>
</item> </item>
<item row="2" column="0" colspan="2"> <item row="2" column="0" colspan="2">
...@@ -84,7 +69,7 @@ ...@@ -84,7 +69,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0" colspan="2"> <item row="8" column="0" colspan="2">
<widget class="QSlider" name="slider_verticesScaleFactor"> <widget class="QSlider" name="slider_verticesScaleFactor">
<property name="value"> <property name="value">
<number>50</number> <number>50</number>
...@@ -97,6 +82,13 @@ ...@@ -97,6 +82,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Position :</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2"> <item row="4" column="0" colspan="2">
<widget class="Line" name="line_2"> <widget class="Line" name="line_2">
<property name="orientation"> <property name="orientation">
...@@ -104,14 +96,43 @@ ...@@ -104,14 +96,43 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0" colspan="2"> <item row="0" column="1">
<widget class="QComboBox" name="combo_positionAttribute">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>- select attribute -</string>
</property>
</item>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="label_4">
<property name="text"> <property name="text">
<string>Selected vertice size</string> <string>Selected vertice size</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="1"> <item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Method :</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Selected vertices color</string>
</property>
</widget>
</item>
<item row="14" column="1">
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
...@@ -124,23 +145,16 @@ ...@@ -124,23 +145,16 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="3" column="0"> <item row="10" column="0" colspan="2">
<widget class="QLabel" name="label_3"> <widget class="ColorComboBox" name="combo_color"/>
<property name="text">
<string>Method :</string>
</property>
</widget>
</item> </item>
<item row="7" column="0" colspan="2"> <item row="6" column="0" colspan="2">
<widget class="QLabel" name="label_5"> <widget class="Line" name="line_3">
<property name="text"> <property name="orientation">
<string>Selected vertices color</string> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="0" colspan="2">
<widget class="ColorComboBox" name="combo_color"/>
</item>
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>
......
...@@ -80,14 +80,56 @@ private slots: ...@@ -80,14 +80,56 @@ private slots:
void selectedMapBoundingBoxModified(); void selectedMapBoundingBoxModified();
public slots: public slots:
// slots for Python calls /**
* @brief change the position attribute
* @param map map name
* @param name position attribute name
*/
void changePositionAttribute(const QString& map, const QString& name); void changePositionAttribute(const QString& map, const QString& name);
/**
* @brief change the normal attribute
* @param map map name
* @param name normal attribute name
*/
void changeNormalAttribute(const QString& map, const QString& name); void changeNormalAttribute(const QString& map, const QString& name);
/**
* @brief change the selection
* @param map map name
* @param method selection method 0:single Cell / 1: WithinSphere / 2: Normal angle
*/
void changeSelectionMethod(const QString& map, unsigned int method); void changeSelectionMethod(const QString& map, unsigned int method);
/**
* @brief change the vertices scale factor
* @param map map name
* @param f scaling factor 0 - 2
*/
void changeVerticesScaleFactor(const QString& map, float f); void changeVerticesScaleFactor(const QString& map, float f);
/**
* @brief change the vertices rendering size (when scaling is 1)
* @param map map name
* @param f vertex size ( in object frame)
*/
void changeVerticesBaseSize(const QString& map, float f); void changeVerticesBaseSize(const QString& map, float f);
/**
* @brief change the color for rendering selected cells
* @param map map name
* @param col color in Qt string format "#rrggbb". Each component is given in hexa, for example red is #ff0000
*/
void changeSelectedColor(const QString& map, const QString& col); void changeSelectedColor(const QString& map, const QString& col);
/**
* @brief clear the selection
* @param map map name
* @param orbit orbit selector 0:DART 1:VERTEX 2:EDGE 3:FACE
* @param selectorName name of selector
*/
void clearSelection(const QString& map, unsigned int orbit, const QString& selectorName);
protected: protected:
Surface_Selection_DockTab* m_dockTab; Surface_Selection_DockTab* m_dockTab;
QHash<MapHandlerGen*, MapParameters> h_parameterSet; QHash<MapHandlerGen*, MapParameters> h_parameterSet;
......
...@@ -34,7 +34,7 @@ private slots: ...@@ -34,7 +34,7 @@ private slots:
void verticesScaleFactorChanged(int i); void verticesScaleFactorChanged(int i);
void verticesScaleFactorPressed(); void verticesScaleFactorPressed();
void colorChanged(int i); void colorChanged(int i);
void clearPressed();
private: private:
void addVertexAttribute(const QString& name); void addVertexAttribute(const QString& name);
......
...@@ -290,6 +290,9 @@ void Surface_Selection_Plugin::keyRelease(View* view, QKeyEvent* event) ...@@ -290,6 +290,9 @@ void Surface_Selection_Plugin::keyRelease(View* view, QKeyEvent* event)
} }
} }
void Surface_Selection_Plugin::mousePress(View* view, QMouseEvent* event) void Surface_Selection_Plugin::mousePress(View* view, QMouseEvent* event)
{ {
if(m_selecting && (event->button() == Qt::LeftButton || event->button() == Qt::RightButton)) if(m_selecting && (event->button() == Qt::LeftButton || event->button() == Qt::RightButton))
...@@ -514,8 +517,6 @@ void Surface_Selection_Plugin::wheelEvent(View* view, QWheelEvent* event) ...@@ -514,8 +517,6 @@ void Surface_Selection_Plugin::wheelEvent(View* view, QWheelEvent* event)
void Surface_Selection_Plugin::selectedMapChanged(MapHandlerGen *prev, MapHandlerGen *cur) void Surface_Selection_Plugin::selectedMapChanged(MapHandlerGen *prev, MapHandlerGen *cur)
{ {
m_dockTab->updateMapParameters(); m_dockTab->updateMapParameters();
...@@ -684,12 +685,12 @@ void Surface_Selection_Plugin::changePositionAttribute(const QString& map, const ...@@ -684,12 +685,12 @@ void Surface_Selection_Plugin::changePositionAttribute(const QString& map, const
if(m->isSelectedMap()) if(m->isSelectedMap())
m_dockTab->updateMapParameters(); m_dockTab->updateMapParameters();
} }
//View* v = m_schnapps->getSelectedView(); View* v = m_schnapps->getSelectedView();
//if (v) if (v)
//{ {
// if (v->isLinkedToMap(m)) if (v->isLinkedToMap(m))
// v->updateGL(); v->updateGL();
//} }
} }
void Surface_Selection_Plugin::changeNormalAttribute(const QString& map, const QString& name) void Surface_Selection_Plugin::changeNormalAttribute(const QString& map, const QString& name)
...@@ -702,12 +703,12 @@ void Surface_Selection_Plugin::changeNormalAttribute(const QString& map, const Q ...@@ -702,12 +703,12 @@ void Surface_Selection_Plugin::changeNormalAttribute(const QString& map, const Q
if(m->isSelectedMap()) if(m->isSelectedMap())
m_dockTab->updateMapParameters(); m_dockTab->updateMapParameters();
} }
//View* v = m_schnapps->getSelectedView(); View* v = m_schnapps->getSelectedView();
//if (v) if (v)
//{ {
// if (v->isLinkedToMap(m)) if (v->isLinkedToMap(m))
// v->updateGL(); v->updateGL();
//} }
} }
void Surface_Selection_Plugin::changeSelectionMethod(const QString& map, unsigned int method) void Surface_Selection_Plugin::changeSelectionMethod(const QString& map, unsigned int method)
...@@ -719,12 +720,12 @@ void Surface_Selection_Plugin::changeSelectionMethod(const QString& map, unsigne ...@@ -719,12 +720,12 @@ void Surface_Selection_Plugin::changeSelectionMethod(const QString& map, unsigne
if(m->isSelectedMap()) if(m->isSelectedMap())
m_dockTab->updateMapParameters(); m_dockTab->updateMapParameters();
} }
//View* v = m_schnapps->getSelectedView(); View* v = m_schnapps->getSelectedView();
//if (v) if (v)
//{ {
// if (v->isLinkedToMap(m)) if (v->isLinkedToMap(m))
// v->updateGL(); v->updateGL();
//} }
} }
void Surface_Selection_Plugin::changeVerticesScaleFactor(const QString& map, float f) void Surface_Selection_Plugin::changeVerticesScaleFactor(const QString& map, float f)
...@@ -738,12 +739,12 @@ void Surface_Selection_Plugin::changeVerticesScaleFactor(const QString& map, flo ...@@ -738,12 +739,12 @@ void Surface_Selection_Plugin::changeVerticesScaleFactor(const QString& map, flo
m_dockTab->updateMapParameters(); m_dockTab->updateMapParameters();
} }
//View* v = m_schnapps->getSelectedView(); View* v = m_schnapps->getSelectedView();
//if (v) if (v)
//{ {
// if (v->isLinkedToMap(m)) if (v->isLinkedToMap(m))
// v->updateGL(); v->updateGL();
//} }
} }
void Surface_Selection_Plugin::changeVerticesBaseSize(const QString& map, float f) void Surface_Selection_Plugin::changeVerticesBaseSize(const QString& map, float f)
...@@ -757,12 +758,12 @@ void Surface_Selection_Plugin::changeVerticesBaseSize(const QString& map, float ...@@ -757,12 +758,12 @@ void Surface_Selection_Plugin::changeVerticesBaseSize(const QString& map, float
m_dockTab->updateMapParameters(); m_dockTab->updateMapParameters();
} }
//View* v = m_schnapps->getSelectedView(); View* v = m_schnapps->getSelectedView();
//if (v) if (v)
//{ {
// if (v->isLinkedToMap(m)) if (v->isLinkedToMap(m))
// v->updateGL(); v->updateGL();
//} }
} }
...@@ -775,16 +776,34 @@ void Surface_Selection_Plugin::changeSelectedColor( const QString& map, const QS ...@@ -775,16 +776,34 @@ void Surface_Selection_Plugin::changeSelectedColor( const QString& map, const QS
if (m->isSelectedMap()) if (m->isSelectedMap())
m_dockTab->updateMapParameters(); m_dockTab->updateMapParameters();
// View* v = m_schnapps->getSelectedView(); View* v = m_schnapps->getSelectedView();
// if (v) if (v)
// { {
// if (v->isLinkedToMap(m)) if (v->isLinkedToMap(m))
// v->updateGL(); v->updateGL();
// } }
} }
} }
void Surface_Selection_Plugin::clearSelection(const QString& map, unsigned int orbit, const QString& selectorName)
{
MapHandlerGen* m = m_schnapps->getMap(map);
if (m)
{
CellSelectorGen* selector = m->getCellSelector(orbit, selectorName);
if (selector)
{
selector->clearAll();
}
View* v = m_schnapps->getSelectedView();
if (v)
{
if (v->isLinkedToMap(m))
v->updateGL();
}
}
}
#if CGOGN_QT_DESIRED_VERSION == 5 #if CGOGN_QT_DESIRED_VERSION == 5
......
...@@ -24,6 +24,7 @@ Surface_Selection_DockTab::Surface_Selection_DockTab(SCHNApps* s, Surface_Select ...@@ -24,6 +24,7 @@ Surface_Selection_DockTab::Surface_Selection_DockTab(SCHNApps* s, Surface_Select
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))); connect(combo_color, SIGNAL(currentIndexChanged(int)), this, SLOT(colorChanged(int)));
connect(button_clear, SIGNAL(pressed()), this, SLOT(clearPressed()));
// force color for map parameter updating // force color for map parameter updating
// combo_color->setCurrentIndex(0); // combo_color->setCurrentIndex(0);
...@@ -149,6 +150,21 @@ void Surface_Selection_DockTab::colorChanged(int i) ...@@ -149,6 +150,21 @@ void Surface_Selection_DockTab::colorChanged(int i)
} }
void Surface_Selection_DockTab::clearPressed()
{
if (!b_updatingUI)
{
MapHandlerGen* map = m_schnapps->getSelectedMap();
unsigned int orbit = m_schnapps->getCurrentOrbit();
if (map)
{
m_plugin->clearSelection(map->getName(), orbit, m_schnapps->getSelectedSelector(orbit)->getName());
m_plugin->pythonRecording("clearSelection", "", map->getName(), orbit, m_schnapps->getSelectedSelector(orbit)->getName());
}
}
}
void Surface_Selection_DockTab::updateMapParameters() void Surface_Selection_DockTab::updateMapParameters()
{ {
b_updatingUI = true; b_updatingUI = true;
...@@ -186,6 +202,8 @@ void Surface_Selection_DockTab::updateMapParameters() ...@@ -186,6 +202,8 @@ void Surface_Selection_DockTab::updateMapParameters()
combo_selectionMethod->setCurrentIndex(p.selectionMethod); combo_selectionMethod->setCurrentIndex(p.selectionMethod);
combo_color->setColor(p.color); combo_color->setColor(p.color);
slider_verticesScaleFactor->setValue(int(50.0*p.verticesScaleFactor));
} }
b_updatingUI = false; b_updatingUI = false;
......
...@@ -53,6 +53,8 @@ public: ...@@ -53,6 +53,8 @@ public:
inline bool isMutuallyExclusive() const { return m_isMutuallyExclusive; } inline bool isMutuallyExclusive() const { return m_isMutuallyExclusive; }
virtual void setMutuallyExclusiveSet(const QList<CellSelectorGen*>& mex) = 0; virtual void setMutuallyExclusiveSet(const QList<CellSelectorGen*>& mex) = 0;
virtual void clearAll() = 0;
signals: signals:
void selectedCellsChanged(); void selectedCellsChanged();
...@@ -184,6 +186,16 @@ public: ...@@ -184,6 +186,16 @@ public:
} }
} }
inline void clearAll()
{
std::vector<CELL> tempo;
m_cells.swap(tempo);
m_cm.unmarkAll();
m_selectionChanged = true;
checkChange();
}
private: private:
MAP& m_map; MAP& m_map;
CellMarker<MAP, ORBIT> m_cm; CellMarker<MAP, ORBIT> m_cm;
......
...@@ -273,9 +273,10 @@ public slots: ...@@ -273,9 +273,10 @@ public slots:
/** /**
* @brief Load a python script store in a file. * @brief Load a python script store in a file.
* @param fileName the filename * @param fileName the filename with absolute path or relative to path set with setPythonPath
* #return true if reading file ok
*/ */
void loadPythonScriptFromFile(const QString& fileName); bool loadPythonScriptFromFile(const QString& fileName);
/** /**
* Associate a python command with a key shortcut * Associate a python command with a key shortcut
...@@ -306,7 +307,7 @@ public slots: ...@@ -306,7 +307,7 @@ public slots:
* @brief set the default path used when opening python file dialog. * @brief set the default path used when opening python file dialog.