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
Hurstel
CGoGN
Commits
2dd3f2a4
Commit
2dd3f2a4
authored
Oct 12, 2013
by
Pierre Kraemer
Browse files
add surface modelisation plugin
parent
ea92bf90
Changes
10
Hide whitespace changes
Inline
Side-by-side
SCHNApps/Plugins/CMakeLists.txt
View file @
2dd3f2a4
...
...
@@ -9,3 +9,4 @@ ADD_SUBDIRECTORY(surface_differentialProperties)
ADD_SUBDIRECTORY
(
surface_subdivision
)
ADD_SUBDIRECTORY
(
surface_selection
)
ADD_SUBDIRECTORY
(
surface_deformation
)
ADD_SUBDIRECTORY
(
surface_modelisation
)
SCHNApps/Plugins/surface_modelisation/CMakeLists.txt
0 → 100644
View file @
2dd3f2a4
cmake_minimum_required
(
VERSION 2.8
)
SET
(
PLUGIN_NAME Surface_Modelisation
)
SET
(
PLUGIN_ROOT_DIR
${
SCHNApps_ROOT_DIR
}
/Plugins/surface_modelisation
)
INCLUDE_DIRECTORIES
(
${
PLUGIN_ROOT_DIR
}
/include
${
CMAKE_CURRENT_BINARY_DIR
}
)
file
(
GLOB_RECURSE
PLUGIN_FILES
${
PLUGIN_ROOT_DIR
}
/src/*.cpp
${
PLUGIN_ROOT_DIR
}
/include/*.h
${
PLUGIN_ROOT_DIR
}
/include/*.hpp
)
file
(
GLOB_RECURSE
PLUGIN_UI_FILES
${
PLUGIN_ROOT_DIR
}
/forms/*.ui
)
SET
(
PLUGIN_QOBJECT_FILES
${
PLUGIN_ROOT_DIR
}
/include/surface_modelisation.h
${
PLUGIN_ROOT_DIR
}
/include/surface_modelisation_dockTab.h
)
include
(
${
SCHNApps_ROOT_DIR
}
/Plugins/plugins_cmake.txt
)
SCHNApps/Plugins/surface_modelisation/forms/surface_modelisation.ui
0 → 100644
View file @
2dd3f2a4
<?xml version="1.0" encoding="UTF-8"?>
<ui
version=
"4.0"
>
<class>
Surface_Modelisation_TabWidget
</class>
<widget
class=
"QWidget"
name=
"Surface_Modelisation_TabWidget"
>
<property
name=
"geometry"
>
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
259
</width>
<height>
600
</height>
</rect>
</property>
<property
name=
"windowTitle"
>
<string>
Form
</string>
</property>
<layout
class=
"QGridLayout"
name=
"gridLayout"
>
<item
row=
"1"
column=
"0"
colspan=
"3"
>
<widget
class=
"QLabel"
name=
"label_3"
>
<property
name=
"text"
>
<string>
Vertex selector :
</string>
</property>
</widget>
</item>
<item
row=
"2"
column=
"0"
colspan=
"2"
>
<widget
class=
"QLabel"
name=
"label"
>
<property
name=
"text"
>
<string>
Edge selector :
</string>
</property>
</widget>
</item>
<item
row=
"2"
column=
"2"
colspan=
"3"
>
<widget
class=
"QComboBox"
name=
"combo_edgeSelector"
>
<item>
<property
name=
"text"
>
<string>
- select selector -
</string>
</property>
</item>
</widget>
</item>
<item
row=
"3"
column=
"0"
colspan=
"2"
>
<widget
class=
"QLabel"
name=
"label_4"
>
<property
name=
"text"
>
<string>
Face selector :
</string>
</property>
</widget>
</item>
<item
row=
"3"
column=
"2"
colspan=
"3"
>
<widget
class=
"QComboBox"
name=
"combo_faceSelector"
>
<item>
<property
name=
"text"
>
<string>
- select selector -
</string>
</property>
</item>
</widget>
</item>
<item
row=
"4"
column=
"0"
colspan=
"5"
>
<widget
class=
"Line"
name=
"line"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
</widget>
</item>
<item
row=
"1"
column=
"3"
colspan=
"2"
>
<widget
class=
"QComboBox"
name=
"combo_vertexSelector"
>
<item>
<property
name=
"text"
>
<string>
- select selector -
</string>
</property>
</item>
</widget>
</item>
<item
row=
"5"
column=
"0"
colspan=
"5"
>
<widget
class=
"QPushButton"
name=
"button_createCube"
>
<property
name=
"text"
>
<string>
Create cube
</string>
</property>
</widget>
</item>
<item
row=
"6"
column=
"0"
colspan=
"5"
>
<widget
class=
"QPushButton"
name=
"button_flipEdge"
>
<property
name=
"text"
>
<string>
Flip edge
</string>
</property>
</widget>
</item>
<item
row=
"7"
column=
"2"
>
<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=
"0"
column=
"2"
colspan=
"3"
>
<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=
"0"
column=
"0"
colspan=
"2"
>
<widget
class=
"QLabel"
name=
"label_2"
>
<property
name=
"text"
>
<string>
Position :
</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
SCHNApps/Plugins/surface_modelisation/include/surface_modelisation.h
0 → 100644
View file @
2dd3f2a4
#ifndef _SURFACE_MODELISATION_PLUGIN_H_
#define _SURFACE_MODELISATION_PLUGIN_H_
#include
"plugin_interaction.h"
#include
"surface_modelisation_dockTab.h"
#include
"mapHandler.h"
namespace
CGoGN
{
namespace
SCHNApps
{
struct
MapParameters
{
MapParameters
()
:
vertexSelector
(
NULL
),
edgeSelector
(
NULL
),
faceSelector
(
NULL
)
{}
VertexAttribute
<
PFP2
::
VEC3
>
positionAttribute
;
CellSelector
<
VERTEX
>*
vertexSelector
;
CellSelector
<
EDGE
>*
edgeSelector
;
CellSelector
<
FACE
>*
faceSelector
;
};
class
Surface_Modelisation_Plugin
:
public
PluginInteraction
{
Q_OBJECT
Q_INTERFACES
(
CGoGN
::
SCHNApps
::
Plugin
)
friend
class
Surface_Modelisation_DockTab
;
public:
Surface_Modelisation_Plugin
();
~
Surface_Modelisation_Plugin
()
{}
virtual
bool
enable
();
virtual
void
disable
();
virtual
void
draw
(
View
*
view
)
{}
virtual
void
drawMap
(
View
*
view
,
MapHandlerGen
*
map
)
{}
virtual
void
keyPress
(
View
*
view
,
QKeyEvent
*
event
)
{}
virtual
void
keyRelease
(
View
*
view
,
QKeyEvent
*
event
)
{}
virtual
void
mousePress
(
View
*
view
,
QMouseEvent
*
event
)
{}
virtual
void
mouseRelease
(
View
*
view
,
QMouseEvent
*
event
)
{}
virtual
void
mouseMove
(
View
*
view
,
QMouseEvent
*
event
)
{}
virtual
void
wheelEvent
(
View
*
view
,
QWheelEvent
*
event
)
{}
virtual
void
viewLinked
(
View
*
view
)
{}
virtual
void
viewUnlinked
(
View
*
view
)
{}
private
slots
:
// slots called from SCHNApps signals
void
selectedMapChanged
(
MapHandlerGen
*
prev
,
MapHandlerGen
*
cur
);
void
mapAdded
(
MapHandlerGen
*
map
);
void
mapRemoved
(
MapHandlerGen
*
map
);
// slots called from MapHandler signals
void
attributeAdded
(
unsigned
int
orbit
,
const
QString
&
name
);
void
cellSelectorAdded
(
unsigned
int
orbit
,
const
QString
&
name
);
void
cellSelectorRemoved
(
unsigned
int
orbit
,
const
QString
&
name
);
public
slots
:
// slots for Python calls
void
changePositionAttribute
(
const
QString
&
view
,
const
QString
&
map
,
const
QString
&
name
);
void
changeVertexSelector
(
const
QString
&
map
,
const
QString
&
name
);
void
changeEdgeSelector
(
const
QString
&
map
,
const
QString
&
name
);
void
changeFaceSelector
(
const
QString
&
map
,
const
QString
&
name
);
protected:
void
createCube
(
MapHandlerGen
*
mhg
);
void
flipEdge
(
MapHandlerGen
*
mhg
);
protected:
Surface_Modelisation_DockTab
*
m_dockTab
;
QHash
<
MapHandlerGen
*
,
MapParameters
>
h_parameterSet
;
};
}
// namespace SCHNApps
}
// namespace CGoGN
#endif
SCHNApps/Plugins/surface_modelisation/include/surface_modelisation_dockTab.h
0 → 100644
View file @
2dd3f2a4
#ifndef _SURFACE_MODELISATION_DOCK_TAB_H_
#define _SURFACE_MODELISATION_DOCK_TAB_H_
#include
"ui_surface_modelisation.h"
namespace
CGoGN
{
namespace
SCHNApps
{
class
SCHNApps
;
class
Surface_Modelisation_Plugin
;
struct
MapParameters
;
class
Surface_Modelisation_DockTab
:
public
QWidget
,
public
Ui
::
Surface_Modelisation_TabWidget
{
Q_OBJECT
friend
class
Surface_Modelisation_Plugin
;
public:
Surface_Modelisation_DockTab
(
SCHNApps
*
s
,
Surface_Modelisation_Plugin
*
p
);
private:
SCHNApps
*
m_schnapps
;
Surface_Modelisation_Plugin
*
m_plugin
;
bool
b_updatingUI
;
private
slots
:
void
positionAttributeChanged
(
int
index
);
void
vertexSelectorChanged
(
int
index
);
void
edgeSelectorChanged
(
int
index
);
void
faceSelectorChanged
(
int
index
);
void
createCubeButtonClicked
();
void
flipEdgeButtonClicked
();
private:
void
addVertexAttribute
(
const
QString
&
name
);
void
updateMapParameters
();
};
}
// namespace SCHNApps
}
// namespace CGoGN
#endif
SCHNApps/Plugins/surface_modelisation/src/surface_modelisation.cpp
0 → 100644
View file @
2dd3f2a4
#include
"surface_modelisation.h"
#include
"schnapps.h"
#include
"view.h"
#include
"mapHandler.h"
#include
"Algo/Modelisation/polyhedron.h"
namespace
CGoGN
{
namespace
SCHNApps
{
Surface_Modelisation_Plugin
::
Surface_Modelisation_Plugin
()
{}
bool
Surface_Modelisation_Plugin
::
enable
()
{
m_dockTab
=
new
Surface_Modelisation_DockTab
(
m_schnapps
,
this
);
m_schnapps
->
addPluginDockTab
(
this
,
m_dockTab
,
"Surface_Modelisation"
);
connect
(
m_schnapps
,
SIGNAL
(
selectedMapChanged
(
MapHandlerGen
*
,
MapHandlerGen
*
)),
this
,
SLOT
(
selectedMapChanged
(
MapHandlerGen
*
,
MapHandlerGen
*
)));
connect
(
m_schnapps
,
SIGNAL
(
mapAdded
(
MapHandlerGen
*
)),
this
,
SLOT
(
mapAdded
(
MapHandlerGen
*
)));
connect
(
m_schnapps
,
SIGNAL
(
mapRemoved
(
MapHandlerGen
*
)),
this
,
SLOT
(
mapRemoved
(
MapHandlerGen
*
)));
foreach
(
MapHandlerGen
*
map
,
m_schnapps
->
getMapSet
().
values
())
mapAdded
(
map
);
m_dockTab
->
updateMapParameters
();
return
true
;
}
void
Surface_Modelisation_Plugin
::
disable
()
{
disconnect
(
m_schnapps
,
SIGNAL
(
selectedMapChanged
(
MapHandlerGen
*
,
MapHandlerGen
*
)),
this
,
SLOT
(
selectedMapChanged
(
MapHandlerGen
*
,
MapHandlerGen
*
)));
}
void
Surface_Modelisation_Plugin
::
selectedMapChanged
(
MapHandlerGen
*
prev
,
MapHandlerGen
*
cur
)
{
m_dockTab
->
updateMapParameters
();
}
void
Surface_Modelisation_Plugin
::
mapAdded
(
MapHandlerGen
*
map
)
{
connect
(
map
,
SIGNAL
(
attributeAdded
(
unsigned
int
,
const
QString
&
)),
this
,
SLOT
(
attributeAdded
(
unsigned
int
,
const
QString
&
)));
}
void
Surface_Modelisation_Plugin
::
mapRemoved
(
MapHandlerGen
*
map
)
{
disconnect
(
map
,
SIGNAL
(
attributeAdded
(
unsigned
int
,
const
QString
&
)),
this
,
SLOT
(
attributeAdded
(
unsigned
int
,
const
QString
&
)));
}
void
Surface_Modelisation_Plugin
::
attributeAdded
(
unsigned
int
orbit
,
const
QString
&
name
)
{
MapHandlerGen
*
map
=
static_cast
<
MapHandlerGen
*>
(
QObject
::
sender
());
if
(
orbit
==
VERTEX
&&
map
->
isSelectedMap
())
m_dockTab
->
addVertexAttribute
(
name
);
}
void
Surface_Modelisation_Plugin
::
changePositionAttribute
(
const
QString
&
view
,
const
QString
&
map
,
const
QString
&
name
)
{
MapHandlerGen
*
m
=
m_schnapps
->
getMap
(
map
);
if
(
m
)
{
h_parameterSet
[
m
].
positionAttribute
=
m
->
getAttribute
<
PFP2
::
VEC3
,
VERTEX
>
(
name
);
if
(
m
->
isSelectedMap
())
m_dockTab
->
updateMapParameters
();
}
}
void
Surface_Modelisation_Plugin
::
changeVertexSelector
(
const
QString
&
map
,
const
QString
&
name
)
{
MapHandlerGen
*
m
=
m_schnapps
->
getMap
(
map
);
if
(
m
)
{
MapParameters
&
p
=
h_parameterSet
[
m
];
p
.
vertexSelector
=
m
->
getCellSelector
<
VERTEX
>
(
name
);
if
(
m
->
isSelectedMap
())
m_dockTab
->
updateMapParameters
();
}
}
void
Surface_Modelisation_Plugin
::
changeEdgeSelector
(
const
QString
&
map
,
const
QString
&
name
)
{
MapHandlerGen
*
m
=
m_schnapps
->
getMap
(
map
);
if
(
m
)
{
MapParameters
&
p
=
h_parameterSet
[
m
];
p
.
edgeSelector
=
m
->
getCellSelector
<
EDGE
>
(
name
);
if
(
m
->
isSelectedMap
())
m_dockTab
->
updateMapParameters
();
}
}
void
Surface_Modelisation_Plugin
::
changeFaceSelector
(
const
QString
&
map
,
const
QString
&
name
)
{
MapHandlerGen
*
m
=
m_schnapps
->
getMap
(
map
);
if
(
m
)
{
MapParameters
&
p
=
h_parameterSet
[
m
];
p
.
faceSelector
=
m
->
getCellSelector
<
FACE
>
(
name
);
if
(
m
->
isSelectedMap
())
m_dockTab
->
updateMapParameters
();
}
}
void
Surface_Modelisation_Plugin
::
createCube
(
MapHandlerGen
*
mhg
)
{
MapHandler
<
PFP2
>*
mh
=
static_cast
<
MapHandler
<
PFP2
>*>
(
mhg
);
PFP2
::
MAP
*
map
=
mh
->
getMap
();
VertexAttribute
<
PFP2
::
VEC3
>&
position
=
h_parameterSet
[
mhg
].
positionAttribute
;
Algo
::
Surface
::
Modelisation
::
embedPrism
<
PFP2
>
(
*
map
,
position
,
4
,
false
,
1.0
f
,
1.0
f
,
1.0
f
);
mh
->
notifyAttributeModification
(
position
);
mh
->
notifyConnectivityModification
();
}
void
Surface_Modelisation_Plugin
::
flipEdge
(
MapHandlerGen
*
mhg
)
{
MapHandler
<
PFP2
>*
mh
=
static_cast
<
MapHandler
<
PFP2
>*>
(
mhg
);
PFP2
::
MAP
*
map
=
mh
->
getMap
();
const
MapParameters
&
p
=
h_parameterSet
[
mhg
];
if
(
p
.
edgeSelector
&&
!
p
.
edgeSelector
->
getSelectedCells
().
empty
())
{
const
std
::
vector
<
Dart
>&
edge
=
p
.
edgeSelector
->
getSelectedCells
();
map
->
flipEdge
(
edge
[
0
]);
}
mh
->
notifyConnectivityModification
();
}
#ifndef DEBUG
Q_EXPORT_PLUGIN2
(
Surface_Modelisation_Plugin
,
Surface_Modelisation_Plugin
)
#else
Q_EXPORT_PLUGIN2
(
Surface_Modelisation_PluginD
,
Surface_Modelisation_Plugin
)
#endif
}
// namespace SCHNApps
}
// namespace CGoGN
SCHNApps/Plugins/surface_modelisation/src/surface_modelisation_dockTab.cpp
0 → 100644
View file @
2dd3f2a4
#include
"surface_modelisation_dockTab.h"
#include
"surface_modelisation.h"
#include
"mapHandler.h"
namespace
CGoGN
{
namespace
SCHNApps
{
Surface_Modelisation_DockTab
::
Surface_Modelisation_DockTab
(
SCHNApps
*
s
,
Surface_Modelisation_Plugin
*
p
)
:
m_schnapps
(
s
),
m_plugin
(
p
),
b_updatingUI
(
false
)
{
setupUi
(
this
);
connect
(
combo_positionAttribute
,
SIGNAL
(
currentIndexChanged
(
int
)),
this
,
SLOT
(
positionAttributeChanged
(
int
)));
connect
(
button_createCube
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
createCubeButtonClicked
()));
connect
(
button_flipEdge
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
flipEdgeButtonClicked
()));
}
void
Surface_Modelisation_DockTab
::
positionAttributeChanged
(
int
index
)
{
if
(
!
b_updatingUI
)
{
MapHandlerGen
*
map
=
m_schnapps
->
getSelectedMap
();
if
(
map
)
m_plugin
->
h_parameterSet
[
map
].
positionAttribute
=
map
->
getAttribute
<
PFP2
::
VEC3
,
VERTEX
>
(
combo_positionAttribute
->
currentText
());
}
}
void
Surface_Modelisation_DockTab
::
vertexSelectorChanged
(
int
index
)
{
if
(
!
b_updatingUI
)
{
MapHandlerGen
*
map
=
m_schnapps
->
getSelectedMap
();
if
(
map
)
m_plugin
->
h_parameterSet
[
map
].
vertexSelector
=
map
->
getCellSelector
<
VERTEX
>
(
combo_vertexSelector
->
currentText
());
}
}
void
Surface_Modelisation_DockTab
::
edgeSelectorChanged
(
int
index
)
{
if
(
!
b_updatingUI
)
{
MapHandlerGen
*
map
=
m_schnapps
->
getSelectedMap
();
if
(
map
)
m_plugin
->
h_parameterSet
[
map
].
edgeSelector
=
map
->
getCellSelector
<
EDGE
>
(
combo_edgeSelector
->
currentText
());
}
}
void
Surface_Modelisation_DockTab
::
faceSelectorChanged
(
int
index
)
{
if
(
!
b_updatingUI
)
{
MapHandlerGen
*
map
=
m_schnapps
->
getSelectedMap
();
if
(
map
)
m_plugin
->
h_parameterSet
[
map
].
faceSelector
=
map
->
getCellSelector
<
FACE
>
(
combo_faceSelector
->
currentText
());
}
}
void
Surface_Modelisation_DockTab
::
createCubeButtonClicked
()
{
if
(
!
b_updatingUI
)
{
MapHandlerGen
*
map
=
m_schnapps
->
getSelectedMap
();
if
(
map
)
m_plugin
->
createCube
(
map
);
}
}
void
Surface_Modelisation_DockTab
::
flipEdgeButtonClicked
()
{
if
(
!
b_updatingUI
)
{
MapHandlerGen
*
map
=
m_schnapps
->
getSelectedMap
();
if
(
map
)
m_plugin
->
flipEdge
(
map
);
}
}
void
Surface_Modelisation_DockTab
::
addVertexAttribute
(
const
QString
&
nameAttr
)
{
b_updatingUI
=
true
;
QString
vec3TypeName
=
QString
::
fromStdString
(
nameOfType
(
PFP2
::
VEC3
()));
const
QString
&
typeAttr
=
m_schnapps
->
getSelectedMap
()
->
getAttributeTypeName
(
VERTEX
,
nameAttr
);
if
(
typeAttr
==
vec3TypeName
)
combo_positionAttribute
->
addItem
(
nameAttr
);
b_updatingUI
=
false
;
}
void
Surface_Modelisation_DockTab
::
updateMapParameters
()
{
b_updatingUI
=
true
;
combo_positionAttribute
->
clear
();
combo_positionAttribute
->
addItem
(
"- select attribute -"
);
MapHandlerGen
*
map
=
m_schnapps
->
getSelectedMap
();
if
(
map
)
{
const
MapParameters
&
p
=
m_plugin
->
h_parameterSet
[
map
];
QString
vec3TypeName
=
QString
::
fromStdString
(
nameOfType
(
PFP2
::
VEC3
()));
unsigned
int
i
=
1
;
const
AttributeSet
&
attribs
=
map
->
getAttributeSet
(
VERTEX
);
for
(
AttributeSet
::
const_iterator
it
=
attribs
.
constBegin
();
it
!=
attribs
.
constEnd
();
++
it
)