Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CGoGN
CGoGN
Commits
ec5fcdbb
Commit
ec5fcdbb
authored
Jul 02, 2015
by
Sylvain Thery
Browse files
update python loading & selection
parent
897bd129
Changes
10
Hide whitespace changes
Inline
Side-by-side
SCHNApps/Plugins/surface_import/src/surface_import.cpp
View file @
ec5fcdbb
...
...
@@ -31,8 +31,10 @@ bool Surface_Import_Plugin::enable()
return
true
;
}
MapHandlerGen
*
Surface_Import_Plugin
::
importMeshFromFile
(
const
QString
&
fileNam
e
)
MapHandlerGen
*
Surface_Import_Plugin
::
importMeshFromFile
(
const
QString
&
nameOfFil
e
)
{
QString
fileName
=
SCHNApps
::
noBackSlash
(
nameOfFile
);
QFileInfo
fi
(
fileName
);
if
(
fi
.
exists
())
{
...
...
@@ -75,8 +77,10 @@ void Surface_Import_Plugin::importMeshFromFileDialog()
}
}
MapHandlerGen
*
Surface_Import_Plugin
::
importImageFromFile
(
const
QString
&
fileNam
e
)
MapHandlerGen
*
Surface_Import_Plugin
::
importImageFromFile
(
const
QString
&
nameOfFil
e
)
{
QString
fileName
=
SCHNApps
::
noBackSlash
(
nameOfFile
);
QFileInfo
fi
(
fileName
);
if
(
fi
.
exists
())
{
...
...
SCHNApps/Plugins/surface_selection/forms/surface_selection.ui
View file @
ec5fcdbb
...
...
@@ -14,29 +14,11 @@
<string>
Form
</string>
</property>
<layout
class=
"QGridLayout"
name=
"gridLayout"
>
<item
row=
"3"
column=
"1"
>
<widget
class=
"QComboBox"
name=
"combo_selectionMethod"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Expanding"
vsizetype=
"Fixed"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
<item
row=
"5"
column=
"0"
colspan=
"2"
>
<widget
class=
"QPushButton"
name=
"button_clear"
>
<property
name=
"text"
>
<string>
Clear current selection
</string>
</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>
</item>
<item
row=
"1"
column=
"1"
>
...
...
@@ -55,8 +37,8 @@
</property>
</widget>
</item>
<item
row=
"
0
"
column=
"1"
>
<widget
class=
"QComboBox"
name=
"combo_
positionAttribute
"
>
<item
row=
"
3
"
column=
"1"
>
<widget
class=
"QComboBox"
name=
"combo_
selectionMethod
"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Expanding"
vsizetype=
"Fixed"
>
<horstretch>
0
</horstretch>
...
...
@@ -65,16 +47,19 @@
</property>
<item>
<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>
</item>
</widget>
</item>
<item
row=
"0"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_2"
>
<property
name=
"text"
>
<string>
Position :
</string>
</property>
</widget>
</item>
<item
row=
"2"
column=
"0"
colspan=
"2"
>
...
...
@@ -84,7 +69,7 @@
</property>
</widget>
</item>
<item
row=
"
6
"
column=
"0"
colspan=
"2"
>
<item
row=
"
8
"
column=
"0"
colspan=
"2"
>
<widget
class=
"QSlider"
name=
"slider_verticesScaleFactor"
>
<property
name=
"value"
>
<number>
50
</number>
...
...
@@ -97,6 +82,13 @@
</property>
</widget>
</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"
>
<widget
class=
"Line"
name=
"line_2"
>
<property
name=
"orientation"
>
...
...
@@ -104,14 +96,43 @@
</property>
</widget>
</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"
>
<property
name=
"text"
>
<string>
Selected vertice size
</string>
</property>
</widget>
</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"
>
<property
name=
"orientation"
>
<enum>
Qt::Vertical
</enum>
...
...
@@ -124,23 +145,16 @@
</property>
</spacer>
</item>
<item
row=
"3"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_3"
>
<property
name=
"text"
>
<string>
Method :
</string>
</property>
</widget>
<item
row=
"10"
column=
"0"
colspan=
"2"
>
<widget
class=
"ColorComboBox"
name=
"combo_color"
/>
</item>
<item
row=
"
7
"
column=
"0"
colspan=
"2"
>
<widget
class=
"
QLabel
"
name=
"l
abel_5
"
>
<property
name=
"
text
"
>
<
string>
Selected vertices color
</string
>
<item
row=
"
6
"
column=
"0"
colspan=
"2"
>
<widget
class=
"
Line
"
name=
"l
ine_3
"
>
<property
name=
"
orientation
"
>
<
enum>
Qt::Horizontal
</enum
>
</property>
</widget>
</item>
<item
row=
"8"
column=
"0"
colspan=
"2"
>
<widget
class=
"ColorComboBox"
name=
"combo_color"
/>
</item>
</layout>
</widget>
<customwidgets>
...
...
SCHNApps/Plugins/surface_selection/include/surface_selection.h
View file @
ec5fcdbb
...
...
@@ -80,14 +80,56 @@ private slots:
void
selectedMapBoundingBoxModified
();
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
);
/**
* @brief change the normal attribute
* @param map map name
* @param name normal attribute 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
);
/**
* @brief change the vertices scale factor
* @param map map name
* @param f scaling factor 0 - 2
*/
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
);
/**
* @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
);
/**
* @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:
Surface_Selection_DockTab
*
m_dockTab
;
QHash
<
MapHandlerGen
*
,
MapParameters
>
h_parameterSet
;
...
...
SCHNApps/Plugins/surface_selection/include/surface_selection_dockTab.h
View file @
ec5fcdbb
...
...
@@ -34,7 +34,7 @@ private slots:
void
verticesScaleFactorChanged
(
int
i
);
void
verticesScaleFactorPressed
();
void
colorChanged
(
int
i
);
void
clearPressed
();
private:
void
addVertexAttribute
(
const
QString
&
name
);
...
...
SCHNApps/Plugins/surface_selection/src/surface_selection.cpp
View file @
ec5fcdbb
...
...
@@ -290,6 +290,9 @@ void Surface_Selection_Plugin::keyRelease(View* view, QKeyEvent* event)
}
}
void
Surface_Selection_Plugin
::
mousePress
(
View
*
view
,
QMouseEvent
*
event
)
{
if
(
m_selecting
&&
(
event
->
button
()
==
Qt
::
LeftButton
||
event
->
button
()
==
Qt
::
RightButton
))
...
...
@@ -514,8 +517,6 @@ void Surface_Selection_Plugin::wheelEvent(View* view, QWheelEvent* event)
void
Surface_Selection_Plugin
::
selectedMapChanged
(
MapHandlerGen
*
prev
,
MapHandlerGen
*
cur
)
{
m_dockTab
->
updateMapParameters
();
...
...
@@ -684,12 +685,12 @@ void Surface_Selection_Plugin::changePositionAttribute(const QString& map, const
if
(
m
->
isSelectedMap
())
m_dockTab
->
updateMapParameters
();
}
//
View* v = m_schnapps->getSelectedView();
//
if (v)
//
{
//
if (v->isLinkedToMap(m))
//
v->updateGL();
//
}
View
*
v
=
m_schnapps
->
getSelectedView
();
if
(
v
)
{
if
(
v
->
isLinkedToMap
(
m
))
v
->
updateGL
();
}
}
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
if
(
m
->
isSelectedMap
())
m_dockTab
->
updateMapParameters
();
}
//
View* v = m_schnapps->getSelectedView();
//
if (v)
//
{
//
if (v->isLinkedToMap(m))
//
v->updateGL();
//
}
View
*
v
=
m_schnapps
->
getSelectedView
();
if
(
v
)
{
if
(
v
->
isLinkedToMap
(
m
))
v
->
updateGL
();
}
}
void
Surface_Selection_Plugin
::
changeSelectionMethod
(
const
QString
&
map
,
unsigned
int
method
)
...
...
@@ -719,12 +720,12 @@ void Surface_Selection_Plugin::changeSelectionMethod(const QString& map, unsigne
if
(
m
->
isSelectedMap
())
m_dockTab
->
updateMapParameters
();
}
//
View* v = m_schnapps->getSelectedView();
//
if (v)
//
{
//
if (v->isLinkedToMap(m))
//
v->updateGL();
//
}
View
*
v
=
m_schnapps
->
getSelectedView
();
if
(
v
)
{
if
(
v
->
isLinkedToMap
(
m
))
v
->
updateGL
();
}
}
void
Surface_Selection_Plugin
::
changeVerticesScaleFactor
(
const
QString
&
map
,
float
f
)
...
...
@@ -738,12 +739,12 @@ void Surface_Selection_Plugin::changeVerticesScaleFactor(const QString& map, flo
m_dockTab
->
updateMapParameters
();
}
//
View* v = m_schnapps->getSelectedView();
//
if (v)
//
{
//
if (v->isLinkedToMap(m))
//
v->updateGL();
//
}
View
*
v
=
m_schnapps
->
getSelectedView
();
if
(
v
)
{
if
(
v
->
isLinkedToMap
(
m
))
v
->
updateGL
();
}
}
void
Surface_Selection_Plugin
::
changeVerticesBaseSize
(
const
QString
&
map
,
float
f
)
...
...
@@ -757,12 +758,12 @@ void Surface_Selection_Plugin::changeVerticesBaseSize(const QString& map, float
m_dockTab
->
updateMapParameters
();
}
//
View* v = m_schnapps->getSelectedView();
//
if (v)
//
{
//
if (v->isLinkedToMap(m))
//
v->updateGL();
//
}
View
*
v
=
m_schnapps
->
getSelectedView
();
if
(
v
)
{
if
(
v
->
isLinkedToMap
(
m
))
v
->
updateGL
();
}
}
...
...
@@ -775,16 +776,34 @@ void Surface_Selection_Plugin::changeSelectedColor( const QString& map, const QS
if
(
m
->
isSelectedMap
())
m_dockTab
->
updateMapParameters
();
//
View* v = m_schnapps->getSelectedView();
//
if (v)
//
{
//
if (v->isLinkedToMap(m))
//
v->updateGL();
//
}
View
*
v
=
m_schnapps
->
getSelectedView
();
if
(
v
)
{
if
(
v
->
isLinkedToMap
(
m
))
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
...
...
SCHNApps/Plugins/surface_selection/src/surface_selection_dockTab.cpp
View file @
ec5fcdbb
...
...
@@ -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
(
sliderPressed
()),
this
,
SLOT
(
verticesScaleFactorPressed
()));
connect
(
combo_color
,
SIGNAL
(
currentIndexChanged
(
int
)),
this
,
SLOT
(
colorChanged
(
int
)));
connect
(
button_clear
,
SIGNAL
(
pressed
()),
this
,
SLOT
(
clearPressed
()));
// force color for map parameter updating
// combo_color->setCurrentIndex(0);
...
...
@@ -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
()
{
b_updatingUI
=
true
;
...
...
@@ -186,6 +202,8 @@ void Surface_Selection_DockTab::updateMapParameters()
combo_selectionMethod
->
setCurrentIndex
(
p
.
selectionMethod
);
combo_color
->
setColor
(
p
.
color
);
slider_verticesScaleFactor
->
setValue
(
int
(
50.0
*
p
.
verticesScaleFactor
));
}
b_updatingUI
=
false
;
...
...
SCHNApps/include/cellSelector.h
View file @
ec5fcdbb
...
...
@@ -53,6 +53,8 @@ public:
inline
bool
isMutuallyExclusive
()
const
{
return
m_isMutuallyExclusive
;
}
virtual
void
setMutuallyExclusiveSet
(
const
QList
<
CellSelectorGen
*>&
mex
)
=
0
;
virtual
void
clearAll
()
=
0
;
signals:
void
selectedCellsChanged
();
...
...
@@ -184,6 +186,16 @@ public:
}
}
inline
void
clearAll
()
{
std
::
vector
<
CELL
>
tempo
;
m_cells
.
swap
(
tempo
);
m_cm
.
unmarkAll
();
m_selectionChanged
=
true
;
checkChange
();
}
private:
MAP
&
m_map
;
CellMarker
<
MAP
,
ORBIT
>
m_cm
;
...
...
SCHNApps/include/schnapps.h
View file @
ec5fcdbb
...
...
@@ -273,9 +273,10 @@ public slots:
/**
* @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
...
...
@@ -306,7 +307,7 @@ public slots:
* @brief set the default path used when opening python file dialog.
* @param path the default path
*/
inline
void
setPythonPath
(
const
QString
&
path
)
{
m_pyPathFile
=
path
;
}
void
setPythonPath
(
const
QString
&
path
)
;
private
slots
:
void
loadPythonScriptFromFileDialog
();
...
...
@@ -333,6 +334,8 @@ public:
inline
void
pythonVarDeclare
(
const
QString
&
var
)
{
m_pyVarNames
.
push_back
(
var
);
}
inline
void
pythonVarsClear
()
{
m_pyVarNames
.
clear
();
}
/// replace \ by / in file path for window
static
QString
noBackSlash
(
const
QString
&
name
);
signals:
...
...
SCHNApps/src/controlDock_mapTab.cpp
View file @
ec5fcdbb
...
...
@@ -475,6 +475,7 @@ void ControlDock_MapTab::updateSelectedMapInfo()
item
->
setCheckState
(
Qt
::
Checked
);
else
item
->
setCheckState
(
Qt
::
Unchecked
);
// item->setToolTip(QString("Check for VBO"));
}
break
;
case
EDGE
:
{
list_edgeAttributes
->
addItem
(
name
+
" ("
+
type
+
")"
);
...
...
SCHNApps/src/schnapps.cpp
View file @
ec5fcdbb
...
...
@@ -1000,44 +1000,34 @@ void SCHNApps::showHidePythonDock()
void
SCHNApps
::
execPythonCmd
(
const
QString
&
cmd
)
{
QString
line
=
cmd
;
if
(
line
.
size
()
>=
2
)
{
int
j
=
0
;
while
(
line
[
j
]
==
' '
)
++
j
;
QString
spaces
(
4
-
j
,
QChar
(
' '
));
// need 4 spaces at begin of line
line
.
replace
(
QChar
(
'\\'
),
QChar
(
'/'
));
// replace \ by / in win path
m_pythonConsole
.
consoleMessage
(
spaces
+
line
);
m_pythonConsole
.
executeLine
(
false
);
}
m_pythonContext
.
evalScript
(
cmd
);
}
void
SCHNApps
::
loadPythonScriptFromFile
(
const
QString
&
fileName
)
bool
SCHNApps
::
loadPythonScriptFromFile
(
const
QString
&
fileName
)
{
#ifdef WIN32
// NOT VERY NICE BUT ONLY WAY ON WINDOWS TO LOAD SCRIPT FILES
QFile
file
(
fileName
);
if
(
!
file
.
open
(
QIODevice
::
ReadOnly
|
QIODevice
::
Text
))
return
;
QTextStream
in
(
&
file
);
while
(
!
in
.
atEnd
())
QString
fullName
=
fileName
;
if
(
!
QFile
::
exists
(
fullName
))
{
QString
line
=
in
.
readLine
();
if
(
line
.
size
()
>=
2
)
QString
pypath
=
m_pyPathFile
;
if
(
pypath
.
isEmpty
())
pypath
=
this
->
getAppPath
();
fullName
=
pypath
+
"/"
+
fileName
;
if
(
!
QFile
::
exists
(
fullName
))
{
int
j
=
0
;
while
(
line
[
j
]
==
' '
)
++
j
;
QString
spaces
(
4
-
j
,
QChar
(
' '
));
// need 4 spaces at begin of line
line
.
replace
(
QChar
(
'\\'
),
QChar
(
'/'
));
// replace \ by / in win path
m_pythonConsole
.
consoleMessage
(
spaces
+
line
);
m_pythonConsole
.
executeLine
(
false
);
std
::
cerr
<<
"python script "
<<
fullName
.
toStdString
()
<<
" not found"
<<
std
::
endl
;
return
false
;
}
}
#ifdef WIN32
QFile
file
(
fullName
);
if
(
!
file
.
open
(
QIODevice
::
ReadOnly
|
QIODevice
::
Text
))
return
false
;
QTextStream
in
(
&
file
);
m_pythonContext
.
evalScript
(
in
.
readAll
());
#else
QFileInfo
fi
(
fileName
);
if
(
fi
.
exists
())
m_pythonContext
.
evalFile
(
fi
.
filePath
());
m_pythonContext
.
evalFile
(
fullName
);
#endif
return
true
;
}
void
SCHNApps
::
loadPythonScriptFromFileDialog
()
...
...
@@ -1050,6 +1040,28 @@ void SCHNApps::loadPythonScriptFromFileDialog()
loadPythonScriptFromFile
(
fileName
);
}
QString
SCHNApps
::
noBackSlash
(
const
QString
&
name
)
{
#ifdef WIN32
// if copy from interface need to replace \ by / !!
QString
slashed
=
name
;
slashed
.
replace
(
QString
(
"
\t
"
),
QString
(
"/t"
));
slashed
.
replace
(
QString
(
"
\n
"
),
QString
(
"/n"
));
slashed
.
replace
(
QString
(
"
\v
"
),
QString
(
"/v"
));
slashed
.
replace
(
QString
(
"
\f
"
),
QString
(
"/f"
));
slashed
.
replace
(
QString
(
"
\r
"
),
QString
(
"/r"
));
slashed
.
replace
(
QChar
(
'\\'
),
QChar
(
'/'
));
return
slashed
;
#else
return
name
;
#endif
}
void
SCHNApps
::
setPythonPath
(
const
QString
&
path
)